Last active
March 22, 2023 13:23
-
-
Save merttoptas/91b6a8caf880fad03f6845df0cf572d2 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@RunWith(AndroidJUnit4::class) | |
class AppDeepLinkingTest { | |
@get:Rule | |
val activityScenarioRule = ActivityScenarioRule(MainActivity::class.java) | |
@get:Rule | |
val composeTestRule = createAndroidComposeRule<MainActivity>() | |
private lateinit var scenario: ActivityScenario<MainActivity> | |
@Before | |
fun setup() { | |
scenario = activityScenarioRule.scenario | |
} | |
@After | |
fun cleanup() { | |
scenario.close() | |
} | |
@Test | |
fun deepLinkApplicationTextDashboardDeeplinkHasText() { | |
// Launch the activity with the deep link | |
val intent = Intent(Intent.ACTION_VIEW).apply { | |
data = Uri.parse("example://compose/dashboard/johnDoe") | |
} | |
scenario.onActivity { activity -> | |
activity.startActivity(intent) | |
} | |
// Verify that the activity displays the expected text | |
val value = composeTestRule.onNodeWithTag("dashboardDeeplinkArgument") | |
value.assertTextEquals("This is Home Screen johnDoe") | |
for ((key, value) in value.fetchSemanticsNode().config) { | |
if (key.name == "EditableText") { | |
assertEquals("This is Home Screen johnDoe", value.toString()) | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment