diff --git a/src/SamplesApp/SamplesApp.UITests/Windows_UI_Xaml_Shapes/Shapes_Tests.cs b/src/SamplesApp/SamplesApp.UITests/Windows_UI_Xaml_Shapes/Shapes_Tests.cs index ad70de97361b..27cf7fbb4bd6 100644 --- a/src/SamplesApp/SamplesApp.UITests/Windows_UI_Xaml_Shapes/Shapes_Tests.cs +++ b/src/SamplesApp/SamplesApp.UITests/Windows_UI_Xaml_Shapes/Shapes_Tests.cs @@ -9,6 +9,7 @@ using SamplesApp.UITests.TestFramework; using Uno.UITest.Helpers; using Uno.UITest.Helpers.Queries; +using Uno.UITests.Helpers; namespace SamplesApp.UITests.Windows_UI_Xaml_Shapes { @@ -130,5 +131,102 @@ public void Check_Bound_Color() ImageAssert.HasColorAt(screenshot, bounds.CenterX, bounds.CenterY, Color.Blue); } + + [Test] + [AutoRetry] + public void Default_StrokeThickness() + { + const string red = "#FF0000"; + const string reddish = "#FF8080"; + + var shapeExpectations = new[] + { + new ShapeExpectation + { + Name = "MyLine", + Offsets = new [] {0, 0, 0, 0}, + Colors = red, + }, + new ShapeExpectation + { + Name = "MyRect", + Offsets = new [] {0, 0, -1, -1}, + Colors = red, + }, + new ShapeExpectation + { + Name = "MyPolyline", + Offsets = new [] {2, 2, -1, -1}, + Colors = AppInitializer.GetLocalPlatform() == Platform.Browser ? reddish : red, + }, + new ShapeExpectation + { + Name = "MyPolygon", + Offsets = new [] {2, 2, -1, -1}, + Colors = AppInitializer.GetLocalPlatform() == Platform.Browser ? reddish : red, + }, + new ShapeExpectation + { + Name = "MyEllipse", + Offsets = new [] {0, 0, -1, -1}, + Colors = red, + }, + new ShapeExpectation + { + Name = "MyPath", + Offsets = new [] {0, 0, 0, 0}, + Colors = red, + }, + }; + Run("UITests.Windows_UI_Xaml_Shapes.Shapes_Default_StrokeThickness"); + + _app.WaitForElement("TestZone"); + + foreach(var expectation in shapeExpectations) + { + _app.Marked($"{expectation.Name}Selector").FastTap(); + + using var screenshot = TakeScreenshot($"{expectation}"); + if (expectation.Name == "MyLine" || expectation.Name == "MyPath") + { + var targetRect = _app.GetPhysicalRect($"{expectation.Name}Target"); + ImageAssert.DoesNotHaveColorAt(screenshot, targetRect.CenterX, targetRect.CenterY, Color.White); + + _app.Marked("StrokeThicknessButton").FastTap(); + + using var zeroStrokeThicknessScreenshot = TakeScreenshot($"{expectation.Name}_0_StrokeThickness"); + ImageAssert.HasColorAt(zeroStrokeThicknessScreenshot, targetRect.CenterX, targetRect.CenterY, Color.White); + } + else + { + var shapeContainer = _app.GetPhysicalRect($"{expectation}Grid"); + + ImageAssert.HasColorAt(screenshot, shapeContainer.X + expectation.Offsets[0], shapeContainer.CenterY, expectation.Colors, tolerance: 15); + ImageAssert.HasColorAt(screenshot, shapeContainer.CenterX, shapeContainer.Y + expectation.Offsets[1], expectation.Colors, tolerance: 15); + ImageAssert.HasColorAt(screenshot, shapeContainer.Right + expectation.Offsets[2], shapeContainer.CenterY, expectation.Colors, tolerance: 15); + ImageAssert.HasColorAt(screenshot, shapeContainer.CenterX, shapeContainer.Bottom + expectation.Offsets[3], expectation.Colors, tolerance: 15); + + _app.Marked("StrokeThicknessButton").FastTap(); + + using var zeroStrokeThicknessScreenshot = TakeScreenshot($"{expectation.Name}_0_StrokeThickness"); + + ImageAssert.DoesNotHaveColorAt(zeroStrokeThicknessScreenshot, shapeContainer.X + expectation.Offsets[0], shapeContainer.CenterY, expectation.Colors); + ImageAssert.DoesNotHaveColorAt(zeroStrokeThicknessScreenshot, shapeContainer.CenterX, shapeContainer.Y + expectation.Offsets[1], expectation.Colors); + ImageAssert.DoesNotHaveColorAt(zeroStrokeThicknessScreenshot, shapeContainer.Right + expectation.Offsets[2], shapeContainer.CenterY, expectation.Colors); + ImageAssert.DoesNotHaveColorAt(zeroStrokeThicknessScreenshot, shapeContainer.CenterX, shapeContainer.Bottom + expectation.Offsets[3], expectation.Colors); + } + } + + } + + private struct ShapeExpectation + { + public string Name { get; set; } + public int[] Offsets { get; set; } + public string Colors { get; set; } + + public override string ToString() => $"{Name}"; + } + } } diff --git a/src/SamplesApp/UITests.Shared/UITests.Shared.projitems b/src/SamplesApp/UITests.Shared/UITests.Shared.projitems index f79711c4d4c9..64374c65776a 100644 --- a/src/SamplesApp/UITests.Shared/UITests.Shared.projitems +++ b/src/SamplesApp/UITests.Shared/UITests.Shared.projitems @@ -3757,6 +3757,10 @@ Designer MSBuild:Compile + + Designer + MSBuild:Compile + Designer MSBuild:Compile @@ -5983,6 +5987,9 @@ ShapeControlsPage.xaml + + Shapes_Default_StrokeThickness.xaml + StretchPage.xaml diff --git a/src/SamplesApp/UITests.Shared/Windows_UI_Xaml_Shapes/Shapes_Default_StrokeThickness.xaml b/src/SamplesApp/UITests.Shared/Windows_UI_Xaml_Shapes/Shapes_Default_StrokeThickness.xaml new file mode 100644 index 000000000000..36e5d4f050e5 --- /dev/null +++ b/src/SamplesApp/UITests.Shared/Windows_UI_Xaml_Shapes/Shapes_Default_StrokeThickness.xaml @@ -0,0 +1,122 @@ + + + + + + + + + + + + + + + + +