File tree Expand file tree Collapse file tree 2 files changed +30
-0
lines changed
androidTest/java/org/mozilla/tryfox
main/java/org/mozilla/tryfox Expand file tree Collapse file tree 2 files changed +30
-0
lines changed Original file line number Diff line number Diff line change @@ -50,4 +50,25 @@ class MainActivityDeeplinkTest {
5050 composeTestRule.onNodeWithText(revision).assertExists()
5151 }
5252 }
53+
54+ @Test
55+ fun testDeeplink_whenAppIsAlreadyOpen_populatesRevision () {
56+ // Launch the app first
57+ ActivityScenario .launch(MainActivity ::class .java)
58+
59+ val project = " autoland"
60+ val revision = " abcdef123456"
61+ val deeplinkUri = Uri .parse(" https://treeherder.mozilla.org/#/jobs?repo=$project &revision=$revision " )
62+ val intent = Intent (ApplicationProvider .getApplicationContext(), MainActivity ::class .java).apply {
63+ action = Intent .ACTION_VIEW
64+ data = deeplinkUri
65+ addFlags(Intent .FLAG_ACTIVITY_NEW_TASK )
66+ }
67+
68+ // Now send the deeplink intent
69+ ApplicationProvider .getApplicationContext< android.content.Context > ().startActivity(intent)
70+
71+ composeTestRule.waitForIdle()
72+ composeTestRule.onNodeWithText(revision).assertExists()
73+ }
5374}
Original file line number Diff line number Diff line change @@ -56,6 +56,15 @@ class MainActivity : ComponentActivity() {
5656 }
5757 }
5858
59+ override fun onNewIntent (intent : Intent ) {
60+ super .onNewIntent(intent)
61+ Log .d(" MainActivity" , " onNewIntent called. Intent: $intent , Data: ${intent.data} " )
62+ setIntent(intent)
63+ if (::navController.isInitialized) {
64+ navController.handleDeepLink(intent)
65+ }
66+ }
67+
5968 private fun installApk (file : File ) {
6069 val fileUri: Uri = FileProvider .getUriForFile(
6170 this ,
You can’t perform that action at this time.
0 commit comments