package Ġcom . reddit . indicator fast scroll Ċ Ċ import Ġandroid . support . test . espress o . Esp ress o . on View Ċ import Ġandroid . support . test . espress o . action . View Actions Ċ import Ġandroid . support . test . espress o . assertion . View Assertions . matches Ċ import Ġandroid . support . test . espress o . matcher . View Matchers .* Ċ import Ġandroid . support . test . filters . Large Test Ċ import Ġandroid . support . test . rule . Activity Test Rule Ċ import Ġandroid . support . test . runner . Android JUnit 4 Ċ import Ġcom . reddit . indicator fast scroll . test . R Ċ import Ġorg . hamcrest . Matchers .* Ċ import Ġorg . junit . Assert . assertEquals Ċ import Ġorg . junit . Rule Ċ import Ġorg . junit . Test Ċ import Ġorg . junit . runner . RunWith Ċ Ċ @ RunWith ( Android JUnit 4 :: class ) Ċ @ Large Test Ċ class ĠTests Ġ{ ĊĊĠ Ġ@ get : Rule ĊĠ Ġval Ġactivity Rule Ġ= ĠActivity Test Rule ( Test Activity :: class . java ) ĊĠ Ġval Ġactivity : ĠTest Activity Ġget () Ġ= Ġactivity Rule . activity ĊĊĠ Ġ@ Test ĊĠ Ġfun Ġcheck Text Batch ing () Ġ{ ĊĠĠĠ Ġval Ġitems Ġ= ĠlistOf ( ĊĠĠĠĠĠĠĠ ĠTest Activity . ListItem (" A "), ĊĠĠĠĠĠĠĠ ĠTest Activity . ListItem (" B ", Ġandroid . R . drawable . ic _ dialog _ alert ), ĊĠĠĠĠĠĠĠ ĠTest Activity . ListItem (" C "), ĊĠĠĠĠĠĠĠ ĠTest Activity . ListItem (" D "), ĊĠĠĠĠĠĠĠ ĠTest Activity . ListItem (" E ", Ġandroid . R . drawable . ic _ dialog _ dial er ), ĊĠĠĠĠĠĠĠ ĠTest Activity . ListItem (" F "), ĊĠĠĠĠĠĠĠ ĠTest Activity . ListItem (" G "), ĊĠĠĠĠĠĠĠ ĠTest Activity . ListItem (" H "), ĊĠĠĠĠĠĠĠ ĠTest Activity . ListItem (" I ", Ġandroid . R . drawable . ic _ dialog _ email ), ĊĠĠĠĠĠĠĠ ĠTest Activity . ListItem (" J "), ĊĠĠĠĠĠĠĠ ĠTest Activity . ListItem (" K "), ĊĠĠĠĠĠĠĠ ĠTest Activity . ListItem (" L "), ĊĠĠĠĠĠĠĠ ĠTest Activity . ListItem (" M "), ĊĠĠĠĠĠĠĠ ĠTest Activity . ListItem (" N "), ĊĠĠĠĠĠĠĠ ĠTest Activity . ListItem (" O ", Ġandroid . R . drawable . ic _ dialog _ info ) ĊĠĠĠ Ġ) ĊĠĠĠ Ġval Ġexpected Texts Ġ= ĠlistOf ( ĊĠĠĠĠĠĠĠ Ġ" A ", Ġ" C \ n D ", Ġ" F \ n G \ n H ", Ġ" J \ n K \ n L \ n M \ n N " ĊĠĠĠ Ġ) ĊĠĠĠ Ġval Ġexpected Icon Count Ġ= Ġitems . count Ġ{ Ġit . icon Res Ġ!= Ġnull Ġ} ĊĊĠĠĠ Ġactivity . run On Ui Thread Ġ{ ĊĠĠĠĠĠ Ġactivity . present Data ( items ) ĊĠĠĠ Ġ} ĊĠĠĠ Ġon View ( with Id ( R . id . test _ fast sc roller )) ĊĠĠĠĠĠĠĠ Ġ. check ( matches ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġall Of ( expected Texts . map Ġ{ Ġwith Child ( with Text ( it )) Ġ}) ĊĠĠĠĠĠĠĠ Ġ)) ĊĠĠĠĠĠĠĠ Ġ. check ( matches ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġhas Child Count ( expected Texts . size Ġ+ Ġexpected Icon Count ) ĊĠĠĠĠĠĠĠ Ġ)) ĊĠ Ġ} ĊĊĠ Ġ@ Test ĊĠ Ġfun Ġcheck Null Indicator Does nt Show () Ġ{ ĊĠĠĠ Ġval Ġitems Ġ= ĠlistOf ( ĊĠĠĠĠĠĠĠ ĠTest Activity . ListItem (" A "), ĊĠĠĠĠĠĠĠ ĠTest Activity . ListItem (" B ", Ġshow In Fast Scroll Ġ= Ġfalse ), ĊĠĠĠĠĠĠĠ ĠTest Activity . ListItem (" C ") ĊĠĠĠ Ġ) ĊĠĠĠ Ġval Ġexpected Text Ġ= Ġ" A \ n C " ĊĊĠĠĠ Ġactivity . run On Ui Thread Ġ{ ĊĠĠĠĠĠ Ġactivity . present Data ( items ) ĊĠĠĠ Ġ} ĊĠĠĠ Ġon View ( with Id ( R . id . test _ fast sc roller )). check ( matches ( with Child ( with Text ( expected Text )))) ĊĠ Ġ} ĊĊĠ Ġ@ Test ĊĠ Ġfun Ġcheck Scroll s When T apped () Ġ{ ĊĠĠĠ Ġval Ġitems Ġ= ĠlistOf ( ĊĠĠĠĠĠĠĠ ĠTest Activity . ListItem (" A "), ĊĠĠĠĠĠĠĠ ĠTest Activity . ListItem (" B ", Ġandroid . R . drawable . ic _ dialog _ alert ), ĊĠĠĠĠĠĠĠ ĠTest Activity . ListItem (" C "), ĊĠĠĠĠĠĠĠ ĠTest Activity . ListItem (" D "), ĊĠĠĠĠĠĠĠ ĠTest Activity . ListItem (" E ", Ġandroid . R . drawable . ic _ dialog _ dial er ), ĊĠĠĠĠĠĠĠ ĠTest Activity . ListItem (" F "), ĊĠĠĠĠĠĠĠ ĠTest Activity . ListItem (" G "), ĊĠĠĠĠĠĠĠ ĠTest Activity . ListItem (" H "), ĊĠĠĠĠĠĠĠ ĠTest Activity . ListItem (" I "), ĊĠĠĠĠĠĠĠ ĠTest Activity . ListItem (" J "), ĊĠĠĠĠĠĠĠ ĠTest Activity . ListItem (" K "), ĊĠĠĠĠĠĠĠ ĠTest Activity . ListItem (" L ", Ġandroid . R . drawable . ic _ dialog _ email ), ĊĠĠĠĠĠĠĠ ĠTest Activity . ListItem (" M "), ĊĠĠĠĠĠĠĠ ĠTest Activity . ListItem (" N "), ĊĠĠĠĠĠĠĠ ĠTest Activity . ListItem (" O ", Ġandroid . R . drawable . ic _ dialog _ info ), ĊĠĠĠĠĠĠĠ ĠTest Activity . ListItem (" P "), ĊĠĠĠĠĠĠĠ ĠTest Activity . ListItem (" Q ", Ġandroid . R . drawable . ic _ dialog _ map ) ĊĠĠĠ Ġ) ĊĠĠĠ Ġ// ĠFor Ġsimplicity , Ġthese Ġhave Ġun bat ched Ġtext Ġindicators ĊĠĠĠ Ġval Ġfirst Item Ġ= Ġitems . first () ĊĠĠĠ Ġval Ġtarget Item Ġ= Ġitems . find Ġ{ Ġit . text Ġ== Ġ" P " Ġ} !! ĊĊĠĠĠ Ġactivity . run On Ui Thread Ġ{ ĊĠĠĠĠĠ Ġactivity . present Data ( items ) ĊĠĠĠ Ġ} ĊĠĠĠ Ġval Ġtarget View Matcher Ġ= Ġall Of ( ĊĠĠĠĠĠĠĠ Ġwith Text ( target Item . text ), ĊĠĠĠĠĠĠĠ Ġwith Parent ( with Id ( R . id . test _ recyclerview )) ĊĠĠĠ Ġ) ĊĠĠĠ Ġval Ġtop View Matcher Ġ= Ġall Of ( ĊĠĠĠĠĠĠĠ Ġwith Text ( first Item . text ), ĊĠĠĠĠĠĠĠ Ġwith Parent ( with Id ( R . id . test _ recyclerview )) ĊĠĠĠ Ġ) ĊĠĠĠ Ġon View ( with Id ( R . id . test _ recyclerview )). check ( matches ( all Of ( ĊĠĠĠĠĠĠĠ Ġnot ( with Child ( all Of ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġtarget View Matcher , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġis Comp let ely Displayed () ĊĠĠĠĠĠĠĠ Ġ)) ), ĊĠĠĠĠĠĠĠ Ġwith Child ( all Of ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġtop View Matcher , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġis Comp let ely Displayed () ĊĠĠĠĠĠĠĠ Ġ)) ĊĠĠĠ Ġ))) ĊĠĠĠ Ġon View ( all Of ( ĊĠĠĠĠĠĠĠ Ġwith Text ( target Item . text ), ĊĠĠĠĠĠĠĠ Ġwith Parent ( with Id ( R . id . test _ fast sc roller )) ĊĠĠĠ Ġ )). perform ( View Actions . long Click ()) ĊĠĠĠ Ġon View ( target View Matcher ). check ( matches ( is Comp let ely Displayed ())) ĊĠĠĠ Ġon View ( with Id ( R . id . test _ recyclerview )). check ( matches ( ĊĠĠĠĠĠĠĠ Ġnot ( with Child ( all Of ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġtop View Matcher , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġis Comp let ely Displayed () ĊĠĠĠĠĠĠĠ Ġ))) ĊĠĠĠ Ġ)) ĊĠ Ġ} ĊĊĠ Ġ@ Test ĊĠ Ġfun Ġcheck Update Item Indicators Only Called Once After Multiple Posts () Ġ{ ĊĠĠĠ Ġval Ġitems Ġ= ĠlistOf ( ĊĠĠĠĠĠĠĠ ĠTest Activity . ListItem (" A "), ĊĠĠĠĠĠĠĠ ĠTest Activity . ListItem (" B "), ĊĠĠĠĠĠĠĠ ĠTest Activity . ListItem (" C ") ĊĠĠĠ Ġ) ĊĊĠĠĠ Ġval Ġtest Item Indicators Builder Ġ= ĠTest Item Indicators Builder () ĊĠĠĠ Ġactivity . fast Scroller View . item Indicators Builder Ġ= Ġtest Item Indicators Builder ĊĠĠĠ Ġactivity . run On Ui Thread Ġ{ ĊĠĠĠĠĠ Ġ// ĠCall Ġadapter . notify DataSet Changed () Ġmultiple Ġtimes Ġin Ġthe Ġsame Ġframe ĊĠĠĠĠĠ Ġactivity . present Data ( items ) ĊĠĠĠĠĠ Ġactivity . present Data ( items ) ĊĠĠĠĠĠ Ġactivity . present Data ( items ) ĊĠĠĠ Ġ} ĊĠĠĠ Ġon View ( with Id ( R . id . test _ fast sc roller )). check ( matches ( anything ())) Ġ// ĠWait Ġfor Ġidle ĊĠĠĠ ĠassertEquals ( 1 , Ġtest Item Indicators Builder . times Build Called ) ĊĊĠĠĠ Ġactivity . run On Ui Thread Ġ{ ĊĠĠĠĠĠ Ġactivity . present Data ( items ) ĊĠĠĠĠĠ Ġactivity . present Data ( items ) ĊĠĠĠĠĠ Ġactivity . present Data ( items ) ĊĠĠĠ Ġ} ĊĠĠĠ Ġon View ( with Id ( R . id . test _ fast sc roller )). check ( matches ( anything ())) ĊĠĠĠ ĠassertEquals ( 2 , Ġtest Item Indicators Builder . times Build Called ) ĊĠ Ġ} Ċ Ċ } Ċ