package Ġorg . n aho ft . n aho ft Ċ Ċ import Ġandroidx . test . espress o . Esp ress o . on View Ċ 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 .* Ċ import Ġandroidx . test . ext . junit . rules . Activity Scenario Rule Ċ import Ġandroidx . test . internal . runner . junit 4 . Android JUnit 4 Class Runner Ċ import Ġorg . junit . Before Ċ import Ġorg . junit . Rule Ċ import Ġorg . junit . Test Ċ import Ġorg . junit . runner . RunWith Ċ import Ġorg . n aho ft . n aho ft . activities . Log In Activity Ċ Ċ // Ensure Ġemulator Ġis Ġopen Ġto Ġthe ĠEnter ĠPass code ĠActivity ĠScreen Ġbefore Ġpressing Ġplay Ġfor ĠEnter Pass code Activity Test ( s ) Ċ @ RunWith ( Android JUnit 4 Class Runner :: class ) Ċ class ĠLog In Activity Test { ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġtest _ is Activity In View () Ġ{ ĊĊĠĠĠĠĠĠĠ Ġon View ( with Id ( R . id . pass code _ digit _ 1 )). check ( matches ( is Displayed ())) ĊĠĠĠĠĠĠĠ Ġon View ( with Id ( R . id . pass code _ digit _ 2 )). check ( matches ( is Displayed ())) ĊĠĠĠĠĠĠĠ Ġon View ( with Id ( R . id . pass code _ digit _ 3 )). check ( matches ( is Displayed ())) ĊĠĠĠĠĠĠĠ Ġon View ( with Id ( R . id . pass code _ digit _ 4 )). check ( matches ( is Displayed ())) ĊĠĠĠĠĠĠĠ Ġon View ( with Id ( R . id . pass code _ digit _ 5 )). check ( matches ( is Displayed ())) ĊĠĠĠĠĠĠĠ Ġon View ( with Id ( R . id . pass code _ digit _ 6 )). check ( matches ( is Displayed ())) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġtest _ Enter Pass code Button Is Visible () Ġ{ ĊĊĠĠĠĠĠĠĠ Ġon View ( with Id ( R . id . login _ button )). check ( matches ( is Displayed ())) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġtest Is Title Text Of Login Button Displayed () Ġ{ ĊĊĠĠĠĠĠĠĠ Ġon View ( with Id ( R . id . login _ button )) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. check ( matches ( with Text ( R . string . Login ))) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġprivate Ġlateinit Ġvar Ġstring ToBe Typed : ĠString ĊĠĠĠ Ġprivate Ġlateinit Ġvar Ġfirst String ToBe Typed : ĠString ĊĠĠĠ Ġprivate Ġlateinit Ġvar Ġsecond String ToBe Typed : ĠString ĊĊĠĠĠ Ġ@ get : Rule ĊĠĠĠ Ġvar Ġactivity Rule : ĠActivity Scenario Rule < Log In Activity > ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ= ĠActivity Scenario Rule ( Log In Activity :: class . java ) ĊĊĠĠĠ Ġ@ Before ĊĠĠĠ Ġfun Ġinit Valid String () Ġ{ ĊĠĠĠĠĠĠĠ Ġ// ĠSpecify Ġa Ġvalid Ġstring . ĊĠĠĠĠĠĠĠ Ġfirst String ToBe Typed Ġ= Ġ" 2 " ĊĠĠĠĠĠĠĠ Ġsecond String ToBe Typed Ġ= Ġ" 1 " ĊĠĠĠĠĠĠĠ Ġstring ToBe Typed Ġ= Ġ" 2 1 2 1 2 1 " ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġperform Login () Ġ{ ĊĠĠĠĠĠĠĠ Ġ// Tests Ġif ĠLogin ĠWorks ĊĠĠĠĠĠĠĠ Ġon View ( with Id ( R . id . pass code _ digit _ 1 )). perform ( type Text ( first String ToBe Typed )) ĊĊĠĠĠĠĠĠĠ Ġ// ĠCheck Ġthat Ġthe Ġtext Ġwas Ġchanged . ĊĠĠĠĠĠĠĠ Ġon View ( with Id ( R . id . pass code _ digit _ 1 )). check ( matches ( with Text ( first String ToBe Typed ))) ĊĊĠĠĠĠĠĠĠ Ġon View ( with Id ( R . id . pass code _ digit _ 2 )). perform ( type Text ( second String ToBe Typed )) ĊĊĠĠĠĠĠĠĠ Ġon View ( with Id ( R . id . pass code _ digit _ 2 )). check ( matches ( with Text ( second String ToBe Typed ))) ĊĊĠĠĠĠĠĠĠ Ġon View ( with Id ( R . id . pass code _ digit _ 3 )). perform ( type Text ( first String ToBe Typed )) ĊĊĠĠĠĠĠĠĠ Ġon View ( with Id ( R . id . pass code _ digit _ 3 )). check ( matches ( with Text ( first String ToBe Typed ))) ĊĊĠĠĠĠĠĠĠ Ġon View ( with Id ( R . id . pass code _ digit _ 4 )). perform ( type Text ( second String ToBe Typed )) ĊĊĠĠĠĠĠĠĠ Ġon View ( with Id ( R . id . pass code _ digit _ 4 )). check ( matches ( with Text ( second String ToBe Typed ))) ĊĊĠĠĠĠĠĠĠ Ġon View ( with Id ( R . id . pass code _ digit _ 5 )). perform ( type Text ( first String ToBe Typed )) ĊĊĠĠĠĠĠĠĠ Ġon View ( with Id ( R . id . pass code _ digit _ 5 )). check ( matches ( with Text ( first String ToBe Typed ))) ĊĊĠĠĠĠĠĠĠ Ġon View ( with Id ( R . id . pass code _ digit _ 6 )). perform ( type Text ( second String ToBe Typed )) ĊĊĠĠĠĠĠĠĠ Ġon View ( with Id ( R . id . pass code _ digit _ 6 )). check ( matches ( with Text ( second String ToBe Typed ))) ĊĠĠĠ Ġ} Ċ Ġ} ĊĊ