Beispiel #1
0
        private void TimePickerDensityTest_Click(object sender, RoutedEventArgs e)
        {
            SimpleVerify simpleVerify     = new SimpleVerify();
            var          root             = (FrameworkElement)VisualTreeHelper.GetChild(TimePicker, 0);
            var          contentPresenter = (ContentPresenter)root.FindName("HeaderContentPresenter");

            simpleVerify.IsTrue(contentPresenter != null, "HeaderContentPresenter can't be found");

            string expectedHeaderMargin = "0,0,0,4";
            string expectTimePickerFlyoutPresenterItemPadding = "0,3,0,6";

            if (contentPresenter != null)
            {
                simpleVerify.IsEqual(contentPresenter.Margin.ToString(), expectedHeaderMargin, "HeaderContentPresenter.Margin");
            }

            // Down-level need to change code, so RS5 have different ItemPadding, see bug 19373347, but we will not fix it
            if (!PlatformConfiguration.IsOsVersionGreaterThan(OSVersion.Redstone4))
            {
                var textBlock = (TextBlock)root.FindName("HourTextBlock");
                simpleVerify.IsEqual(textBlock.Padding.ToString(), expectTimePickerFlyoutPresenterItemPadding, "HourTextBlock.Padding");

                textBlock = (TextBlock)root.FindName("MinuteTextBlock");
                simpleVerify.IsEqual(textBlock.Padding.ToString(), expectTimePickerFlyoutPresenterItemPadding, "MinuteTextBlock.Padding");

                textBlock = (TextBlock)root.FindName("PeriodTextBlock");
                simpleVerify.IsEqual(textBlock.Padding.ToString(), expectTimePickerFlyoutPresenterItemPadding, "PeriodTextBlock.Padding");
            }
            DensityTestResult.Text = simpleVerify.ToString();
        }
Beispiel #2
0
        private void ToggleSwitchDensityTest_Click(object sender, RoutedEventArgs e)
        {
            SimpleVerify simpleVerify     = new SimpleVerify();
            var          root             = (FrameworkElement)VisualTreeHelper.GetChild(ToggleSwitch, 0);
            var          contentPresenter = (ContentPresenter)root.FindName("HeaderContentPresenter");

            simpleVerify.IsTrue(contentPresenter != null, "HeaderContentPresenter can't be found");

            string expectedHeaderMargin = "0,0,0,0";
            string expectToggleSwitchPreContentMargin  = "6";
            string expectToggleSwitchPostContentMargin = "6";

            if (contentPresenter != null)
            {
                simpleVerify.IsEqual(contentPresenter.Margin.ToString(), expectedHeaderMargin, "HeaderContentPresenter.Margin");
            }

            var grid = (Grid)root;

            if (grid != null)
            {
                var rowDefinitions = grid.RowDefinitions;

                // layout has been changed since RS5 and it's not 4 rows anymore. We expect RS5  will be covered by UIElement tree test case in os repo.
                if (rowDefinitions.Count == 4)
                {
                    simpleVerify.IsEqual(rowDefinitions[1].Height.ToString(), expectToggleSwitchPreContentMargin, "rowDefinitions[1].Height");
                    simpleVerify.IsEqual(rowDefinitions[3].Height.ToString(), expectToggleSwitchPostContentMargin, "rowDefinitions[3].Height");
                }
            }
            DensityTestResult.Text = simpleVerify.ToString();
        }
