Last active
July 7, 2024 14:03
-
-
Save birojow/facbe1cab4f990f73ddcda38cf885fd4 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
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