From 1c07fa2ccf0c42172ed80ec28a5904a7ce5e0562 Mon Sep 17 00:00:00 2001 From: AndiAJ Date: Mon, 9 May 2022 16:12:57 +0300 Subject: [PATCH] [fenix] Fix externalLinkPWATest UI test --- .../org/mozilla/fenix/ui/CustomTabsTest.kt | 8 ++++++-- .../java/org/mozilla/fenix/ui/PwaTest.kt | 10 ++++++---- .../mozilla/fenix/ui/robots/BrowserRobot.kt | 18 ------------------ .../mozilla/fenix/ui/robots/CustomTabRobot.kt | 5 +++++ 4 files changed, 17 insertions(+), 24 deletions(-) diff --git a/app/src/androidTest/java/org/mozilla/fenix/ui/CustomTabsTest.kt b/app/src/androidTest/java/org/mozilla/fenix/ui/CustomTabsTest.kt index 3eb2922394..d9214ba498 100644 --- a/app/src/androidTest/java/org/mozilla/fenix/ui/CustomTabsTest.kt +++ b/app/src/androidTest/java/org/mozilla/fenix/ui/CustomTabsTest.kt @@ -27,7 +27,10 @@ import org.mozilla.fenix.ui.robots.searchScreen class CustomTabsTest { private lateinit var mockWebServer: MockWebServer private val customMenuItem = "TestMenuItem" - private val externalLinksPWAPage = "https://mozilla-mobile.github.io/testapp/externalLinks.html" + /* Updated externalLinks.html to v2.0, + changed the hypertext reference to mozilla-mobile.github.io/testapp/downloads for "External link" + */ + private val externalLinksPWAPage = "https://mozilla-mobile.github.io/testapp/v2.0/externalLinks.html" private val loginPage = "https://mozilla-mobile.github.io/testapp/loginForm" @get:Rule @@ -54,6 +57,7 @@ class CustomTabsTest { @SmokeTest @Test fun customTabsOpenExternalLinkTest() { + val externalLinkURL = "https://mozilla-mobile.github.io/testapp/downloads" intentReceiverActivityTestRule.launchActivity( createCustomTabIntent( @@ -66,7 +70,7 @@ class CustomTabsTest { waitForPageToLoad() clickLinkMatchingText("External link") waitForPageToLoad() - verifyCustomTabToolbarTitle("Google") + verifyCustomTabToolbarTitle(externalLinkURL) } } diff --git a/app/src/androidTest/java/org/mozilla/fenix/ui/PwaTest.kt b/app/src/androidTest/java/org/mozilla/fenix/ui/PwaTest.kt index 5ef434f3a9..9d28f62144 100644 --- a/app/src/androidTest/java/org/mozilla/fenix/ui/PwaTest.kt +++ b/app/src/androidTest/java/org/mozilla/fenix/ui/PwaTest.kt @@ -16,7 +16,10 @@ import org.mozilla.fenix.ui.robots.navigationToolbar class PwaTest { private val featureSettingsHelper = FeatureSettingsHelper() - private val externalLinksPWAPage = "https://mozilla-mobile.github.io/testapp/externalLinks.html" + /* Updated externalLinks.html to v2.0, + changed the hypertext reference to mozilla-mobile.github.io/testapp/downloads for "External link" + */ + private val externalLinksPWAPage = "https://mozilla-mobile.github.io/testapp/v2.0/externalLinks.html" private val emailLink = "mailto://example@example.com" private val phoneLink = "tel://1234567890" private val shortcutTitle = "TEST_APP" @@ -37,7 +40,7 @@ class PwaTest { @SmokeTest @Test fun externalLinkPWATest() { - val customTabTitle = "Google" + val externalLinkURL = "https://mozilla-mobile.github.io/testapp/downloads" navigationToolbar { }.enterURLAndEnterToBrowser(externalLinksPWAPage.toUri()) { @@ -46,11 +49,10 @@ class PwaTest { clickAddAutomaticallyButton() }.openHomeScreenShortcut(shortcutTitle) { clickLinkMatchingText("External link") - fillAndSubmitGoogleSearchQuery("Mozilla") } customTabScreen { - verifyCustomTabToolbarTitle(customTabTitle) + verifyCustomTabToolbarTitle(externalLinkURL) } } diff --git a/app/src/androidTest/java/org/mozilla/fenix/ui/robots/BrowserRobot.kt b/app/src/androidTest/java/org/mozilla/fenix/ui/robots/BrowserRobot.kt index 719960806a..7b26e4031a 100644 --- a/app/src/androidTest/java/org/mozilla/fenix/ui/robots/BrowserRobot.kt +++ b/app/src/androidTest/java/org/mozilla/fenix/ui/robots/BrowserRobot.kt @@ -570,15 +570,6 @@ class BrowserRobot { tabCrashRestoreButton.click() } - fun fillAndSubmitGoogleSearchQuery(searchString: String) { - mDevice.findObject( - UiSelector().resourceId("$packageName:id/engineView") - ).waitForExists(waitingTime) - googleSearchBox.setText(searchString) - mDevice.pressEnter() - mDevice.waitForIdle(waitingTime) - } - fun fillAndSubmitLoginCredentials(userName: String, password: String) { userNameTextBox.setText(userName) passwordTextBox.setText(password) @@ -929,12 +920,3 @@ val passwordTextBox = .className("android.widget.EditText") .packageName("$packageName") ) - -val googleSearchBox = - mDevice.findObject( - UiSelector() - .index(0) - .resourceId("mib") - .className("android.widget.EditText") - .packageName("$packageName") - ) diff --git a/app/src/androidTest/java/org/mozilla/fenix/ui/robots/CustomTabRobot.kt b/app/src/androidTest/java/org/mozilla/fenix/ui/robots/CustomTabRobot.kt index ca4eb82826..7f1a4c086a 100644 --- a/app/src/androidTest/java/org/mozilla/fenix/ui/robots/CustomTabRobot.kt +++ b/app/src/androidTest/java/org/mozilla/fenix/ui/robots/CustomTabRobot.kt @@ -60,12 +60,17 @@ class CustomTabRobot { } fun verifyCustomTabToolbarTitle(title: String) { + waitForPageToLoad() + mDevice.waitForObjects( mDevice.findObject( UiSelector() .resourceId("$packageName:id/mozac_browser_toolbar_title_view") .textContains(title) ) + .getFromParent( + UiSelector().resourceId("$packageName:id/mozac_browser_toolbar_origin_view") + ) ) assertTrue(