package Ġru . m rf ro zz en . cookbook . ui ĊĊ Ċ import Ġandroidx . test . espress o . Esp ress o Ċ import Ġandroidx . test . espress o . Esp ress o . on Data Ċ import Ġandroidx . test . espress o . Esp ress o . on View Ċ 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 . ext . junit . runners . Android JUnit 4 Ċ import Ġandroidx . test . filters . Large Test Ċ import Ġandroidx . test . rule . Activity Test Rule Ċ import Ġru . m rf ro zz en . cookbook . R Ċ import Ġru . m rf ro zz en . cookbook . presentation . main . MainActivity Ċ import Ġorg . hamcrest . Core Matchers . not Ċ import Ġorg . hamcrest . Matchers . anything Ċ 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 ĠF avorite Test Ġ{ ĊĊĠĠĠ Ġ@ Rule Ġ@ Jvm Field Ġval Ġactivity Test Rule Ġ= ĠActivity Test Rule ( MainActivity :: class . java ) ĊĊĠĠĠ Ġ@ Before Ġfun Ġpopulate Db () Ġ{ ĊĠĠĠĠĠĠĠ ĠDatabase Helper . re populate Db () ĊĠĠĠĠĠĠĠ Ġon View ( is Root ()). perform ( MainActivity Test . waitFor ( 1 0 0 0 )) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test Ġfun Ġfavorite Test () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġrecipe Tab Ġ= Ġ" REC IP ES " ĊĠĠĠĠĠĠĠ Ġval Ġfavorite Tab Ġ= Ġ" FA V OR ITES " ĊĠĠĠĠĠĠĠ Ġval Ġname Ġ= Ġ" Best Ġbrown ies " ĊĊĠĠĠĠĠĠĠ ĠThread . sleep ( 7 0 0 ) ĊĊĠĠĠĠĠĠĠ Ġ// ĠRemove Ġrecipe Ġfrom Ġfavor ites ĊĠĠĠĠĠĠĠ Ġon View ( with Text ( favorite Tab )) ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ. perform ( click ()) ĊĊĠĠĠĠĠĠĠ Ġ// ĠEnsure Ġno Ġfavor ites Ġtext Ġis Ġnot Ġvisible ĊĠĠĠĠĠĠĠ Ġon View ( with Id ( R . id . text _ no _ favorites )) ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ. check ( matches ( not ( is Displayed ()))) ĊĊĠĠĠĠĠĠĠ Ġ// ĠRemove Ġrecipe Ġfrom Ġfavor ites ĊĠĠĠĠĠĠĠ Ġon Data ( anything ()). in Adapter View ( with Id ( R . id . list _ favorites )). at Position ( 0 ) ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ. perform ( click ()) ĊĊĠĠĠĠĠĠĠ ĠThread . sleep ( 7 0 0 ) ĊĊĠĠĠĠĠĠĠ Ġon View ( with Id ( R . id . button _ favorite )) ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ. perform ( click ()) ĊĊĠĠĠĠĠĠĠ Ġ// ĠEnsure Ġno Ġfavor ites Ġtext Ġis Ġvisible ĊĠĠĠĠĠĠĠ ĠE sp ress o . press Back () ĊĊĠĠĠĠĠĠĠ ĠThread . sleep ( 7 0 0 ) ĊĊĠĠĠĠĠĠĠ Ġon View ( with Id ( R . id . text _ no _ favorites )) ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ. check ( matches ( is Displayed ())) ĊĊĠĠĠĠĠĠĠ Ġ// ĠNow Ġadd Ġa Ġrecipe Ġto Ġfavor ites ĊĠĠĠĠĠĠĠ Ġon View ( with Text ( recipe Tab )) ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ. perform ( click ()) ĊĊĠĠĠĠĠĠĠ Ġon Data ( anything ()). in Adapter View ( with Id ( R . id . list _ recipes _ all )). at Position ( 0 ) ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ. perform ( click ()) ĊĊĠĠĠĠĠĠĠ ĠThread . sleep ( 7 0 0 ) ĊĊĠĠĠĠĠĠĠ Ġon View ( with Id ( R . id . button _ favorite )) ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ. perform ( click ()) ĊĊĠĠĠĠĠĠĠ Ġ// ĠEnsure Ġrecipe Ġwas Ġadded Ġto Ġfavor ites Ġlist ĊĠĠĠĠĠĠĠ ĠE sp ress o . press Back () ĊĊĠĠĠĠĠĠĠ ĠThread . sleep ( 7 0 0 ) ĊĊĠĠĠĠĠĠĠ Ġon View ( with Text ( favorite Tab )) ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ. perform ( click ()) ĊĊĠĠĠĠĠĠĠ Ġon Data ( anything ()). in Adapter View ( with Id ( R . id . list _ favorites )). at Position ( 0 ) ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ. check ( matches ( has Desc endant ( with Text ( name )))) ĊĠĠĠ Ġ} Ċ } Ċ