Esempio n. 1
0
        public void VerifyClearingNodeWithNoChildren()
        {
            RunOnUIThread.Execute(() =>
            {
                var treeViewNode1 = new TreeViewNode();
                var treeView      = new TreeView();

                Content = treeView;
                Content.UpdateLayout();
                var listControl = VisualTreeUtils.FindVisualChildByName(treeView, "ListControl") as TreeViewList;
                treeView.RootNodes.Add(treeViewNode1);
                var children            = (treeViewNode1.Children as IObservableVector <TreeViewNode>);
                children.VectorChanged += (vector, args) =>
                {
                    if (((IVectorChangedEventArgs)args).CollectionChange == CollectionChange.Reset)
                    {
                        // should not reset if there are not children items
                        throw new InvalidOperationException();
                    }
                };
                Verify.AreEqual(listControl.Items.Count, 1);

                // this should no-op and not crash
                treeViewNode1.Children.Clear();
            });
        }
        private void GetLayoutHeightsButton_Click(object sender, RoutedEventArgs e)
        {
            var itemsScroll  = (FrameworkElement)VisualTreeUtils.FindVisualChildByName(RootNavigationView, "MenuItemsScrollViewer");
            var footerScroll = (FrameworkElement)VisualTreeUtils.FindVisualChildByName(RootNavigationView, "FooterItemsScrollViewer");

            LayoutHeightsReport.Text = itemsScroll.ActualHeight + ";" + footerScroll.ActualHeight;
        }
Esempio n. 3
0
        private bool IsMultiSelectCheckBoxChecked(TreeView tree, TreeViewNode node)
        {
            var treeViewItem = tree.ContainerFromNode(node) as TreeViewItem;
            var checkBox     = VisualTreeUtils.FindVisualChildByName(treeViewItem, "MultiSelectCheckBox") as CheckBox;

            return(checkBox.IsChecked == true);
        }
 private void GetScrollIncreaseButtonToolTipButton_Click(object sender, RoutedEventArgs e)
 {
     if (VisualTreeUtils.FindVisualChildByName(Tabs, "ScrollIncreaseButton") is RepeatButton scrollIncreaseButton)
     {
         GetToolTipStringForUIElement(scrollIncreaseButton, ScrollIncreaseButtonToolTipTextBlock);
     }
 }
Esempio n. 5
0
        private void FindAndGiveAutomationNameToVisualChild(string childName)
        {
            DependencyObject obj = VisualTreeUtils.FindVisualChildByName(this.TestPersonPicture, childName);

            if (obj != null)
            {
                AutomationProperties.SetName(obj, childName);
            }
        }
        public void TeachingTipHeroContentPlacementTest()
        {
            RunOnUIThread.Execute(() =>
            {
                foreach (var iPlacementMode in Enum.GetValues(typeof(TeachingTipHeroContentPlacementMode)))
                {
                    var placementMode = (TeachingTipHeroContentPlacementMode)iPlacementMode;

                    Log.Comment($"Verifying TeachingTipHeroContentPlacementMode [{placementMode}]");

                    TeachingTip teachingTip          = new TeachingTip();
                    teachingTip.HeroContentPlacement = placementMode;

                    // Open the teaching tip to enter the correct visual state for the HeroContentPlacement.
                    teachingTip.IsOpen = true;

                    Content = teachingTip;
                    Content.UpdateLayout();

                    Verify.IsTrue(teachingTip.HeroContentPlacement == placementMode, $"HeroContentPlacement should have been [{placementMode}]");

                    var root = VisualTreeUtils.FindVisualChildByName(teachingTip, "Container") as FrameworkElement;

                    switch (placementMode)
                    {
                    case TeachingTipHeroContentPlacementMode.Auto:
                        Verify.IsTrue(IsVisualStateActive(root, "HeroContentPlacementStates", "HeroContentTop"),
                                      "The [HeroContentTop] visual state should have been active");
                        break;

                    case TeachingTipHeroContentPlacementMode.Top:
                        Verify.IsTrue(IsVisualStateActive(root, "HeroContentPlacementStates", "HeroContentTop"),
                                      "The [HeroContentTop] visual state should have been active");
                        break;

                    case TeachingTipHeroContentPlacementMode.Bottom:
                        Verify.IsTrue(IsVisualStateActive(root, "HeroContentPlacementStates", "HeroContentBottom"),
                                      "The [HeroContentBottom] visual state should have been active");
                        break;
                    }
                }
            });

            bool IsVisualStateActive(FrameworkElement root, string groupName, string stateName)
            {
                foreach (var group in VisualStateManager.GetVisualStateGroups(root))
                {
                    if (group.Name == groupName)
                    {
                        return(group.CurrentState != null && group.CurrentState.Name == stateName);
                    }
                }

                return(false);
            }
        }
