Skip to content

Commit

Permalink
fix: Adjust for scaling in description tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jeromelaban committed Feb 5, 2022
1 parent a116275 commit 6a968da
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,10 @@ public void NumberBox_Description()
{
Run("UITests.Microsoft_UI_Xaml_Controls.NumberBoxTests.NumberBox_Description", skipInitialScreenshot: true);

var numberBox = _app.WaitForElement("DescriptionNumberBox")[0];
var numberBoxRect = ToPhysicalRect(_app.WaitForElement("DescriptionNumberBox")[0].Rect);
using var screenshot = TakeScreenshot("NumberBox Description", new ScreenshotOptions() { IgnoreInSnapshotCompare = true });
ImageAssert.HasColorAt(screenshot, numberBox.Rect.X + numberBox.Rect.Width / 2, numberBox.Rect.Y + numberBox.Rect.Height - 150, Color.Red);

ImageAssert.HasColorAt(screenshot, numberBoxRect.X + numberBoxRect.Width / 2, numberBoxRect.Y + numberBoxRect.Height - 50, Color.Red);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ public partial class AutoSuggestBoxTests : SampleControlUITestBase
public void PasswordBox_With_Description()
{
Run("UITests.Windows_UI_Xaml_Controls.AutoSuggestBoxTests.AutoSuggestBox_Description", skipInitialScreenshot: true);
var autoSuggestBox = _app.WaitForElement("DescriptionAutoSuggestBox")[0];
var autoSuggestBoxRect = ToPhysicalRect(_app.WaitForElement("DescriptionAutoSuggestBox")[0].Rect);
using var screenshot = TakeScreenshot("AutoSuggestBox Description", new ScreenshotOptions() { IgnoreInSnapshotCompare = true });
ImageAssert.HasColorAt(screenshot, autoSuggestBox.Rect.X + autoSuggestBox.Rect.Width / 2, autoSuggestBox.Rect.Y + autoSuggestBox.Rect.Height - 150, Color.Red);
ImageAssert.HasColorAt(screenshot, autoSuggestBoxRect.X + autoSuggestBoxRect.Width / 2, autoSuggestBoxRect.Y + autoSuggestBoxRect.Height - 50, Color.Red);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -875,19 +875,19 @@ public void TextBox_WithPadding_Focus()
public void TextBox_With_Description()
{
Run("UITests.Windows_UI_Xaml_Controls.TextBox.TextBox_Description", skipInitialScreenshot: true);
var textBox = _app.WaitForElement("DescriptionTextBox")[0];
var textBoxRect = ToPhysicalRect(_app.WaitForElement("DescriptionTextBox")[0].Rect);
using var screenshot = TakeScreenshot("TextBox Description", new ScreenshotOptions() { IgnoreInSnapshotCompare = true });
ImageAssert.HasColorAt(screenshot, textBox.Rect.X + textBox.Rect.Width / 2, textBox.Rect.Y + textBox.Rect.Height - 150, Color.Red);
ImageAssert.HasColorAt(screenshot, textBoxRect.X + textBoxRect.Width / 2, textBoxRect.Y + textBoxRect.Height - 50, Color.Red);
}

[Test]
[AutoRetry]
public void PasswordBox_With_Description()
{
Run("UITests.Windows_UI_Xaml_Controls.TextBox.PasswordBox_Description", skipInitialScreenshot: true);
var passwordBox = _app.WaitForElement("DescriptionPasswordBox")[0];
var passwordBoxRect = ToPhysicalRect(_app.WaitForElement("DescriptionPasswordBox")[0].Rect);
using var screenshot = TakeScreenshot("PasswordBox Description", new ScreenshotOptions() { IgnoreInSnapshotCompare = true });
ImageAssert.HasColorAt(screenshot, passwordBox.Rect.X + passwordBox.Rect.Width / 2, passwordBox.Rect.Y + passwordBox.Rect.Height - 150, Color.Red);
ImageAssert.HasColorAt(screenshot, passwordBoxRect.X + passwordBoxRect.Width / 2, passwordBoxRect.Y + passwordBoxRect.Height - 50, Color.Red);
}
}
}

0 comments on commit 6a968da

Please sign in to comment.