package Ġcom . example . ti ptime Ċ Ċ import Ġandroidx . test . espress o . Esp ress o . on View Ċ import Ġandroidx . test . espress o . action . View Actions . click Ċ import Ġandroidx . test . espress o . action . View Actions . type Text Ċ import Ġandroidx . test . espress o . assertion . View Assertions . matches Ċ import Ġandroidx . test . espress o . matcher . View Matchers . with Id Ċ import Ġandroidx . test . espress o . matcher . View Matchers . with Text Ċ import Ġandroidx . test . ext . junit . rules . Activity Scenario Rule Ċ import Ġandroidx . test . ext . junit . runners . Android JUnit 4 Ċ import Ġorg . hamcrest . Matchers . contains String Ċ Ċ import Ġorg . junit . Rule Ċ import Ġorg . junit . Test Ċ import Ġorg . junit . runner . RunWith Ċ Ċ @ RunWith ( Android JUnit 4 :: class ) Ċ class ĠCalculator Tests Ġ{ ĊĠĠĠ Ġ@ get : Rule () ĊĠĠĠ Ġval Ġactivity Ġ= ĠActivity Scenario Rule ( MainActivity :: class . java ) ĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġcalculate _ 2 0 _ percent _ tip () Ġ{ ĊĠĠĠĠĠĠĠ Ġon View ( with Id ( R . id . cost _ of _ service _ edit _ text )). perform ( type Text (" 5 0 . 0 0 ")) ĊĠĠĠĠĠĠĠ Ġon View ( with Id ( R . id . calculate _ button )). perform ( click ()) ĊĠĠĠĠĠĠĠ Ġon View ( with Id ( R . id . tip _ result )). check ( matches ( with Text ( contains String (" 1 0 . 0 0 ")) )) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġcalculate _ 1 8 _ percent _ tip () Ġ{ ĊĠĠĠĠĠĠĠ Ġon View ( with Id ( R . id . cost _ of _ service _ edit _ text )). perform ( type Text (" 6 0 . 0 0 ")) ĊĠĠĠĠĠĠĠ Ġon View ( with Id ( R . id . option _ eight een _ percent )). perform ( click ()) ĊĠĠĠĠĠĠĠ Ġon View ( with Id ( R . id . round _ up _ switch )). perform ( click ()) ĊĠĠĠĠĠĠĠ Ġon View ( with Id ( R . id . calculate _ button )). perform ( click ()) ĊĠĠĠĠĠĠĠ Ġon View ( with Id ( R . id . tip _ result )). check ( matches ( with Text ( contains String (" 1 0 . 8 0 ")) )) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġcalculate _ 1 5 _ percent _ tip (){ ĊĠĠĠĠĠĠĠ Ġon View ( with Id ( R . id . option _ fif teen _ percent )). perform ( click ()) ĊĠĠĠĠĠĠĠ Ġon View ( with Id ( R . id . cost _ of _ service _ edit _ text )). perform ( type Text (" 1 5 0 ")) ĊĠĠĠĠĠĠĠ Ġon View ( with Id ( R . id . round _ up _ switch )). perform ( click ()) ĊĠĠĠĠĠĠĠ Ġon View ( with Id ( R . id . calculate _ button )). perform ( click ()) ĊĠĠĠĠĠĠĠ Ġon View ( with Id ( R . id . tip _ result )). check ( matches ( with Text ( contains String (" 2 2 . 5 0 ")) )) ĊĠĠĠ Ġ} Ċ }