package Ġcom . gard ener . uit est basics Ċ Ċ import Ġandroidx . test . core . app . Activity Scenario Ċ import Ġandroidx . test . espress o . Esp ress o . on View Ċ import Ġandroidx . test . espress o . Esp ress o . press Back Ċ import Ġandroidx . test . espress o . action . View Actions . click Ċ import Ġandroidx . test . espress o . assertion . View Assertions . matches Ċ import Ġandroidx . test . espress o . matcher . View Matchers .* Ċ import Ġandroidx . test . internal . runner . junit 4 . Android JUnit 4 Class Runner Ċ import Ġcom . gard ener . uit est basics . ui . movie . MainActivity Ċ import Ġorg . junit . Test Ċ import Ġorg . junit . runner . RunWith Ċ Ċ @ RunWith ( Android JUnit 4 Class Runner :: class ) Ċ class ĠMainActivity Test Ġ{ ĊĊĠĠĠ Ġ/*@ Test ĊĠĠĠ Ġfun Ġtest _ is Activity In View () Ġ{ ĊĊĠĠĠĠĠĠĠ Ġval Ġactivity Scenario Ġ= ĠActivity Scenario . launch ( MainActivity :: class . java ) ĊĊĠĠĠĠĠĠĠ Ġon View ( with Id ( R . id . main )). check ( matches ( is Displayed ())) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġtest _ visibility _ title _ next Button () Ġ{ ĊĊĠĠĠĠĠĠĠ Ġval Ġactivity Scenario Ġ= ĠActivity Scenario . launch ( MainActivity :: class . java ) ĊĊĠĠĠĠĠĠĠ Ġon View ( with Id ( R . id . activity _ main _ title )) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. check ( matches ( is Displayed ())) ĊĊĠĠĠĠĠĠĠ Ġon View ( with Id ( R . id . button _ next _ activity )) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. check ( matches ( is Displayed ())) ĊĊĠĠĠĠĠĠĠ Ġ// ĠDifferent Ġway ĊĠĠĠĠĠĠĠ Ġon View ( with Id ( R . id . button _ next _ activity )) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. check ( matches ( with Effective Visibility ( Visibility . VISIBLE ))) ĊĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġtest _ is _ title _ text _ display ed () Ġ{ ĊĊĠĠĠĠĠĠĠ Ġval Ġactivity Scenario Ġ= ĠActivity Scenario . launch ( MainActivity :: class . java ) ĊĊĠĠĠĠĠĠĠ Ġon View ( with Id ( R . id . activity _ main _ title )) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. check ( matches ( with Text ( R . string . text _ main activity ))) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġtest _ nav Secondary Activity () Ġ{ ĊĊĠĠĠĠĠĠĠ Ġval Ġactivity Scenario Ġ= ĠActivity Scenario . launch ( MainActivity :: class . java ) ĊĊĠĠĠĠĠĠĠ Ġon View ( with Id ( R . id . button _ next _ activity )) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. perform ( click ()) ĊĊĠĠĠĠĠĠĠ Ġon View ( with Id ( R . id . secondary )) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. check ( matches ( is Displayed ())) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġtest _ back Pressed _ to MainActivity () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġactivity Scenario Ġ= ĠActivity Scenario . launch ( MainActivity :: class . java ) ĊĠĠĠĠĠĠĠ Ġon View ( with Id ( R . id . button _ next _ activity )) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. perform ( click ()) ĊĊĠĠĠĠĠĠĠ Ġon View ( with Id ( R . id . secondary )) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. check ( matches ( is Displayed ())) ĊĊĠĠĠĠĠĠĠ Ġon View ( with Id ( R . id . button _ back )) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. perform ( click ()) ĊĠĠĠĠĠĠĠ Ġon View ( with Id ( R . id . main )) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. check ( matches ( is Displayed ())) ĊĊĠĠĠĠĠĠĠ Ġ// ĠOR ĊĊĠĠĠĠĠĠĠ Ġval Ġactivity Scenario 2 Ġ= ĠActivity Scenario . launch ( MainActivity :: class . java ) ĊĠĠĠĠĠĠĠ Ġon View ( with Id ( R . id . button _ next _ activity )) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. perform ( click ()) ĊĊĠĠĠĠĠĠĠ Ġon View ( with Id ( R . id . secondary )) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. check ( matches ( is Displayed ())) ĊĊĠĠĠĠĠĠĠ Ġpress Back () ĊĊĠĠĠĠĠĠĠ Ġon View ( with Id ( R . id . main )) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. check ( matches ( is Displayed ())) ĊĊĠĠĠ Ġ}*/ Ċ }