diff --git a/Lombiq.Tests.UI/Extensions/VisualVerificationUITestContextExtensions.cs b/Lombiq.Tests.UI/Extensions/VisualVerificationUITestContextExtensions.cs index d76dd5d23..89a70938c 100644 --- a/Lombiq.Tests.UI/Extensions/VisualVerificationUITestContextExtensions.cs +++ b/Lombiq.Tests.UI/Extensions/VisualVerificationUITestContextExtensions.cs @@ -53,7 +53,6 @@ public static void AssertVisualVerificationOnAllResolutions( IEnumerable sizes, Func getSelector, double pixelErrorPercentageThreshold = 0, - bool checkOS = false, Action configurator = null) { context.HideScrollbar(); @@ -70,16 +69,7 @@ public static void AssertVisualVerificationOnAllResolutions( pixelErrorPercentageThreshold: pixelErrorPercentageThreshold, configurator: configuration => { - var fileNameSuffix = StringHelper.CreateInvariant($"{size.Width}x{size.Height}"); - - if (checkOS) - { - var oS = OperatingSystem.IsWindows() ? "Windows" : "Unix"; - - fileNameSuffix = $"{fileNameSuffix}-{oS}"; - } - - configuration.WithFileNameSuffix(fileNameSuffix); + configuration.WithFileNameSuffix(StringHelper.CreateInvariant($"{size.Width}x{size.Height}")); configurator?.Invoke(configuration); }); } @@ -103,6 +93,40 @@ public static void AssertVisualVerificationOnAllResolutions( context.RestoreHiddenScrollbar(); } + /// + /// Compares the baseline image and screenshot of the selected element on multiple different resolutions, based on + /// the operating system's platform. + /// + /// The comparison is performed on each of these resolutions. + /// + /// Returns the selector for the given screen size. This may return the same selector all the time, or a different + /// selector, e.g. if mobile and desktop views have different DOMs. + /// + /// Maximum acceptable pixel error in percentage. + /// Action callback to configure the behavior. Can be , but in the + /// method we are always using . + /// + /// + /// The parameter beforeAssertAsync was removed, because it sometimes polluted the stack trace, which was + /// used in visual verification tests, so it caused tests to fail. The point of beforeAssertAsync was, that + /// sometimes the page can change on the resize window event. So the navigation happening after the window resize + /// ensures that the currently loaded page only existed with the desired screen size. + /// + /// + [VisualVerificationApprovedMethod] + public static void AssertVisualVerificationApprovedOnAllResolutionsWithPlatformSuffix( + this UITestContext context, + IEnumerable sizes, + Func getSelector, + double pixelErrorPercentageThreshold = 0, + Action configurator = null) => + context.AssertVisualVerificationOnAllResolutions( + sizes, + getSelector, + pixelErrorPercentageThreshold, + configuration => configuration.WithUsePlatformAsSuffix()); + /// /// Compares the baseline image and screenshot of the whole page. /// .