Esempio n. 7
0
        public void VerifyVSMStatesForPhotosAndInitials()
        {
            RunOnUIThread.Execute(() =>
            {
                var personPicture = new PersonPicture();
                Content           = personPicture;
                Content.UpdateLayout();
                var initialsTextBlock = (TextBlock)VisualTreeUtils.FindVisualChildByName(personPicture, "InitialsTextBlock");
                var placeholderIcon   = (Controls.FontIconFallback)VisualTreeUtils.FindVisualChildByName(personPicture, "PlaceholderIcon");
                personPicture.IsGroup = true;
                Content.UpdateLayout();
                //Verify.IsTrue(initialsTextBlock.FontFamily.Source.Contains("Segoe MDL2 Assets"));
                //Verify.AreEqual(initialsTextBlock.Text, "\xE716");
                Verify.IsTrue(initialsTextBlock.Visibility == System.Windows.Visibility.Collapsed);
                Verify.IsTrue(placeholderIcon.Visibility == System.Windows.Visibility.Visible);
                Verify.IsTrue(placeholderIcon.Data == placeholderIcon.FindResource("People"));

                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.IsTrue(initialsTextBlock.FontFamily.Source.Contains("Segoe MDL2 Assets"));
                //Verify.AreEqual(initialsTextBlock.Text, "\xE77B");
                Verify.IsTrue(initialsTextBlock.Visibility == System.Windows.Visibility.Collapsed);
                Verify.IsTrue(placeholderIcon.Visibility == System.Windows.Visibility.Visible);
                Verify.IsTrue(placeholderIcon.Data == placeholderIcon.FindResource("Contact"));

                // 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.IsTrue(initialsTextBlock.FontFamily.Source.Contains("Segoe MDL2 Assets"));
                //Verify.AreEqual(initialsTextBlock.Text, "\xE716");
                Verify.IsTrue(initialsTextBlock.Visibility == System.Windows.Visibility.Collapsed);
                Verify.IsTrue(placeholderIcon.Visibility == System.Windows.Visibility.Visible);
                Verify.IsTrue(placeholderIcon.Data == placeholderIcon.FindResource("People"));
            });
        }
Esempio n. 8
0
        private void TabViewTabCloseRequested(object sender, Microsoft.UI.Xaml.Controls.TabViewTabCloseRequestedEventArgs e)
        {
            Tabs.TabItems.Remove(e.Tab);

            TabViewWidth.Text = Tabs.ActualWidth.ToString();

            var scrollButtonStateValue = "";

            var scrollIncreaseButton = VisualTreeUtils.FindVisualChildByName(Tabs, "ScrollIncreaseButton") as RepeatButton;
            var scrollDecreaseButton = VisualTreeUtils.FindVisualChildByName(Tabs, "ScrollDecreaseButton") as RepeatButton;

            scrollButtonStateValue += scrollIncreaseButton.IsEnabled + ";";
            scrollButtonStateValue += scrollDecreaseButton.IsEnabled + ";";

            ScrollButtonStatus.Text = scrollButtonStateValue;
        }
Esempio n. 9
0
        private void PersonPicture_LayoutUpdated(object sender, object e)
        {
            // Register items that are delay loaded
            if (!primaryEllipseLoaded)
            {
                string  primaryEllipseName = "PersonPictureEllipse";
                Ellipse primaryEllipse     = VisualTreeUtils.FindVisualChildByName(this.TestPersonPicture, primaryEllipseName) as Ellipse;
                if (primaryEllipse != null)
                {
                    // Capture initial state of the property
                    PrimaryEllipseFillChanged(primaryEllipse, Ellipse.FillProperty);

                    primaryEllipse.RegisterPropertyChangedCallback(Ellipse.FillProperty, new DependencyPropertyChangedCallback(PrimaryEllipseFillChanged));
                    primaryEllipseLoaded = true;
                }
            }
        }
        public void VerifyOverflowButtonToolTip()
        {
            RunOnUIThread.Execute(() =>
            {
                var navView             = new NavigationView();
                navView.PaneDisplayMode = NavigationViewPaneDisplayMode.Top;

                Content = navView;
                Content.UpdateLayout();

                var overflowButton = VisualTreeUtils.FindVisualChildByName(navView, "TopNavOverflowButton") as Button;
                var toolTipObject  = ToolTipService.GetToolTip(overflowButton);

                bool testCondition = toolTipObject is ToolTip toolTip && toolTip.Content.Equals("More");
                Verify.IsTrue(testCondition, "ToolTip text should have been \"More\".");
            });
        }
