Bug 1810404 - Fix flaky scanButtonAllowPermissionTest UI test

fenix/113.0
AndiAJ 1 year ago committed by mergify[bot]
parent 67a7811835
commit 88214343c1

@ -65,6 +65,7 @@ import org.mozilla.fenix.R
import org.mozilla.fenix.customtabs.ExternalAppBrowserActivity
import org.mozilla.fenix.ext.components
import org.mozilla.fenix.helpers.Constants.PackageName.YOUTUBE_APP
import org.mozilla.fenix.helpers.MatcherHelper.itemWithResIdAndText
import org.mozilla.fenix.helpers.TestAssetHelper.waitingTime
import org.mozilla.fenix.helpers.TestAssetHelper.waitingTimeShort
import org.mozilla.fenix.helpers.ext.waitNotNull
@ -340,17 +341,24 @@ object TestHelper {
fun grantPermission() {
if (Build.VERSION.SDK_INT >= 23) {
mDevice.findObject(
By.text(
when (Build.VERSION.SDK_INT) {
Build.VERSION_CODES.R -> Pattern.compile(
"WHILE USING THE APP",
Pattern.CASE_INSENSITIVE,
)
else -> Pattern.compile("Allow", Pattern.CASE_INSENSITIVE)
},
),
).click()
when (Build.VERSION.SDK_INT) {
Build.VERSION_CODES.R ->
itemWithResIdAndText(
"com.android.permissioncontroller:id/permission_allow_foreground_only_button",
"While using the app",
).also {
it.waitForExists(waitingTime)
it.click()
}
else ->
itemWithResIdAndText(
"com.android.packageinstaller:id/permission_allow_button",
"ALLOW",
).also {
it.waitForExists(waitingTime)
it.click()
}
}
}
}

@ -39,6 +39,7 @@ import org.mozilla.fenix.helpers.Constants
import org.mozilla.fenix.helpers.Constants.LONG_CLICK_DURATION
import org.mozilla.fenix.helpers.Constants.RETRY_COUNT
import org.mozilla.fenix.helpers.Constants.SPEECH_RECOGNITION
import org.mozilla.fenix.helpers.MatcherHelper.itemWithResIdAndText
import org.mozilla.fenix.helpers.SessionLoadedIdlingResource
import org.mozilla.fenix.helpers.TestAssetHelper.waitingTime
import org.mozilla.fenix.helpers.TestAssetHelper.waitingTimeShort
@ -212,10 +213,11 @@ class SearchRobot {
searchEnginesShortcutButton.click()
}
fun clickScanButton() {
scanButton.waitForExists(waitingTime)
scanButton.click()
}
fun clickScanButton() =
scanButton.also {
it.waitForExists(waitingTime)
it.click()
}
fun clickDismissPermissionRequiredDialog() {
dismissPermissionButton.waitForExists(waitingTime)
@ -399,7 +401,10 @@ private val goToPermissionsSettingsButton =
mDevice.findObject(UiSelector().text("GO TO SETTINGS"))
private val scanButton =
mDevice.findObject(UiSelector().resourceId("$packageName:id/qr_scan_button"))
itemWithResIdAndText(
"$packageName:id/qr_scan_button",
getStringResource(R.string.search_scan_button),
)
private fun clearButton() =
mDevice.findObject(UiSelector().resourceId("$packageName:id/mozac_browser_toolbar_clear_view"))

Loading…
Cancel
Save