package Ġcom . sample . assignment . ui Ċ Ċ import Ġandroidx . arch . core . executor . testing . Count ing Task Executor Rule Ċ import Ġandroidx . recyclerview . widget . RecyclerView Ċ import Ġandroidx . test . espress o . Esp ress o . on View Ċ 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 Ġcom . sample . assignment . base . Base IT Ċ import Ġcom . sample . assignment . utils . waitFor Adapter Change Ċ import Ġcom . sample . assignment . R Ċ import Ġcom . sample . assignment . view . activity . MainActivity Ċ import Ġorg . hamcrest . Matchers . all Of Ċ import Ġorg . hamcrest . Matchers . not Ċ import Ġorg . junit . Before Ċ import Ġorg . junit . Rule Ċ import Ġorg . junit . Test Ċ import Ġorg . junit . runner . RunWith Ċ import Ġjava . net . Http URLConnection Ċ Ċ /** Ċ Ġ* ĠCreated Ġby ĠA jay ĠA ry a Ġon Ġ 3 1 / 0 8 / 2 0 Ċ Ġ*/ Ċ Ċ @ RunWith ( Android JUnit 4 :: class ) Ċ @ Large Test Ċ class ĠMain Instrument Test Ġ: ĠBase IT () Ġ{ ĊĊĠĠĠ Ġ@ Rule ĊĠĠĠ Ġ@ Jvm Field ĊĠĠĠ Ġval Ġactivity Rule Ġ= ĠActivity Test Rule ( MainActivity :: class . java , Ġtrue , Ġfalse ) ĊĊĠĠĠ Ġ@ get : Rule ĊĠĠĠ Ġvar Ġexecutor Rule Ġ= ĠCount ing Task Executor Rule () ĊĊĠĠĠ Ġ// ĠOVER RIDE Ġ--- ĊĠĠĠ Ġoverride Ġfun Ġis Mock Server Enabled () Ġ= Ġtrue ĊĊĠĠĠ Ġ@ Before ĊĠĠĠ Ġoverride Ġfun ĠsetUp () Ġ{ ĊĠĠĠĠĠĠĠ Ġsuper . setUp () ĊĠĠĠĠĠĠĠ Ġactivity Rule . launch Activity ( null ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ// ĠUI ĠTEST S Ġ--- ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġwhen _ list _ is _ empty () Ġ{ ĊĠĠĠĠĠĠĠ Ġon View ( with Id ( R . id . tool _ title )). check ( matches ( is Displayed ())) ĊĠĠĠĠĠĠĠ Ġon View ( all Of ( with Id ( R . id . tool _ title ), Ġwith Text (" Title ")) ). check ( matches ( is Displayed ())) ĊĠĠĠĠĠĠĠ Ġon View ( with Id ( R . id . tv _ error )). check ( matches ( is Displayed ())) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġwhen _ list _ is _ pop ulated () Ġ{ ĊĠĠĠĠĠĠĠ Ġmock HttpResponse (" list _ data . json ", ĠHttp URLConnection . HTTP _ OK ) ĊĊĠĠĠĠĠĠĠ Ġon View ( with Id ( R . id . tool _ title )). check ( matches ( is Displayed ())) ĊĠĠĠĠĠĠĠ ĠwaitFor Adapter Change ( get RecyclerView (), Ġexecutor Rule , Ġ 1 ) ĊĊĠĠĠĠĠĠĠ Ġon View ( all Of ( with Id ( R . id . tv _ title ), Ġwith Text (" Be a vers ")) ). check ( matches ( is Displayed ())) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġwhen _ list _ is _ not _ pop ulated _ with _ wrong text () Ġ{ ĊĠĠĠĠĠĠĠ Ġmock HttpResponse (" list _ data . json ", ĠHttp URLConnection . HTTP _ OK ) ĊĊĠĠĠĠĠĠĠ Ġon View ( with Id ( R . id . tool _ title )). check ( matches ( is Displayed ())) ĊĠĠĠĠĠĠĠ ĠwaitFor Adapter Change ( get RecyclerView (), Ġexecutor Rule , Ġ 1 ) ĊĊĠĠĠĠĠĠĠ Ġon View ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġall Of ( ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġwith Id ( R . id . tv _ title ), ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġnot ( ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġwith Text (" Be aver ssss ") Ġ// wrong Ġtext ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠĠĠ Ġ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ// ĠUT IL S ĊĠĠĠ Ġ/** ĊĠĠĠĠ Ġ* ĠCon ven ient Ġaccess Ġto Ġ[ Venue List Fragment ]' s ĠRecyclerView ĊĠĠĠĠ Ġ*/ ĊĠĠĠ Ġprivate Ġfun Ġget RecyclerView () Ġ= ĊĠĠĠĠĠĠĠ Ġactivity Rule . activity . findViewById < RecyclerView >( R . id . list ) Ċ }