[fenix] Fix externalLinkPWATest UI test

pull/600/head
AndiAJ 2 years ago committed by mergify[bot]
parent df143ec5b5
commit 1c07fa2ccf

@ -27,7 +27,10 @@ import org.mozilla.fenix.ui.robots.searchScreen
class CustomTabsTest { class CustomTabsTest {
private lateinit var mockWebServer: MockWebServer private lateinit var mockWebServer: MockWebServer
private val customMenuItem = "TestMenuItem" 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" private val loginPage = "https://mozilla-mobile.github.io/testapp/loginForm"
@get:Rule @get:Rule
@ -54,6 +57,7 @@ class CustomTabsTest {
@SmokeTest @SmokeTest
@Test @Test
fun customTabsOpenExternalLinkTest() { fun customTabsOpenExternalLinkTest() {
val externalLinkURL = "https://mozilla-mobile.github.io/testapp/downloads"
intentReceiverActivityTestRule.launchActivity( intentReceiverActivityTestRule.launchActivity(
createCustomTabIntent( createCustomTabIntent(
@ -66,7 +70,7 @@ class CustomTabsTest {
waitForPageToLoad() waitForPageToLoad()
clickLinkMatchingText("External link") clickLinkMatchingText("External link")
waitForPageToLoad() waitForPageToLoad()
verifyCustomTabToolbarTitle("Google") verifyCustomTabToolbarTitle(externalLinkURL)
} }
} }

@ -16,7 +16,10 @@ import org.mozilla.fenix.ui.robots.navigationToolbar
class PwaTest { class PwaTest {
private val featureSettingsHelper = FeatureSettingsHelper() 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 emailLink = "mailto://example@example.com"
private val phoneLink = "tel://1234567890" private val phoneLink = "tel://1234567890"
private val shortcutTitle = "TEST_APP" private val shortcutTitle = "TEST_APP"
@ -37,7 +40,7 @@ class PwaTest {
@SmokeTest @SmokeTest
@Test @Test
fun externalLinkPWATest() { fun externalLinkPWATest() {
val customTabTitle = "Google" val externalLinkURL = "https://mozilla-mobile.github.io/testapp/downloads"
navigationToolbar { navigationToolbar {
}.enterURLAndEnterToBrowser(externalLinksPWAPage.toUri()) { }.enterURLAndEnterToBrowser(externalLinksPWAPage.toUri()) {
@ -46,11 +49,10 @@ class PwaTest {
clickAddAutomaticallyButton() clickAddAutomaticallyButton()
}.openHomeScreenShortcut(shortcutTitle) { }.openHomeScreenShortcut(shortcutTitle) {
clickLinkMatchingText("External link") clickLinkMatchingText("External link")
fillAndSubmitGoogleSearchQuery("Mozilla")
} }
customTabScreen { customTabScreen {
verifyCustomTabToolbarTitle(customTabTitle) verifyCustomTabToolbarTitle(externalLinkURL)
} }
} }

@ -570,15 +570,6 @@ class BrowserRobot {
tabCrashRestoreButton.click() 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) { fun fillAndSubmitLoginCredentials(userName: String, password: String) {
userNameTextBox.setText(userName) userNameTextBox.setText(userName)
passwordTextBox.setText(password) passwordTextBox.setText(password)
@ -929,12 +920,3 @@ val passwordTextBox =
.className("android.widget.EditText") .className("android.widget.EditText")
.packageName("$packageName") .packageName("$packageName")
) )
val googleSearchBox =
mDevice.findObject(
UiSelector()
.index(0)
.resourceId("mib")
.className("android.widget.EditText")
.packageName("$packageName")
)

@ -60,12 +60,17 @@ class CustomTabRobot {
} }
fun verifyCustomTabToolbarTitle(title: String) { fun verifyCustomTabToolbarTitle(title: String) {
waitForPageToLoad()
mDevice.waitForObjects( mDevice.waitForObjects(
mDevice.findObject( mDevice.findObject(
UiSelector() UiSelector()
.resourceId("$packageName:id/mozac_browser_toolbar_title_view") .resourceId("$packageName:id/mozac_browser_toolbar_title_view")
.textContains(title) .textContains(title)
) )
.getFromParent(
UiSelector().resourceId("$packageName:id/mozac_browser_toolbar_origin_view")
)
) )
assertTrue( assertTrue(

Loading…
Cancel
Save