package Ġcom . stripe . android . view Ċ Ċ import Ġandroid . graphics . Color Ċ import Ġandroidx . annotation . Color Int Ċ import Ġandroidx . test . core . app . Application Provider Ċ import Ġcom . google . common . truth . Truth . assertThat Ċ import Ġcom . n ha ar man . mock it ok otlin 2 . mock Ċ import Ġcom . stripe . android . Customer Session Ċ import Ġcom . stripe . android . Payment Session Fixtures Ċ import Ġkotlin . test . Before Test Ċ import Ġkotlin . test . Test Ċ import Ġkotlin . test . assertFalse Ċ import Ġkotlin . test . assertTrue Ċ import Ġorg . junit . runner . RunWith Ċ import Ġorg . ro bo lectric . Ro bo lectric TestRunner Ċ Ċ @ RunWith ( Ro bo lectric TestRunner :: class ) Ċ internal Ġclass ĠStripe Color UtilsTest Ġ{ ĊĠĠĠ Ġprivate Ġval Ġactivity Scenario Factory Ġ= ĠActivity Scenario Factory ( ĊĠĠĠĠĠĠĠ ĠApplication Provider . getApplicationContext () ĊĠĠĠ Ġ) ĊĊĠĠĠ Ġ@ Before Test ĊĠĠĠ Ġfun Ġsetup () Ġ{ ĊĠĠĠĠĠĠĠ ĠCustomer Session . instance Ġ= Ġmock () ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġget Theme Accent Color _ gets Non zero Color () Ġ{ ĊĠĠĠĠĠĠĠ Ġactivity Scenario Factory . create < Payment Flow Activity >( ĊĠĠĠĠĠĠĠĠĠĠĠ ĠPayment Session Fixtures . PAYMENT _ FLOW _ ARGS ĊĠĠĠĠĠĠĠ Ġ). use Ġ{ Ġactivity Scenario Ġ-> ĊĠĠĠĠĠĠĠĠĠĠĠ Ġactivity Scenario . on Activity Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠassertThat ( Color . alpha ( Stripe Color Utils ( it ). color Accent )) ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ. is GreaterThan ( 0 ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġget Theme Color Control Normal _ gets Non zero Color () Ġ{ ĊĠĠĠĠĠĠĠ Ġactivity Scenario Factory . create < Payment Flow Activity >( ĊĠĠĠĠĠĠĠĠĠĠĠ ĠPayment Session Fixtures . PAYMENT _ FLOW _ ARGS ĊĠĠĠĠĠĠĠ Ġ). use Ġ{ Ġactivity Scenario Ġ-> ĊĠĠĠĠĠĠĠĠĠĠĠ Ġactivity Scenario . on Activity Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠassertThat ( Color . alpha ( Stripe Color Utils ( it ). color Control Normal )) ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ. is GreaterThan ( 0 ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġis Color Transparent _ when Color Is Zero _ returns True () Ġ{ ĊĠĠĠĠĠĠĠ ĠassertTrue ( Stripe Color Utils . is Color Transparent ( 0 )) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġis Color Transparent _ when Color Is Non zero But Has Low Alpha _ returns True () Ġ{ ĊĠĠĠĠĠĠĠ Ġ@ Color Int Ġval Ġinvisible Blue Ġ= Ġ 0 x 0 5 0 0 0 0 ff ĊĠĠĠĠĠĠĠ Ġ@ Color Int Ġval Ġinvisible Red Ġ= Ġ 0 x 0 bff 0 0 0 0 ĊĊĠĠĠĠĠĠĠ ĠassertTrue ( Stripe Color Utils . is Color Transparent ( invisible Blue )) ĊĠĠĠĠĠĠĠ ĠassertTrue ( Stripe Color Utils . is Color Transparent ( invisible Red )) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġis Color Transparent _ when Color IsNot Close To Transparent _ returns False () Ġ{ ĊĠĠĠĠĠĠĠ Ġ@ Color Int Ġval Ġbright White Ġ= Ġ- 0 x 1 ĊĠĠĠĠĠĠĠ Ġ@ Color Int Ġval Ġcompletely Black Ġ= Ġ- 0 x 1 0 0 0 0 0 0 ĊĊĠĠĠĠĠĠĠ ĠassertFalse ( Stripe Color Utils . is Color Transparent ( bright White )) ĊĠĠĠĠĠĠĠ ĠassertFalse ( Stripe Color Utils . is Color Transparent ( comp let ely Black )) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġis Color Dark _ for Example Light Colors _ returns False () Ġ{ ĊĠĠĠĠĠĠĠ Ġ@ Color Int Ġval Ġmiddle Gray Ġ= Ġ 0 x 8 8 8 8 8 8 ĊĠĠĠĠĠĠĠ Ġ@ Color Int Ġval Ġoff White Ġ= Ġ 0 xfa ebd 7 ĊĠĠĠĠĠĠĠ Ġ@ Color Int Ġval Ġlight C yan Ġ= Ġ 0 x 8 fe ffb ĊĠĠĠĠĠĠĠ Ġ@ Color Int Ġval Ġlight Yellow Ġ= Ġ 0 xf cf 4 b 2 ĊĠĠĠĠĠĠĠ Ġ@ Color Int Ġval Ġlight Blue Ġ= Ġ 0 x 9 cdb ff ĊĊĠĠĠĠĠĠĠ ĠassertFalse ( Stripe Color Utils . is Color Dark ( middle Gray )) ĊĠĠĠĠĠĠĠ ĠassertFalse ( Stripe Color Utils . is Color Dark ( off White )) ĊĠĠĠĠĠĠĠ ĠassertFalse ( Stripe Color Utils . is Color Dark ( light C yan )) ĊĠĠĠĠĠĠĠ ĠassertFalse ( Stripe Color Utils . is Color Dark ( light Yellow )) ĊĠĠĠĠĠĠĠ ĠassertFalse ( Stripe Color Utils . is Color Dark ( light Blue )) ĊĠĠĠĠĠĠĠ ĠassertFalse ( Stripe Color Utils . is Color Dark ( Color . WHITE )) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġis Color Dark _ for Example Dark Colors _ returns True () Ġ{ ĊĠĠĠĠĠĠĠ Ġ@ Color Int Ġval Ġlogo Blue Ġ= Ġ 0 x 6 7 7 2 e 5 ĊĠĠĠĠĠĠĠ Ġ@ Color Int Ġval Ġs late Ġ= Ġ 0 x 5 2 5 f 7 f ĊĠĠĠĠĠĠĠ Ġ@ Color Int Ġval Ġdark Pur ple Ġ= Ġ 0 x 6 b 3 7 9 1 ĊĠĠĠĠĠĠĠ Ġ@ Color Int Ġval Ġdark ish Red Ġ= Ġ 0 x 9 e 2 1 4 6 ĊĊĠĠĠĠĠĠĠ ĠassertTrue ( Stripe Color Utils . is Color Dark ( logo Blue )) ĊĠĠĠĠĠĠĠ ĠassertTrue ( Stripe Color Utils . is Color Dark ( s late )) ĊĠĠĠĠĠĠĠ ĠassertTrue ( Stripe Color Utils . is Color Dark ( dark Pur ple )) ĊĠĠĠĠĠĠĠ ĠassertTrue ( Stripe Color Utils . is Color Dark ( dark ish Red )) ĊĠĠĠĠĠĠĠ ĠassertTrue ( Stripe Color Utils . is Color Dark ( Color . BLACK )) ĊĠĠĠ Ġ} Ċ } Ċ