/* Ċ Ġ* ĠCopyright Ġ( C ) Ġ 2 0 1 7 ĠThe ĠAndroid ĠOpen ĠSource ĠProject Ċ Ġ* Ċ Ġ* ĠLicensed Ġunder Ġthe ĠApache ĠLicense , ĠVersion Ġ 2 . 0 Ġ( the Ġ" License "); Ċ Ġ* Ġyou Ġmay Ġnot Ġuse Ġthis Ġfile Ġexcept Ġin Ġcompliance Ġwith Ġthe ĠLicense . Ċ Ġ* ĠYou Ġmay Ġobtain Ġa Ġcopy Ġof Ġthe ĠLicense Ġat Ċ Ġ* Ċ Ġ* ĠĠĠĠĠ Ġhttp :// www . apache . org / licenses / LICENSE - 2 . 0 Ċ Ġ* Ċ Ġ* ĠUnless Ġrequired Ġby Ġapplicable Ġlaw Ġor Ġagreed Ġto Ġin Ġwriting , Ġsoftware Ċ Ġ* Ġdistributed Ġunder Ġthe ĠLicense Ġis Ġdistributed Ġon Ġan Ġ" AS ĠIS " ĠBASIS , Ċ Ġ* ĠWITHOUT ĠWARRANTIES ĠOR ĠCONDITIONS ĠOF ĠANY ĠKIND , Ġeither Ġexpress Ġor Ġimplied . Ċ Ġ* ĠSee Ġthe ĠLicense Ġfor Ġthe Ġspecific Ġlanguage Ġgoverning Ġpermissions Ġand Ċ Ġ* Ġlimitations Ġunder Ġthe ĠLicense . Ċ Ġ*/ Ċ Ċ package Ġit . coding jam . github . ui . repo Ċ Ċ import Ġandroid . app . Application Ċ import Ġandroidx . annotation . String Res Ċ import Ġandroidx . arch . core . executor . testing . Instant Task Executor Rule Ċ import Ġandroidx . test . core . app . Application Provider Ċ 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 Ġcom . n ha ar man . mock it ok otlin 2 . do Answer Ċ import Ġcom . n ha ar man . mock it ok otlin 2 . mock Ċ import Ġit . coding jam . github . core . Repo Detail Ċ import Ġit . coding jam . github . core . Repo Id Ċ import Ġit . coding jam . github . espress o . Test Application Ċ import Ġit . coding jam . github . espress o . rule Ċ import Ġit . coding jam . github . testdata . TEST _ DISPATCH ER Ċ import Ġit . coding jam . github . testdata . TestData . CONTRIBUT OR 1 Ċ import Ġit . coding jam . github . testdata . TestData . CONTRIBUT OR 2 Ċ import Ġit . coding jam . github . testdata . TestData . OWNER Ċ import Ġit . coding jam . github . testdata . TestData . REPO _ 1 Ċ import Ġit . coding jam . github . util . ViewState Store Ċ import Ġit . coding jam . github . vo . L ce Ċ import Ġit . cos en on jav iste . d agger mock . D agger Mock Ċ import Ġit . cos en on jav iste . d agger mock . interceptor Ċ import Ġkotlinx . coroutines . Coroutine Scope Ċ import Ġkotlinx . coroutines . Dispatch ers Ċ import Ġorg . hamcrest . Matchers . not Ċ import Ġorg . junit . Before Ċ import Ġorg . junit . Rule Ċ import Ġorg . junit . Test ĊĊ Ċ class ĠRepo Fragment Test Ġ{ ĊĊĠĠĠ Ġ@ get : Rule ĊĠĠĠ Ġval Ġfragment Rule Ġ= ĠRepo Fragment . rule () ĊĊĠĠĠ Ġ@ get : Rule ĊĠĠĠ Ġval Ġinstant Executor Rule Ġ= ĠInstant Task Executor Rule () ĊĊĠĠĠ Ġprivate Ġval Ġview State Store Ġby Ġlazy Ġ{ ĊĠĠĠĠĠĠĠ ĠView State Store < Repo ViewState >( L ce . Loading , ĠCor outine Scope ( Dispatch ers . Main ), ĠTEST _ DISPATCH ER ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġprivate Ġval ĠviewModel Ġ= Ġmock < Repo ViewModel > Ġ{ ĊĠĠĠĠĠĠĠ Ġon ( it . state ) Ġdo Answer Ġ{ Ġview State Store Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Before ĊĠĠĠ Ġfun ĠsetUp () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġapp Ġ= ĠApplication Provider . getApplicationContext < Test Application >() ĊĠĠĠĠĠĠĠ Ġapp . init ( D agger Mock . interceptor ( this )) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġtest Loading () Ġ{ ĊĠĠĠĠĠĠĠ Ġfragment Rule . launch Fragment ( Repo Id (" a ", Ġ" b ")) ĊĊĠĠĠĠĠĠĠ Ġview State Store . dispatch State ( L ce . Loading ) ĊĊĠĠĠĠĠĠĠ Ġon View ( with Id ( R . id . progress _ bar )). check ( matches ( is Displayed ())) ĊĠĠĠĠĠĠĠ Ġon View ( with Id ( R . id . retry )). check ( matches ( not ( is Displayed ()))) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġtest Value While Loading () Ġ{ ĊĠĠĠĠĠĠĠ Ġfragment Rule . launch Fragment ( Repo Id (" a ", Ġ" b ")) ĊĊĠĠĠĠĠĠĠ Ġview State Store . dispatch State ( L ce . Loading ) ĊĠĠĠĠĠĠĠ Ġview State Store . dispatch State ( L ce . Success ( Repo Detail ( REPO _ 1 , ĠlistOf ( CONTRIBUT OR 1 , ĠCONTRIBUT OR 2 )))) ĊĊĠĠĠĠĠĠĠ Ġon View ( with Id ( R . id . progress _ bar )). check ( matches ( not ( is Displayed ()))) ĊĠĠĠĠĠĠĠ Ġon View ( with Id ( R . id . name )). check ( matches ( ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġwith Text ( getString ( R . string . repo _ full _ name , ĠOWNER . login , ĠRE PO _ 1 . name )))) ĊĠĠĠĠĠĠĠ Ġon View ( with Id ( R . id . description )). check ( matches ( with Text ( REPO _ 1 . description ))) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġprivate Ġfun ĠgetString (@ String Res Ġid : ĠInt , Ġvar arg Ġargs : ĠAny ) Ġ= ĠApplication Provider . getApplicationContext < Application >(). getString ( id , Ġ* args ) Ċ }