diff --git a/src/SamplesApp/SamplesApp.UITests/Extensions/AppExtensions.cs b/src/SamplesApp/SamplesApp.UITests/Extensions/AppExtensions.cs index 059ec3350558..e8e499f67238 100644 --- a/src/SamplesApp/SamplesApp.UITests/Extensions/AppExtensions.cs +++ b/src/SamplesApp/SamplesApp.UITests/Extensions/AppExtensions.cs @@ -5,6 +5,8 @@ using System.IO; using System.Linq; using System.Text; +using System.Threading; +using System.Threading.Tasks; using Uno.UITest; using Uno.UITest.Helpers; using Uno.UITest.Helpers.Queries; @@ -13,6 +15,14 @@ namespace SamplesApp.UITests.Extensions { public static class AppExtensions { +#if !IS_RUNTIME_UI_TESTS + public static async Task TakeScreenshotAsync(this IApp app, string title) + => app.Screenshot(title); + + public static async ValueTask DragCoordinatesAsync(this IApp app, float fromX, float fromY, float toX, float toY, CancellationToken ct = default) + => app.DragCoordinates(fromX, fromY, toX, toY); +#endif + public static void DragCoordinates(this IApp app, PointF from, PointF to) => app.DragCoordinates(from.X, from.Y, to.X, to.Y); #if !IS_RUNTIME_UI_TESTS diff --git a/src/SamplesApp/SamplesApp.UITests/SampleControlUITestBase.cs b/src/SamplesApp/SamplesApp.UITests/SampleControlUITestBase.cs index dbeaa0ff1279..dacf493805d8 100644 --- a/src/SamplesApp/SamplesApp.UITests/SampleControlUITestBase.cs +++ b/src/SamplesApp/SamplesApp.UITests/SampleControlUITestBase.cs @@ -281,6 +281,9 @@ private void WriteSystemLogs(string fileName) } } + public async ValueTask TakeScreenshotAsync(string stepName, bool? ignoreInSnapshotCompare = null) + => TakeScreenshot(stepName, ignoreInSnapshotCompare); + public ScreenshotInfo TakeScreenshot(string stepName, bool? ignoreInSnapshotCompare = null) => TakeScreenshot( stepName, @@ -289,6 +292,9 @@ public ScreenshotInfo TakeScreenshot(string stepName, bool? ignoreInSnapshotComp : null ); + public async ValueTask TakeScreenshotAsync(string stepName, ScreenshotOptions options) + => TakeScreenshot(stepName, options); + public ScreenshotInfo TakeScreenshot(string stepName, ScreenshotOptions options) { if (_app == null) diff --git a/src/SamplesApp/SamplesApp.UITests/SamplesApp.UITests.csproj b/src/SamplesApp/SamplesApp.UITests/SamplesApp.UITests.csproj index f7c4c2ece07e..3b26d315785f 100644 --- a/src/SamplesApp/SamplesApp.UITests/SamplesApp.UITests.csproj +++ b/src/SamplesApp/SamplesApp.UITests/SamplesApp.UITests.csproj @@ -8,7 +8,7 @@ $(DefineConstants);TARGET_FRAMEWORK_OVERRIDE_IOS - $(NoWarn);SYSLIB1045 + $(NoWarn);SYSLIB1045;CS1998 diff --git a/src/SamplesApp/SamplesApp.UITests/TestFramework/ImageAssert.cs b/src/SamplesApp/SamplesApp.UITests/TestFramework/ImageAssert.cs index 78350753dd12..4f09ccb0ced0 100644 --- a/src/SamplesApp/SamplesApp.UITests/TestFramework/ImageAssert.cs +++ b/src/SamplesApp/SamplesApp.UITests/TestFramework/ImageAssert.cs @@ -37,16 +37,27 @@ static ImageAssert() #region Are[Almost]Equal public static void AreEqual(ScreenshotInfo expected, ScreenshotInfo actual, IAppRect rect, double expectedToActualScale = 1, PixelTolerance tolerance = default, [CallerLineNumber] int line = 0) => AreEqualImpl(expected, rect.ToRectangle(), actual, rect.ToRectangle(), expectedToActualScale, tolerance, line); + public static async Task AreEqualAsync(ScreenshotInfo expected, ScreenshotInfo actual, IAppRect rect, double expectedToActualScale = 1, PixelTolerance tolerance = default, [CallerLineNumber] int line = 0) + => AreEqualImpl(expected, rect.ToRectangle(), actual, rect.ToRectangle(), expectedToActualScale, tolerance, line); public static void AreEqual(ScreenshotInfo expected, ScreenshotInfo actual, Rectangle? rect = null, double expectedToActualScale = 1, PixelTolerance tolerance = default, [CallerLineNumber] int line = 0) => AreEqualImpl(expected, rect ?? FirstQuadrant, actual, rect ?? FirstQuadrant, expectedToActualScale, tolerance, line); + public static async Task AreEqualAsync(ScreenshotInfo expected, ScreenshotInfo actual, Rectangle? rect = null, double expectedToActualScale = 1, PixelTolerance tolerance = default, [CallerLineNumber] int line = 0) + => AreEqualImpl(expected, rect ?? FirstQuadrant, actual, rect ?? FirstQuadrant, expectedToActualScale, tolerance, line); + public static void AreEqual(ScreenshotInfo expected, IAppRect expectedRect, ScreenshotInfo actual, IAppRect actualRect, double expectedToActualScale = 1, PixelTolerance tolerance = default, [CallerLineNumber] int line = 0) => AreEqualImpl(expected, expectedRect.ToRectangle(), actual, actualRect.ToRectangle(), expectedToActualScale, tolerance, line); + public static async Task AreEqualAsync(ScreenshotInfo expected, IAppRect expectedRect, ScreenshotInfo actual, IAppRect actualRect, double expectedToActualScale = 1, PixelTolerance tolerance = default, [CallerLineNumber] int line = 0) + => AreEqualImpl(expected, expectedRect.ToRectangle(), actual, actualRect.ToRectangle(), expectedToActualScale, tolerance, line); + public static void AreEqual(ScreenshotInfo expected, Rectangle expectedRect, ScreenshotInfo actual, Rectangle actualRect, double expectedToActualScale = 1, PixelTolerance tolerance = default, [CallerLineNumber] int line = 0) => AreEqualImpl(expected, expectedRect, actual, actualRect, expectedToActualScale, tolerance, line); + public static async Task AreEqualAsync(ScreenshotInfo expected, Rectangle expectedRect, ScreenshotInfo actual, Rectangle actualRect, double expectedToActualScale = 1, PixelTolerance tolerance = default, [CallerLineNumber] int line = 0) + => AreEqualImpl(expected, expectedRect, actual, actualRect, expectedToActualScale, tolerance, line); + /// /// Asserts that two screenshots are equal to each other inside the area of the nominated rect to within the given pixel error /// (ie, the A, R, G, or B values cumulatively differ by more than the permitted error for any pixel). diff --git a/src/SamplesApp/SamplesApp.UITests/Windows_UI_Xaml/DragAndDropTests/DragDrop_TreeView_Reorder_Automated.cs b/src/SamplesApp/SamplesApp.UITests/Windows_UI_Xaml/DragAndDropTests/DragDrop_TreeView_Reorder_Automated.cs index 38af39b9120a..a23d23545668 100644 --- a/src/SamplesApp/SamplesApp.UITests/Windows_UI_Xaml/DragAndDropTests/DragDrop_TreeView_Reorder_Automated.cs +++ b/src/SamplesApp/SamplesApp.UITests/Windows_UI_Xaml/DragAndDropTests/DragDrop_TreeView_Reorder_Automated.cs @@ -1,14 +1,36 @@ -using NUnit.Framework; +#if IS_RUNTIME_UI_TESTS +#define CAN_ASSERT_CONTENT +#if HAS_RENDER_TARGET_BITMAP +#define CAN_ASSERT_IMAGE +#endif +using Microsoft/* UWP don't rename */.UI.Xaml.Controls; +using Uno.UI.RuntimeTests.Helpers; +#else +#define CAN_ASSERT_IMAGE +#endif + +#if !CAN_ASSERT_CONTENT && !CAN_ASSERT_IMAGE +#error No way to assert the test result +#endif + +using NUnit.Framework; using SamplesApp.UITests.TestFramework; using Uno.UITest; using Uno.UITest.Helpers; using Uno.UITest.Helpers.Queries; using System.Linq; using System; +using System.Collections.Generic; +using System.IO; +using System.Text; using System.Threading.Tasks; +using Windows.Devices.Input; +using SamplesApp.UITests.Extensions; +using Uno.Testing; namespace SamplesApp.UITests.Windows_UI_Xaml.DragAndDropTests { + [TestFixture] public partial class DragDrop_TreeView_Reorder_Automated : SampleControlUITestBase { const int _itemHeight = 70; @@ -16,87 +38,213 @@ public partial class DragDrop_TreeView_Reorder_Automated : SampleControlUITestBa [Test] [AutoRetry] [ActivePlatforms(Platform.Browser)] - public void When_Dragging_TreeView_Item() + [InjectedPointer(PointerDeviceType.Mouse)] +#if !IS_RUNTIME_UI_TESTS + [Ignore("Flaky")] +#endif + public async Task When_Dragging_TreeView_Item() { - Run("UITests.Windows_UI_Xaml.DragAndDrop.DragDrop_TreeView", skipInitialScreenshot: true); - - var tv = _app.Marked("tv"); - var bt0 = _app.Marked("bt0"); - var bt1 = _app.Marked("bt1"); - var bt2 = _app.Marked("bt2"); - var bt3 = _app.Marked("bt3"); - var focusbt = _app.Marked("focusbt"); - var radio_disable = _app.Marked("radio_disable"); - - _app.WaitForElement(radio_disable); - _app.Tap(radio_disable); - - _app.WaitForElement(tv); - _app.Tap(bt1); - _app.Tap(focusbt); - var case1 = _app.Screenshot("case1"); - - _app.Tap(bt2); - _app.Tap(focusbt); - var case2 = _app.Screenshot("case2"); - - _app.Tap(bt3); - _app.Tap(focusbt); - var case3 = _app.Screenshot("case3"); - - _app.Tap(bt0); - var tvBounds = _app.Query("tv").Single().Rect; - float fromX = tvBounds.X + 100; - float fromY = tvBounds.Y + _itemHeight * 3 + _offset; - float toX = tvBounds.X + 100; - float toY = tvBounds.Y + _offset; - _app.DragCoordinates(fromX, fromY, toX, toY); - _app.Tap(focusbt); - var result = _app.Screenshot("result1"); - ImageAssert.AreEqual(case1, result); + await RunAsync("UITests.Windows_UI_Xaml.DragAndDrop.DragDrop_TreeView", skipInitialScreenshot: true); + + var tv = App.Marked("tv"); + var bt0 = App.Marked("bt0"); + var bt1 = App.Marked("bt1"); + var bt2 = App.Marked("bt2"); + var bt3 = App.Marked("bt3"); + var focusbt = App.Marked("focusbt"); + var radio_disable = App.Marked("radio_disable"); + + App.WaitForElement(radio_disable); + App.Tap(radio_disable); + + App.WaitForElement(tv); + +#if CAN_ASSERT_IMAGE + App.Tap(bt1); + App.Tap(focusbt); + var case1 = await Screenshot("case1"); + + App.Tap(bt2); + App.Tap(focusbt); + var case2 = await Screenshot("ase2"); + + App.Tap(bt3); + App.Tap(focusbt); + var case3 = await Screenshot("case3"); + + App.Tap(bt0); +#endif +#if CAN_ASSERT_CONTENT + App.Tap(bt0); + await UITestHelper.WaitForIdle(); + await UITestHelper.WaitForIdle(); + await UITestHelper.WaitForIdle(); + + var treeView = (TreeView)App.Query(tv).Single().Element; + Assert.IsNotNull(treeView); + Assert.AreEqual( + """" + v aaa + - bbb + - ccc + - ddd + - eee + """".Trim().Replace("\r\n", "\n"), + Dump(treeView)); +#endif + + var tvBounds = App.Query("tv").Single().Rect; + var fromX = tvBounds.X + 100; + var fromY = tvBounds.Y + _itemHeight * 3 + _offset; + var toX = tvBounds.X + 100; + var toY = tvBounds.Y + _offset; + + await App.DragCoordinatesAsync(fromX, fromY, toX, toY); + App.Tap(focusbt); + +#if CAN_ASSERT_IMAGE + var result = await Screenshot("result1"); + await ImageAssert.AreEqualAsync(case1, result); +#endif +#if CAN_ASSERT_CONTENT + await UITestHelper.WaitForIdle(); + Assert.AreEqual( + """" + v aaa + - bbb + - ddd + - ccc + - eee + """".Trim().Replace("\r\n", "\n"), + Dump(treeView)); +#endif fromY = tvBounds.Y + _itemHeight * 1 + _offset; toY = tvBounds.Y + _itemHeight * 4 + _offset; - _app.DragCoordinates(fromX, fromY, toX, toY); - _app.Tap(focusbt); - result = _app.Screenshot("result2"); - ImageAssert.AreEqual(case2, result); + await App.DragCoordinatesAsync(fromX, fromY, toX, toY); + App.Tap(focusbt); + +#if CAN_ASSERT_IMAGE + result = await Screenshot("result2"); + await ImageAssert.AreEqualAsync(case2, result); +#endif +#if CAN_ASSERT_CONTENT + await UITestHelper.WaitForIdle(); + Assert.AreEqual( + """" + v aaa + - ddd + - ccc + > eee + """".Trim().Replace("\r\n", "\n"), + Dump(treeView)); +#endif fromY = tvBounds.Y + _itemHeight * 3 + _offset; toY = tvBounds.Y + _itemHeight - 5; - _app.DragCoordinates(fromX, fromY, toX, toY); - _app.Tap(focusbt); - result = _app.Screenshot("result3"); - ImageAssert.AreEqual(case3, result); + await App.DragCoordinatesAsync(fromX, fromY, toX, toY); + App.Tap(focusbt); + +#if CAN_ASSERT_IMAGE + result = await Screenshot("result3"); + await ImageAssert.AreEqualAsync(case3, result); +#endif +#if CAN_ASSERT_CONTENT + await UITestHelper.WaitForIdle(); + Assert.AreEqual( + """" + v aaa + > eee + - ddd + - ccc + """".Trim().Replace("\r\n", "\n"), + Dump(treeView)); +#endif + +#if CAN_ASSERT_IMAGE +#if IS_RUNTIME_UI_TESTS + async ValueTask Screenshot(string name) => await UITestHelper.ScreenShot((TreeView)App.Query(tv).Single().Element); +#else + async ValueTask Screenshot(string name) => await App.TakeScreenshotAsync(name); +#endif +#endif } [Test] [AutoRetry] [ActivePlatforms(Platform.Browser)] - public void When_OnDragItemsCompleted() + [InjectedPointer(PointerDeviceType.Mouse)] + public async Task When_OnDragItemsCompleted() { - Run("UITests.Windows_UI_Xaml.DragAndDrop.DragDrop_TreeView", skipInitialScreenshot: true); - var tv = _app.Marked("tv"); - var bt0 = _app.Marked("bt0"); - var radio_enable = _app.Marked("radio_enable"); - var tb = _app.Marked("tb"); - - _app.WaitForElement(tv); - - _app.WaitForElement(radio_enable); - _app.Tap(radio_enable); - _app.WaitForElement(bt0); - _app.Tap(bt0); - - var tvBounds = _app.Query("tv").Single().Rect; - float fromX = tvBounds.X + 100; - float fromY = tvBounds.Y + _itemHeight * 3 + _offset; - float toX = tvBounds.X + 100; - float toY = tvBounds.Y + _offset; - _app.DragCoordinates(fromX, fromY, toX, toY); - - string text = _app.GetText("tb").Trim(); + await RunAsync("UITests.Windows_UI_Xaml.DragAndDrop.DragDrop_TreeView", skipInitialScreenshot: true); + var tv = App.Marked("tv"); + var bt0 = App.Marked("bt0"); + var radio_enable = App.Marked("radio_enable"); + var tb = App.Marked("tb"); + + App.WaitForElement(tv); + + App.WaitForElement(radio_enable); + App.Tap(radio_enable); + App.WaitForElement(bt0); + App.Tap(bt0); + +#if IS_RUNTIME_UI_TESTS + await UITestHelper.WaitForIdle(); + await UITestHelper.WaitForIdle(); + await UITestHelper.WaitForIdle(); +#endif + + var tvBounds = App.Query("tv").Single().Rect; + var fromX = tvBounds.X + 100; + var fromY = tvBounds.Y + _itemHeight * 3 + _offset; + var toX = tvBounds.X + 100; + var toY = tvBounds.Y + _offset; + await App.DragCoordinatesAsync(fromX, fromY, toX, toY); + +#if IS_RUNTIME_UI_TESTS + await UITestHelper.WaitForIdle(); + await UITestHelper.WaitForIdle(); + await UITestHelper.WaitForIdle(); +#endif + + string text = App.GetText("tb").Trim(); Assert.AreEqual("DragItemsCompleted is triggered", text); } + +#if CAN_ASSERT_CONTENT + private string Dump(TreeView tv) + { + var dump = new StringBuilder(); + DumpCore(0, tv.RootNodes); + return dump.ToString().Trim().Replace("\r\n", "\n"); + + void DumpCore(int level, IList nodes) + { + foreach (var node in nodes) + { + dump.Append(new string('\t', level)); + switch (node) + { + case { Children: null or { Count: 0 } }: + dump.Append("- "); + dump.AppendLine(node.Content?.ToString() ?? "--null--"); + break; + + case { IsExpanded: false }: + dump.Append("> "); + dump.AppendLine(node.Content?.ToString() ?? "--null--"); + break; + + default: + dump.Append("v "); + dump.AppendLine(node.Content?.ToString() ?? "--null--"); + DumpCore(level + 1, node.Children); + break; + } + } + } + } +#endif } } diff --git a/src/SamplesApp/SamplesApp.UITests/Windows_UI_Xaml_Controls/ContentDialog/UnoSamples_Tests.ContentDialog.cs b/src/SamplesApp/SamplesApp.UITests/Windows_UI_Xaml_Controls/ContentDialog/UnoSamples_Tests.ContentDialog.cs index e39ae29e004a..61a944472cc6 100644 --- a/src/SamplesApp/SamplesApp.UITests/Windows_UI_Xaml_Controls/ContentDialog/UnoSamples_Tests.ContentDialog.cs +++ b/src/SamplesApp/SamplesApp.UITests/Windows_UI_Xaml_Controls/ContentDialog/UnoSamples_Tests.ContentDialog.cs @@ -409,7 +409,8 @@ public void ContentDialog_Simple_NotLightDismissible() var dialogClosedScreenshot = CurrentTestTakeScreenShot("3 ContentDialog Closed"); // Test only to the left of the TextBox, which can have a blinking cursor and might fail the screenshot tests - var testRect = new Rectangle(0, 0, (int)dialogRectangle.X + 10, dialogOpenedScreenshot.Height); + // Note: We also make sure to exclude the opening buttons below the overlay as the focus might have changed + var testRect = new Rectangle(dialogRectangle.X, dialogRectangle.Y, 10, dialogRectangle.Height); // compare ImageAssert.AreNotEqual(initialScreenshot, dialogOpenedScreenshot); diff --git a/src/SamplesApp/SamplesApp.UITests/Windows_UI_Xaml_Controls/FlyoutTests/UnoSamples_Tests.Flyout_OverlayInputPassThroughElement.cs b/src/SamplesApp/SamplesApp.UITests/Windows_UI_Xaml_Controls/FlyoutTests/UnoSamples_Tests.Flyout_OverlayInputPassThroughElement.cs index 2b187dffc6a4..d6ed4d47c83c 100644 --- a/src/SamplesApp/SamplesApp.UITests/Windows_UI_Xaml_Controls/FlyoutTests/UnoSamples_Tests.Flyout_OverlayInputPassThroughElement.cs +++ b/src/SamplesApp/SamplesApp.UITests/Windows_UI_Xaml_Controls/FlyoutTests/UnoSamples_Tests.Flyout_OverlayInputPassThroughElement.cs @@ -11,7 +11,7 @@ namespace SamplesApp.UITests.Windows_UI_Xaml_Controls.FlyoutTests; -#if __SKIA__ +#if IS_RUNTIME_UI_TESTS [TestFixture] partial class Flyout_Tests : SampleControlUITestBase #else diff --git a/src/SamplesApp/SamplesApp.UITests/Windows_UI_Xaml_Controls/ListViewTests/Selection_Pointers.cs b/src/SamplesApp/SamplesApp.UITests/Windows_UI_Xaml_Controls/ListViewTests/Selection_Pointers.cs index aedc61d2f0f6..b908e6fe44a2 100644 --- a/src/SamplesApp/SamplesApp.UITests/Windows_UI_Xaml_Controls/ListViewTests/Selection_Pointers.cs +++ b/src/SamplesApp/SamplesApp.UITests/Windows_UI_Xaml_Controls/ListViewTests/Selection_Pointers.cs @@ -19,36 +19,42 @@ public partial class ListViewTests_Tests : SampleControlUITestBase [Test] [AutoRetry] [InjectedPointer(PointerDeviceType.Touch)] + [InjectedPointer(PointerDeviceType.Mouse)] public Task When_NoSelection_Then_PointersEvents() => RunTest("_noSelection_noClick", clicked: false); [Test] [AutoRetry] [InjectedPointer(PointerDeviceType.Touch)] + [InjectedPointer(PointerDeviceType.Mouse)] public Task When_SingleSelectionWithoutItemClick_Then_PointersEvents() => RunTest("_singleSelection_noClick", clicked: false); [Test] [AutoRetry] [InjectedPointer(PointerDeviceType.Touch)] + [InjectedPointer(PointerDeviceType.Mouse)] public Task When_MultipleSelectionWithoutItemClick_Then_PointersEvents() => RunTest("_multipleSelection_noClick", clicked: false); [Test] [AutoRetry] [InjectedPointer(PointerDeviceType.Touch)] + [InjectedPointer(PointerDeviceType.Mouse)] public Task When_ExtendedSelectionWithoutItemClick_Then_PointersEvents() => RunTest("_extendedSelection_noClick", clicked: false); [Test] [AutoRetry] [InjectedPointer(PointerDeviceType.Touch)] + [InjectedPointer(PointerDeviceType.Mouse)] public Task When_NoSelectionWithItemClick_Then_PointersEvents() => RunTest("_noSelection_withClick", clicked: true); [Test] [AutoRetry] [InjectedPointer(PointerDeviceType.Touch)] + [InjectedPointer(PointerDeviceType.Mouse)] public Task When_SingleSelectionWithItemClick_Then_PointersEvents() => RunTest("_singleSelection_withClick", clicked: true); diff --git a/src/SamplesApp/SamplesApp.UITests/Windows_UI_Xaml_Controls/SwipeControlTests/SwipeControlTests.cs b/src/SamplesApp/SamplesApp.UITests/Windows_UI_Xaml_Controls/SwipeControlTests/SwipeControlTests.cs index cd23b074de81..cb0166daa1f0 100644 --- a/src/SamplesApp/SamplesApp.UITests/Windows_UI_Xaml_Controls/SwipeControlTests/SwipeControlTests.cs +++ b/src/SamplesApp/SamplesApp.UITests/Windows_UI_Xaml_Controls/SwipeControlTests/SwipeControlTests.cs @@ -11,6 +11,10 @@ using Uno.Testing; using Uno.UITest.Helpers.Queries; +#if IS_RUNTIME_UI_TESTS +using Uno.UI.RuntimeTests.Helpers; +#endif + namespace SamplesApp.UITests.Windows_UI_Xaml_Controls.SwipeControlTests { [TestFixture] @@ -66,16 +70,25 @@ public async Task When_MultipleItems() } -#if !__SKIA__ // No screenshot on skia [Test] [AutoRetry] [ActivePlatforms(Platform.iOS, Platform.Android)] +#if __SKIA__ + [Ignore("Invalid layout of items")] +#elif !HAS_RENDER_TARGET_BITMAP + [Ignore("Cannot take screenshot on this platform.")] +#endif public Task When_InListView() => When_InScrollableContainer("UITests.Windows_UI_Xaml_Controls.SwipeControlTests.SwipeControl_ListView"); [Test] [AutoRetry] [ActivePlatforms(Platform.iOS, Platform.Android)] +#if __SKIA__ + [Ignore("Invalid layout of items")] +#elif !HAS_RENDER_TARGET_BITMAP + [Ignore("Cannot take screenshot on this platform.")] +#endif public Task When_InScrollViewer() => When_InScrollableContainer("UITests.Windows_UI_Xaml_Controls.SwipeControlTests.SwipeControl_ScrollViewer"); @@ -84,37 +97,36 @@ private async Task When_InScrollableContainer(string testName) QueryEx sut = new QueryEx(q => q.All().Marked("SUT")); QueryEx output = new QueryEx(q => q.All().Marked("Output")); - Run(testName, skipInitialScreenshot: true); + await RunAsync(testName); - var sutPhyRect = _app.GetPhysicalRect(sut); - var item2PhyPosition = new Point((int)sutPhyRect.X + 150, (int)sutPhyRect.Y + 150).LogicalToPhysicalPixels(_app); + var sutPhyRect = App.GetPhysicalRect(sut); + var item2PhyPosition = new Point((int)sutPhyRect.X + 150, (int)sutPhyRect.Y + 150).LogicalToPhysicalPixels(App); // Validate initial state - var initial = TakeScreenshot("initial"); + var initial = await TakeScreenshotAsync("initial"); ImageAssert.HasColorAt(initial, item2PhyPosition.X, item2PhyPosition.Y, "#FFFFA52C"); // Execute left command on item 2 - _app.DragCoordinates(item2PhyPosition.X, item2PhyPosition.Y, item2PhyPosition.X + 300.LogicalToPhysicalPixels(_app), item2PhyPosition.Y); + App.DragCoordinates(item2PhyPosition.X, item2PhyPosition.Y, item2PhyPosition.X + 300.LogicalToPhysicalPixels(App), item2PhyPosition.Y); await Task.Delay(1000); // We cannot detect the animation ... var swippedItem = output.GetDependencyPropertyValue("Text"); Assert.AreEqual("#FFFFA52C", swippedItem); // Scroll up - _app.DragCoordinates(sutPhyRect.CenterX, sutPhyRect.Bottom - 10.LogicalToPhysicalPixels(_app), sutPhyRect.CenterX, sutPhyRect.Y + 10.LogicalToPhysicalPixels(_app)); + App.DragCoordinates(sutPhyRect.CenterX, sutPhyRect.Bottom - 10.LogicalToPhysicalPixels(App), sutPhyRect.CenterX, sutPhyRect.Y + 10.LogicalToPhysicalPixels(App)); // Validate scrolled successfully - var postScroll = TakeScreenshot("after scroll"); + var postScroll = await TakeScreenshotAsync("after scroll"); ImageAssert.DoesNotHaveColorAt(postScroll, item2PhyPosition.X, item2PhyPosition.Y, "#FFFFA52C"); // Execute left command on item that is now at item 2 location - _app.DragCoordinates(item2PhyPosition.X, item2PhyPosition.Y, item2PhyPosition.X + 300.LogicalToPhysicalPixels(_app), item2PhyPosition.Y); + App.DragCoordinates(item2PhyPosition.X, item2PhyPosition.Y, item2PhyPosition.X + 300.LogicalToPhysicalPixels(App), item2PhyPosition.Y); await Task.Delay(1000); // We cannot detect the animation ... swippedItem = output.GetDependencyPropertyValue("Text"); Assert.AreNotEqual("#FFFFA52C", swippedItem); } -#endif [Test] [AutoRetry] diff --git a/src/SamplesApp/SamplesApp.UITests/Windows_UI_Xaml_Input/Capture_Tests.cs b/src/SamplesApp/SamplesApp.UITests/Windows_UI_Xaml_Input/Capture_Tests.cs index e3007d924e48..165414f207b0 100644 --- a/src/SamplesApp/SamplesApp.UITests/Windows_UI_Xaml_Input/Capture_Tests.cs +++ b/src/SamplesApp/SamplesApp.UITests/Windows_UI_Xaml_Input/Capture_Tests.cs @@ -70,8 +70,8 @@ private async Task RunTest(string testName, Action act = null) App.WaitForElement(target); act(target); -#if !__SKIA__ - TakeScreenshot("Result"); +#if HAS_RENDER_TARGET_BITMAP + await TakeScreenshotAsync("Result"); #endif result.GetDependencyPropertyValue("Text").Should().Be("SUCCESS"); diff --git a/src/SamplesApp/SamplesApp.UITests/Windows_UI_Xaml_Input/NestedHandling_Tests.cs b/src/SamplesApp/SamplesApp.UITests/Windows_UI_Xaml_Input/NestedHandling_Tests.cs index 10aedaeec85d..e2f0af7ad85d 100644 --- a/src/SamplesApp/SamplesApp.UITests/Windows_UI_Xaml_Input/NestedHandling_Tests.cs +++ b/src/SamplesApp/SamplesApp.UITests/Windows_UI_Xaml_Input/NestedHandling_Tests.cs @@ -21,6 +21,7 @@ public partial class NestedHandling_Tests : SampleControlUITestBase #endif [Test] [AutoRetry] + [InjectedPointer(PointerDeviceType.Mouse)] [InjectedPointer(PointerDeviceType.Touch)] public async Task When_NestedHandlesPressed_Then_ContainerStillGetsSubsequentEvents() { @@ -35,9 +36,11 @@ public async Task When_NestedHandlesPressed_Then_ContainerStillGetsSubsequentEve [Test] [AutoRetry] -#if !__SKIA__ [ActivePlatforms(Platform.Browser)] // Not supported on iOS and Android where dispatch is native and has "implicit capture". +#if !IS_RUNTIME_UI_TESTS + [Ignore("Flaky")] #endif + [InjectedPointer(PointerDeviceType.Mouse)] [InjectedPointer(PointerDeviceType.Touch)] public async Task When_Nested_Then_EnterAndExitedDoesNotBubble() { @@ -63,11 +66,7 @@ public async Task When_Nested_Then_EnterAndExitedDoesNotBubble() // The results should be "ENTERED SUCCESS" and "EXITED SUCCESS", but even if tests are passing locally they are failing on CI // We are validating as much as we can to reduce risk of regression ... -#if __SKIA__ enterResult.Should().Contain("ENTERED SUCCESS", "we should have received ENTER only on '_intermediate' which has subscribed to handled events too."); -#else - enterResult.Should().BeOneOf(new[] { "ENTERED", "ENTERED SUCCESS" }, "we should have received ENTER only on '_intermediate' which has subscribed to handled events too."); -#endif #if false exitResult.Should().Be("EXITED SUCCESS", "we should have received EXIT only on '_intermediate' which has subscribed to handled events too."); #endif diff --git a/src/SamplesApp/UITests.Shared/Windows_UI_Input/PointersTests/EventsSequences.xaml b/src/SamplesApp/UITests.Shared/Windows_UI_Input/PointersTests/EventsSequences.xaml index 47742f12b9d5..cace5f594ca4 100644 --- a/src/SamplesApp/UITests.Shared/Windows_UI_Input/PointersTests/EventsSequences.xaml +++ b/src/SamplesApp/UITests.Shared/Windows_UI_Input/PointersTests/EventsSequences.xaml @@ -76,7 +76,7 @@ - +