public void VerifyPersonPictureVisualTree()
        {
            PersonPicture personPicture = null;

            RunOnUIThread.Execute(() =>
            {
                personPicture = new PersonPicture {
                    Initials = "LC", Width = 100, Height = 100
                };
            });
            TestUtilities.SetAsVisualTreeRoot(personPicture);

            VisualTreeTestHelper.VerifyVisualTree(root: personPicture, verificationFileNamePrefix: "PersonPicture");
        }
        public void VerifySmallWidthAndHeightDoNotCrash()
        {
            ManualResetEvent sizeChangedEvent = new ManualResetEvent(false);

            RunOnUIThread.Execute(() =>
            {
                var personPicture = new PersonPicture();
                Content           = personPicture;
                Content.UpdateLayout();
                personPicture.SizeChanged += (sender, args) => sizeChangedEvent.Set();
                personPicture.Width        = 0.4;
                personPicture.Height       = 0.4;
                Content.UpdateLayout();
            });
            sizeChangedEvent.WaitOne();
        }
        public void VerifyAutomationName()
        {
            RunOnUIThread.Execute(() =>
            {
                PersonPicture personPicture = new PersonPicture();
                Verify.IsNotNull(personPicture);

                // Set properties and ensure that the AutomationName updates accordingly
                personPicture.Initials = "AB";
                String automationName  = AutomationProperties.GetName(personPicture);
                Verify.AreEqual(automationName, "AB");

                personPicture.DisplayName = "Jane Smith";
                automationName            = AutomationProperties.GetName(personPicture);
                Verify.AreEqual(automationName, "Jane Smith");

                Contact contact       = new Contact();
                contact.FirstName     = "John";
                contact.LastName      = "Doe";
                personPicture.Contact = contact;
                automationName        = AutomationProperties.GetName(personPicture);
                Verify.AreEqual(automationName, "John Doe");

                personPicture.IsGroup = true;
                automationName        = AutomationProperties.GetName(personPicture);
                Verify.AreEqual(automationName, "Group");
                personPicture.IsGroup = false;

                personPicture.BadgeGlyph = "\uE765";
                automationName           = AutomationProperties.GetName(personPicture);
                Verify.AreEqual(automationName, "John Doe, icon");

                personPicture.BadgeText = "Skype";
                automationName          = AutomationProperties.GetName(personPicture);
                Verify.AreEqual(automationName, "John Doe, Skype");
                personPicture.BadgeText = "";

                personPicture.BadgeNumber = 5;
                automationName            = AutomationProperties.GetName(personPicture);
                Verify.AreEqual(automationName, "John Doe, 5 items");

                personPicture.BadgeText = "direct reports";
                automationName          = AutomationProperties.GetName(personPicture);
                Verify.AreEqual(automationName, "John Doe, 5 direct reports");
            });
        }
        public void VerifyDefaultsAndBasicSetting()
        {
            RunOnUIThread.Execute(() =>
            {
                PersonPicture personPicture = new PersonPicture();
                Verify.IsNotNull(personPicture);

                // Confirm initial dependency property values
                Verify.AreEqual(personPicture.BadgeGlyph, "");
                Verify.AreEqual(personPicture.BadgeNumber, 0);
                Verify.AreEqual(personPicture.IsGroup, false);
                Verify.AreEqual(personPicture.PreferSmallImage, false);
                Verify.AreEqual(personPicture.ProfilePicture, null);
                Verify.AreEqual(personPicture.Contact, null);
                Verify.AreEqual(personPicture.DisplayName, "");
                Verify.AreEqual(personPicture.Initials, "");

                // Now verify setting/retrieving the parameters
                personPicture.BadgeGlyph = "\uE765";
                Verify.AreEqual(personPicture.BadgeGlyph, "\uE765");
                personPicture.BadgeNumber = 10;
                Verify.AreEqual(personPicture.BadgeNumber, 10);
                personPicture.IsGroup = true;
                Verify.AreEqual(personPicture.IsGroup, true);
                personPicture.PreferSmallImage = true;
                Verify.AreEqual(personPicture.PreferSmallImage, true);
                personPicture.DisplayName = "Some Name";
                Verify.AreEqual(personPicture.DisplayName, "Some Name");
                personPicture.Initials = "MS";
                Verify.AreEqual(personPicture.Initials, "MS");

                Contact contact       = new Contact();
                contact.FirstName     = "FirstName";
                personPicture.Contact = contact;
                Verify.AreEqual(personPicture.Contact.FirstName, "FirstName");

                ImageSource imageSrc         = new BitmapImage(new Uri("ms-appx:/Assets/StoreLogo.png"));
                personPicture.ProfilePicture = imageSrc;
                Verify.IsNotNull(personPicture.ProfilePicture);
            });
        }
        public void VerifyVSMStatesForPhotosAndInitials()
        {
            RunOnUIThread.Execute(() =>
            {
                var personPicture = new PersonPicture();
                Content           = personPicture;
                Content.UpdateLayout();
                var initialsTextBlock = (TextBlock)VisualTreeUtils.FindVisualChildByName(personPicture, "InitialsTextBlock");
                personPicture.IsGroup = true;
                Content.UpdateLayout();
                Verify.AreEqual(initialsTextBlock.FontFamily.Source, "Segoe MDL2 Assets");
                Verify.AreEqual(initialsTextBlock.Text, "\xE716");

                personPicture.IsGroup  = false;
                personPicture.Initials = "JS";
                Content.UpdateLayout();
                Verify.AreEqual(initialsTextBlock.FontFamily.Source, "Segoe UI");
                Verify.AreEqual(initialsTextBlock.Text, "JS");

                personPicture.Initials = "";
                Content.UpdateLayout();
                Verify.AreEqual(initialsTextBlock.FontFamily.Source, "Segoe MDL2 Assets");
                Verify.AreEqual(initialsTextBlock.Text, "\xE77B");

                // Make sure that custom FontFamily takes effect after the control is created
                // and also goes back to the MDL2 font after setting IsGroup = true.
                personPicture.FontFamily = new FontFamily("Segoe UI Emoji");
                personPicture.Initials   = "👍";
                Content.UpdateLayout();
                Verify.AreEqual(initialsTextBlock.FontFamily.Source, "Segoe UI Emoji");
                Verify.AreEqual(initialsTextBlock.Text, "👍");

                personPicture.IsGroup = true;
                Content.UpdateLayout();
                Verify.AreEqual(initialsTextBlock.FontFamily.Source, "Segoe MDL2 Assets");
                Verify.AreEqual(initialsTextBlock.Text, "\xE716");
            });
        }
