From fb8d22e37b6e8283070602ba76aec915e7b69c45 Mon Sep 17 00:00:00 2001 From: sv-ohorvath Date: Wed, 17 Aug 2022 14:32:44 +0300 Subject: [PATCH] Issue #26127, #26092: Ads RetryTestRule to TopSitesTest class, other small refactors --- .../java/org/mozilla/fenix/ui/TopSitesTest.kt | 66 +++++++++---------- 1 file changed, 33 insertions(+), 33 deletions(-) diff --git a/app/src/androidTest/java/org/mozilla/fenix/ui/TopSitesTest.kt b/app/src/androidTest/java/org/mozilla/fenix/ui/TopSitesTest.kt index e2db1f63d9..daba0e3f26 100644 --- a/app/src/androidTest/java/org/mozilla/fenix/ui/TopSitesTest.kt +++ b/app/src/androidTest/java/org/mozilla/fenix/ui/TopSitesTest.kt @@ -16,7 +16,9 @@ import org.mozilla.fenix.customannotations.SmokeTest import org.mozilla.fenix.helpers.AndroidAssetDispatcher import org.mozilla.fenix.helpers.FeatureSettingsHelper import org.mozilla.fenix.helpers.HomeActivityIntentTestRule -import org.mozilla.fenix.helpers.TestAssetHelper +import org.mozilla.fenix.helpers.RetryTestRule +import org.mozilla.fenix.helpers.TestAssetHelper.getGenericAsset +import org.mozilla.fenix.helpers.TestHelper.generateRandomString import org.mozilla.fenix.helpers.TestHelper.getStringResource import org.mozilla.fenix.ui.robots.browserScreen import org.mozilla.fenix.ui.robots.homeScreen @@ -39,6 +41,9 @@ class TopSitesTest { @get:Rule val activityIntentTestRule = HomeActivityIntentTestRule(skipOnboarding = true) + @get:Rule + val retryTestRule = RetryTestRule(3) + @Before fun setUp() { mDevice = UiDevice.getInstance(InstrumentationRegistry.getInstrumentation()) @@ -59,8 +64,7 @@ class TopSitesTest { @SmokeTest @Test fun verifyAddToFirefoxHome() { - val defaultWebPage = TestAssetHelper.getGenericAsset(mockWebServer, 1) - val defaultWebPageTitle = "Test_Page_1" + val defaultWebPage = getGenericAsset(mockWebServer, 1) navigationToolbar { }.enterURLAndEnterToBrowser(defaultWebPage.url) { @@ -71,14 +75,13 @@ class TopSitesTest { verifySnackBarText(getStringResource(R.string.snackbar_added_to_shortcuts)) }.goToHomescreen { verifyExistingTopSitesList() - verifyExistingTopSitesTabs(defaultWebPageTitle) + verifyExistingTopSitesTabs(defaultWebPage.title) } } @Test fun verifyOpenTopSiteNormalTab() { - val defaultWebPage = TestAssetHelper.getGenericAsset(mockWebServer, 1) - val defaultWebPageTitle = "Test_Page_1" + val defaultWebPage = getGenericAsset(mockWebServer, 1) navigationToolbar { }.enterURLAndEnterToBrowser(defaultWebPage.url) { @@ -89,13 +92,13 @@ class TopSitesTest { verifySnackBarText(getStringResource(R.string.snackbar_added_to_shortcuts)) }.goToHomescreen { verifyExistingTopSitesList() - verifyExistingTopSitesTabs(defaultWebPageTitle) - }.openTopSiteTabWithTitle(title = defaultWebPageTitle) { + verifyExistingTopSitesTabs(defaultWebPage.title) + }.openTopSiteTabWithTitle(title = defaultWebPage.title) { verifyUrl(defaultWebPage.url.toString().replace("http://", "")) }.goToHomescreen { verifyExistingTopSitesList() - verifyExistingTopSitesTabs(defaultWebPageTitle) - }.openContextMenuOnTopSitesWithTitle(defaultWebPageTitle) { + verifyExistingTopSitesTabs(defaultWebPage.title) + }.openContextMenuOnTopSitesWithTitle(defaultWebPage.title) { verifyTopSiteContextMenuItems() } @@ -105,8 +108,7 @@ class TopSitesTest { @Test fun verifyOpenTopSitePrivateTab() { - val defaultWebPage = TestAssetHelper.getGenericAsset(mockWebServer, 1) - val defaultWebPageTitle = "Test_Page_1" + val defaultWebPage = getGenericAsset(mockWebServer, 1) navigationToolbar { }.enterURLAndEnterToBrowser(defaultWebPage.url) { @@ -117,8 +119,8 @@ class TopSitesTest { verifySnackBarText(getStringResource(R.string.snackbar_added_to_shortcuts)) }.goToHomescreen { verifyExistingTopSitesList() - verifyExistingTopSitesTabs(defaultWebPageTitle) - }.openContextMenuOnTopSitesWithTitle(defaultWebPageTitle) { + verifyExistingTopSitesTabs(defaultWebPage.title) + }.openContextMenuOnTopSitesWithTitle(defaultWebPage.title) { verifyTopSiteContextMenuItems() }.openTopSiteInPrivateTab { verifyCurrentPrivateSession(activityIntentTestRule.activity.applicationContext) @@ -127,12 +129,12 @@ class TopSitesTest { @Test fun verifyRenameTopSite() { - val defaultWebPage = TestAssetHelper.getGenericAsset(mockWebServer, 1) - val defaultWebPageTitle = "Test_Page_1" - val defaultWebPageTitleNew = "Test_Page_2" + val defaultWebPage = getGenericAsset(mockWebServer, 1) + val newPageTitle = generateRandomString(5) navigationToolbar { }.enterURLAndEnterToBrowser(defaultWebPage.url) { + waitForPageToLoad() }.openThreeDotMenu { expandMenu() verifyAddToTopSitesButton() @@ -140,19 +142,18 @@ class TopSitesTest { verifySnackBarText(getStringResource(R.string.snackbar_added_to_shortcuts)) }.goToHomescreen { verifyExistingTopSitesList() - verifyExistingTopSitesTabs(defaultWebPageTitle) - }.openContextMenuOnTopSitesWithTitle(defaultWebPageTitle) { + verifyExistingTopSitesTabs(defaultWebPage.title) + }.openContextMenuOnTopSitesWithTitle(defaultWebPage.title) { verifyTopSiteContextMenuItems() - }.renameTopSite(defaultWebPageTitleNew) { + }.renameTopSite(newPageTitle) { verifyExistingTopSitesList() - verifyExistingTopSitesTabs(defaultWebPageTitleNew) + verifyExistingTopSitesTabs(newPageTitle) } } @Test fun verifyRemoveTopSite() { - val defaultWebPage = TestAssetHelper.getGenericAsset(mockWebServer, 1) - val defaultWebPageTitle = "Test_Page_1" + val defaultWebPage = getGenericAsset(mockWebServer, 1) navigationToolbar { }.enterURLAndEnterToBrowser(defaultWebPage.url) { @@ -163,18 +164,17 @@ class TopSitesTest { verifySnackBarText(getStringResource(R.string.snackbar_added_to_shortcuts)) }.goToHomescreen { verifyExistingTopSitesList() - verifyExistingTopSitesTabs(defaultWebPageTitle) - }.openContextMenuOnTopSitesWithTitle(defaultWebPageTitle) { + verifyExistingTopSitesTabs(defaultWebPage.title) + }.openContextMenuOnTopSitesWithTitle(defaultWebPage.title) { verifyTopSiteContextMenuItems() }.removeTopSite { - verifyNotExistingTopSitesList(defaultWebPageTitle) + verifyNotExistingTopSitesList(defaultWebPage.title) } } @Test fun verifyRemoveTopSiteFromMainMenu() { - val defaultWebPage = TestAssetHelper.getGenericAsset(mockWebServer, 1) - val defaultWebPageTitle = "Test_Page_1" + val defaultWebPage = getGenericAsset(mockWebServer, 1) navigationToolbar { }.enterURLAndEnterToBrowser(defaultWebPage.url) { @@ -185,13 +185,13 @@ class TopSitesTest { verifySnackBarText(getStringResource(R.string.snackbar_added_to_shortcuts)) }.goToHomescreen { verifyExistingTopSitesList() - verifyExistingTopSitesTabs(defaultWebPageTitle) - }.openTopSiteTabWithTitle(defaultWebPageTitle) { + verifyExistingTopSitesTabs(defaultWebPage.title) + }.openTopSiteTabWithTitle(defaultWebPage.title) { }.openThreeDotMenu { verifyRemoveFromShortcutsButton() }.clickRemoveFromShortcuts { }.goToHomescreen { - verifyNotExistingTopSitesList(defaultWebPageTitle) + verifyNotExistingTopSitesList(defaultWebPage.title) } } @@ -217,13 +217,13 @@ class TopSitesTest { @SmokeTest @Test fun addAndRemoveMostViewedTopSiteTest() { - val defaultWebPage = TestAssetHelper.getGenericAsset(mockWebServer, 1) + val defaultWebPage = getGenericAsset(mockWebServer, 1) for (i in 0..1) { navigationToolbar { }.enterURLAndEnterToBrowser(defaultWebPage.url) { - mDevice.waitForIdle() waitForPageToLoad() + verifyPageContent(defaultWebPage.content) } }