package Ġcom . mapbox . maps . plugin . at tribution Ċ Ċ import Ġandroid . content . Context Ċ import Ġandroid . content . res . Typed Array Ċ import Ġandroid . graphics . Color Ċ import Ġandroid . util . Attribute Set Ċ import Ġandroid . view . Gravity Ċ import Ġandroid . view . View Ċ import Ġandroid . widget . Frame Layout Ċ import Ġcom . mapbox . maps . plugin . deleg ates . Map At tribution Delegate Ċ import Ġcom . mapbox . maps . plugin . deleg ates . Map Delegate Provider Ċ import Ġio . mock k .* Ċ import Ġorg . junit . After Ċ import Ġorg . junit . Assert . assertEquals Ċ import Ġorg . junit . Before Ċ import Ġorg . junit . Test Ċ import Ġorg . junit . runner . RunWith Ċ import Ġorg . ro bo lectric . Ro bo lectric TestRunner Ċ Ċ @ RunWith ( Ro bo lectric TestRunner :: class ) Ċ class ĠAt tribution View Plugin Impl Test Ġ{ ĊĊĠ Ġprivate Ġlateinit Ġvar Ġat tribution Plugin : ĠAt tribution Plugin ĊĠ Ġprivate Ġval Ġat tribution View Ġ= Ġmock k < At tribution View Impl >( relax Unit Fun Ġ= Ġtrue ) ĊĠ Ġprivate Ġval Ġdelegate Provider Ġ= Ġmock k < Map Delegate Provider >( relax ed Ġ= Ġtrue ) ĊĠ Ġprivate Ġval Ġmap At tribution Delegate Ġ= Ġmock k < Map At tribution Delegate >( relax ed Ġ= Ġtrue ) ĊĠ Ġprivate Ġval Ġclick S ot Ġ= Ġslot < View . OnClickListener >() ĊĠ Ġprivate Ġval Ġcontext : ĠContext Ġ= Ġmock k ( relax ed Ġ= Ġtrue ) ĊĠ Ġprivate Ġval Ġattrs : ĠAttributeSet Ġ= Ġmock k ( relax Unit Fun Ġ= Ġtrue ) ĊĠ Ġprivate Ġval Ġmap View Ġ= Ġmock k < Frame Layout >() ĊĠ Ġprivate Ġval Ġtyped Array : ĠTyped Array Ġ= Ġmock k ( relax Unit Fun Ġ= Ġtrue ) ĊĊĠ Ġ@ Before ĊĠ Ġfun ĠsetUp () Ġ{ ĊĠĠĠ Ġmock k Static ( Color :: class ) ĊĠĠĠ Ġevery Ġ{ ĠColor . parse Color ( any ()) Ġ} Ġreturns ĠColor . WHITE ĊĠĠĠ Ġevery Ġ{ Ġdelegate Provider . map At tribution Delegate Ġ} Ġreturns Ġmap At tribution Delegate ĊĠĠĠ Ġevery Ġ{ Ġmap View . context Ġ} Ġreturns Ġcontext ĊĠĠĠ Ġevery Ġ{ Ġcontext . obtain Styled Attributes ( any (), Ġany (), Ġ 0 , Ġ 0 ) Ġ} Ġreturns Ġtyped Array ĊĠĠĠ Ġevery Ġ{ Ġtyped Array . getBoolean ( any (), Ġany ()) Ġ} Ġreturns Ġtrue ĊĠĠĠ Ġevery Ġ{ Ġtyped Array . getColor ( any (), Ġany ()) Ġ} Ġreturns ĠColor . WHITE ĊĠĠĠ Ġevery Ġ{ Ġtyped Array . getInt ( any (), Ġany ()) Ġ} Ġreturns Ġ( Gravity . BOTTOM Ġor ĠGr avity . START ) ĊĠĠĠ Ġevery Ġ{ Ġtyped Array . get Dimension ( any (), Ġany ()) Ġ} Ġreturns Ġ 0 f ĊĊĠĠĠ Ġat tribution Plugin Ġ= ĠAt tribution View Plugin Ġ{ Ġat tribution View Ġ} ĊĠĠĠ Ġat tribution Plugin . on Delegate Provider ( delegate Provider ) ĊĠĠĠ Ġat tribution Plugin . bind ( map View , Ġattrs , Ġ 1 f ) ĊĠĠĠ Ġat tribution Plugin . on Plugin View ( at tribution View ) ĊĠĠĠ Ġverify Ġ{ ĊĠĠĠĠĠ Ġat tribution View . setOnClickListener ( capture ( click S ot )) ĊĠĠĠ Ġ} ĊĠĠĠ Ġat tribution Plugin . initialize () ĊĠ Ġ} ĊĊĠ Ġ@ After ĊĠ Ġfun Ġstop () Ġ{ ĊĠĠĠ Ġat tribution Plugin . on Stop () ĊĠ Ġ} ĊĊĠ Ġ@ Test ĊĠ Ġfun Ġat tribution Gravity () Ġ{ ĊĠĠĠ ĠassertEquals ( Gravity . BOTTOM Ġor ĠGr avity . START , Ġat tribution Plugin . position ) ĊĠĠĠ Ġat tribution Plugin . position Ġ= ĠGr avity . BOTTOM ĊĠĠĠ Ġverify Ġ{ Ġat tribution View . set Gravity ( Gravity . BOTTOM ) Ġ} ĊĠ Ġ} ĊĊĠ Ġ@ Test ĊĠ Ġfun Ġenabled () Ġ{ ĊĠĠĠ ĠassertEquals ( true , Ġat tribution Plugin . enabled ) ĊĠĠĠ Ġat tribution Plugin . enabled Ġ= Ġfalse ĊĠĠĠ Ġverify Ġ{ Ġat tribution View . set Enable ( false ) Ġ} ĊĠĠĠ Ġat tribution Plugin . enabled Ġ= Ġtrue ĊĠĠĠ Ġverify Ġ{ Ġat tribution View . set Enable ( true ) Ġ} ĊĠ Ġ} ĊĊĠ Ġ@ Test ĊĠ Ġfun Ġbind () Ġ{ ĊĠĠĠ Ġval Ġmap View Ġ= Ġmock k < Frame Layout >() ĊĠĠĠ Ġevery Ġ{ Ġmap View . context Ġ} Ġreturns Ġmock k ( relax ed Ġ= Ġtrue ) ĊĠĠĠ ĠassertEquals ( at tribution View , Ġat tribution Plugin . bind ( map View , Ġmock k ( relax ed Ġ= Ġtrue ), Ġ 1 . 0 f )) ĊĠ Ġ} ĊĊĠ Ġ@ Test ĊĠ Ġfun Ġset At tribution Margins () Ġ{ ĊĠĠĠ Ġat tribution Plugin . update Settings Ġ{ ĊĠĠĠĠĠ ĠmarginLeft Ġ= Ġ 0 f ; ĠmarginTop Ġ= Ġ 5 f ; ĠmarginRight Ġ= Ġ 0 f ; ĠmarginBottom Ġ= Ġ 0 f ĊĠĠĠ Ġ} ĊĠĠĠ Ġverify Ġ{ Ġat tribution View . set At tribution Margins ( 0 , Ġ 5 , Ġ 0 , Ġ 0 ) Ġ} ĊĠ Ġ} ĊĊĠ Ġ@ Test ĊĠ Ġfun Ġset Dialog Manager () Ġ{ ĊĠĠĠ Ġval Ġdialog Manager Ġ= Ġmock k < At tribution Dialog Manager >( relax ed Ġ= Ġtrue ) ĊĠĠĠ Ġat tribution Plugin . set Custom At tribution Dialog Manager ( dialog Manager ) ĊĠĠĠ Ġat tribution Plugin . click able Ġ= Ġfalse ĊĠĠĠ Ġclick S ot . captured . onClick ( at tribution View ) ĊĠĠĠ Ġverify ( exact ly Ġ= Ġ 0 ) Ġ{ Ġdialog Manager . show At tribution ( map At tribution Delegate ) Ġ} ĊĠĠĠ Ġat tribution Plugin . click able Ġ= Ġtrue ĊĠĠĠ Ġclick S ot . captured . onClick ( at tribution View ) ĊĠĠĠ Ġverify ( exact ly Ġ= Ġ 1 ) Ġ{ Ġdialog Manager . show At tribution ( map At tribution Delegate ) Ġ} ĊĠ Ġ} ĊĊĠ Ġ@ Test ĊĠ Ġfun Ġmap At tribution Delegate () Ġ{ ĊĠĠĠ ĠassertEquals ( map At tribution Delegate , Ġat tribution Plugin . getMap At tribution Delegate ()) ĊĠ Ġ} Ċ }