Skip to content

Instantly share code, notes, and snippets.

@birojow
Last active July 7, 2024 14:03
Show Gist options
  • Save birojow/facbe1cab4f990f73ddcda38cf885fd4 to your computer and use it in GitHub Desktop.
Save birojow/facbe1cab4f990f73ddcda38cf885fd4 to your computer and use it in GitHub Desktop.
class CalculatorScreenRobot(
private val composeRule: AndroidComposeTestRule<ActivityScenarioRule<MainActivity>, MainActivity>
) {
inner class Arrange {
fun enterFormula(formula: String) {
formula.forEach { character ->
if (!character.isWhitespace()) {
val buttonLabel = when (character) {
'(', ')' -> "()"
else -> character.toString()
}
composeRule
.onNodeWithText(buttonLabel)
.performClick()
}
}
}
}
inner class Act {
fun performCalculation() {
composeRule
.onNodeWithText("=")
.performClick()
}
}
inner class Assert {
fun assertResultIs(result: String) {
composeRule
.onNodeWithText(result)
.assertIsDisplayed()
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment