package Ġcom . jor ged gue zm . election s . ui Ċ Ċ import Ġandroid . content . Context Ċ import Ġandroid . content . Intent Ċ import Ġandroidx . test . core . app . Activity Scenario Ċ import Ġandroidx . test . core . app . Application Provider Ċ Ċ import Ġcom . jor ged gue zm . election s . utils . Constants . KEY _ CON G RESS Ċ import Ġcom . jor ged gue zm . election s . utils . Constants . KEY _ CON G RESS _ E LECTION Ċ import Ġcom . jor ged gue zm . election s . utils . Constants . KEY _ S EN ATE Ċ import Ġcom . jor ged gue zm . election s . utils . Constants . KEY _ S EN ATE _ E LECTION Ċ import Ġcom . jor ged gue zm . election s . utils . Utils Ċ import Ġcom . jor ged gue zm . election s . data . Data Utils Ċ import Ġcom . jor ged gue zm . election s . view . ui . detail . Detail Activity Ċ import Ġcom . jor ged gue zm . election s . view . ui . detail . Detail Fragment Ċ Ċ import Ġjunit . framework . TestCase .* Ċ Ċ 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 ĠDetail Activity Test Ġ{ ĊĊĠĠĠ Ġprivate Ġval Ġcontext Ġ= ĠApplication Provider . getApplicationContext < Context >() ĊĠĠĠ Ġprivate Ġval Ġutils Ġ= ĠUtils ( context ) ĊĠĠĠ Ġprivate Ġval Ġcon gress E lection Ġ= ĠData Utils . generate E lection ( KEY _ CON G RESS ) ĊĠĠĠ Ġprivate Ġval Ġs enate E lection Ġ= ĠData Utils . generate E lection ( KEY _ S EN ATE ) ĊĠĠĠ Ġprivate Ġval Ġintent Ġ= ĠIntent ( context , ĠDetail Activity :: class . java ). apply Ġ{ ĊĠĠĠĠĠĠĠ Ġput Extra ( KEY _ CON G RESS _ E LECTION , Ġcon gress E lection ) ĊĠĠĠĠĠĠĠ Ġput Extra ( KEY _ S EN ATE _ E LECTION , Ġs enate E lection ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġlaunch Detail Activity () Ġ{ ĊĠĠĠĠĠĠĠ ĠActivity Scenario . launch < Detail Activity >( intent ). use Ġ{ Ġscenario Ġ-> ĊĠĠĠĠĠĠĠĠĠĠĠ Ġscenario . on Activity Ġ{ Ġactivity Ġ-> ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠassertEquals ( activity . binding . toolbar . title , Ġutils . generate Toolbar Title ( con gress E lection )) ĊĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ// ĠC ong ress Ġresults Ġloaded ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠassertEquals ( con gress E lection . id , Ġactivity . current E lection . id ) ĊĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ// ĠC ong ress Ġoption Ġclicked ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġactivity . on Options ItemSelected ( activity . binding . toolbar . menu . getItem ( 0 )) ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠassertEquals ( con gress E lection . id , Ġactivity . current E lection . id ) ĊĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ// ĠS enate Ġoption Ġclicked ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġactivity . on Options ItemSelected ( activity . binding . toolbar . menu . getItem ( 1 )) ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠassertEquals ( activity . binding . toolbar . title , Ġutils . generate Toolbar Title ( sen ate E lection )) ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠassertEquals ( sen ate E lection . id , Ġactivity . current E lection . id ) ĊĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ// ĠS enate Ġoption Ġclicked Ġagain ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġactivity . on Options ItemSelected ( activity . binding . toolbar . menu . getItem ( 1 )) ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠassertEquals ( sen ate E lection . id , Ġactivity . current E lection . id ) ĊĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ// ĠC ong ress Ġoption Ġclicked ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġactivity . on Options ItemSelected ( activity . binding . toolbar . menu . getItem ( 0 )) ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠassertEquals ( con gress E lection . id , Ġactivity . current E lection . id ) ĊĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġval Ġfragment Ġ= Ġactivity . support FragmentManager . fragments [ 0 ] Ġas ĠDetail Fragment ĊĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ// ĠCheck Ġhighlight Ġfunction ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġfragment . binding . list View . on ItemClickListener ?. on Item Click ( null , Ġnull , Ġ 0 , Ġ 0 ) ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠassertTrue ( fragment . binding . pie Chart . highlighted . isNotEmpty ()) ĊĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġfragment . count Down Timer . on Tick ( 1 ) ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠassertTrue ( fragment . binding . pie Chart . highlighted . isNotEmpty ()) ĊĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġfragment . count Down Timer . on Finish () ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠassertNull ( fragment . binding . pie Chart . highlighted ) ĊĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġfragment . binding . floating Button More Info . perform Click () ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} Ċ }