Exemple #6
0
        public void VerifySmallWidthAndHeightDoNotCrash()
        {
            PersonPicture personPicture = null;

            RunOnUIThread.Execute(() =>
            {
                personPicture = new PersonPicture();
                MUXControlsTestApp.App.TestContentRoot = personPicture;
            });

            IdleSynchronizer.Wait();

            ManualResetEvent sizeChangedEvent = new ManualResetEvent(false);

            RunOnUIThread.Execute(() =>
            {
                personPicture.SizeChanged += (sender, args) => sizeChangedEvent.Set();
                personPicture.Width        = 0.4;
                personPicture.Height       = 0.4;
            });

            sizeChangedEvent.WaitOne();
            IdleSynchronizer.Wait();
        }
Exemple #7
0
        public void VerifyOverrides()
        {
            RatingControl ratingControl = null;
            PersonPicture personPicture = null;
            Slider        slider        = null;
            Grid          root          = null;

            RunOnUIThread.Execute(() =>
            {
                var appResources = Application.Current.Resources;
                // 1) Override WinUI defined brush in App.Resources.
                appResources["RatingControlCaptionForeground"] = new SolidColorBrush(Colors.Orange);

                // 2) Override system brush used by WinUI ThemeResource.

                ((ResourceDictionary)appResources.ThemeDictionaries["Light"])["SystemAltHighColor"]   = Colors.Green;
                ((ResourceDictionary)appResources.ThemeDictionaries["Default"])["SystemAltHighColor"] = Colors.Green;
                ((ResourceDictionary)appResources.ThemeDictionaries["HighContrast"])["SystemColorButtonTextColor"] = Colors.Green;

                // 3) Override brush name used by a system control
                appResources["SliderTrackValueFill"] = new SolidColorBrush(Colors.Purple);

                root = new Grid
                {
                    Background = new SolidColorBrush(Colors.AntiqueWhite),
                };

                StackPanel panel = new StackPanel {
                    Orientation = Orientation.Vertical
                };
                panel.Children.Add(slider = new Slider());

                panel.Children.Add(ratingControl = new RatingControl()
                {
                    Value = 2
                });
                panel.Children.Add(personPicture = new PersonPicture());

                root.Children.Add(panel);
                // Add an element over top to prevent stray mouse input from interfering.
                root.Children.Add(new Button
                {
                    Background          = new SolidColorBrush(Color.FromArgb(30, 0, 255, 0)),
                    HorizontalAlignment = HorizontalAlignment.Stretch,
                    VerticalAlignment   = VerticalAlignment.Stretch
                });

                MUXControlsTestApp.App.TestContentRoot = root;
            });
            IdleSynchronizer.TryWait();

            //System.Threading.Tasks.Task.Delay(TimeSpan.FromSeconds(20)).Wait();

            RunOnUIThread.Execute(() =>
            {
                // 1) Verify that overriding WinUI defined brushes in App.Resources works.
                Verify.AreEqual(Colors.Orange, ((SolidColorBrush)ratingControl.Foreground).Color,
                                "Verify RatingControlCaptionForeground override in Application.Resources gets picked up by WinUI control");

                // 2) Verify that overriding a system color used by a WinUI control works.
                Verify.AreEqual(Colors.Green, ((SolidColorBrush)personPicture.Foreground).Color,
                                "Verify PersonPictureForegroundThemeBrush (which uses SystemAltHighColor) overridden in Application.Resources gets picked up by WinUI control");

                // 3) Verify that overriding a system brush used by a system control works.
                if (PlatformConfiguration.IsOsVersionGreaterThan(OSVersion.Redstone1))
                {
                    // Below code is comment because of bug 19180323 and we expect the code to be enabled again after test case is moved to nuget testapp

                    //Verify.AreEqual(Colors.Purple, ((SolidColorBrush)slider.Foreground).Color,
                    //    "Verify Slider (which uses SliderTrackValueFill as its .Foreground) overridden in Application.Resources gets picked up by Slider control");
                }
                else
                {
                    // Before RS1, we used to reference system brushes directly.
                }

                Log.Comment("Setting Window.Current.Content = null");
                MUXControlsTestApp.App.TestContentRoot = null;
            });
            IdleSynchronizer.TryWait();
        }
