package Ġcom . example . android . architecture . blueprint s . todo app . test . chapter 1 2 . robots Ċ Ċ import Ġandroidx . test . espress o . Esp ress o . on View Ċ import Ġandroidx . test . espress o . Esp ress o . open Context ual Action Mode Overflow Menu Ċ 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 Ġcom . example . android . architecture . blueprint s . todo app . R Ċ import Ġorg . hamcrest . Core Matchers . all Of Ċ import Ġorg . hamcrest . Core Matchers . not Ċ Ċ /** Ċ Ġ* ĠRobot Ġclass Ġsample Ġwith Ġinner Ġclasses Ġthat Ġrepresent Ġfunctional Ġview Ġgroups . Ċ Ġ*/ Ċ fun Ġtasks List Inner Classes ( func : ĠTasks List Robot With Inner Classes . () Ġ-> ĠUnit ) Ġ= ĠTasks List Robot With Inner Classes (). apply Ġ{ Ġfunc () Ġ} Ċ class ĠTasks List Robot With Inner Classes Ġ{ ĊĊĠĠĠ Ġin fix Ġfun Ġadd Task ( func : ĠAdd Edit ToDo Robot . () Ġ-> ĠUnit ): ĠAdd Edit ToDo Robot Ġ{ ĊĠĠĠĠĠĠĠ Ġon View ( with Id ( R . id . fab _ add _ task )). perform ( click ()) ĊĠĠĠĠĠĠĠ Ġreturn ĠAdd Edit ToDo Robot (). apply ( func ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġfun Ġadd Task () Ġ{ ĊĠĠĠĠĠĠĠ Ġon View ( with Id ( R . id . fab _ add _ task )). perform ( click ()) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġfun Ġverify Task Shown ( with Title : ĠString ) Ġ{ ĊĠĠĠĠĠĠĠ Ġon View ( with Text ( with Title )). check ( matches ( is Displayed ())) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġfun Ġverify Task Not Shown ( with Title : ĠString ) Ġ{ ĊĠĠĠĠĠĠĠ Ġon View ( with Text ( with Title )). check ( matches ( not ( is Displayed ()))) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġfun Ġmark Completed ( to Do Title : ĠString ) Ġ{ ĊĠĠĠĠĠĠĠ Ġon View ( all Of ( with Id ( R . id . todo _ complete ), Ġhas Sibling ( with Text ( to Do Title )) )). perform ( click ()) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġfun Ġcheck Empty State () Ġ{ ĊĠĠĠĠĠĠĠ Ġon View ( with Id ( R . id . no Tasks Main )). check ( matches ( is Displayed ())) ĊĠĠĠĠĠĠĠ Ġon View ( with Id ( R . id . no Tasks Icon )). check ( matches ( is Displayed ())) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ/** ĊĠĠĠĠ Ġ* ĠFilter Ġview Ġgroup Ġthat Ġrepresents ĠFilter Ġfunctionality . ĊĠĠĠĠ Ġ*/ ĊĠĠĠ Ġfun Ġto Do List Filter ( func : ĠTo Do List Filter . () Ġ-> ĠUnit ) Ġ= ĠTo Do List Filter (). apply Ġ{ Ġfunc () Ġ} ĊĠĠĠ Ġinner Ġclass ĠTo Do List Filter Ġ{ ĊĠĠĠĠĠĠĠ Ġinit Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġon View ( with Id ( R . id . menu _ filter )). perform ( click ()) ĊĠĠĠĠĠĠĠ Ġ} ĊĊĠĠĠĠĠĠĠ Ġfun Ġshow All () Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġon View ( all Of ( with Id ( R . id . title ), Ġwith Text (" All ")) ). perform ( click ()) ĊĠĠĠĠĠĠĠ Ġ} ĊĊĠĠĠĠĠĠĠ Ġfun Ġshow Completed () Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġon View ( all Of ( with Id ( R . id . title ), Ġwith Text (" Completed ")) ). perform ( click ()) ĊĠĠĠĠĠĠĠ Ġ} ĊĊĠĠĠĠĠĠĠ Ġfun Ġshow Active () Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġon View ( all Of ( with Id ( R . id . title ), Ġwith Text (" Active ")) ). perform ( click ()) ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ/** ĊĠĠĠĠ Ġ* ĠMenu Ġview Ġgroup Ġthat Ġrepresents ĠMenu Ġfunctionality . ĊĠĠĠĠ Ġ*/ ĊĠĠĠ Ġfun Ġto Do List Menu ( func : ĠTo Do List Menu . () Ġ-> ĠUnit ) Ġ= ĠTo Do List Menu (). apply Ġ{ Ġfunc () Ġ} ĊĠĠĠ Ġinner Ġclass ĠTo Do List Menu Ġ{ ĊĠĠĠĠĠĠĠ Ġinit Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġopen Context ual Action Mode Overflow Menu () ĊĠĠĠĠĠĠĠ Ġ} ĊĊĠĠĠĠĠĠĠ Ġfun Ġclear Completed () Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġon View ( all Of ( with Id ( R . id . title ), Ġwith Text (" Clear Ġcompleted ")) ). perform ( click ()) ĊĠĠĠĠĠĠĠ Ġ} ĊĊĠĠĠĠĠĠĠ Ġfun Ġrefresh () Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġon View ( all Of ( with Id ( R . id . title ), Ġwith Text (" Refresh ")) ). perform ( click ()) ĊĠĠĠĠĠĠĠ Ġ} ĊĊĠĠĠĠĠĠĠ Ġfun Ġshare () Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġon View ( all Of ( with Id ( R . id . title ), Ġwith Text (" Share ")) ). perform ( click ()) ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} Ċ } Ċ