Esempio n. 11
0
        public void TreeViewUpdateTest()
        {
            RunOnUIThread.Execute(() =>
            {
                var treeViewNode1 = new TreeViewNode();
                var treeViewNode2 = new TreeViewNode();
                var treeViewNode3 = new TreeViewNode();
                var treeViewNode4 = new TreeViewNode();
                var treeViewNode5 = new TreeViewNode();

                treeViewNode1.Children.Add(treeViewNode2);
                treeViewNode1.Children.Add(treeViewNode3);
                treeViewNode1.Children.Add(treeViewNode4);
                treeViewNode1.Children.Add(treeViewNode5);

                var treeView = new TreeView();
                Content      = treeView;
                Content.UpdateLayout();
                var listControl = VisualTreeUtils.FindVisualChildByName(treeView, "ListControl") as TreeViewList;
                treeView.RootNodes.Add(treeViewNode1);
                Verify.AreEqual(listControl.Items.Count, 1);

                treeView.Expand(treeViewNode1);
                Verify.AreEqual(listControl.Items.Count, 5);

                treeViewNode1.Children.RemoveAt(2);
                Verify.AreEqual(listControl.Items.Count, 4);
                Verify.AreEqual(listControl.Items[0], treeViewNode1);
                Verify.AreEqual(listControl.Items[1], treeViewNode2);
                Verify.AreEqual(listControl.Items[2], treeViewNode3);
                Verify.AreEqual(listControl.Items[3], treeViewNode5);

                treeViewNode1.Children.Insert(1, treeViewNode4);
                Verify.AreEqual(listControl.Items.Count, 5);
                Verify.AreEqual(listControl.Items[0], treeViewNode1);
                Verify.AreEqual(listControl.Items[1], treeViewNode2);
                Verify.AreEqual(listControl.Items[2], treeViewNode4);
                Verify.AreEqual(listControl.Items[3], treeViewNode3);
                Verify.AreEqual(listControl.Items[4], treeViewNode5);

                treeViewNode1.Children.Clear();
                Verify.AreEqual(listControl.Items.Count, 1);
                Verify.AreEqual(listControl.Items[0], treeViewNode1);
            });
        }
        public void GetScrollButtonsVisible_Click(object sender, RoutedEventArgs e)
        {
            var scrollDecrease = VisualTreeUtils.FindVisualChildByName(Tabs, "ScrollDecreaseButtonContainer") as FrameworkElement;
            var scrollIncrease = VisualTreeUtils.FindVisualChildByName(Tabs, "ScrollIncreaseButtonContainer") as FrameworkElement;

            if (scrollDecrease.Visibility == Visibility.Visible && scrollIncrease.Visibility == Visibility.Visible)
            {
                ScrollButtonsVisible.Text = "True";
            }
            else if (scrollIncrease.Visibility == Visibility.Collapsed && scrollDecrease.Visibility == Visibility.Collapsed)
            {
                ScrollButtonsVisible.Text = "False";
            }
            else
            {
                ScrollButtonsVisible.Text = "Unexpected";
            }
        }
Esempio n. 13
0
        private void PersonPicture_Loaded(object sender, RoutedEventArgs e)
        {
            string    InitialTextBlockName = "InitialsTextBlock";
            TextBlock initialTextBlock     = VisualTreeUtils.FindVisualChildByName(this.TestPersonPicture, InitialTextBlockName) as TextBlock;

            if (initialTextBlock != null)
            {
                AutomationProperties.SetName(initialTextBlock, InitialTextBlockName);
                AutomationProperties.SetAccessibilityView(initialTextBlock, AccessibilityView.Content);
            }

            string    badgeTextBlockName = "BadgeNumberTextBlock";
            TextBlock badgeTextBlock     = VisualTreeUtils.FindVisualChildByName(this.TestPersonPicture, badgeTextBlockName) as TextBlock;

            if (badgeTextBlock != null)
            {
                AutomationProperties.SetName(badgeTextBlock, badgeTextBlockName);
                AutomationProperties.SetAccessibilityView(badgeTextBlock, AccessibilityView.Content);
            }

            string   badgeGlyphIconName = "BadgeGlyphIcon";
            FontIcon badgeFontIcon      = VisualTreeUtils.FindVisualChildByName(this.TestPersonPicture, badgeGlyphIconName) as FontIcon;

            if (badgeFontIcon != null)
            {
                AutomationProperties.SetName(badgeFontIcon, badgeGlyphIconName);
                AutomationProperties.SetAccessibilityView(badgeFontIcon, AccessibilityView.Content);
            }

            string  badgeEllipseName = "BadgingEllipse";
            Ellipse badgeEllipse     = VisualTreeUtils.FindVisualChildByName(this.TestPersonPicture, badgeEllipseName) as Ellipse;

            if (badgeEllipse != null)
            {
                AutomationProperties.SetName(badgeEllipse, badgeEllipseName);
                AutomationProperties.SetAccessibilityView(badgeEllipse, AccessibilityView.Content);
            }

            // Uno docs: This currently fails and returns null.
            // https://github.com/unoplatform/uno/issues/7258
            //CollectionViewSource cvs = rootGrid.FindName("cvs") as CollectionViewSource;
            cvs.Source          = GetGroupedPeople();
            cvs.IsSourceGrouped = true;
        }
