-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #16944 from wordpress-mobile/refactor/ui-testing-s…
…wipe-to-avoid-viewpager-gray-overlay Refactor swipeToAvoidGrayOverlay to ignore failures and become reusable
- Loading branch information
Showing
3 changed files
with
30 additions
and
31 deletions.
There are no files selected for viewing
This file contains 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 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
25 changes: 25 additions & 0 deletions
25
WordPress/src/androidTest/java/org/wordpress/android/util/UiTestingUtils.kt
This file contains 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 |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package org.wordpress.android.util | ||
|
||
import org.wordpress.android.support.WPSupportUtils | ||
|
||
object UiTestingUtils { | ||
/** | ||
* Workaround to avoid gray overlay. | ||
* In some cases there's a gray overlay on view pager screens when taking screenshots. | ||
* This function swipes left and then right as a workaround to clear it. | ||
* @param resourceID: Int the ID of the viewPager | ||
*/ | ||
@JvmStatic | ||
fun swipeToAvoidGrayOverlayIgnoringFailures(resourceID: Int) { | ||
try { | ||
WPSupportUtils.swipeLeftOnViewPager(resourceID) | ||
WPSupportUtils.idleFor(1000) | ||
WPSupportUtils.swipeRightOnViewPager(resourceID) | ||
WPSupportUtils.idleFor(1000) | ||
} catch (e: Throwable) { | ||
// Fail softly | ||
@Suppress("PrintStackTrace") | ||
e.printStackTrace() | ||
} | ||
} | ||
} |