Skip to content

Commit

Permalink
Fix issue where pips pagers crash when the next or previous arrow but…
Browse files Browse the repository at this point in the history
…ton 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
  • Loading branch information
StephenLPeters authored Feb 4, 2022
1 parent f2797be commit e4c5d34
Show file tree
Hide file tree
Showing 6 changed files with 95 additions and 48 deletions.
16 changes: 15 additions & 1 deletion dev/PipsPager/InteractionTests/PipsPagerTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,7 @@ public void PipSizeWithDifferentOrientationsTest()
elements = new PipsPagerElements();
Button getButtonSizesButton = elements.GetPipsPagerButtonSizesButton();
getButtonSizesButton.InvokeAndWait();

TextBlock horizontalOrientationPipsPagerButtonWidth = elements.GetHorizontalOrientationPipsPagerButtonWidthTextBlock();
TextBlock horizontalOrientationPipsPagerButtonHeight = elements.GetHorizontalOrientationPipsPagerButtonHeightTextBlock();

Expand Down Expand Up @@ -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());
}
}
}
}
28 changes: 14 additions & 14 deletions dev/PipsPager/PipsPager_themeresources.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -207,21 +207,21 @@
</VisualState>
</VisualStateGroup>
</VisualStateManager.VisualStateGroups>
<FontIcon
x:Name="Content"
FontSize="{TemplateBinding FontSize}"
FontFamily="{TemplateBinding FontFamily}"
Glyph="{TemplateBinding Content}"
MirroredWhenRightToLeft="True"
Foreground="{TemplateBinding Foreground}"
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
AutomationProperties.AccessibilityView="Raw"
RenderTransformOrigin="0.5, 0.5">
<FontIcon.RenderTransform>
<Border RenderTransformOrigin="0.5, 0.5">
<Border.RenderTransform>
<ScaleTransform x:Name="ScaleTransform" ScaleY="1" ScaleX="1" />
</FontIcon.RenderTransform>
</FontIcon>
</Border.RenderTransform>
<FontIcon
x:Name="Content"
FontSize="{TemplateBinding FontSize}"
FontFamily="{TemplateBinding FontFamily}"
Glyph="{TemplateBinding Content}"
MirroredWhenRightToLeft="True"
Foreground="{TemplateBinding Foreground}"
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
AutomationProperties.AccessibilityView="Raw"/>
</Border>
</Grid>
</ControlTemplate>
</Setter.Value>
Expand Down
7 changes: 3 additions & 4 deletions dev/RatingControl/InteractionTests/RatingControlTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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");
Expand Down
39 changes: 23 additions & 16 deletions test/TestAppUtils/TestFrame.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;

Expand All @@ -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
Expand All @@ -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;
Expand Down
6 changes: 6 additions & 0 deletions test/TestAppUtils/Themes/Generic.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,12 @@
IsChecked="True" Margin="0,0,4,0"
AutomationProperties.AutomationId="__InnerFrameInLabDimensions"
Content="Render innerframe in lab dimensions"/>
<ToggleButton
x:Name="EnableRTL"
IsChecked="False" Margin="0,0,4,0"
AutomationProperties.AutomationId="__EnableRTL"
IsTabStop="False"
Content="Enable RTL"/>

<TextBlock x:Name="CurrentPageTextBlock" AutomationProperties.AutomationId="__CurrentPage" FontSize="18" VerticalAlignment="Center" Margin="10,0,0,0"/>
</StackPanel>
Expand Down
47 changes: 34 additions & 13 deletions test/testinfra/MUXTestInfra/Infra/TestHelpers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -176,19 +176,7 @@ private bool TestSingleRun(ICollection<string> 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++;
}
Expand Down Expand Up @@ -246,6 +234,39 @@ public TestSetupHelper(ICollection<string> 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()
{
Expand Down

0 comments on commit e4c5d34

Please sign in to comment.