package Ġcom . shop app . ui . blog Ċ Ċ import Ġandroid . content . Context Ċ import Ġandroid . view . View Ċ import Ġandroid . webkit . Web Settings Ċ import Ġcom . n ha ar man . mockito _ kotlin . given Ċ import Ġcom . n ha ar man . mockito _ kotlin . verify Ċ import Ġcom . shop app . R Ċ import Ġcom . shop app . Test Shop Application Ċ import Ġcom . shop app . gateway . entity . Error Ċ import Ġcom . shop app . test . Mock Instanti ator Ċ import Ġcom . shop app . test . ext . replace Command Symbols Ċ import Ġkotlinx . android . synt hetic . main . activity _ article .* Ċ import Ġkotlinx . android . synt hetic . main . activity _ l ce .* Ċ import Ġkotlinx . android . synt hetic . main . layout _ l ce .* Ċ import Ġkotlinx . android . synt hetic . main . layout _ l ce . view .* Ċ import Ġkotlinx . android . synt hetic . main . view _ l ce _ error . view .* Ċ import Ġorg . junit . After Ċ import Ġorg . junit . Assert . assertEquals Ċ import Ġorg . junit . Assert . assertTrue Ċ import Ġorg . junit . Before Ċ import Ġorg . junit . Test Ċ import Ġorg . junit . runner . RunWith Ċ import Ġorg . ro bo lectric . Ro bo lectric Ċ import Ġorg . ro bo lectric . Ro bo lectric TestRunner Ċ import Ġorg . ro bo lectric . Runtime Environment Ċ import Ġorg . ro bo lectric . Shadow s . shadow Of Ċ import Ġorg . ro bo lectric . annotation . Config Ċ Ċ @ RunWith ( Ro bo lectric TestRunner :: class ) Ċ @ Config ( manifest Ġ= ĠConfig . NONE , Ġapplication Ġ= ĠTest Shop Application :: class ) Ċ class ĠArticle Activity Test Ġ{ ĊĊĠĠĠ Ġprivate Ġlateinit Ġvar Ġactivity : ĠArticle Activity ĊĠĠĠ Ġprivate Ġlateinit Ġvar Ġcontext : ĠContext ĊĊĠĠĠ Ġ@ Before ĊĠĠĠ Ġfun ĠsetUp Test () Ġ{ ĊĠĠĠĠĠĠĠ Ġcontext Ġ= ĠRuntime Environment . application . base Context ĊĠĠĠĠĠĠĠ Ġval Ġintent Ġ= ĠArticle Activity . getStart Intent ( context , ĠMock Instanti ator . DEFAULT _ ID ) ĊĠĠĠĠĠĠĠ Ġactivity Ġ= ĠRo bo lectric . build Activity ( Article Activity :: class . java , Ġintent ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. create () ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. resume () ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. visible () ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. get () ĊĠĠĠĠĠĠĠ Ġactivity . loading View . min Show Time Ġ= Ġ 0 ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġshould Setup WebView On Create () Ġ{ ĊĠĠĠĠĠĠĠ Ġwith ( activity . content . settings ) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ ĠassertTrue ( java Script Enabled ) ĊĠĠĠĠĠĠĠĠĠĠĠ ĠassertTrue ( dom Storage Enabled ) ĊĠĠĠĠĠĠĠĠĠĠĠ ĠassertEquals ( Web Settings . Layout Algorithm . TEXT _ AUTO SIZ ING , Ġlayout Algorithm ) ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġshould Get Article On Create () Ġ{ ĊĠĠĠĠĠĠĠ Ġverify ( activity . presenter ). load Articles ( Mock Instanti ator . DEFAULT _ ID ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġshould Show Article Title On Show Content () Ġ{ ĊĠĠĠĠĠĠĠ Ġactivity . show Content ( Pair ( Mock Instanti ator . new Article (), ĠMock Instanti ator . DEFAULT _ URL )) ĊĠĠĠĠĠĠĠ ĠassertEquals ( Mock Instanti ator . DEFAULT _ TITLE , Ġactivity . article Title . text . toString ()) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġshould Show Article Author On Show Content () Ġ{ ĊĠĠĠĠĠĠĠ Ġactivity . show Content ( Pair ( Mock Instanti ator . new Article (), ĠMock Instanti ator . DEFAULT _ URL )) ĊĠĠĠĠĠĠĠ ĠassertEquals ( Mock Instanti ator . DEFAULT _ NAME , Ġactivity . author . text . toString ()) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġshould Show Article Image () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġarticle Ġ= ĠMock Instanti ator . new Article () ĊĠĠĠĠĠĠĠ Ġactivity . show Content ( Pair ( article , ĠMock Instanti ator . DEFAULT _ URL )) ĊĠĠĠĠĠĠĠ ĠassertEquals ( View . VISIBLE , Ġactivity . image . visibility ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġshould Not Show Article Image () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġarticle Ġ= ĠMock Instanti ator . new Article () ĊĠĠĠĠĠĠĠ Ġgiven ( article . image ?. src ). willReturn ( null ) ĊĠĠĠĠĠĠĠ Ġactivity . show Content ( Pair ( article , ĠMock Instanti ator . DEFAULT _ URL )) ĊĠĠĠĠĠĠĠ ĠassertEquals ( View . GONE , Ġactivity . image . visibility ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġshould Show Content In WebView () Ġ{ ĊĠĠĠĠĠĠĠ ĠassertEquals ( View . VISIBLE , Ġactivity . l ce Layout . loading View . visibility ) ĊĠĠĠĠĠĠĠ Ġactivity . show Content ( Pair ( Mock Instanti ator . new Article (), ĠMock Instanti ator . DEFAULT _ URL )) ĊĠĠĠĠĠĠĠ ĠassertEquals ( View . GONE , Ġactivity . l ce Layout . loading View . visibility ) ĊĠĠĠĠĠĠĠ Ġval ĠwebView Ġ= Ġshadow Of ( activity . content ) ĊĠĠĠĠĠĠĠ Ġval Ġtmp Ġ= Ġshadow Of ( activity . main Looper ) ĊĠĠĠĠĠĠĠ Ġtmp . idle () ĊĠĠĠĠĠĠĠ ĠassertEquals ( Mock Instanti ator . DEFAULT _ URL , ĠwebView . last Load Data With Base URL . baseUrl ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( ĊĠĠĠĠĠĠĠĠĠĠĠ ĠMock Instanti ator . DEFAULT _ CONTENT _ HTML . replace Command Symbols (), ĊĠĠĠĠĠĠĠĠĠĠĠ ĠwebView . last Load Data With Base URL . data . replace Command Symbols () ĊĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠĠĠ ĠassertEquals (" text / html ", ĠwebView . last Load Data With Base URL . mime Type ) ĊĠĠĠĠĠĠĠ ĠassertEquals (" UTF - 8 ", ĠwebView . last Load Data With Base URL . encoding ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġshould Show NotFoundError With Target When Critical Error Received () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġtarget Ġ= Ġcontext . getString ( R . string . article ) ĊĠĠĠĠĠĠĠ Ġactivity . show Error ( Error . Critical ()) ĊĠĠĠĠĠĠĠ ĠassertEquals ( View . VISIBLE , Ġactivity . l ce Layout . error View . visibility ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( context . getString ( R . string . Ñģ ould _ not _ find _ with _ placeholder , Ġtarget ), ĊĠĠĠĠĠĠĠĠĠĠĠ Ġactivity . l ce Layout . error View . errorMessage . text ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ After ĊĠĠĠ Ġfun ĠtearDown () Ġ{ ĊĠĠĠĠĠĠĠ Ġactivity . finish () ĊĠĠĠ Ġ} Ċ }