-
Notifications
You must be signed in to change notification settings - Fork 2k
[Testing] Added Left/Right Cropping Support for Screenshot Verification in UI Tests #31715
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Binary file modified
BIN
-20 KB
(31%)
...droid.Tests/snapshots/android/BorderBackgroundSizeUpdatesWhenRotatingScreen.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
-9.11 KB
(40%)
...stCases.Android.Tests/snapshots/android/CarouselViewItemShouldScaleProperly.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
-31.2 KB
(74%)
.../TestCases.Android.Tests/snapshots/android/ShouldFlyoutTextWrapsInLandscape.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -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( | |||||||||
| /// </summary> | ||||||||||
| /// <param name="name">Optional name for the screenshot. If not provided, a default name will be used.</param> | ||||||||||
| /// <param name="retryDelay">Optional delay between retry attempts when verification fails.</param> | ||||||||||
| /// <param name="cropLeft">Number of pixels to crop from the left of the screenshot.</param> | ||||||||||
| /// <param name="cropRight">Number of pixels to crop from the right of the screenshot.</param> | ||||||||||
| /// <param name="cropTop">Number of pixels to crop from the top of the screenshot.</param> | ||||||||||
| /// <param name="cropBottom">Number of pixels to crop from the bottom of the screenshot.</param> | ||||||||||
| /// <param name="tolerance">Tolerance level for image comparison as a percentage from 0 to 100.</param> | ||||||||||
|
|
@@ -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; | ||||||||||
|
Comment on lines
+332
to
+333
|
||||||||||
| cropFromLeft = cropLeft > 0 ? cropLeft : cropFromLeft; | |
| cropFromRight = cropRight > 0 ? cropRight : cropFromRight; | |
| cropFromLeft = cropLeft; | |
| cropFromRight = cropRight; |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The magic number
125for crop pixels should be defined as a named constant to improve maintainability and ensure consistency across test files. Consider definingprivate const int AndroidNavigationCropLeft = 125;at the class level.