Skip to content

Commit 710b8b6

Browse files
committed
test: add When_Focus_Changes_Selection_Is_Not_Shown
1 parent d098f15 commit 710b8b6

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

src/Uno.UI.RuntimeTests/Tests/Windows_UI_Xaml_Controls/Given_TextBlock.cs

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1749,6 +1749,35 @@ public async Task When_IsTextSelectionEnabled_TouchScroll_Then_DoesNotAlterSelec
17491749
}
17501750
Assert.AreEqual(selectedText, sut.SelectedText);
17511751
}
1752+
1753+
#if HAS_UNO
1754+
[TestMethod]
1755+
public async Task When_Focus_Changes_Selection_Is_Not_Shown()
1756+
{
1757+
if (!ApiInformation.IsTypePresent("Microsoft.UI.Xaml.Media.Imaging.RenderTargetBitmap, Uno.UI"))
1758+
{
1759+
Assert.Inconclusive("RenderTargetBitmap is not supported on this platform");
1760+
}
1761+
1762+
var SUT = new TextBlock { Text = "Some text", IsTextSelectionEnabled = true };
1763+
var focusBtn = new Button();
1764+
await UITestHelper.Load(new StackPanel { Children = { SUT, focusBtn } });
1765+
1766+
SUT.Focus(FocusState.Programmatic);
1767+
SUT.SelectAll();
1768+
await UITestHelper.WaitForIdle();
1769+
await UITestHelper.WaitForRender();
1770+
var screenshot = await UITestHelper.ScreenShot(SUT);
1771+
ImageAssert.HasColorInRectangle(screenshot, new Rectangle(0, 0, screenshot.Width, screenshot.Height), ((SolidColorBrush)Uno.UI.Xaml.Media.DefaultBrushes.SelectionHighlightColor).Color);
1772+
1773+
focusBtn.Focus(FocusState.Programmatic);
1774+
await UITestHelper.WaitForIdle();
1775+
await UITestHelper.WaitForRender();
1776+
var screenshot2 = await UITestHelper.ScreenShot(SUT);
1777+
ImageAssert.DoesNotHaveColorInRectangle(screenshot2, new Rectangle(0, 0, screenshot2.Width, screenshot2.Height), ((SolidColorBrush)Uno.UI.Xaml.Media.DefaultBrushes.SelectionHighlightColor).Color);
1778+
}
1779+
#endif
1780+
17521781
#endregion
17531782
#endif
17541783

0 commit comments

Comments
 (0)