Esempio n. 14
0
 public void TreeViewItemContainerTransitionTest()
 {
     RunOnUIThread.Execute(() =>
     {
         TreeView treeView = new TreeView();
         treeView.Loaded  += (object sender, RoutedEventArgs e) =>
         {
             var transition = (TransitionCollection)XamlReader.Load(
                 @"<TransitionCollection xmlns='http://schemas.microsoft.com/winfx/2006/xaml/presentation'> 
                     <ContentThemeTransition />
               </TransitionCollection>");
             treeView.ItemContainerTransitions = transition;
             var node = new TreeViewNode();
             treeView.RootNodes.Add(node);
             var listControl  = VisualTreeUtils.FindVisualChildByName(treeView, "ListControl") as TreeViewList;
             var treeViewItem = listControl.ContainerFromItem(node) as TreeViewItem;
             Verify.AreEqual(treeViewItem.ContentTransitions, transition);
         };
     });
 }
Esempio n. 15
0
 public void TreeViewItemTemplateTest()
 {
     RunOnUIThread.Execute(() =>
     {
         TreeView treeView = new TreeView();
         treeView.Loaded  += (object sender, RoutedEventArgs e) =>
         {
             var dataTemplate = (DataTemplate)XamlReader.Load(
                 @"<DataTemplate xmlns='http://schemas.microsoft.com/winfx/2006/xaml/presentation'> 
                   <TextBlock Text='TreeViewItemTemplate'/>
               </DataTemplate>");
             treeView.ItemTemplate = dataTemplate;
             var node = new TreeViewNode();
             treeView.RootNodes.Add(node);
             var listControl  = VisualTreeUtils.FindVisualChildByName(treeView, "ListControl") as TreeViewList;
             var treeViewItem = listControl.ContainerFromItem(node) as TreeViewItem;
             Verify.AreEqual(treeViewItem.ContentTemplate, dataTemplate);
         };
     });
 }
Esempio n. 16
0
 public void TreeViewItemContainerStyleTest()
 {
     RunOnUIThread.Execute(() =>
     {
         TreeView treeView = new TreeView();
         treeView.Loaded  += (object sender, RoutedEventArgs e) =>
         {
             var style = (Style)XamlReader.Load(
                 @"<Style xmlns='http://schemas.microsoft.com/winfx/2006/xaml/presentation'> 
                   <Setter Property='Background' Value='Green'/>
               </Style>");
             treeView.ItemContainerStyle = style;
             var node = new TreeViewNode();
             treeView.RootNodes.Add(node);
             var listControl  = VisualTreeUtils.FindVisualChildByName(treeView, "ListControl") as TreeViewList;
             var treeViewItem = listControl.ContainerFromItem(node) as TreeViewItem;
             Verify.AreEqual(treeViewItem.Style, style);
         };
     });
 }
        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");
            });
        }
        // This takes a FrameworkElement parameter so you can pass in either a ColorPicker or a ColorSpectrum.
        private void SetAsRootAndWaitForColorSpectrumFill(FrameworkElement element)
        {
            ManualResetEvent spectrumLoadedEvent = new ManualResetEvent(false);

            RunOnUIThread.Execute(() =>
            {
                element.Loaded += (sender, args) =>
                {
                    var spectrumRectangle = VisualTreeUtils.FindVisualChildByName(element, "SpectrumRectangle") as Rectangle;
                    Verify.IsNotNull(spectrumRectangle);

                    spectrumRectangle.RegisterPropertyChangedCallback(Shape.FillProperty, (o, dp) =>
                    {
                        spectrumLoadedEvent.Set();
                    });
                };

                Content = element;
                Content.UpdateLayout();
            });

            spectrumLoadedEvent.WaitOne();
        }
