package Ġcom . github . b ass aer . qi it ac lient Ċ Ċ import Ġandroid . support . test . espress o . Esp ress o . on View Ċ import Ġandroid . support . test . espress o . action . View Actions . click Ċ import Ġandroid . support . test . espress o . action . View Actions . type Text Ċ import Ġandroid . support . test . espress o . assertion . View Assertions . matches Ċ import Ġandroid . support . test . espress o . matcher . View Matchers . is Displayed Ċ import Ġandroid . support . test . espress o . matcher . View Matchers . with Id Ċ import Ġandroid . support . test . rule . Activity Test Rule Ċ import Ġandroid . support . test . runner . Android JUnit 4 Ċ import Ġandroid . view . View Ċ import Ġcom . github . b ass aer . qi it ac lient . model . Article Client Ċ import Ġio . reactivex . Observable Ċ import Ġorg . hamcrest . Matcher Ċ import Ġorg . hamcrest . Matchers . not Ċ import Ġorg . junit . Rule Ċ import Ġorg . junit . Test Ċ import Ġorg . junit . runner . RunWith Ċ import Ġorg . mockito . Mockito .* Ċ Ċ /** Ċ Ġ* ĠCreated Ġby Ġn ak ay ama Ġon Ġ 2 0 1 7 / 0 9 / 1 6 . Ċ Ġ*/ Ċ @ RunWith ( Android JUnit 4 :: class ) Ċ class ĠMainActivity Test Ġ{ ĊĊĠĠĠ Ġ@ Jvm Field ĊĠĠĠ Ġ@ Rule ĊĠĠĠ Ġval Ġactivity Test Rule Ġ= ĠActivity Test Rule ( MainActivity :: class . java ) ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġall _ views _ should _ be _ shown _ except _ progress _ bar () Ġ{ ĊĠĠĠĠĠĠĠ Ġon View ( with Id ( R . id . list _ view )). check ( matches ( is Displayed ())) ĊĠĠĠĠĠĠĠ Ġon View ( with Id ( R . id . query _ edit _ text )). check ( matches ( is Displayed ())) ĊĠĠĠĠĠĠĠ Ġon View ( with Id ( R . id . search _ button )). check ( matches ( is Displayed ())) ĊĠĠĠĠĠĠĠ Ġon View ( with Id ( R . id . progress _ bar )). check ( matches ( isNot Displayed ())) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġsend _ query _ when _ search _ button _ was _ t apped () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġarticle Client Ġ= Ġmock ( Article Client :: class . java ). apply Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ` when `( search (" user : b ass aer ")). thenReturn ( Observable . just ( listOf ())) ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠ Ġactivity Test Rule . activity . article Client Ġ= Ġarticle Client ĊĊĠĠĠĠĠĠĠ Ġon View ( with Id ( R . id . query _ edit _ text )). perform ( type Text (" user : b ass aer ")) ĊĠĠĠĠĠĠĠ Ġon View ( with Id ( R . id . search _ button )). perform ( click ()) ĊĠĠĠĠĠĠĠ Ġverify ( article Client ). search (" user : b ass aer ") ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġfun Ġis Not Displayed (): ĠMatcher < View > Ġ= Ġnot ( is Displayed ()) Ċ }