package Ġcom . github . j nu ut inen . functional . ui Ċ Ċ 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 . has Desc endant Ċ 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 . runners . Android JUnit 4 Ċ import Ġandroidx . test . filters . Large Test Ċ import Ġandroidx . test . platform . app . Instrumentation Registry Ċ import Ġandroidx . test . rule . Activity Test Rule Ċ import Ġcom . github . j nu ut inen . functional . R Ċ import Ġcom . github . j nu ut inen . functional . helper . Recycler ItemCount Assert . Companion . has Size Ċ import Ġcom . github . j nu ut inen . functional . helper . RecyclerView Matcher . Companion . with RecyclerView Ċ import Ġcom . github . j nu ut inen . functional . helper . Test Database Helper . Companion . re populate Db Ċ import Ġcom . github . j nu ut inen . functional . helper . Test Database Helper . Companion . setActive List Shared Pref Ċ import Ġcom . github . j nu ut inen . functional . helper . Ui TestHelper . Companion . open Navigation Drawer Ċ import Ġcom . github . j nu ut inen . functional . presentation . activity . Tasks Activity Ċ import Ġorg . hamcrest . Core Matchers . not Ċ import Ġorg . junit . Before Ċ import Ġorg . junit . Rule Ċ import Ġorg . junit . Test Ċ import Ġorg . junit . runner . RunWith Ċ Ċ @ Large Test Ċ @ RunWith ( Android JUnit 4 :: class ) Ċ class ĠDelete TaskList Test Ġ{ ĊĊĠĠĠ Ġ@ Rule ĊĠĠĠ Ġ@ Jvm Field ĊĠĠĠ Ġval Ġm Activity Test Rule Ġ= Ġobject Ġ: ĠActivity Test Rule < Tasks Activity >( ĊĠĠĠĠĠĠĠ ĠTasks Activity :: class . java , Ġfalse , Ġfalse ĊĠĠĠ Ġ) Ġ{ ĊĠĠĠĠĠĠĠ Ġoverride Ġfun Ġbefore Activity La unched () Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġset Active List Shared Pref ( Instrumentation Registry . get Instrumentation (). target Context , Ġ 2 ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġsuper . before Activity La unched () ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Before ĊĠĠĠ Ġfun ĠsetUp () Ġ{ ĊĠĠĠĠĠĠĠ Ġre populate Db () ĊĠĠĠĠĠĠĠ ĠThread . sleep ( 1 0 0 0 ) ĊĠĠĠĠĠĠĠ Ġm Activity Test Rule . launch Activity ( null ) ĊĠĠĠĠĠĠĠ ĠThread . sleep ( 1 0 0 0 ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġdelete List () Ġ{ ĊĠĠĠĠĠĠĠ Ġ// ĠDelete Ġthe Ġfirst Ġtask Ġlist . ĊĠĠĠĠĠĠĠ Ġopen Context ual Action Mode Overflow Menu () ĊĠĠĠĠĠĠĠ Ġon View ( with Text ( R . string . action _ delete _ list )) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. perform ( click ()) ĊĠĠĠĠĠĠĠ Ġon View ( with Text ( R . string . action _ delete )) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. perform ( click ()) ĊĊĠĠĠĠĠĠĠ Ġ// ĠEnsure Ġcurrent Ġtask Ġlist Ġchanged Ġto Ġ" Second Ġtask Ġlist ". ĊĠĠĠĠĠĠĠ Ġon View ( with Id ( R . id . toolbar )) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. check ( matches ( has Desc endant ( with Text (" Second Ġtask Ġlist ")) )) ĊĠĠĠĠĠĠĠ Ġon View ( with Id ( R . id . task _ recycler )) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. check ( has Size ( 3 )) ĊĠĠĠĠĠĠĠ Ġon View ( with RecyclerView ( R . id . task _ recycler ). at Position ( 0 )) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. check ( matches ( has Desc endant ( with Text (" Second Ġlist , Ġfirst Ġtask ")) )) ĊĊĠĠĠĠĠĠĠ Ġ// ĠEnsure Ġdeleted Ġlist Ġis Ġno Ġlonger Ġin Ġthe ĠNavigation Ġdrawer . ĊĠĠĠĠĠĠĠ Ġopen Navigation Drawer ( m Activity Test Rule . activity ) ĊĠĠĠĠĠĠĠ Ġon View ( with Id ( R . id . nav _ view )) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. check ( matches ( not ( has Desc endant ( with Text (" First Ġtask Ġlist ")) ))) ĊĠĠĠĠĠĠĠ Ġon View ( with Id ( R . id . nav _ view )) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġdelete All Lists _ Default List ShouldBe Created () Ġ{ ĊĠĠĠĠĠĠĠ Ġ// ĠDelete Ġall Ġthree Ġof Ġthe Ġtest Ġlists . ĊĠĠĠĠĠĠĠ Ġfor Ġ( i Ġin Ġ 1 .. 3 ) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġopen Context ual Action Mode Overflow Menu () ĊĠĠĠĠĠĠĠĠĠĠĠ Ġon View ( with Text ( R . string . action _ delete _ list )) ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ. perform ( click ()) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġon View ( with Text ( R . string . action _ delete )) ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ. perform ( click ()) ĊĠĠĠĠĠĠĠ Ġ} ĊĊĠĠĠĠĠĠĠ Ġ// ĠCheck Ġthe Ġtoolbar Ġtitle . ĊĠĠĠĠĠĠĠ Ġon View ( with Id ( R . id . toolbar )) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. check ( matches ( has Desc endant ( with Text ( R . string . list _ default _ name )))) ĊĊĠĠĠĠĠĠĠ Ġ// ĠEnsure Ġonly Ġthe Ġdefault Ġlist Ġis Ġin Ġthe ĠNavigation Ġdrawer . ĊĠĠĠĠĠĠĠ Ġopen Navigation Drawer ( m Activity Test Rule . activity ) ĊĠĠĠĠĠĠĠ Ġon View ( with Id ( R . id . nav _ view )) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. check ( matches ( has Desc endant ( with Text ( R . string . list _ default _ name )))) ĊĠĠĠĠĠĠĠ Ġon View ( with Id ( R . id . nav _ view )) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. check ( matches ( not ( has Desc endant ( with Text (" First Ġtask Ġlist ")) ))) ĊĠĠĠĠĠĠĠ Ġon View ( with Id ( R . id . nav _ view )) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. check ( matches ( not ( has Desc endant ( with Text (" Second Ġtask Ġlist ")) ))) ĊĠĠĠĠĠĠĠ Ġon View ( with Id ( R . id . nav _ view )) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. check ( matches ( not ( has Desc endant ( with Text (" Third Ġtask Ġlist ")) ))) ĊĠĠĠ Ġ} Ċ } Ċ