public void ElevatedView_Corners_Validation() { Run("UITests.Toolkit.ElevatedView_Corners"); _app.WaitForElement("Elevation"); var elevationRect = _app.GetPhysicalRect("Elevation"); using var snapshot = this.TakeScreenshot("check", ignoreInSnapshotCompare: true); const string white = "#FFFFFF"; const string gray = "#A9A9A9"; // DarkGray const string pink = "#FFE0E0"; // Red shadow mixed with white background ImageAssert.HasPixels( snapshot, ExpectedPixels .At("top-middle", elevationRect.CenterX, elevationRect.Y) .WithPixelTolerance(1, 1) .Pixel(gray), ExpectedPixels .At("bottom-middle", elevationRect.CenterX, elevationRect.Bottom) .WithPixelTolerance(1, 1) .Pixel(gray), ExpectedPixels .At("left-middle", elevationRect.X, elevationRect.CenterY) .WithPixelTolerance(1, 1) .Pixel(gray), ExpectedPixels .At("right-middle", elevationRect.Right, elevationRect.CenterY) .WithPixelTolerance(1, 1) .Pixel(gray), ExpectedPixels .At("right-middle-shadow", elevationRect.Right + 1, elevationRect.CenterY) .WithPixelTolerance(5, 1) .WithColorTolerance(22) .Pixel(pink), ExpectedPixels .At("bottom-middle-shadow", elevationRect.CenterX, elevationRect.Bottom + 1) .WithPixelTolerance(1, 5) .WithColorTolerance(22) .Pixel(pink), ExpectedPixels .At("top-left", elevationRect.X, elevationRect.Y) .WithPixelTolerance(1, 1) .Pixel(white), ExpectedPixels .At("top-right", elevationRect.Right, elevationRect.Y) .WithPixelTolerance(1, 1) .Pixel(white), ExpectedPixels .At("bottom-left", elevationRect.X, elevationRect.Bottom) .WithPixelTolerance(1, 1) .Pixel(white), ExpectedPixels .At("bottom-right", elevationRect.Right, elevationRect.Bottom) .WithPixelTolerance(1, 1) .Pixel(white) ); }
[ActivePlatforms(Platform.Browser)] // TODO: support drag-and-drop testing on mobile https://github.com/unoplatform/Uno.UITest/issues/31 public void When_Reorder_SelectedItem_Down() { const int itemHeight = 75; Run("UITests.Windows_UI_Xaml.DragAndDrop.DragDrop_ListView_Selection", skipInitialScreenshot: true); var mode = App.Marked("SelectionModeConfig"); var sut = App.Marked("SUT"); mode.SetDependencyPropertyValue("SelectedValue", "Single"); var sutBounds = _app.Query(sut).Single().Rect; var x = sutBounds.X + 50; float Item(int index) => this.Item(sutBounds, index, itemHeight); // Select "Item #3" App.TapCoordinates(x, Item(2)); var afterSelect = TakeScreenshot("Item_2_Selected"); // Reorder "Item #3" to position 6 App.DragCoordinates(x, Item(2), x, Item(5)); var afterReorder = TakeScreenshot("Item_2_selected_at_position_5"); ImageAssert.HasColorAt(afterSelect, x, Item(1), Color.White); ImageAssert.HasPixels(afterSelect, ExpectedPixels.At(x, Item(2)).Pixel(Color.Red).OrPixel("#FFFF00").OrPixel("#FFA000C0")); // Any selected state ImageAssert.HasColorAt(afterSelect, x, Item(3), Color.White); ImageAssert.HasColorAt(afterSelect, x, Item(5), Color.White); ImageAssert.HasColorAt(afterReorder, x, Item(2), Color.White); ImageAssert.HasColorAt(afterReorder, x, Item(4), Color.White); ImageAssert.HasPixels(afterReorder, ExpectedPixels.At(x, Item(5)).Pixel(Color.Red).OrPixel("#FFFF00").OrPixel("#FFA000C0")); // Any selected state ImageAssert.HasColorAt(afterReorder, x, Item(6), Color.White); }
public void Border_CornerRadius_Clipping() { const string red = "#FF0000"; Run("UITests.Windows_UI_Xaml_Controls.BorderTests.Border_CornerRadius_Clipping"); _app.WaitForElement("MainBorder"); var topLeftTarget = _app.GetPhysicalRect("TopLeftTarget"); var topRightTarget = _app.GetPhysicalRect("TopRightTarget"); var bottomLeftTarget = _app.GetPhysicalRect("BottomLeftTarget"); var bottomRightTarget = _app.GetPhysicalRect("BottomRightTarget"); using var snapshot = TakeScreenshot("Screenshot"); ImageAssert.HasPixels( snapshot, ExpectedPixels .At($"top-left", topLeftTarget.CenterX, topLeftTarget.CenterY) .WithPixelTolerance(1, 1) .Pixel(red), ExpectedPixels .At($"top-right", topRightTarget.CenterX, topRightTarget.CenterY) .WithPixelTolerance(1, 1) .Pixel(red), ExpectedPixels .At($"bottom-left", bottomLeftTarget.CenterX, bottomLeftTarget.CenterY) .WithPixelTolerance(1, 1) .Pixel(red), ExpectedPixels .At($"bottom-right", bottomRightTarget.CenterX, bottomRightTarget.CenterY) .WithPixelTolerance(1, 1) .Pixel(red) ); }
public void Check_CornerRadius_Border_Basic() { const string white = "#FFFFFF"; // Verify that border is drawn with CornerRadius Run("Uno.UI.Samples.UITests.BorderTestsControl.Border_CornerRadius", skipInitialScreenshot: true); var sample = _app.GetPhysicalRect("Sample1"); var eighth = sample.Width / 8; using var result = TakeScreenshot("sample"); ImageAssert.HasPixels( result, ExpectedPixels.At(sample.X + eighth, sample.Y + eighth).Named("top left corner").Pixel(white), ExpectedPixels.At(sample.Right - eighth, sample.Y + eighth).Named("top right corner").Pixel(white), ExpectedPixels.At(sample.Right - eighth, sample.Bottom - eighth).Named("bottom right corner").Pixel(white), ExpectedPixels.At(sample.X + eighth, sample.Bottom - eighth).Named("bottom left corner").Pixel(white) ); }
public void Detereminate_ProgressRing_Validation() { Run("UITests.Microsoft_UI_Xaml_Controls.ProgressRing.WinUIDeterminateProgressRing"); _app.WaitForElement("ProgressRing"); var topLeftTargetRect = _app.GetPhysicalRect("TopLeftTarget"); var topRightTargetRect = _app.GetPhysicalRect("TopRightTarget"); var bottomLeftTargetRect = _app.GetPhysicalRect("BottomLeftTarget"); var bottomRightTargetRect = _app.GetPhysicalRect("BottomRightTarget"); foreach (var expected in _expectedColors) { SetComboBox("ProgressValue", expected.Value.ToString()); _app.Wait(TimeSpan.FromSeconds(5)); //Wait for animations to finish using var snapshot = TakeScreenshot($"Progress-Ring-Value-{expected.Value}"); ImageAssert.HasPixels( snapshot, ExpectedPixels .At($"top-left-{expected.Value}-progress", topLeftTargetRect.CenterX, topLeftTargetRect.CenterY) .WithPixelTolerance(1, 1) .Pixel(expected.Colors[0]), ExpectedPixels .At($"top-right-{expected.Value}-progress", topRightTargetRect.CenterX, topRightTargetRect.CenterY) .WithPixelTolerance(1, 1) .Pixel(expected.Colors[1]), ExpectedPixels .At($"bottom-right-{expected.Value}-progress", bottomRightTargetRect.CenterX, bottomRightTargetRect.CenterY) .WithPixelTolerance(1, 1) .Pixel(expected.Colors[2]), ExpectedPixels .At($"bottom-left-{expected.Value}-progress", bottomLeftTargetRect.CenterX, bottomLeftTargetRect.CenterY) .WithPixelTolerance(1, 1) .Pixel(expected.Colors[3]) ); } }
public void Border_AntiAlias() { const string firstRectBlueish = "#ffd8d8ff"; const string secondRectBlueish = "#ff9e9eff"; Run("UITests.Windows_UI_Xaml_Controls.BorderTests.BorderAntiAlias"); var firstBorderRect = _app.GetPhysicalRect("firstBorder"); var secondBorderRect = _app.GetPhysicalRect("secondBorder"); using var screenshot = TakeScreenshot(nameof(Border_AntiAlias)); ImageAssert.HasColorInRectangle( screenshot, firstBorderRect.ToRectangle(), ColorCodeParser.Parse(firstRectBlueish) ); ImageAssert.HasPixels( screenshot, ExpectedPixels .At($"top-left", secondBorderRect.X, secondBorderRect.Y) .WithPixelTolerance(1, 1) .Pixel(secondRectBlueish), ExpectedPixels .At($"top-right", secondBorderRect.Right, secondBorderRect.Y) .WithPixelTolerance(1, 1) .Pixel(secondRectBlueish), ExpectedPixels .At($"bottom-right", secondBorderRect.Right, secondBorderRect.Bottom) .WithPixelTolerance(1, 1) .Pixel(secondRectBlueish), ExpectedPixels .At($"bottom-left", secondBorderRect.X, secondBorderRect.Bottom) .WithPixelTolerance(1, 1) .Pixel(secondRectBlueish) ); }
public void ItemsControl_ItemContainerStyle() { Run("UITests.Windows_UI_Xaml_Controls.ItemsControl.ItemsControl_ItemContainerStyle"); _app.WaitForElement(_app.Marked("theItemsControl")); var theItemsControl = _app.Marked("theItemsControl"); const string deepPink = "#FF1493"; const string lime = "#00FF00"; var firstItem = _app.GetPhysicalRect("FirstItem"); var secondItem = _app.GetPhysicalRect("SecondItem"); using var snapshot = TakeScreenshot("ItemsControl_ItemContainerStyle"); ImageAssert.HasPixels( snapshot, ExpectedPixels .At("first item center", firstItem.CenterX, firstItem.CenterY) .Pixel(deepPink), ExpectedPixels .At("second item center", secondItem.CenterX, secondItem.CenterY) .Pixel(lime)); }
//Only include Browser as a platform until following issue is fixed: https://github.com/unoplatform/uno/issues/5271 public void When_StretchAndAlignment() { Run("UITests.Windows_UI_Xaml_Media.ImageBrushTests.ImageBrushShapeStretchesAlignments"); _app.WaitForElement("MyRectangle"); foreach (var expected in _expectedColors) { SetProperty("MyStretch", "SelectedIndex", ((int)expected.Stretch).ToString()); SetProperty("MyAlignmentX", "SelectedIndex", ((int)expected.AlignmentX).ToString()); SetProperty("MyAlignmentY", "SelectedIndex", ((int)expected.AlignmentY).ToString()); SetProperty("MyWidth", "Text", expected.Size.Width.ToString()); SetProperty("MyHeight", "Text", expected.Size.Height.ToString()); var greenContainer = _app.GetPhysicalRect("GreenBackground"); var permutation = $"{expected.Size.Width}-{expected.Size.Height}-{Enum.GetName(typeof(Stretch), expected.Stretch)}-X{Enum.GetName(typeof(AlignmentX), expected.AlignmentX)}-Y{Enum.GetName(typeof(AlignmentY), expected.AlignmentY)}"; using var snapshot = TakeScreenshot($"ImageBrush-{permutation}"); ImageAssert.HasPixels( snapshot, ExpectedPixels .At($"middle-left-{permutation}", greenContainer.X, greenContainer.CenterY) .WithPixelTolerance(1, 1) .Pixel(expected.Colors[0]), ExpectedPixels .At($"top-left-{permutation}", greenContainer.X, greenContainer.Y) .WithPixelTolerance(1, 1) .Pixel(expected.Colors[1]), ExpectedPixels .At($"middle-top-{permutation}", greenContainer.CenterX, greenContainer.Y) .WithPixelTolerance(1, 1) .Pixel(expected.Colors[2]), ExpectedPixels .At($"top-right-{permutation}", greenContainer.Right, greenContainer.Y) .WithPixelTolerance(1, 1) .Pixel(expected.Colors[3]), ExpectedPixels .At($"middle-right-{permutation}", greenContainer.Right, greenContainer.CenterY) .WithPixelTolerance(1, 1) .Pixel(expected.Colors[4]), ExpectedPixels .At($"bottom-right-{permutation}", greenContainer.Right, greenContainer.Bottom) .WithPixelTolerance(1, 1) .Pixel(expected.Colors[5]), ExpectedPixels .At($"middle-bottom-{permutation}", greenContainer.CenterX, greenContainer.Bottom) .WithPixelTolerance(1, 1) .Pixel(expected.Colors[6]), ExpectedPixels .At($"bottom-left-{permutation}", greenContainer.X, greenContainer.Bottom) .WithPixelTolerance(1, 1) .Pixel(expected.Colors[7]), ExpectedPixels .At($"middle-middle-{permutation}", greenContainer.CenterX, greenContainer.CenterY) .WithPixelTolerance(1, 1) .Pixel(expected.Colors[8]) ); } }
public void When_TransformGroup_Translate() { const string color = color1; const int trY = 50; var(host, scale, half, final) = BeginTransformGroupTest("TranslateHost"); // "Half" is approximative, we only validate that the element has move bellow ImageAssert.HasPixels( half, ExpectedPixels .At("Top left", host.X - 1, host.Y - 1) .WithPixelTolerance(x: 1, y: 1) .Pixels(new[, ] { { defaultColor, defaultColor }, { defaultColor, bgColor }, }), ExpectedPixels .At("Top right", host.Right - 1, host.Y - 1) .WithPixelTolerance(x: 1, y: 1) .Pixels(new[, ] { { defaultColor, defaultColor }, { bgColor, defaultColor }, }), ExpectedPixels .At("Bottom right", host.Right - 1, host.Bottom - 1) .WithPixelTolerance(x: 1, y: 1) .Pixels(new[, ] { { color, defaultColor }, { color, defaultColor }, }), ExpectedPixels .At("Bottom left", host.X - 1, host.Bottom - 1) .WithPixelTolerance(x: 1, y: 1) .Pixels(new[, ] { { defaultColor, color }, { defaultColor, color }, }) ); //// Complete animation var finalTrY = trY * scale; ImageAssert.HasPixels( final, ExpectedPixels .At("Top left", host.X - 1, host.Y + finalTrY - 1) .WithPixelTolerance(x: 1, y: 1) .Pixels(new[, ] { { defaultColor, bgColor }, { defaultColor, color } }), ExpectedPixels .At("Top right", host.Right - 1, host.Y + finalTrY - 1) .WithPixelTolerance(x: 1, y: 1) .Pixels(new[, ] { { bgColor, defaultColor }, { color, defaultColor }, }), ExpectedPixels .At("Bottom right", host.Right - 1, host.Bottom + finalTrY - 1) .WithPixelTolerance(x: 1, y: 1) .Pixels(new[, ]
public void Border_CornerRadius_BorderThickness() { // White Background color underneath const string white = "#FFFFFF"; //Colors with 50% Opacity const string red50 = "#80FF0000"; const string blue50 = "#800000FF"; //Same colors but with the addition of a White background color underneath const string lightPink = "#FF7F7F"; const string lightBlue = "#7F7FFF"; var expectedColors = new[] { new ExpectedColor { Thicknesses = new [] { 10, 10, 10, 10 }, Colors = new [] { lightPink, lightPink, lightPink, lightPink } }, new ExpectedColor { Thicknesses = new [] { 10, 0, 10, 10 }, Colors = new [] { lightPink, lightBlue, lightPink, lightPink } }, new ExpectedColor { Thicknesses = new [] { 10, 0, 0, 10 }, Colors = new [] { lightPink, lightBlue, lightBlue, lightPink } }, new ExpectedColor { Thicknesses = new [] { 10, 0, 0, 0 }, Colors = new [] { lightPink, lightBlue, lightBlue, lightBlue } }, new ExpectedColor { Thicknesses = new [] { 0, 0, 0, 0 }, Colors = new [] { lightBlue, lightBlue, lightBlue, lightBlue } }, }; Run("UITests.Windows_UI_Xaml_Controls.BorderTests.Border_CornerRadius_BorderThickness"); _app.WaitForElement("MyBackgroundUnderneath"); SetBorderProperty("MyBackgroundUnderneath", "Background", white); _app.WaitForElement("MyBorder"); var leftTarget = _app.GetPhysicalRect("LeftTarget"); var topTarget = _app.GetPhysicalRect("TopTarget"); var rightTarget = _app.GetPhysicalRect("RightTarget"); var bottomTarget = _app.GetPhysicalRect("BottomTarget"); var centerTarget = _app.GetPhysicalRect("CenterTarget"); SetBorderProperty("MyBorder", "CornerRadius", "10"); SetBorderProperty("MyBorder", "BorderBrush", red50); SetBorderProperty("MyBorder", "Background", blue50); foreach (var expected in expectedColors) { SetBorderProperty("MyBorder", "BorderThickness", expected.ToString()); using var snapshot = TakeScreenshot($"Border-CornerRadius-10-BorderThickness-{expected}"); ImageAssert.HasPixels( snapshot, ExpectedPixels .At($"left-{expected}", leftTarget.CenterX, leftTarget.CenterY) .WithPixelTolerance(1, 1) .Pixel(expected.Colors[0]), ExpectedPixels .At($"top-{expected}", topTarget.CenterX, topTarget.CenterY) .WithPixelTolerance(1, 1) .Pixel(expected.Colors[1]), ExpectedPixels .At($"right-{expected}", rightTarget.CenterX, rightTarget.CenterY) .WithPixelTolerance(1, 1) .Pixel(expected.Colors[2]), ExpectedPixels .At($"bottom-{expected}", bottomTarget.CenterX, bottomTarget.CenterY) .WithPixelTolerance(1, 1) .Pixel(expected.Colors[3]), ExpectedPixels .At($"center-{expected}", centerTarget.CenterX, centerTarget.CenterY) .WithPixelTolerance(1, 1) .Pixel(lightBlue) ); } }
public void When_CornerRadiusControls() { Run("UITests.Windows_UI_Xaml.Clipping.CornerRadiusControls"); _app.WaitForElement("TestRoot"); using var snapshot = this.TakeScreenshot("validation", ignoreInSnapshotCompare: false); using (new AssertionScope("Rounded corners")) { CheckRoundedCorners("ctl1"); CheckRoundedCorners("ctl2"); CheckRoundedCorners("ctl3"); CheckRoundedCorners("ctl4"); CheckRoundedCorners("ctl5"); CheckRoundedCorners("ctl6"); CheckRoundedCorners("ctl7"); CheckRoundedCorners("ctl8"); } using (new AssertionScope("No Rounded corners")) { CheckNoRoundedCorners("ctl1_rect"); CheckNoRoundedCorners("ctl2_rect"); CheckNoRoundedCorners("ctl3_rect"); } void CheckRoundedCorners(string s) { var rectCtl = _app.GetPhysicalRect(s); var green = "#FF008000"; var white = "#FFFFFFFF"; ImageAssert.HasPixels( snapshot, ExpectedPixels .At("top-middle " + s, rectCtl.CenterX, rectCtl.Y + 2) .WithPixelTolerance(1, 1) .Pixel(green), ExpectedPixels .At("bottom-middle " + s, rectCtl.CenterX, rectCtl.Bottom - 2) .WithPixelTolerance(1, 1) .Pixel(green), ExpectedPixels .At("left-middle " + s, rectCtl.X + 2, rectCtl.CenterY) .WithPixelTolerance(1, 1) .Pixel(green), ExpectedPixels .At("right-middle " + s, rectCtl.Right - 2, rectCtl.CenterY) .WithPixelTolerance(1, 1) .Pixel(green), ExpectedPixels .At("top-left " + s, rectCtl.X + 1, rectCtl.Y + 1) .Pixel(white), ExpectedPixels .At("top-right " + s, rectCtl.Right - 1, rectCtl.Y + 1) .Pixel(white), ExpectedPixels .At("bottom-left " + s, rectCtl.X + 1, rectCtl.Bottom - 1) .Pixel(white), ExpectedPixels .At("bottom-right " + s, rectCtl.Right - 1, rectCtl.Bottom - 1) .Pixel(white) ); } void CheckNoRoundedCorners(string s) { var rectCtl = _app.GetPhysicalRect(s); var green = "#FF008000"; ImageAssert.HasPixels( snapshot, ExpectedPixels .At("top-middle " + s, rectCtl.CenterX, rectCtl.Y + 2) .WithPixelTolerance(1, 1) .Pixel(green), ExpectedPixels .At("bottom-middle " + s, rectCtl.CenterX, rectCtl.Bottom - 2) .WithPixelTolerance(1, 1) .Pixel(green), ExpectedPixels .At("left-middle " + s, rectCtl.X + 2, rectCtl.CenterY) .WithPixelTolerance(1, 1) .Pixel(green), ExpectedPixels .At("right-middle " + s, rectCtl.Right - 2, rectCtl.CenterY) .WithPixelTolerance(1, 1) .Pixel(green), ExpectedPixels .At("top-left " + s, rectCtl.X + 1, rectCtl.Y + 1) .Pixel(green), ExpectedPixels .At("top-right " + s, rectCtl.Right - 1, rectCtl.Y + 1) .Pixel(green), ExpectedPixels .At("bottom-left " + s, rectCtl.X + 1, rectCtl.Bottom - 1) .Pixel(green), ExpectedPixels .At("bottom-right " + s, rectCtl.Right - 1, rectCtl.Bottom - 1) .Pixel(green) ); } }
public void Border_CornerRadius_BorderThickness() { const string red = "#FF0000"; const string blue = "#0000FF"; var expectedColors = new[] { new ExpectedColor { Thicknesses = new [] { 10, 10, 10, 10 }, Colors = new [] { red, red, red, red } }, new ExpectedColor { Thicknesses = new [] { 10, 0, 10, 10 }, Colors = new [] { red, blue, red, red } }, new ExpectedColor { Thicknesses = new [] { 10, 0, 0, 10 }, Colors = new [] { red, blue, blue, red } }, new ExpectedColor { Thicknesses = new [] { 10, 0, 0, 0 }, Colors = new [] { red, blue, blue, blue } }, new ExpectedColor { Thicknesses = new [] { 0, 0, 0, 0 }, Colors = new [] { blue, blue, blue, blue } }, }; Run("UITests.Windows_UI_Xaml_Controls.BorderTests.Border_CornerRadius_BorderThickness"); _app.WaitForElement("MyBorder"); var leftTarget = _app.GetPhysicalRect("LeftTarget"); var topTarget = _app.GetPhysicalRect("TopTarget"); var rightTarget = _app.GetPhysicalRect("RightTarget"); var bottomTarget = _app.GetPhysicalRect("BottomTarget"); var centerTarget = _app.GetPhysicalRect("CenterTarget"); SetBorderProperty("MyBorder", "CornerRadius", "10"); foreach (var expected in expectedColors) { SetBorderProperty("MyBorder", "BorderThickness", expected.ToString()); using var snapshot = TakeScreenshot($"Border-CornerRadius-10-BorderThickness-{expected}"); ImageAssert.HasPixels( snapshot, ExpectedPixels .At($"left-{expected}", leftTarget.CenterX, leftTarget.CenterY) .WithPixelTolerance(1, 1) .Pixel(expected.Colors[0]), ExpectedPixels .At($"top-{expected}", topTarget.CenterX, topTarget.CenterY) .WithPixelTolerance(1, 1) .Pixel(expected.Colors[1]), ExpectedPixels .At($"right-{expected}", rightTarget.CenterX, rightTarget.CenterY) .WithPixelTolerance(1, 1) .Pixel(expected.Colors[2]), ExpectedPixels .At($"bottom-{expected}", bottomTarget.CenterX, bottomTarget.CenterY) .WithPixelTolerance(1, 1) .Pixel(expected.Colors[3]), ExpectedPixels .At($"center-{expected}", centerTarget.CenterX, centerTarget.CenterY) .WithPixelTolerance(1, 1) .Pixel(blue) ); } }