Beispiel #3
0
        private void SliderDensityTest_Click(object sender, RoutedEventArgs e)
        {
            string expectSliderPreContentMargin  = "15";
            string expectSliderPostContentMargin = "15";
            string expectSliderHorizontalHeight  = "32";
            string expectSliderVerticalWidth     = "32";

            SimpleVerify simpleVerify = new SimpleVerify();
            // Horizontal Slider
            var root = (FrameworkElement)VisualTreeHelper.GetChild(Slider1, 0);
            var grid = (Grid)root.FindName("HorizontalTemplate");

            simpleVerify.IsTrue(grid != null, "HorizontalTemplate can't be found");
            if (grid != null)
            {
                simpleVerify.IsEqual(grid.MinHeight.ToString(), expectSliderHorizontalHeight, "HorizontalTemplate|MinHeight=SliderHorizontalHeight");
                var rowDefinitions = grid.RowDefinitions;
                if (rowDefinitions.Count == 3)
                {
                    simpleVerify.IsEqual(rowDefinitions[0].Height.ToString(), expectSliderPreContentMargin, "HorizontalTemplate.RowDefinitions[0].Height=SliderPreContentMargin");
                    simpleVerify.IsEqual(rowDefinitions[2].Height.ToString(), expectSliderPostContentMargin, "HorizontalTemplate.RowDefinitions[2].Height=SliderPostContentMargin");
                }
            }

            // Vertical Slider
            root = (FrameworkElement)VisualTreeHelper.GetChild(Slider2, 0);
            grid = (Grid)root.FindName("VerticalTemplate");
            simpleVerify.IsTrue(grid != null, "VerticalTemplate can't be found");
            if (grid != null)
            {
                simpleVerify.IsEqual(grid.MinWidth.ToString(), expectSliderVerticalWidth, "VerticalTemplate|MinWidth=SliderVerticalWidth");
                var columnDefinitions = grid.ColumnDefinitions;
                if (columnDefinitions.Count == 3)
                {
                    simpleVerify.IsEqual(columnDefinitions[0].Width.ToString(), expectSliderPreContentMargin, "VerticalTemplate.columnDefinitions[0].Width=SliderPreContentMargin");
                    simpleVerify.IsEqual(columnDefinitions[2].Width.ToString(), expectSliderPostContentMargin, "VerticalTemplate.columnDefinitions[2].Width=SliderPostContentMargin");
                }
            }
            DensityTestResult.Text = simpleVerify.ToString();
        }
Beispiel #4
0
        private void ListViewItemDensityTest_Click(object sender, RoutedEventArgs e)
        {
            var          item         = ListView1.FindVisualChildByType <ListViewItem>();
            SimpleVerify simpleVerify = new SimpleVerify();

            if (item != null)
            {
                simpleVerify.IsEqual(item.MinHeight.ToString(), "40", "ListViewItem minHeight is 40");
            }
            else
            {
                simpleVerify.IsTrue(false, "Can't find ListViewItem");
            }
            DensityTestResult.Text = simpleVerify.ToString();
        }
 private void VerifyHeight(SimpleVerify simpleVerify, FrameworkElement item, int expectHeight, string controlName)
 {
     if (item != null)
     {
         // Avoid Height because of CornerRadius
         if (Math.Abs(item.ActualHeight - expectHeight) > 0.5)
         {
             simpleVerify.IsEqual(item.ActualHeight.ToString(), expectHeight, controlName + ".ActualHeight=" + expectHeight);
         }
     }
     else
     {
         simpleVerify.IsTrue(false, "Can't find " + controlName);
     }
 }
Beispiel #6
0
        private void HeaderContentPresenterMarginTest(DependencyObject control)
        {
            SimpleVerify simpleVerify     = new SimpleVerify();
            var          root             = (FrameworkElement)VisualTreeHelper.GetChild(control, 0);
            var          contentPresenter = (ContentPresenter)root.FindName("HeaderContentPresenter");

            simpleVerify.IsTrue(contentPresenter != null, "HeaderContentPresenter can't be found");

            string expectedHeaderMargin = control == ComboBox ? "0,0,0,8" : "0,0,0,4";

            if (contentPresenter != null)
            {
                simpleVerify.IsEqual(contentPresenter.Margin.ToString(), expectedHeaderMargin, "HeaderContentPresenter.Margin");
            }

            DensityTestResult.Text = simpleVerify.ToString();
        }