package Ġweather . ek amp . com . weather app kotlin . presenter Ċ Ċ import Ġandroid . app . Activity Ċ import Ġandroid . app . Application Ċ import Ġorg . easy mock .* Ċ import Ġorg . easy mock . Easy Mock . expect Ċ import Ġorg . junit . Assert . assertThat Ċ import Ġorg . junit . Before Ċ import Ġorg . junit . Rule Ċ import Ġorg . junit . Test Ċ import Ġtoo th pick . testing . T ooth Pick Rule Ċ import Ġweather . ek amp . com . weather app kotlin . model . location . Location Permission Manager Ċ import Ġweather . ek amp . com . weather app kotlin . view . Splash View Ċ import Ġjavax . inject . Inject Ċ Ċ import Ġorg . hamcrest . Core Matchers .` is ` Ċ Ċ class ĠSpl ash Presenter Test Ġ: ĠEasy Mock Support () Ġ{ ĊĊĠĠĠ Ġval Ġeasy Mock Rule Ġ= ĠEasy Mock Rule ( this ) ĊĠĠĠ Ġ@ Rule Ġget ĊĊĠĠĠ Ġval Ġtoo th pick Rule Ġ= ĠT ooth Pick Rule ( this ) ĊĠĠĠ Ġ@ Rule Ġget ĊĊĠĠĠ Ġ@ Mock Ġlateinit Ġvar Ġsplash View Ġ: ĠSpl ash View ĊĠĠĠ Ġ@ Mock Ġlateinit Ġvar Ġactivity Ġ: ĠActivity ĊĠĠĠ Ġ@ Mock Ġlateinit Ġvar Ġapplication Ġ: ĠApplication ĊĠĠĠ Ġ@ Mock Ġlateinit Ġvar Ġlocation Permission Manager Ġ: ĠLocation Permission Manager ĊĊĠĠĠ Ġ@ Inject Ġlateinit Ġvar Ġsplash Presenter Ġ: ĠSpl ash Presenter ĊĊĠĠĠ Ġ@ Before ĊĠĠĠ Ġfun Ġsetup () Ġ{ ĊĠĠĠĠĠĠĠ Ġtoo th pick Rule . set Scope Name ( application ) ĊĠĠĠĠĠĠĠ Ġtoo th pick Rule . inject ( this ) ĊĠĠĠĠĠĠĠ Ġsplash Presenter . splash View Ġ= Ġsplash View ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġtest _ on Attach View _ landing Is Started _ when _ location Permission HasBeen Granted () Ġ{ ĊĠĠĠĠĠĠĠ Ġ// G IV EN ĊĠĠĠĠĠĠĠ Ġexpect ( splash View . start Landing ()) ĊĠĠĠĠĠĠĠ Ġexpect ( location Permission Manager . has Location Permission Been Granted ()). andReturn ( true ) ĊĠĠĠĠĠĠĠ Ġreplay All () ĊĊĠĠĠĠĠĠĠ Ġ// WHEN ĊĠĠĠĠĠĠĠ Ġsplash Presenter . on Attach View ( splash View ) ĊĊĠĠĠĠĠĠĠ Ġ// THEN ĊĠĠĠĠĠĠĠ Ġverify All () ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġtest _ on Attach View _ location Permission Is Requested _ when _ location Permission Has Not Been Granted () Ġ{ ĊĠĠĠĠĠĠĠ Ġ// G IV EN ĊĠĠĠĠĠĠĠ Ġexpect ( location Permission Manager . has Location Permission Been Granted ()). andReturn ( false ) ĊĠĠĠĠĠĠĠ Ġexpect ( location Permission Manager . request Location Permission ( activity )) ĊĠĠĠĠĠĠĠ Ġexpect ( splash View . getActivity Reference ()). andReturn ( activity ) ĊĠĠĠĠĠĠĠ Ġreplay All () ĊĊĠĠĠĠĠĠĠ Ġ// WHEN ĊĠĠĠĠĠĠĠ Ġsplash Presenter . on Attach View ( splash View ) ĊĊĠĠĠĠĠĠĠ Ġ// THEN ĊĠĠĠĠĠĠĠ Ġverify All () ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġtest _ check If Startup Complete _ returns _ true _ when _ location Permission HasBeen Granted () Ġ{ ĊĠĠĠĠĠĠĠ Ġ// G IV EN ĊĠĠĠĠĠĠĠ Ġexpect ( location Permission Manager . has Location Permission Been Granted ()). andReturn ( true ) ĊĠĠĠĠĠĠĠ Ġreplay All () ĊĊĠĠĠĠĠĠĠ Ġ// WHEN ĊĠĠĠĠĠĠĠ Ġval Ġresult Ġ= Ġsplash Presenter . check If Startup Complete () ĊĊĠĠĠĠĠĠĠ Ġ// THEN ĊĠĠĠĠĠĠĠ Ġverify All () ĊĠĠĠĠĠĠĠ ĠassertThat ( result , Ġ` is `( true )) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġtest _ check If Startup Complete _ returns _ false _ when _ location Permission Has Not Been Granted () Ġ{ ĊĠĠĠĠĠĠĠ Ġ// G IV EN ĊĠĠĠĠĠĠĠ Ġexpect ( location Permission Manager . has Location Permission Been Granted ()). andReturn ( false ) ĊĠĠĠĠĠĠĠ Ġexpect ( location Permission Manager . request Location Permission ( activity )) ĊĠĠĠĠĠĠĠ Ġexpect ( splash View . getActivity Reference ()). andReturn ( activity ) ĊĠĠĠĠĠĠĠ Ġreplay All () ĊĊĠĠĠĠĠĠĠ Ġ// WHEN ĊĠĠĠĠĠĠĠ Ġval Ġresult Ġ= Ġsplash Presenter . check If Startup Complete () ĊĊĠĠĠĠĠĠĠ Ġ// THEN ĊĠĠĠĠĠĠĠ Ġverify All () ĊĠĠĠĠĠĠĠ ĠassertThat ( result , Ġ` is `( false )) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġtest _ on Location Permission Denied _ shows R ationale To User () Ġ{ ĊĠĠĠĠĠĠĠ Ġ// G IV EN ĊĠĠĠĠĠĠĠ Ġexpect ( splash View . show Location Permission R ationale Dialog ()) ĊĠĠĠĠĠĠĠ Ġreplay All () ĊĊĠĠĠĠĠĠĠ Ġ// WHEN ĊĠĠĠĠĠĠĠ Ġsplash Presenter . on Location Permission Denied () ĊĊĠĠĠĠĠĠĠ Ġ// THEN ĊĠĠĠĠĠĠĠ Ġverify All () ĊĠĠĠ Ġ} Ċ } Ċ