From e4c5d3443caa0242be0953010dd5ab3ddb4c2925 Mon Sep 17 00:00:00 2001 From: Stephen L Peters Date: Fri, 4 Feb 2022 09:26:05 -0800 Subject: [PATCH] Fix issue where pips pagers crash when the next or previous arrow button is clicked in RTL flow direction (#6607) * Fix by moving scale transform to a parent border. * Remove new button from tab order to preserve test behavior * Fix rating control test --- .../InteractionTests/PipsPagerTests.cs | 16 ++++++- dev/PipsPager/PipsPager_themeresources.xaml | 28 +++++------ .../InteractionTests/RatingControlTests.cs | 7 ++- test/TestAppUtils/TestFrame.cs | 39 ++++++++------- test/TestAppUtils/Themes/Generic.xaml | 6 +++ .../MUXTestInfra/Infra/TestHelpers.cs | 47 ++++++++++++++----- 6 files changed, 95 insertions(+), 48 deletions(-) diff --git a/dev/PipsPager/InteractionTests/PipsPagerTests.cs b/dev/PipsPager/InteractionTests/PipsPagerTests.cs index 7fb218abfa..354b4d1888 100755 --- a/dev/PipsPager/InteractionTests/PipsPagerTests.cs +++ b/dev/PipsPager/InteractionTests/PipsPagerTests.cs @@ -326,7 +326,7 @@ public void PipSizeWithDifferentOrientationsTest() elements = new PipsPagerElements(); Button getButtonSizesButton = elements.GetPipsPagerButtonSizesButton(); getButtonSizesButton.InvokeAndWait(); - + TextBlock horizontalOrientationPipsPagerButtonWidth = elements.GetHorizontalOrientationPipsPagerButtonWidthTextBlock(); TextBlock horizontalOrientationPipsPagerButtonHeight = elements.GetHorizontalOrientationPipsPagerButtonHeightTextBlock(); @@ -364,5 +364,19 @@ public void PipSizeAfterOrientationChangeTest() Verify.AreEqual("12", horizontalOrientationPipsPagerButtonHeight.DocumentText); } } + + + [TestMethod] + [TestProperty("TestSuite", "F")] + public void PipsPagerRTLDoesNotCrash() + { + using (var setup = new TestSetupHelper("PipsPager Tests")) + { + elements = new PipsPagerElements(); + TestSetupHelper.SetInnerFrameFlowDirection(FlowDirection.RightToLeft); + SetNextPageButtonVisibilityMode(ButtonVisibilityMode.Visible); + InputHelper.LeftClick(elements.GetNextPageButton()); + } + } } } diff --git a/dev/PipsPager/PipsPager_themeresources.xaml b/dev/PipsPager/PipsPager_themeresources.xaml index 2165f8a081..b1da3275fe 100755 --- a/dev/PipsPager/PipsPager_themeresources.xaml +++ b/dev/PipsPager/PipsPager_themeresources.xaml @@ -207,21 +207,21 @@ - - + + - - + + + diff --git a/dev/RatingControl/InteractionTests/RatingControlTests.cs b/dev/RatingControl/InteractionTests/RatingControlTests.cs index c494fd4da2..7084a0b1be 100644 --- a/dev/RatingControl/InteractionTests/RatingControlTests.cs +++ b/dev/RatingControl/InteractionTests/RatingControlTests.cs @@ -85,9 +85,8 @@ public void BasicInteractionTest() Verify.AreEqual("1", textBlock.DocumentText); - Log.Comment("Verify a left key on an RTL rating increases the rating."); - Button rtlbutton = new Button(FindElement.ByName("RTLButton")); - rtlbutton.Invoke(); + Log.Comment("Verify a left key on an RTL rating increases the rating."); + TestSetupHelper.SetInnerFrameFlowDirection(FlowDirection.RightToLeft); Wait.ForIdle(); KeyboardHelper.PressKey(ratingUIObject, Key.Left); @@ -107,7 +106,7 @@ public void BasicInteractionTest() KeyboardHelper.PressKey(ratingUIObject, Key.Up); Verify.AreEqual("5", textBlock.DocumentText); - rtlbutton.Invoke(); + TestSetupHelper.SetInnerFrameFlowDirection(FlowDirection.LeftToRight); Wait.ForIdle(); Log.Comment("Verify home/end keys in LTR"); diff --git a/test/TestAppUtils/TestFrame.cs b/test/TestAppUtils/TestFrame.cs index 6e08a87245..6813759e14 100644 --- a/test/TestAppUtils/TestFrame.cs +++ b/test/TestAppUtils/TestFrame.cs @@ -31,6 +31,7 @@ public UIElement CustomElement private Button _goFullScreenInvokerButton = null; private Button _toggleThemeButton = null; private ToggleButton _innerFrameInLabDimensions = null; + private ToggleButton _enableRTL = null; private TextBlock _currentPageTextBlock = null; private Type _mainPageType = null; private ContentPresenter _pagePresenter = null; @@ -123,6 +124,18 @@ protected override void OnApplyTemplate() _innerFrameInLabDimensions_Unchecked(null, null); } + _enableRTL = (ToggleButton)GetTemplateChild("EnableRTL"); + _enableRTL.Checked += _enableRTL_Checked; + _enableRTL.Unchecked += _enableRTL_Unchecked; + if (_enableRTL.IsChecked == true) + { + _enableRTL_Checked(null, null); + } + else + { + _enableRTL_Unchecked(null, null); + } + _goBackInvokerButton = (Button)GetTemplateChild("GoBackInvokerButton"); _goBackInvokerButton.Click += GoBackInvokerButton_Click; @@ -134,22 +147,6 @@ protected override void OnApplyTemplate() _keyInputReceived = (CheckBox)GetTemplateChild("KeyInputReceived"); } - private void _innerFrameInLabDimensions_Click(object sender, RoutedEventArgs e) - { - if(double.IsInfinity(_pagePresenter.MaxWidth)) - { - // Not CI mode, so enter it now - _pagePresenter.MaxWidth = 1024; - _pagePresenter.MaxHeight = 664; - } - else - { - // We are already in "CI mode" - _pagePresenter.ClearValue(MaxWidthProperty); - _pagePresenter.ClearValue(MaxHeightProperty); - } - } - private void _innerFrameInLabDimensions_Checked(object sender, RoutedEventArgs e) { // Enter CI mode @@ -164,6 +161,16 @@ private void _innerFrameInLabDimensions_Unchecked(object sender, RoutedEventArgs _pagePresenter.ClearValue(MaxHeightProperty); } + private void _enableRTL_Checked(object sender, RoutedEventArgs e) + { + _pagePresenter.FlowDirection = FlowDirection.RightToLeft; + } + + private void _enableRTL_Unchecked(object sender, RoutedEventArgs e) + { + _pagePresenter.FlowDirection = FlowDirection.LeftToRight; + } + private void ToggleThemeButton_Click(object sender,RoutedEventArgs e) { var contentAsFrameworkElement = Window.Current.Content as FrameworkElement; diff --git a/test/TestAppUtils/Themes/Generic.xaml b/test/TestAppUtils/Themes/Generic.xaml index a66a11d5e6..542a7274ac 100644 --- a/test/TestAppUtils/Themes/Generic.xaml +++ b/test/TestAppUtils/Themes/Generic.xaml @@ -61,6 +61,12 @@ IsChecked="True" Margin="0,0,4,0" AutomationProperties.AutomationId="__InnerFrameInLabDimensions" Content="Render innerframe in lab dimensions"/> + diff --git a/test/testinfra/MUXTestInfra/Infra/TestHelpers.cs b/test/testinfra/MUXTestInfra/Infra/TestHelpers.cs index 4b9edb79aa..edc0072fb4 100644 --- a/test/testinfra/MUXTestInfra/Infra/TestHelpers.cs +++ b/test/testinfra/MUXTestInfra/Infra/TestHelpers.cs @@ -176,19 +176,7 @@ private bool TestSingleRun(ICollection testNames, bool shouldRestrictInn Log.Comment("__TestContentLoadedCheckBox checkbox checked, page has loaded"); - ToggleButton tb = new ToggleButton(FindElement.ById("__InnerFrameInLabDimensions")); - if (tb.ToggleState != ToggleState.On && shouldRestrictInnerFrameSize) - { - Log.Comment("toggling the __InnerFrameInLabDimensions toggle button to On."); - tb.Toggle(); - Wait.ForIdle(); - } - else if (tb.ToggleState != ToggleState.Off && !shouldRestrictInnerFrameSize) - { - Log.Comment("toggling the __InnerFrameInLabDimensions toggle button to Off."); - tb.Toggle(); - Wait.ForIdle(); - } + SetInnerFrameInLabDimensions(shouldRestrictInnerFrameSize); OpenedTestPages++; } @@ -246,6 +234,39 @@ public TestSetupHelper(ICollection testNames, TestSetupHelperOptions opt } } } + public static void SetInnerFrameInLabDimensions(bool shouldRestrictInnerFrameSize) + { + ToggleButton tb = new ToggleButton(FindElement.ById("__InnerFrameInLabDimensions")); + if (tb.ToggleState != ToggleState.On && shouldRestrictInnerFrameSize) + { + Log.Comment("toggling the __InnerFrameInLabDimensions toggle button to On."); + tb.Toggle(); + Wait.ForIdle(); + } + else if (tb.ToggleState != ToggleState.Off && !shouldRestrictInnerFrameSize) + { + Log.Comment("toggling the __InnerFrameInLabDimensions toggle button to Off."); + tb.Toggle(); + Wait.ForIdle(); + } + } + + public static void SetInnerFrameFlowDirection(FlowDirection flowDirection) + { + ToggleButton tb = new ToggleButton(FindElement.ById("__EnableRTL")); + if (tb.ToggleState != ToggleState.On && flowDirection == FlowDirection.RightToLeft) + { + Log.Comment("toggling the __EnableRTL toggle button to On."); + tb.Toggle(); + Wait.ForIdle(); + } + else if (tb.ToggleState != ToggleState.Off && flowDirection == FlowDirection.LeftToRight) + { + Log.Comment("toggling the __EnableRTL toggle button to Off."); + tb.Toggle(); + Wait.ForIdle(); + } + } public static void GoBack() {