Skip to content

Commit

Permalink
Bug 1862911 - Fix restartDownloadFromAppNotificationAfterConnectionIs…
Browse files Browse the repository at this point in the history
…InterruptedTest UI test r=ohorvath

The UI test was disabled because sometimes the download failed prompt was displayed later than usual. (did a status check and noticed that sometimes it's being displayed right away, in other cases it was displayed with a delay)

To overcome this problem I've added a retry loop to extend the waiting time for it to be displayed when needed.

The UI test successfully passed 150x on Firebase.

Differential Revision: https://phabricator.services.mozilla.com/D217555
  • Loading branch information
AndiAJ committed Jul 26, 2024
1 parent c72e533 commit 16442cb
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,6 @@ class DownloadTest : TestSetup() {
}

// TestRail link: https://testrail.stage.mozaws.net/index.php?/cases/view/244125
@Ignore("Failing, see: https://bugzilla.mozilla.org/show_bug.cgi?id=1862911")
@Test
fun restartDownloadFromAppNotificationAfterConnectionIsInterruptedTest() {
downloadFile = "3GB.zip"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ import org.mozilla.fenix.downloads.listscreen.DownloadsListTestTag
import org.mozilla.fenix.helpers.AppAndSystemHelper.assertExternalAppOpens
import org.mozilla.fenix.helpers.AppAndSystemHelper.getPermissionAllowID
import org.mozilla.fenix.helpers.Constants.PackageName.GOOGLE_APPS_PHOTOS
import org.mozilla.fenix.helpers.Constants.RETRY_COUNT
import org.mozilla.fenix.helpers.Constants.TAG
import org.mozilla.fenix.helpers.DataGenerationHelper.getStringResource
import org.mozilla.fenix.helpers.HomeActivityComposeTestRule
Expand Down Expand Up @@ -88,23 +89,35 @@ class DownloadRobot {
itemWithResId("$packageName:id/download_dialog_filename"),
)

fun verifyDownloadFailedPrompt(fileName: String) =
assertUIObjectExists(
itemWithResId("$packageName:id/download_dialog_icon"),
itemWithResIdContainingText(
"$packageName:id/download_dialog_title",
getStringResource(R.string.mozac_feature_downloads_failed_notification_text2),
),
itemWithResIdContainingText(
"$packageName:id/download_dialog_filename",
fileName,
),
itemWithResIdContainingText(
"$packageName:id/download_dialog_action_button",
getStringResource(R.string.mozac_feature_downloads_button_try_again),
),
waitingTime = waitingTimeLong,
)
fun verifyDownloadFailedPrompt(fileName: String) {
for (i in 1..RETRY_COUNT) {
Log.i(TAG, "verifyDownloadFailedPrompt: Started try #$i")
try {
assertUIObjectExists(
itemWithResId("$packageName:id/download_dialog_icon"),
itemWithResIdContainingText(
"$packageName:id/download_dialog_title",
getStringResource(R.string.mozac_feature_downloads_failed_notification_text2),
),
itemWithResIdContainingText(
"$packageName:id/download_dialog_filename",
fileName,
),
itemWithResIdContainingText(
"$packageName:id/download_dialog_action_button",
getStringResource(R.string.mozac_feature_downloads_button_try_again),
),
)

break
} catch (e: AssertionError) {
Log.i(TAG, "verifyDownloadFailedPrompt: AssertionError caught, executing fallback methods")
if (i == RETRY_COUNT) {
throw e
}
}
}
}

fun clickTryAgainButton() {
Log.i(TAG, "clickTryAgainButton: Trying to click the \"TRY AGAIN\" in app prompt button")
Expand Down

0 comments on commit 16442cb

Please sign in to comment.