public void PopupWithOverlay() { Run("UITests.Shared.Windows_UI_Xaml_Controls.Popup.Popup_Overlay_On"); using var before = TakeScreenshot("Before", ignoreInSnapshotCompare: true); var rect = _app.GetPhysicalRect("LocatorRectangle"); ImageAssert.HasColorAt(before, rect.CenterX, rect.CenterY, Color.Blue); _app.FastTap("PopupCheckBox"); _app.WaitForElement("PopupChild"); using var during = TakeScreenshot("During", ignoreInSnapshotCompare: AppInitializer.GetLocalPlatform() == Platform.Android /*Status bar appears with clock*/); ImageAssert.DoesNotHaveColorAt(during, rect.CenterX, rect.CenterY, Color.Blue); // Dismiss popup var screenRect = _app.Marked("sampleContent").FirstResult().Rect; _app.TapCoordinates(10, screenRect.Bottom - 10); _app.WaitForNoElement("PopupChild"); using var after = TakeScreenshot("After"); ImageAssert.HasColorAt(after, rect.CenterX, rect.CenterY, Color.Blue); }
public void When_Text_Selection_Is_Enabled() { Run("UITests.Windows_UI_Xaml_Controls.TextBlockControl.TextBlock_IsTextSelectionEnabled"); var nonSelectableTextBlock = _app.WaitForElement("NonSelectableUnderscoreTextBlock").Single().Rect; var selectableTextBlock = _app.WaitForElement("SelectableUnderscoreTextBlock").Single().Rect; // Attempt selection _app.DoubleTapCoordinates(nonSelectableTextBlock.CenterX, nonSelectableTextBlock.CenterY); using (var nonSelectableScreenshot = TakeScreenshot("NonSelectableTextBlock", ignoreInSnapshotCompare: true)) { ImageAssert.HasColorAt(nonSelectableScreenshot, nonSelectableTextBlock.CenterX, nonSelectableTextBlock.CenterY, Color.White); } // Click to ensure any selection is removed _app.TapCoordinates(nonSelectableTextBlock.CenterX, nonSelectableTextBlock.CenterY); // Attempt selection _app.DoubleTapCoordinates(selectableTextBlock.CenterX, selectableTextBlock.CenterY); using (var selectableScreenshot = TakeScreenshot("SelectableTextBlock", ignoreInSnapshotCompare: true)) { ImageAssert.DoesNotHaveColorAt(selectableScreenshot, selectableTextBlock.CenterX, selectableTextBlock.CenterY, Color.White); } }
public void Large_Image_With_Margin() { Run("UITests.Windows_UI_Xaml_Controls.ImageTests.Image_Margin_Large"); var bmp = TakeScreenshot("Ready"); var rect = _app.GetRect("outerBorder"); ImageAssert.DoesNotHaveColorAt(bmp, rect.CenterX, rect.CenterY, Color.Black); }
[ActivePlatforms(Platform.Android, Platform.iOS)] // Touch only test public void Manipulation_WhenInListViewAndManipulationTranslateX_ThenAbort() { Run("UITests.Windows_UI_Input.GestureRecognizerTests.Manipulation_WhenInListView"); var scroller = _app.WaitForElement("ItemsSupportsTranslateX").Single().Rect; _app.DragCoordinates(scroller.CenterX, scroller.Bottom - 5, scroller.CenterX, scroller.Y + 10); var result = TakeScreenshot("after_scroll", ignoreInSnapshotCompare: true); ImageAssert.DoesNotHaveColorAt(result, scroller.CenterX, scroller.Y + 10, "#FF0000"); }
public void ToggleCollapsedStateToVerifyClipping() { Run("UITests.Shared.Microsoft_UI_Xaml_Controls.ExpanderTests.ExpanderColorValidationPage"); var expanderResult = _app.WaitForElement("ExpanderWithColor"); var expander = _app.Marked("ExpanderWithColor"); var expanderAppRect = ToPhysicalRect(expanderResult[0].Rect); expander.FastTap(); using var screenshot = TakeScreenshot("Toggle Expanded property", new ScreenshotOptions() { IgnoreInSnapshotCompare = true }); var expanderRectangle = expanderAppRect.ToRectangle(); var centerPoint = new Point(expanderRectangle.Left + expanderRectangle.Width / 2, expanderRectangle.Top + expanderRectangle.Height / 2); // R:128 G:0 B:127 is the color that should be visible if the translucent content reigion occludes the rest of the control ImageAssert.DoesNotHaveColorAt(screenshot, centerPoint.X, centerPoint.Y, Color.FromArgb(128, 0, 127)); }
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); 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"); 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); await Task.Delay(1000); // We cannot detect the animation ... var swippedItem = output.GetDependencyPropertyValue <string>("Text"); Assert.AreEqual("#FFFFA52C", swippedItem); // Scroll up _app.DragCoordinates(sutPhyRect.CenterX, sutPhyRect.Bottom - 10.LogicalToPhysicalPixels(_app), sutPhyRect.CenterX, sutPhyRect.Y + 10.LogicalToPhysicalPixels(_app)); // Validate scrolled successfully var postScroll = TakeScreenshot("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); await Task.Delay(1000); // We cannot detect the animation ... swippedItem = output.GetDependencyPropertyValue <string>("Text"); Assert.AreNotEqual("#FFFFA52C", swippedItem); }
private void TestOpacityFinalState([CallerMemberName] string testName = null) { var match = Regex.Match(testName, @"When_Opacity_(?<type>\w+)_With_FillBehavior(?<fill>\w+)_Then_(?<expected>\w+)"); if (!match.Success) { throw new InvalidOperationException("Invalid test name."); } var type = match.Groups["type"].Value; var fill = match.Groups["fill"].Value; var expected = match.Groups["expected"].Value; bool isSame = false, isGray = false, isDifferent = false; switch (type) { case "Completed" when expected == "Hold": isGray = true; break; case "Completed" when expected == "Rollback": isSame = true; break; case "Paused": isDifferent = true; break; case "Canceled": isSame = true; break; default: throw new InvalidOperationException("Invalid test name."); } Run(_finalStateOpacityTestControl, skipInitialScreenshot: true); using var initial = TakeScreenshot("Initial", ignoreInSnapshotCompare: true); var element = _app.WaitForElement($"{type}AnimationHost_{fill}").Single().Rect; _app.Marked("StartButton").FastTap(); _app.WaitForDependencyPropertyValue(_app.Marked("Status"), "Text", "Completed"); // Assert using var final = TakeScreenshot("Final", ignoreInSnapshotCompare: true); if (isSame) { ImageAssert.AreEqual(initial, final, element); } else if (isGray) { ImageAssert.HasColorAt(final, element.CenterX, element.CenterY, Color.LightGray); } else if (isDifferent) { ImageAssert.AreNotEqual(initial, final, element); ImageAssert.DoesNotHaveColorAt(final, element.CenterX, element.CenterY, Color.LightGray); } }
public void Default_StrokeThickness() { const string red = "#FF0000"; string reddish = GetReddish(); 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 = reddish, }, new ShapeExpectation { Name = "MyPolygon", Offsets = new [] { 2, 2, -1, -1 }, Colors = reddish, }, 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); } } }