package Ġcom . github . ash ut osh g ng wr . no ice . widget Ċ Ċ import Ġorg . junit . Assert . assertEquals Ċ import Ġorg . junit . Assert . assertNot Equals Ċ import Ġorg . junit . Before Ċ import Ġorg . junit . Test Ċ import Ġorg . junit . runner . RunWith Ċ import Ġorg . ro bo lectric . Ro bo lectric TestRunner Ċ import Ġorg . ro bo lectric . Runtime Environment Ċ import Ġorg . ro bo lectric . shadow s . Shadow Looper Ċ Ċ @ RunWith ( Ro bo lectric TestRunner :: class ) Ċ class ĠCount down TextView Test Ġ{ ĊĊĠ Ġprivate Ġlateinit Ġvar Ġview : ĠCount down TextView ĊĊĠ Ġ@ Before ĊĠ Ġfun Ġsetup () Ġ{ ĊĠĠĠ Ġview Ġ= ĠCount down TextView ( Runtime Environment . system Context ) ĊĠ Ġ} ĊĊĠ Ġ@ Test ĊĠ Ġfun Ġtest With Zero Count down () Ġ{ ĊĠĠĠ Ġview . start Count down ( 0 L ) ĊĠĠĠ ĠassertEquals (" 0 0 h Ġ 0 0 m Ġ 0 0 s ", Ġview . text . toString ()) ĊĠ Ġ} ĊĊĠ Ġ@ Test ĊĠ Ġfun Ġtest With Non Zero Count down _ text On Start () Ġ{ ĊĠĠĠ Ġview . start Count down ( 3 6 6 1 0 0 0 L ) ĊĠĠĠ Ġassert Not Equals (" 0 0 h Ġ 0 0 m Ġ 0 s ", Ġview . text . toString ()) ĊĠ Ġ} ĊĊĠ Ġ@ Test ĊĠ Ġfun Ġtest With Non Zero Count down _ text Until Expiry () Ġ{ ĊĠĠĠ Ġview . start Count down ( 2 0 0 0 L ) ĊĠĠĠ ĠassertEquals (" 0 0 h Ġ 0 0 m Ġ 0 2 s ", Ġview . text . toString ()) ĊĊĠĠĠ Ġ// Ġbad Ġcode Ġahead : Ġexecute Ġdelayed Ġtasks Ġtwice Ġfor Ġ 1 Ġsec Ġl apse Ġsince ĠCount down TextView Ġhas Ġa ĊĠĠĠ Ġ// Ġrefresh Ġinterval Ġset Ġto Ġ 5 0 0 ms . ĊĠĠĠ ĠShadow Looper . run Ui Thread Tasks In cluding Delayed Tasks () ĊĠĠĠ ĠShadow Looper . run Ui Thread Tasks In cluding Delayed Tasks () ĊĠĠĠ ĠassertEquals (" 0 0 h Ġ 0 0 m Ġ 0 1 s ", Ġview . text . toString ()) ĊĊĠĠĠ ĠShadow Looper . run Ui Thread Tasks In cluding Delayed Tasks () ĊĠĠĠ ĠShadow Looper . run Ui Thread Tasks In cluding Delayed Tasks () ĊĠĠĠ ĠassertEquals (" 0 0 h Ġ 0 0 m Ġ 0 0 s ", Ġview . text . toString ()) ĊĠ Ġ} Ċ } Ċ