package Ġio . j ent z . w inter . android x . integration . test Ċ Ċ import Ġandroid . app . Activity Ċ import Ġandroid . app . Application Ċ import Ġandroid . app . Service Ċ import Ġandroid . content . Broadcast Receiver Ċ import Ġandroid . content . Context Ċ import Ġandroid . content . Intent Ċ import Ġandroid . os . IB inder Ċ import Ġandroid . view . View Ċ import Ġandroidx . core . content . File Provider Ċ import Ġandroidx . fragment . app . FragmentManager Ċ import Ġandroidx . lifecycle . Lifecycle Ċ import Ġandroidx . test . core . app . Activity Scenario Ċ import Ġandroidx . test . espress o . Esp ress o . on Idle Ċ import Ġandroidx . test . ext . junit . rules . Activity Scenario Rule Ċ import Ġandroidx . test . ext . junit . runners . Android JUnit 4 Ċ import Ġandroidx . test . filters . Large Test Ċ import Ġio . j ent z . w inter . W inter Ċ import Ġio . j ent z . w inter . W inter Application Ċ import Ġio . j ent z . w inter . android x . Dependency Graph Context Wrapper Ċ import Ġio . j ent z . w inter . android x . Simple Android Injection Adapter Ċ import Ġio . j ent z . w inter . android x . inject . Activity Scope Ċ import Ġio . j ent z . w inter . android x . use Simple Android Adapter Ċ import Ġio . j ent z . w inter . empty Graph Ċ import Ġio . j ent z . w inter . junit 4 . W inter Rule Ċ import Ġio . kot lint est . matchers . boolean . shouldBe False Ċ import Ġio . kot lint est . matchers . boolean . shouldBe True Ċ import Ġio . kot lint est . matchers . types . shouldBe InstanceOf Ċ import Ġio . kot lint est . matchers . types . shouldBe Same Instance As Ċ import Ġorg . junit . Before Ċ import Ġorg . junit . Rule Ċ import Ġorg . junit . Test Ċ import Ġorg . junit . rules . External Resource Ċ import Ġorg . junit . rules . Rule Chain Ċ import Ġorg . junit . runner . RunWith Ċ Ċ @ Large Test Ċ @ RunWith ( Android JUnit 4 :: class ) Ċ class ĠSimple Android Injection Adapter Test Ġ{ ĊĊĠĠĠ Ġprivate Ġval Ġadapter Ġ= ĠSimple Android Injection Adapter ( W inter ) ĊĊĠĠĠ Ġprivate Ġval Ġw inter Rule Ġ= ĠW inter Rule Ġ{ ĊĠĠĠĠĠĠĠ Ġtest Graph ( Activity Scope :: class ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġprivate Ġval Ġactivity Scenario Rule Ġ= ĠActivity Scenario Rule ( Test Activity :: class . java ) ĊĊĠĠĠ Ġ@ get : Rule Ġval Ġrule : ĠRule Chain Ġ= ĠRule Chain ĊĠĠĠĠĠĠĠ Ġ. outer Rule ( object Ġ: ĠExternal Resource () Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġoverride Ġfun Ġbefore () Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġval Ġapplication : ĠApplication Ġ= ĠW inter . graph . instance () ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠW inter . close Graph () ĊĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠW inter . component Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġsub component ( Activity Scope :: class ) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠW inter . injection Adapter Ġ= Ġadapter ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠW inter . inject ( application ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠ Ġ}) ĊĠĠĠĠĠĠĠ Ġ. around ( w inter Rule ) ĊĠĠĠĠĠĠĠ Ġ. around ( activity Scenario Rule ) ĊĊĠĠĠ Ġprivate Ġlateinit Ġvar Ġscenario : ĠActivity Scenario < Test Activity > ĊĊĠĠĠ Ġ@ Before ĊĠĠĠ Ġfun ĠbeforeEach () Ġ{ ĊĠĠĠĠĠĠĠ Ġscenario Ġ= Ġactivity Scenario Rule . scenario ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġuse _ app _ extension _ should _ register _ adapter () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġapp Ġ= ĠW inter Application (). apply Ġ{ Ġuse Simple Android Adapter () Ġ} ĊĠĠĠĠĠĠĠ Ġapp . injection Adapter . shouldBe InstanceOf < Simple Android Injection Adapter >() ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġshould _ get _ application _ graph _ for _ application _ instance () Ġ{ ĊĠĠĠĠĠĠĠ Ġscenario . on Activity Ġ{ Ġactivity Ġ-> ĊĠĠĠĠĠĠĠĠĠĠĠ ĠW inter . graph . shouldBe Same Instance As ( adapter . get ( activity . application )) ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġshould _ get _ activity _ graph _ for _ activity _ instance () Ġ{ ĊĠĠĠĠĠĠĠ Ġscenario . on Activity Ġ{ Ġactivity Ġ-> ĊĠĠĠĠĠĠĠĠĠĠĠ Ġw inter Rule . require Test Graph . shouldBe Same Instance As ( adapter . get ( activity )) ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġshould _ close _ activity _ graph _ when _ activity _ gets _ destroy ed () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġgraph Ġ= Ġw inter Rule . require Test Graph ĊĊĠĠĠĠĠĠĠ Ġgraph . is Closed . shouldBe False () ĊĠĠĠĠĠĠĠ Ġscenario . moveTo State ( Lifecycle . State . DESTROY ED ) ĊĠĠĠĠĠĠĠ Ġgraph . is Closed . shouldBe True () ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġshould _ provide _ activity () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġgraph Ġ= Ġw inter Rule . require Test Graph ĊĠĠĠĠĠĠĠ Ġscenario . on Activity Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġgraph . instance < Activity >(). shouldBe Same Instance As ( it ) ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġshould _ provide _ lifecycle _ from _ activity () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġgraph Ġ= Ġw inter Rule . require Test Graph ĊĠĠĠĠĠĠĠ Ġscenario . on Activity Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġgraph . instance < Lifecycle >(). shouldBe Same Instance As ( it . lifecycle ) ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġshould _ provide _ activity _ as _ context () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġgraph Ġ= Ġw inter Rule . require Test Graph ĊĠĠĠĠĠĠĠ Ġscenario . on Activity Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġgraph . instance < Context >(). shouldBe Same Instance As ( it ) ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġshould _ get _ graph _ of _ view _ context _ for _ view _ instance () Ġ{ ĊĠĠĠĠĠĠĠ Ġscenario . on Activity Ġ{ Ġactivity Ġ-> ĊĠĠĠĠĠĠĠĠĠĠĠ Ġval Ġview Ġ= ĠView ( activity ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġw inter Rule . require Test Graph . shouldBe Same Instance As ( adapter . get ( view )) ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġshould _ get _ application _ graph _ for _ broadcast _ receiver _ instance () Ġ{ ĊĠĠĠĠĠĠĠ ĠW inter . graph . shouldBe Same Instance As ( adapter . get ( object Ġ: ĠBroadcast Receiver () Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġoverride Ġfun Ġon Receive ( context : ĠContext ?, Ġintent : ĠIntent ?) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠ Ġ})) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġshould _ get _ application _ graph _ for _ service _ instance () Ġ{ ĊĠĠĠĠĠĠĠ ĠW inter . graph . shouldBe Same Instance As ( adapter . get ( object Ġ: ĠService () Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġoverride Ġfun Ġon Bind ( intent : ĠIntent ?): ĠI Binder ? Ġ= Ġnull ĊĠĠĠĠĠĠĠ Ġ})) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġshould _ get _ application _ graph _ for _ content _ provider _ instance () Ġ{ ĊĠĠĠĠĠĠĠ ĠW inter . graph . shouldBe Same Instance As ( adapter . get ( File Provider ())) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġshould _ get _ graph _ from _ dependency _ graph _ context _ wrapper _ for _ context _ wrapper _ instance () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġgraph Ġ= Ġempty Graph () ĊĠĠĠĠĠĠĠ Ġscenario . on Activity Ġ{ Ġactivity Ġ-> ĊĠĠĠĠĠĠĠĠĠĠĠ Ġadapter . get ( Dependency Graph Context Wrapper ( activity , Ġgraph )) ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ. shouldBe Same Instance As ( graph ) ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} Ċ Ċ } Ċ