Esempio n. 19
0
        public void TreeViewBackgroundTest()
        {
            RunOnUIThread.Execute(() =>
            {
                var treeView = new TreeView();

                Content = treeView;
                Content.UpdateLayout();

                var treeViewList = VisualTreeUtils.FindVisualChildByName(treeView, "ListControl") as TreeViewList;

                // Make sure the TreeViewList does not already have the background color we are using for this test.
                bool testCondition = treeViewList.Background is SolidColorBrush brush && brush.Color == Colors.Green;
                Verify.IsFalse(testCondition, "The default TreeView background color should not match the test color used.");

                // Check if the Background API affects the TreeView control.
                treeView.Background = new SolidColorBrush(Colors.Green);
                Content.UpdateLayout();

                testCondition = treeViewList.Background is SolidColorBrush brush2 && brush2.Color == Colors.Green;
                Verify.IsTrue(testCondition, "The TreeView background UI should have matched the specified test color.");
            });
        }
        public void VerifyClearingAlphaChannelInputFieldDoesNotCrash()
        {
            ColorPicker colorPicker = null;

            RunOnUIThread.Execute(() =>
            {
                colorPicker = new ColorPicker();
                colorPicker.IsAlphaEnabled = true;

                Content = colorPicker;
            });

            IdleSynchronizer.Wait();

            RunOnUIThread.Execute(() =>
            {
                var alphaChannelTextBox = VisualTreeUtils.FindVisualChildByName(colorPicker, "AlphaTextBox") as TextBox;

                Verify.IsGreaterThan(alphaChannelTextBox.Text.Length, 0, "Alpha channel TextBox should have not been empty.");

                // Clearing the alpha channel input field should not crash the app.
                alphaChannelTextBox.Text = "";
            });
        }
        // This takes a FrameworkElement parameter so you can pass in either a ColorPicker or a ColorSpectrum.
        private void SetAsRootAndWaitForColorSpectrumFill(FrameworkElement element)
        {
            ManualResetEvent spectrumLoadedEvent = new ManualResetEvent(false);

            RunOnUIThread.Execute(() =>
            {
                element.Loaded += (sender, args) =>
                {
                    var spectrumRectangle = VisualTreeUtils.FindVisualChildByName(element, "SpectrumRectangle") as Rectangle;
                    Verify.IsNotNull(spectrumRectangle);

                    spectrumRectangle.RegisterPropertyChangedCallback(Shape.FillProperty, (o, dp) =>
                    {
                        spectrumLoadedEvent.Set();
                    });
                };

                StackPanel root = new StackPanel();
                root.Children.Add(element);
                MUXControlsTestApp.App.TestContentRoot = root;
            });

            spectrumLoadedEvent.WaitOne();
        }
        public void GetScrollIncreaseButtonEnabled_Click(object sender, RoutedEventArgs e)
        {
            var scrollIncreaseButton = VisualTreeUtils.FindVisualChildByName(Tabs, "ScrollIncreaseButton") as RepeatButton;

            ScrollIncreaseButtonEnabled.Text = scrollIncreaseButton.IsEnabled ? "True" : "False";
        }
