package Ġcom . merc ad ol ib re . android . an des ui . text field code Ċ Ċ import Ġandroid . os . Build Ċ import Ġcom . merc ad ol ib re . android . an des ui . Build Config Ċ import Ġcom . merc ad ol ib re . android . an des ui . text field . text watcher . An des Code TextChanged Handler Ċ import Ġcom . merc ad ol ib re . android . an des ui . text field . text watcher . OnChange Ċ import Ġcom . merc ad ol ib re . android . an des ui . text field . text watcher . On Complete Ċ import Ġcom . n ha ar man . mock it ok otlin 2 .* Ċ import Ġorg . junit . Before Ċ import Ġorg . junit . Test Ċ import Ġorg . junit . runner . RunWith Ċ import Ġorg . mockito . Mock Ċ import Ġorg . mockito . junit . Mockito JUnit Runner Ċ import Ġorg . ro bo lectric . annotation . Config Ċ Ċ @ RunWith ( Mockito JUnit Runner :: class ) Ċ @ Config ( sdk Ġ= Ġ[ Build . VERSION _ CODES . LO L LI POP ]) Ċ class ĠAn des Code TextChanged Handler Test Ġ{ ĊĊĠĠĠ Ġ@ Mock Ġprivate Ġlateinit Ġvar ĠonComplete : ĠOn Complete ĊĠĠĠ Ġ@ Mock Ġprivate Ġlateinit Ġvar ĠonChange : ĠOn Change ĊĠĠĠ Ġprivate Ġlateinit Ġvar Ġcode TextChanged Handler : ĠAn des Code TextChanged Handler ĊĊĠĠĠ Ġ@ Before ĊĠĠĠ Ġfun ĠsetUp () Ġ{ ĊĠĠĠĠĠĠĠ Ġcode TextChanged Handler Ġ= ĠAn des Code TextChanged Handler ( 3 , ĠonChange , ĠonComplete ) ĊĠĠĠĠĠĠĠ Ġcode TextChanged Handler . on TextChanged (" 1 ", Ġ 0 ) ĊĠĠĠĠĠĠĠ Ġcode TextChanged Handler . on TextChanged (" 2 ", Ġ 1 ) ĊĠĠĠĠĠĠĠ Ġcode TextChanged Handler . on TextChanged (" 3 ", Ġ 2 ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġ` on Ġchange Ġcalled `() Ġ{ ĊĠĠĠĠĠĠĠ Ġverify ( onChange , Ġtimes ( 3 )). invoke ( any ()) ĊĠĠĠĠĠĠĠ Ġverify No More Interactions ( onChange ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġ` on Ġcomplete Ġcalled `() Ġ{ ĊĠĠĠĠĠĠĠ Ġverify ( onComplete , Ġtimes ( 2 )). invoke ( false ) ĊĠĠĠĠĠĠĠ Ġverify ( onComplete , Ġtimes ( 1 )). invoke ( true ) ĊĠĠĠĠĠĠĠ Ġverify No More Interactions ( onComplete ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġ` without Ġinteractions `() Ġ{ ĊĠĠĠĠĠĠĠ Ġcode TextChanged Handler . on TextChanged (" 1 ", Ġ 0 ) ĊĠĠĠĠĠĠĠ Ġcode TextChanged Handler . on TextChanged (" 2 ", Ġ 1 ) ĊĠĠĠĠĠĠĠ Ġcode TextChanged Handler . on TextChanged (" 3 ", Ġ 2 ) ĊĠĠĠĠĠĠĠ Ġverify ( onChange , Ġtimes ( 3 )). invoke ( any ()) ĊĠĠĠĠĠĠĠ Ġverify ( onComplete , Ġtimes ( 2 )). invoke ( false ) ĊĠĠĠĠĠĠĠ Ġverify ( onComplete , Ġtimes ( 1 )). invoke ( true ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġ` reset Ġhandler `() Ġ{ ĊĠĠĠĠĠĠĠ Ġcode TextChanged Handler . reset ( 0 ) ĊĠĠĠĠĠĠĠ Ġcode TextChanged Handler . on TextChanged (" 1 ", Ġ 0 ) ĊĠĠĠĠĠĠĠ Ġcode TextChanged Handler . on TextChanged (" 2 ", Ġ 1 ) ĊĠĠĠĠĠĠĠ Ġcode TextChanged Handler . on TextChanged (" 3 ", Ġ 2 ) ĊĠĠĠĠĠĠĠ Ġverify ( onChange , Ġtimes ( 6 )). invoke ( any ()) ĊĠĠĠĠĠĠĠ Ġverify ( onComplete , Ġtimes ( 4 )). invoke ( false ) ĊĠĠĠĠĠĠĠ Ġverify ( onComplete , Ġtimes ( 2 )). invoke ( true ) ĊĠĠĠ Ġ} Ċ Ċ }