Last active
December 29, 2023 16:14
-
-
Save ngallazzi/8fd62c2f043c45782d958f2007178a4d 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
@Test | |
fun testButtonOff_setsOffState() { | |
val context = composeTestRule.activity | |
val onButtonNodeIdentifier = context.getString(R.string.on_button_description) | |
val offButtonNodeIdentifier = context.getString(R.string.off_button_description) | |
val currentStatusNodeIdentifier = context.getString(R.string.current_status_description) | |
// Start the app | |
composeTestRule.setContent { | |
SemanticsTestingPlaygroundTheme { | |
SwitchLayout() | |
} | |
} | |
// Click off button | |
composeTestRule.onNodeWithContentDescription(offButtonNodeIdentifier).performClick() | |
composeTestRule.onNodeWithContentDescription(currentStatusNodeIdentifier) | |
.assertTextEquals("Status is: ${SwitchStatus.OFF.name}") | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment