Bug 1842262 - Convert CrashReportingTest to compose r=android-reviewers,rsainani,ohorvath

The diff is only a few lines between the [original implementation](https://searchfox.org/mozilla-central/source/mobile/android/fenix/app/src/androidTest/java/org/mozilla/fenix/ui/CrashReportingTest.kt).

Diff for ease of use: https://www.diffchecker.com/dkXUxtQP/

Differential Revision: https://phabricator.services.mozilla.com/D205397
This commit is contained in:
Noah Bond 2024-03-25 20:17:52 +00:00
Родитель 50a2b87128
Коммит 2e69bf53e8
1 изменённых файлов: 97 добавлений и 0 удалений

Просмотреть файл

@ -0,0 +1,97 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
package org.mozilla.fenix.ui
import androidx.compose.ui.test.junit4.AndroidComposeTestRule
import org.junit.Ignore
import org.junit.Rule
import org.junit.Test
import org.mozilla.fenix.R
import org.mozilla.fenix.customannotations.SmokeTest
import org.mozilla.fenix.helpers.DataGenerationHelper.getStringResource
import org.mozilla.fenix.helpers.HomeActivityIntentTestRule
import org.mozilla.fenix.helpers.MatcherHelper.itemWithResId
import org.mozilla.fenix.helpers.TestAssetHelper
import org.mozilla.fenix.helpers.TestHelper.mDevice
import org.mozilla.fenix.helpers.TestHelper.packageName
import org.mozilla.fenix.helpers.TestSetup
import org.mozilla.fenix.ui.robots.clickPageObject
import org.mozilla.fenix.ui.robots.homeScreen
import org.mozilla.fenix.ui.robots.navigationToolbar
class ComposeCrashReportingTest : TestSetup() {
private val tabCrashMessage = getStringResource(R.string.tab_crash_title_2)
@get:Rule
val activityTestRule = AndroidComposeTestRule(
HomeActivityIntentTestRule(
isPocketEnabled = false,
isJumpBackInCFREnabled = false,
isWallpaperOnboardingEnabled = false,
isTCPCFREnabled = false,
tabsTrayRewriteEnabled = true,
),
) { it.activity }
// TestRail link: https://testrail.stage.mozaws.net/index.php?/cases/view/308906
@Test
fun closeTabFromCrashedTabReporterTest() {
homeScreen {
}.openNavigationToolbar {
}.openTabCrashReporter {
}.clickTabCrashedCloseButton {
}.openComposeTabDrawer(activityTestRule) {
verifyNoOpenTabsInNormalBrowsing()
}
}
// TestRail link: https://testrail.stage.mozaws.net/index.php?/cases/view/2336134
@Ignore("Test failure caused by: https://github.com/mozilla-mobile/fenix/issues/19964")
@Test
fun restoreTabFromTabCrashedReporterTest() {
val website = TestAssetHelper.getGenericAsset(mockWebServer, 1)
homeScreen {
}.openNavigationToolbar {
}.enterURLAndEnterToBrowser(website.url) {}
navigationToolbar {
}.openTabCrashReporter {
clickPageObject(itemWithResId("$packageName:id/restoreTabButton"))
verifyPageContent(website.content)
}
}
// TestRail link: https://testrail.stage.mozaws.net/index.php?/cases/view/1681928
@SmokeTest
@Test
fun useAppWhileTabIsCrashedTest() {
val firstWebPage = TestAssetHelper.getGenericAsset(mockWebServer, 1)
val secondWebPage = TestAssetHelper.getGenericAsset(mockWebServer, 2)
homeScreen {
}.openNavigationToolbar {
}.enterURLAndEnterToBrowser(firstWebPage.url) {
mDevice.waitForIdle()
}.openComposeTabDrawer(activityTestRule) {
}.openNewTab {
}.submitQuery(secondWebPage.url.toString()) {
waitForPageToLoad()
}
navigationToolbar {
}.openTabCrashReporter {
verifyPageContent(tabCrashMessage)
}.openComposeTabDrawer(activityTestRule) {
verifyExistingOpenTabs(firstWebPage.title)
verifyExistingOpenTabs("about:crashcontent")
}.closeTabDrawer {
}.goToHomescreen {
verifyExistingTopSitesList()
}.openThreeDotMenu {
verifySettingsButton()
}
}
}