Exemple #8
0
        public void VerifyVSMStatesForPhotosAndInitials()
        {
            PersonPicture personPicture     = null;
            TextBlock     initialsTextBlock = null;

            RunOnUIThread.Execute(() =>
            {
                personPicture = new PersonPicture();
                MUXControlsTestApp.App.TestContentRoot = personPicture;
            });

            IdleSynchronizer.Wait();

            RunOnUIThread.Execute(() =>
            {
                initialsTextBlock     = (TextBlock)VisualTreeUtils.FindVisualChildByName(personPicture, "InitialsTextBlock");
                personPicture.IsGroup = true;
            });

            IdleSynchronizer.Wait();

            RunOnUIThread.Execute(() =>
            {
                Verify.AreEqual(initialsTextBlock.FontFamily.Source, "Segoe MDL2 Assets");
                Verify.AreEqual(initialsTextBlock.Text, "\xE716");

                personPicture.IsGroup  = false;
                personPicture.Initials = "JS";
            });

            IdleSynchronizer.Wait();

            RunOnUIThread.Execute(() =>
            {
                Verify.AreEqual(initialsTextBlock.FontFamily.Source, "Segoe UI");
                Verify.AreEqual(initialsTextBlock.Text, "JS");

                personPicture.Initials = "";
            });

            IdleSynchronizer.Wait();

            RunOnUIThread.Execute(() =>
            {
                Verify.AreEqual(initialsTextBlock.FontFamily.Source, "Segoe MDL2 Assets");
                Verify.AreEqual(initialsTextBlock.Text, "\xE77B");

                // Make sure that custom FontFamily takes effect after the control is created
                // and also goes back to the MDL2 font after setting IsGroup = true.
                personPicture.FontFamily = new FontFamily("Segoe UI Emoji");
                personPicture.Initials   = "👍";
            });

            IdleSynchronizer.Wait();

            RunOnUIThread.Execute(() =>
            {
                Verify.AreEqual(initialsTextBlock.FontFamily.Source, "Segoe UI Emoji");
                Verify.AreEqual(initialsTextBlock.Text, "👍");

                personPicture.IsGroup = true;
            });

            IdleSynchronizer.Wait();

            RunOnUIThread.Execute(() =>
            {
                Verify.AreEqual(initialsTextBlock.FontFamily.Source, "Segoe MDL2 Assets");
                Verify.AreEqual(initialsTextBlock.Text, "\xE716");
            });
        }