commit eb132871cd06207600d97fc1408f6901259ef858
parent 256e9aa1ec073c8895367fd5023f048e13957038
Author: Roger Yang <royang@mozilla.com>
Date: Tue, 4 Nov 2025 17:42:51 +0000
Bug 1997375 - Add UI automated test for marketing fallback. r=android-reviewers,petru
Differential Revision: https://phabricator.services.mozilla.com/D270703
Diffstat:
2 files changed, 30 insertions(+), 0 deletions(-)
diff --git a/mobile/android/fenix/app/src/androidTest/assets/pages/appLinksLinks.html b/mobile/android/fenix/app/src/androidTest/assets/pages/appLinksLinks.html
@@ -24,6 +24,12 @@
</section>
<section>
+ <a href="intent://com.example.app#Intent;package=com.example.app;end">
+ Example app link
+ </a>
+ </section>
+
+ <section>
<a href="appLinksPostNavigationPhone.html" target="_blank">
Telephone post navigation link
</a>
diff --git a/mobile/android/fenix/app/src/androidTest/java/org/mozilla/fenix/ui/AppLinksTest.kt b/mobile/android/fenix/app/src/androidTest/java/org/mozilla/fenix/ui/AppLinksTest.kt
@@ -4,7 +4,14 @@
package org.mozilla.fenix.ui
+import android.app.Instrumentation
+import android.content.Intent
import androidx.compose.ui.test.junit4.AndroidComposeTestRule
+import androidx.test.espresso.intent.Intents.intended
+import androidx.test.espresso.intent.Intents.intending
+import androidx.test.espresso.intent.matcher.IntentMatchers.hasAction
+import androidx.test.espresso.intent.matcher.IntentMatchers.hasDataString
+import org.hamcrest.Matchers.equalTo
import org.junit.Before
import org.junit.Rule
import org.junit.Test
@@ -28,6 +35,7 @@ class AppLinksTest : TestSetup() {
private val intentSchemaUrlLink = itemContainingText("Intent schema link")
private val phoneUrlLink = itemContainingText("Telephone link")
private val formRedirectLink = itemContainingText("Telephone post navigation link")
+ private val intentSchemeWithExampleAppLink = itemContainingText("Example app link")
private val phoneSchemaLink = "tel://1234567890"
@@ -237,4 +245,20 @@ class AppLinksTest : TestSetup() {
verifyOpenLinkInAnotherAppPrompt(appName = "Phone")
}
}
+
+ @Test
+ fun marketingIntentWhenOpeningLinkWithoutApp() {
+ // Use ACTION_DIAL as a non-ACTION_VIEW intent to verify that the marketing flow always
+ // launches with ACTION_VIEW instead of reusing the original intent action.
+ intending(hasAction(Intent.ACTION_DIAL)).respondWith(Instrumentation.ActivityResult(0, null))
+
+ navigationToolbar {
+ }.enterURLAndEnterToBrowser(externalLinksPage.url) {
+ clickPageObject(intentSchemeWithExampleAppLink)
+ clickPageObject(itemWithResIdAndText("android:id/button1", "Open"))
+ mDevice.waitForIdle()
+ intended(hasAction(Intent.ACTION_VIEW))
+ intended(hasDataString(equalTo("market://details?id=com.example.app")))
+ }
+ }
}