/* Ċ Ġ* ĠCopyright Ġ 2 0 2 0 ĠGoogle ĠLLC . Ċ Ġ* Ċ Ġ* ĠThis Ġcode Ġmay Ġonly Ġbe Ġused Ġunder Ġthe ĠBSD Ġstyle Ġlicense Ġfound Ġat Ċ Ġ* Ġhttp :// polymer . github . io / LICENSE . txt Ċ Ġ* Ċ Ġ* ĠCode Ġdistributed Ġby ĠGoogle Ġas Ġpart Ġof Ġthis Ġproject Ġis Ġalso Ġsubject Ġto Ġan Ġadditional ĠIP Ġrights Ċ Ġ* Ġgrant Ġfound Ġat Ċ Ġ* Ġhttp :// polymer . github . io / PAT ENTS . txt Ċ Ġ*/ Ċ Ċ package Ġar cs . android . host Ċ Ċ import Ġandroid . content . Context Ċ import Ġandroidx . test . core . app . Application Provider Ċ import Ġandroidx . test . ext . junit . runners . Android JUnit 4 Ċ import Ġandroidx . work . testing . Work Manager Test Init Helper Ċ import Ġar cs . android . host . prod . Prod Arc Host Service Ċ import Ġar cs . android . sdk . host . to Component Name Ċ import Ġar cs . core . allocator . Allocator TestBase Ċ import Ġar cs . core . host . Testing Jvm Prod Host Ċ import Ġar cs . core . data . Capabilities Ċ import Ġar cs . core . data . Capability . Share able Ċ import Ġar cs . core . host . Arc Host Exception Ċ import Ġar cs . core . host . Arc State Ċ import Ġar cs . core . host . Host Registry Ċ import Ġar cs . core . host . Person Plan Ċ import Ġar cs . core . testutil . assert Sus pending Throws Ċ import Ġar cs . sdk . android . storage . service . testutil . Test ConnectionFactory Ċ import Ġcom . google . common . truth . Truth Ċ import Ġkotlinx . coroutines . Dispatch ers Ċ import Ġkotlinx . coroutines . Experimental Cor outines Api Ċ import Ġkotlinx . coroutines . Global Scope Ċ import Ġkotlinx . coroutines . launch Ċ import Ġkotlinx . coroutines . run Blocking Ċ import Ġorg . junit . Before Ċ import Ġorg . junit . Ignore Ċ import Ġorg . junit . Test Ċ import Ġorg . junit . runner . RunWith Ċ import Ġorg . ro bo lectric . Ro bo lectric Ċ Ċ /** Ċ Ġ* ĠThese Ġtests Ġare Ġthe Ġsame Ġas Ġ[ Allocator TestBase ] Ġbut Ġrun Ġwith ĠAndroid ĠServices , Ċ Ġ* Ġthe Ġreal Ġ[ Service Store ], Ġand Ġa Ġram disk . Ċ Ġ* Ċ Ġ*/ Ċ @ RunWith ( Android JUnit 4 :: class ) Ċ @ Opt In ( Experimental Cor outines Api :: class ) Ċ open Ġclass ĠAndroid Allocator Test Ġ: ĠAllocator TestBase () Ġ{ ĊĊĠĠĠ Ġprotected Ġlateinit Ġvar Ġcontext : ĠContext ĊĠĠĠ Ġprivate Ġlateinit Ġvar Ġreading Service : ĠTest Reading External Host Service ĊĠĠĠ Ġprivate Ġlateinit Ġvar Ġtest Prod Service : ĠPro d Arc Host Service ĊĠĠĠ Ġprivate Ġlateinit Ġvar Ġprod Service : ĠPro d Arc Host Service ĊĊĠĠĠ Ġprivate Ġlateinit Ġvar Ġwriting Service : ĠTest Writing External Host Service ĊĊĠĠĠ Ġoverride Ġsuspend Ġfun Ġhost Registry (): ĠHost Registry Ġ{ ĊĠĠĠĠĠĠĠ Ġreturn ĠAndroid Manifest Host Registry . create For Test ( context ) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ ĠGlobal Scope . launch ( Dispatch ers . Un conf ined ) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġval Ġreading Component Name Ġ= ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠTest Reading External Host Service :: class . to Component Name ( context ) ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġval Ġtest Prod Component Name Ġ= ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠTest Prod Arc Host Service :: class . to Component Name ( context ) ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġval Ġprod Component Name Ġ= ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠPro d Arc Host Service :: class . to Component Name ( context ) ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġval Ġwriting Component Name Ġ= ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠTest Writing External Host Service :: class . to Component Name ( context ) ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġwhen Ġ( it . component ) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġreading Component Name Ġ-> Ġreading Service ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġtest Prod Component Name Ġ-> Ġtest Prod Service ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġprod Component Name Ġ-> Ġprod Service ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġwriting Component Name Ġ-> Ġwriting Service ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġelse Ġ-> Ġthrow ĠIllegalArgumentException (" Unknown Ġ${ it . component }") ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ}. onStart Command ( it , Ġ 0 , Ġ 0 ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġoverride Ġfun Ġreading Host () Ġ= Ġreading Service . arc Host ĊĠĠĠ Ġoverride Ġfun Ġwriting Host () Ġ= Ġwriting Service . arc Host ĊĠĠĠ Ġoverride Ġfun Ġpure Host () Ġ= Ġtest Prod Service . arc Host Ġas ĠTesting Jvm Prod Host ĊĊĠĠĠ Ġ// ĠTODO : Ġwire Ġup Ġsome Ġkind Ġof Ġmock Ġpersistent Ġdatabase ? ĊĠĠĠ Ġoverride Ġval Ġstorage Capability Ġ= ĠCap abilities ( Share able ( true )) ĊĊĠĠĠ Ġ@ Before ĊĠĠĠ Ġoverride Ġfun ĠsetUp () Ġ= Ġrun Blocking Ġ{ ĊĠĠĠĠĠĠĠ Ġcontext Ġ= ĠApplication Provider . getApplicationContext () ĊĠĠĠĠĠĠĠ Ġcontext . set Theme ( R . style . Theme _ AppCompat ); ĊĊĠĠĠĠĠĠĠ Ġ// ĠInitialize ĠWork Manager Ġfor Ġinstrument ation Ġtests . ĊĠĠĠĠĠĠĠ ĠWork Manager Test Init Helper . initialize Test Work Manager ( context ) ĊĊĠĠĠĠĠĠĠ ĠTest External Arc Host Service . test ConnectionFactory Ġ= ĠTest ConnectionFactory ( context ) ĊĠĠĠĠĠĠĠ Ġreading Service Ġ= ĠRo bo lectric . setup Service ( Test Reading External Host Service :: class . java ) ĊĠĠĠĠĠĠĠ Ġwriting Service Ġ= ĠRo bo lectric . setup Service ( Test Writing External Host Service :: class . java ) ĊĠĠĠĠĠĠĠ Ġtest Prod Service Ġ= ĠRo bo lectric . setup Service ( Test Prod Arc Host Service :: class . java ) ĊĠĠĠĠĠĠĠ Ġprod Service Ġ= ĠRo bo lectric . setup Service ( Prod Arc Host Service :: class . java ) ĊĊĠĠĠĠĠĠĠ Ġsuper . setUp () ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Ignore (" b / 1 5 4 9 4 7 3 9 0 Ġ- ĠDe flake ") ĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġallocator _ start Arc _ throws Exception () Ġ= Ġrun Allocator Test Ġ{ ĊĠĠĠĠĠĠĠ Ġwriting Host (). throws Ġ= Ġtrue ĊĊĠĠĠĠĠĠĠ Ġassert Sus pending Throws ( Arc Host Exception :: class ) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġallocator . start Arc For Plan ( Person Plan ). waitFor Start () ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Ignore (" b / 1 5 4 9 4 7 3 9 0 Ġ- ĠDe flake ") ĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġoverride Ġfun Ġallocator _ does nt Create Arc s On Duplicate Start Arc () Ġ{ ĊĠĠĠĠĠĠĠ Ġsuper . allocator _ does nt Create Arc s On Duplicate Start Arc () ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Ignore (" b / 1 5 4 9 4 7 3 9 0 Ġ- ĠDe flake ") ĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġoverride Ġfun Ġallocator _ start From One Allocator And Stop In Another () Ġ{ ĊĠĠĠĠĠĠĠ Ġsuper . allocator _ start From One Allocator And Stop In Another () ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Ignore (" b / 1 5 4 9 4 7 3 9 0 Ġ- ĠDe flake ") ĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġoverride Ġfun Ġallocator _ verify Storage Keys Not Over written () Ġ{ ĊĠĠĠĠĠĠĠ Ġsuper . allocator _ verify Storage Keys Not Over written () ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Ignore (" b / 1 5 4 9 4 7 3 9 0 Ġ- ĠDe flake ") ĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġoverride Ġfun Ġallocator _ verify Arc Host Start Called () Ġ{ ĊĠĠĠĠĠĠĠ Ġsuper . allocator _ verify Arc Host Start Called () ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Ignore (" b / 1 5 4 9 4 7 3 9 0 Ġ- ĠDe flake ") ĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġoverride Ġfun Ġallocator _ restart Arc In Two External Hosts () Ġ{ ĊĠĠĠĠĠĠĠ Ġsuper . allocator _ restart Arc In Two External Hosts () ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Ignore (" b / 1 5 4 9 4 7 3 9 0 Ġ- ĠDe flake ") ĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġoverride Ġfun Ġallocator _ can Start Arc In Two External Hosts () Ġ{ ĊĠĠĠĠĠĠĠ Ġsuper . allocator _ can Start Arc In Two External Hosts () ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Ignore (" b / 1 5 4 9 4 7 3 9 0 Ġ- ĠDe flake ") ĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġoverride Ġfun Ġallocator _ compute Partitions () Ġ{ ĊĠĠĠĠĠĠĠ Ġsuper . allocator _ compute Partitions () ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Ignore (" b / 1 5 4 9 4 7 3 9 0 Ġ- ĠDe flake ") ĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġoverride Ġfun Ġallocator _ verify Storage Keys Created () Ġ{ ĊĠĠĠĠĠĠĠ Ġsuper . allocator _ verify Storage Keys Created () ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Ignore (" b / 1 5 4 9 4 7 3 9 0 Ġ- ĠDe flake ") ĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġoverride Ġfun Ġallocator _ start Arc _ particle Exception _ isError State () Ġ{ ĊĠĠĠĠĠĠĠ Ġsuper . allocator _ start Arc _ particle Exception _ isError State () ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Ignore (" b / 1 5 7 2 6 6 4 4 4 Ġ- ĠDe flake ") ĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġoverride Ġfun Ġallocator _ can Stop Arc In Two External Hosts () Ġ{ ĊĠĠĠĠĠĠĠ Ġsuper . allocator _ can Stop Arc In Two External Hosts () ĊĠĠĠ Ġ} Ċ } Ċ