diff --git a/src/Controls/tests/TestCases.Android.Tests/snapshots/android/BorderBackgroundSizeUpdatesWhenRotatingScreen.png b/src/Controls/tests/TestCases.Android.Tests/snapshots/android/BorderBackgroundSizeUpdatesWhenRotatingScreen.png index 07d5370f608b..8638b74ced8d 100644 Binary files a/src/Controls/tests/TestCases.Android.Tests/snapshots/android/BorderBackgroundSizeUpdatesWhenRotatingScreen.png and b/src/Controls/tests/TestCases.Android.Tests/snapshots/android/BorderBackgroundSizeUpdatesWhenRotatingScreen.png differ diff --git a/src/Controls/tests/TestCases.Android.Tests/snapshots/android/CarouselViewItemShouldScaleProperly.png b/src/Controls/tests/TestCases.Android.Tests/snapshots/android/CarouselViewItemShouldScaleProperly.png index daf55575bde6..a1edb212f527 100644 Binary files a/src/Controls/tests/TestCases.Android.Tests/snapshots/android/CarouselViewItemShouldScaleProperly.png and b/src/Controls/tests/TestCases.Android.Tests/snapshots/android/CarouselViewItemShouldScaleProperly.png differ diff --git a/src/Controls/tests/TestCases.Android.Tests/snapshots/android/ShouldFlyoutTextWrapsInLandscape.png b/src/Controls/tests/TestCases.Android.Tests/snapshots/android/ShouldFlyoutTextWrapsInLandscape.png index 38b7a2626648..4f8fc089211b 100644 Binary files a/src/Controls/tests/TestCases.Android.Tests/snapshots/android/ShouldFlyoutTextWrapsInLandscape.png and b/src/Controls/tests/TestCases.Android.Tests/snapshots/android/ShouldFlyoutTextWrapsInLandscape.png differ diff --git a/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue15154.cs b/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue15154.cs index eb7a45124209..bbdd0873f20d 100644 --- a/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue15154.cs +++ b/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue15154.cs @@ -20,7 +20,11 @@ public void ShouldFlyoutTextWrapsInLandscape() App.WaitForElement("OpenFlyoutButton"); App.Tap("OpenFlyoutButton"); App.SetOrientationLandscape(); +#if ANDROID + VerifyScreenshot(cropLeft: 125); +#else VerifyScreenshot(); +#endif } } #endif \ No newline at end of file diff --git a/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue22606.cs b/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue22606.cs index 70b4100b0874..0621826310d2 100644 --- a/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue22606.cs +++ b/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue22606.cs @@ -29,7 +29,11 @@ public void BorderBackgroundSizeUpdatesWhenRotatingScreen() App.WaitForElement("SetHeightTo200"); App.Tap("SetHeightTo200"); App.SetOrientationLandscape(); +#if ANDROID + VerifyScreenshot(cropLeft: 125); +#else VerifyScreenshot(); +#endif } #endif } diff --git a/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue28523.cs b/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue28523.cs index 5a6172c4571c..8cd41f1de653 100644 --- a/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue28523.cs +++ b/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue28523.cs @@ -19,7 +19,11 @@ public void CarouselViewItemShouldScaleProperly() App.WaitForElement("Baboon"); App.SetOrientationLandscape(); App.WaitForElement("Baboon"); +#if ANDROID + VerifyScreenshot(cropLeft: 125); +#else VerifyScreenshot(); +#endif } [TearDown] diff --git a/src/Controls/tests/TestCases.Shared.Tests/UITest.cs b/src/Controls/tests/TestCases.Shared.Tests/UITest.cs index acd5cb7df1e2..2c265c5befa6 100644 --- a/src/Controls/tests/TestCases.Shared.Tests/UITest.cs +++ b/src/Controls/tests/TestCases.Shared.Tests/UITest.cs @@ -124,6 +124,8 @@ public void VerifyScreenshotOrSetException( ref Exception? exception, string? name = null, TimeSpan? retryDelay = null, + int cropLeft = 0, + int cropRight = 0, int cropTop = 0, int cropBottom = 0, double tolerance = 0.0 @@ -134,7 +136,7 @@ public void VerifyScreenshotOrSetException( { try { - VerifyScreenshot(name, retryDelay, cropTop, cropBottom, tolerance + VerifyScreenshot(name, retryDelay, cropLeft, cropRight, cropTop, cropBottom, tolerance #if MACUITEST || WINTEST , includeTitleBar #endif @@ -151,6 +153,8 @@ public void VerifyScreenshotOrSetException( /// /// Optional name for the screenshot. If not provided, a default name will be used. /// Optional delay between retry attempts when verification fails. + /// Number of pixels to crop from the left of the screenshot. + /// Number of pixels to crop from the right of the screenshot. /// Number of pixels to crop from the top of the screenshot. /// Number of pixels to crop from the bottom of the screenshot. /// Tolerance level for image comparison as a percentage from 0 to 100. @@ -179,6 +183,8 @@ public void VerifyScreenshotOrSetException( public void VerifyScreenshot( string? name = null, TimeSpan? retryDelay = null, + int cropLeft = 0, + int cropRight = 0, int cropTop = 0, int cropBottom = 0, double tolerance = 0.0 // Add tolerance parameter (0.05 = 5%) @@ -316,16 +322,24 @@ but both can happen. TestDevice.iOS => 40, _ => 0, }; - + + // Cropping from the left or right can be applied for any platform using the user-specified crop values. + // The default values are set based on the platform, but the final cropping is determined by the parameters passed in. + // This allows cropping of UI elements (such as navigation bars or home indicators) for any platform as needed. + int cropFromLeft = 0; + int cropFromRight = 0; + + cropFromLeft = cropLeft > 0 ? cropLeft : cropFromLeft; + cropFromRight = cropRight > 0 ? cropRight : cropFromRight; cropFromTop = cropTop > 0 ? cropTop : cropFromTop; cropFromBottom = cropBottom > 0 ? cropBottom : cropFromBottom; - if (cropFromTop > 0 || cropFromBottom > 0) + if (cropFromLeft > 0 || cropFromRight > 0 || cropFromTop > 0 || cropFromBottom > 0) { IImageEditor imageEditor = _imageEditorFactory.CreateImageEditor(actualImage); (int width, int height) = imageEditor.GetSize(); - imageEditor.Crop(0, cropFromTop, width, height - cropFromTop - cropFromBottom); + imageEditor.Crop(cropFromLeft, cropFromTop, width - cropFromLeft - cropFromRight, height - cropFromTop - cropFromBottom); actualImage = imageEditor.GetUpdatedImage(); }