From 4dca7b68f9ae62a65d9e90ad3c8617f999e0add2 Mon Sep 17 00:00:00 2001 From: Ramez Ragaa Date: Wed, 17 Jan 2024 13:05:23 +0200 Subject: [PATCH] test: FeatureConfiguration changes while native textbox overlay is focused --- .../Given_TextBox.skia.cs | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/src/Uno.UI.RuntimeTests/Tests/Windows_UI_Xaml_Controls/Given_TextBox.skia.cs b/src/Uno.UI.RuntimeTests/Tests/Windows_UI_Xaml_Controls/Given_TextBox.skia.cs index b433eac90e4a..8ee3d8876ab9 100644 --- a/src/Uno.UI.RuntimeTests/Tests/Windows_UI_Xaml_Controls/Given_TextBox.skia.cs +++ b/src/Uno.UI.RuntimeTests/Tests/Windows_UI_Xaml_Controls/Given_TextBox.skia.cs @@ -12,6 +12,7 @@ using Microsoft.UI.Xaml.Media; using FluentAssertions; using MUXControlsTestApp.Utilities; +using Uno.Disposables; using Uno.Extensions; using Uno.UI.RuntimeTests.Helpers; using Uno.UI.Xaml.Core; @@ -3182,6 +3183,34 @@ public async Task When_Paste_Does_Not_Change_Text() Assert.AreEqual(0, SUT.SelectionLength); } + [TestMethod] + public async Task When_FeatureConfiguration_Changes() + { + var useOverlay = FeatureConfiguration.TextBox.UseOverlayOnSkia; + using var _ = Disposable.Create(() => FeatureConfiguration.TextBox.UseOverlayOnSkia = useOverlay); + + FeatureConfiguration.TextBox.UseOverlayOnSkia = true; + + var SUT = new TextBox + { + Width = 150, + Text = "hello world" + }; + + await UITestHelper.Load(SUT); + + SUT.Focus(FocusState.Programmatic); + await WindowHelper.WaitForIdle(); + + Assert.AreEqual(0, SUT.TextBoxView.DisplayBlock.Opacity); + + FeatureConfiguration.TextBox.UseOverlayOnSkia = false; + + await UITestHelper.Load(new Button()); // a random control to unload SUT + + Assert.AreEqual(1, SUT.TextBoxView.DisplayBlock.Opacity); + } + private class TextBoxFeatureConfigDisposable : IDisposable { private bool _useOverlay;