Esempio n. 23
0
        public async Task VerifyVSMStatesForPhotosAndInitials()
        {
            PersonPicture personPicture     = null;
            TextBlock     initialsTextBlock = null;

#if WINDOWS_UWP
            string symbolsFontName = "Segoe MDL2 Assets";
#elif __ANDROID__ || __SKIA__
            string symbolsFontName = "ms-appx:///Assets/Fonts/uno-fluentui-assets.ttf#Symbols";
#else
            string symbolsFontName = "Symbols";
#endif
            await RunOnUIThread.ExecuteAsync(() =>
            {
                personPicture = new PersonPicture();
                global::Private.Infrastructure.TestServices.WindowHelper.WindowContent = personPicture;
            });

            await global::Private.Infrastructure.TestServices.WindowHelper.WaitForIdle();

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

            await global::Private.Infrastructure.TestServices.WindowHelper.WaitForIdle();

            await RunOnUIThread.ExecuteAsync(() =>
            {
                Verify.AreEqual(initialsTextBlock.FontFamily.Source, symbolsFontName);
                Verify.AreEqual(initialsTextBlock.Text, "\xE716");

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

            await global::Private.Infrastructure.TestServices.WindowHelper.WaitForIdle();

            await RunOnUIThread.ExecuteAsync(() =>
            {
#if false
                Verify.AreEqual(initialsTextBlock.FontFamily.Source, "Segoe UI");
#endif
                Verify.AreEqual(initialsTextBlock.Text, "JS");

                personPicture.Initials = "";
            });

            await global::Private.Infrastructure.TestServices.WindowHelper.WaitForIdle();

            await RunOnUIThread.ExecuteAsync(() =>
            {
                Verify.AreEqual(initialsTextBlock.FontFamily.Source, symbolsFontName);
                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   = "👍";
            });

            await global::Private.Infrastructure.TestServices.WindowHelper.WaitForIdle();

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

                personPicture.IsGroup = true;
            });

            await global::Private.Infrastructure.TestServices.WindowHelper.WaitForIdle();

            await RunOnUIThread.ExecuteAsync(() =>
            {
                Verify.AreEqual(initialsTextBlock.FontFamily.Source, symbolsFontName);
                Verify.AreEqual(initialsTextBlock.Text, "\xE716");
            });
        }
        public void TabViewScrollToTheMiddleButton_Click(object sender, RoutedEventArgs e)
        {
            var scrollViewer = VisualTreeUtils.FindVisualChildByName(Tabs, "ScrollViewer") as ScrollViewer;

            scrollViewer.ChangeView(scrollViewer.ScrollableWidth / 2.0f, null, null, true);
        }
        public void TabViewScrollToTheRightButton_Click(object sender, RoutedEventArgs e)
        {
            var scrollViewer = VisualTreeUtils.FindVisualChildByName(Tabs, "ScrollViewer") as ScrollViewer;

            scrollViewer.ChangeView(double.MaxValue, null, null, true);
        }
Esempio n. 26
0
        public void IncreaseScrollButton_Click(object sender, RoutedEventArgs e)
        {
            var sv = VisualTreeUtils.FindVisualChildByName(Tabs, "ScrollViewer") as ScrollViewer;

            sv.ChangeView(10000, null, null, disableAnimation: true);
        }
        [TestProperty("TestPass:IncludeOnlyOn", "Desktop")] // TeachingTip doesn't appear to show up correctly in OneCore.
        public void TeachingTipBackgroundTest()
        {
            TeachingTip     teachingTip = null, teachingTipLightDismiss = null;
            SolidColorBrush blueBrush = null;
            Brush           lightDismissBackgroundBrush = null;
            var             loadedEvent = new AutoResetEvent(false);

            RunOnUIThread.Execute(() =>
            {
                Grid root           = new Grid();
                teachingTip         = new TeachingTip();
                teachingTip.Loaded += (object sender, RoutedEventArgs args) => { loadedEvent.Set(); };

                teachingTipLightDismiss = new TeachingTip();
                teachingTipLightDismiss.IsLightDismissEnabled = true;

                // Set LightDismiss background before show... it shouldn't take effect in the tree
                blueBrush = new SolidColorBrush(Colors.Blue);
                teachingTipLightDismiss.Background = blueBrush;

                root.Resources.Add("TeachingTip", teachingTip);
                root.Resources.Add("TeachingTipLightDismiss", teachingTipLightDismiss);

                lightDismissBackgroundBrush = MUXControlsTestApp.App.Current.Resources["TeachingTipTransientBackground"] as Brush;
                Verify.IsNotNull(lightDismissBackgroundBrush, "lightDismissBackgroundBrush");

                teachingTip.IsOpen             = true;
                teachingTipLightDismiss.IsOpen = true;

                MUXControlsTestApp.App.TestContentRoot = root;
            });

            IdleSynchronizer.Wait();
            loadedEvent.WaitOne();
            IdleSynchronizer.Wait();

            RunOnUIThread.Execute(() =>
            {
                var redBrush = new SolidColorBrush(Colors.Red);
                teachingTip.SetValue(TeachingTip.BackgroundProperty, redBrush);
                Verify.AreSame(redBrush, teachingTip.GetValue(TeachingTip.BackgroundProperty) as Brush);
                Verify.AreSame(redBrush, teachingTip.Background);

                teachingTip.Background = blueBrush;
                Verify.AreSame(blueBrush, teachingTip.Background);

                {
                    var popup      = TeachingTipTestHooks.GetPopup(teachingTip);
                    var child      = popup.Child;
                    var grandChild = VisualTreeHelper.GetChild(child, 0);
                    Verify.AreSame(blueBrush, ((Grid)grandChild).Background, "Checking TeachingTip.Background TemplateBinding works");
                }

                {
                    var popup = TeachingTipTestHooks.GetPopup(teachingTipLightDismiss);
                    var child = popup.Child as Grid;

                    Log.Comment("Checking LightDismiss TeachingTip Background is using resource for first invocation");

                    Grid tailEdgeBorder                   = VisualTreeUtils.FindVisualChildByName(child, "TailEdgeBorder") as Grid;
                    Polygon tailPolygon                   = VisualTreeUtils.FindVisualChildByName(child, "TailPolygon") as Polygon;
                    Polygon topTailPolygonHighlight       = VisualTreeUtils.FindVisualChildByName(child, "TopTailPolygonHighlight") as Polygon;
                    Grid contentRootGrid                  = VisualTreeUtils.FindVisualChildByName(child, "ContentRootGrid") as Grid;
                    ContentPresenter mainContentPresenter = VisualTreeUtils.FindVisualChildByName(child, "MainContentPresenter") as ContentPresenter;
                    Border heroContentBorder              = VisualTreeUtils.FindVisualChildByName(child, "HeroContentBorder") as Border;

                    VerifyLightDismissTipBackground(tailEdgeBorder.Background, "TailEdgeBorder");
                    VerifyLightDismissTipBackground(tailPolygon.Fill, "TailPolygon");
                    VerifyLightDismissTipBackground(topTailPolygonHighlight.Fill, "TopTailPolygonHighlight");
                    VerifyLightDismissTipBackground(contentRootGrid.Background, "ContentRootGrid");
                    VerifyLightDismissTipBackground(mainContentPresenter.Background, "MainContentPresenter");
                    VerifyLightDismissTipBackground(heroContentBorder.Background, "HeroContentBorder");

                    void VerifyLightDismissTipBackground(Brush brush, string uiPart)
                    {
                        if (lightDismissBackgroundBrush != brush)
                        {
                            if (brush is SolidColorBrush actualSolidBrush)
                            {
                                string teachingTipMessage = $"LightDismiss TeachingTip's {uiPart} Background is SolidColorBrush with color {actualSolidBrush.Color}";
                                Log.Comment(teachingTipMessage);
                                Verify.Fail(teachingTipMessage);
                            }
                            else
                            {
                                Verify.AreSame(lightDismissBackgroundBrush, brush, $"Checking LightDismiss TeachingTip's {uiPart} Background is using resource for first invocation");
                            }
                        }
                    }
                }

                teachingTip.IsLightDismissEnabled = true;
            });

            IdleSynchronizer.Wait();

            RunOnUIThread.Execute(() =>
            {
                Verify.AreEqual(blueBrush.Color, ((SolidColorBrush)teachingTip.Background).Color);

                var popup = TeachingTipTestHooks.GetPopup(teachingTip);
                var child = popup.Child as Grid;

                Grid tailEdgeBorder                   = VisualTreeUtils.FindVisualChildByName(child, "TailEdgeBorder") as Grid;
                Polygon tailPolygon                   = VisualTreeUtils.FindVisualChildByName(child, "TailPolygon") as Polygon;
                Polygon topTailPolygonHighlight       = VisualTreeUtils.FindVisualChildByName(child, "TopTailPolygonHighlight") as Polygon;
                Grid contentRootGrid                  = VisualTreeUtils.FindVisualChildByName(child, "ContentRootGrid") as Grid;
                ContentPresenter mainContentPresenter = VisualTreeUtils.FindVisualChildByName(child, "MainContentPresenter") as ContentPresenter;
                Border heroContentBorder              = VisualTreeUtils.FindVisualChildByName(child, "HeroContentBorder") as Border;

                VerifyBackgroundChanged(tailEdgeBorder.Background, "TailEdgeBorder");
                VerifyBackgroundChanged(tailPolygon.Fill, "TailPolygon");
                VerifyBackgroundChanged(topTailPolygonHighlight.Fill, "TopTailPolygonHighlight");
                VerifyBackgroundChanged(contentRootGrid.Background, "ContentRootGrid");
                VerifyBackgroundChanged(mainContentPresenter.Background, "MainContentPresenter");
                VerifyBackgroundChanged(heroContentBorder.Background, "HeroContentBorder");

                void VerifyBackgroundChanged(Brush brush, string uiPart)
                {
                    // If we can no longer cast the background brush to a solid color brush then changing the
                    // IsLightDismissEnabled has changed the background as we expected it to.
                    if (brush is SolidColorBrush solidColorBrush)
                    {
                        Verify.AreNotEqual(blueBrush.Color, solidColorBrush.Color, $"TeachingTip's {uiPart} Background should have changed");
                    }
                }
            });
        }
Esempio n. 28
0
        public void TreeViewClearAndSetAtTest()
        {
            RunOnUIThread.Execute(() =>
            {
                var treeView = new TreeView();

                Content = treeView;
                Content.UpdateLayout();
                var listControl = VisualTreeUtils.FindVisualChildByName(treeView, "ListControl") as TreeViewList;
                // Verify TreeViewNode::SetAt
                TreeViewNode setAtChildCheckNode = new TreeViewNode()
                {
                    Content = "Set At Child"
                };
                TreeViewNode setAtRootCheckNode = new TreeViewNode()
                {
                    Content = "Set At Root"
                };

                TreeViewNode child1 = new TreeViewNode()
                {
                    Content = "Child 1"
                };
                child1.Children.Add(new TreeViewNode()
                {
                    Content = "Child 1:1"
                });

                TreeViewNode child2 = new TreeViewNode()
                {
                    Content = "Child 2"
                };
                child2.Children.Add(new TreeViewNode()
                {
                    Content = "Child 2:1"
                });
                child2.Children.Add(new TreeViewNode()
                {
                    Content = "Child 2:2"
                });

                treeView.RootNodes.Add(child1);
                child1.IsExpanded = true;
                treeView.RootNodes.Add(child2);
                Verify.AreEqual(listControl.Items.Count, 3);

                // SetAt node under child node which is not expanded
                child2.Children[1] = setAtChildCheckNode;
                Verify.AreEqual(listControl.Items.Count, 3);

                // SetAt node under root node and child2 is expanded
                treeView.RootNodes[0] = setAtRootCheckNode;
                child2.IsExpanded     = true;
                Verify.AreEqual(listControl.Items.Count, 4);

                // Verify RootNode.Clear
                treeView.RootNodes.Clear();
                Verify.AreEqual(listControl.Items.Count, 0);

                // test clear without any child node
                treeView.RootNodes.Clear();
                Verify.AreEqual(listControl.Items.Count, 0);
            });
        }
Esempio n. 29
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");
            });
        }
Esempio n. 30
0
        public void VerifyExpandCollapseChevronVisibility()
        {
            NavigationView                navView    = null;
            NavigationViewItem            parentItem = null;
            ObservableCollection <string> children   = null;

            RunOnUIThread.Execute(() =>
            {
                navView = new NavigationView();
                Content = navView;

                children   = new ObservableCollection <string>();
                parentItem = new NavigationViewItem()
                {
                    Content = "ParentItem", MenuItemsSource = children
                };

                navView.MenuItems.Add(parentItem);

                navView.Width = 1008; // forces the control into Expanded mode so that the menu renders
                Content.UpdateLayout(true);

                UIElement chevronUIElement = (UIElement)VisualTreeUtils.FindVisualChildByName(parentItem, "ExpandCollapseChevron");
                Verify.IsTrue(chevronUIElement.Visibility == Visibility.Collapsed, "chevron should have been collapsed as NavViewItem has no children");

                // Add a child to parentItem through the MenuItemsSource API. This should make the chevron visible.
                children.Add("Child 1");
                Content.UpdateLayout(true);

                Verify.IsTrue(chevronUIElement.Visibility == Visibility.Visible, "chevron should have been visible as NavViewItem now has children");

                // Remove all children of parentItem. This should collapse the chevron
                children.Clear();
                Content.UpdateLayout(true);

                Verify.IsTrue(chevronUIElement.Visibility == Visibility.Collapsed, "chevron should have been collapsed as NavViewItem no longer has children");

                // Add a child to parentItem and set the MenuItemsSource as null. This should collapse the chevron
                children.Add("Child 2");
                Content.UpdateLayout(true);

                // we are doing this so that when we set MenuItemsSource as null, we can check if the chevron's visibility really changes
                Verify.IsTrue(chevronUIElement.Visibility == Visibility.Visible, "chevron should have been visible as NavViewItem now has children");

                parentItem.MenuItemsSource = null;
                Content.UpdateLayout(true);

                Verify.IsTrue(chevronUIElement.Visibility == Visibility.Collapsed, "chevron should have been collapsed as NavViewItem no longer has children");

                // Add a child to parentItem through the MenuItems API. This should make the chevron visible.
                parentItem.MenuItems.Add(new NavigationViewItem()
                {
                    Content = "Child 3"
                });
                Content.UpdateLayout(true);

                Verify.IsTrue(chevronUIElement.Visibility == Visibility.Visible, "chevron should have been visible as NavViewItem now has children");

                // Remove all children of parentItem. This should collapse the chevron
                parentItem.MenuItems.Clear();
                Content.UpdateLayout(true);

                Verify.IsTrue(chevronUIElement.Visibility == Visibility.Collapsed, "chevron should have been collapsed as NavViewItem no longer has children");
            });
        }