package Ġcom . merc ad ol ib re . android . an des ui . text field code Ċ Ċ import Ġandroid . os . Build Ċ import Ġandroid . text . Editable Ċ import Ġandroid . text . Sp ann able StringBuilder Ċ import Ġcom . facebook . so loader . So Loader Ċ 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 Focus Management Ċ 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 . An des Text field Box Watcher Ċ import Ġcom . merc ad ol ib re . android . an des ui . text field . text watcher . An des Text field Box Watcher . Companion . DIR TY _ CHARACTER Ċ import Ġcom . n ha ar man . mock it ok otlin 2 .* Ċ import Ġorg . junit . Assert . assertEquals Ċ import Ġorg . junit . Before Ċ import Ġorg . junit . BeforeClass Ċ import Ġorg . junit . Test Ċ import Ġorg . junit . runner . RunWith Ċ import Ġorg . mockito . Mock Ċ import Ġorg . mockito . Mockito Annotations Ċ import Ġorg . ro bo lectric . Ro bo lectric TestRunner Ċ import Ġorg . ro bo lectric . annotation . Config Ċ Ċ @ RunWith ( Ro bo lectric TestRunner :: class ) Ċ @ Config ( sdk Ġ= Ġ[ Build . VERSION _ CODES . LO L LI POP ]) Ċ class ĠAn des Text field Box Watcher Test Ġ{ ĊĠĠĠ Ġ@ Mock ĊĠĠĠ Ġprivate Ġlateinit Ġvar Ġfocus Management : ĠAn des Code Focus Management ĊĠĠĠ Ġ@ Mock ĊĠĠĠ Ġprivate Ġlateinit Ġvar Ġcode TextChanged Handler : ĠAn des Code TextChanged Handler ĊĠĠĠ Ġprivate Ġlateinit Ġvar Ġeditable : ĠEdit able ĊĠĠĠ Ġprivate Ġlateinit Ġvar Ġtext field Box Watcher : ĠAn des Text field Box Watcher ĊĊĠĠĠ Ġcompanion Ġobject Ġ{ ĊĠĠĠĠĠĠĠ Ġ@ Jvm Static ĊĠĠĠĠĠĠĠ Ġ@ BeforeClass ĊĠĠĠĠĠĠĠ Ġfun Ġbefore Class () Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ ĠSo Loader . set In Test Mode () ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Before ĊĠĠĠ Ġfun ĠsetUp () Ġ{ ĊĠĠĠĠĠĠĠ ĠMockito Annotations . init Mocks ( this ) ĊĠĠĠĠĠĠĠ Ġeditable Ġ= ĠSp ann able StringBuilder () ĊĠĠĠĠĠĠĠ Ġtext field Box Watcher Ġ= ĠAn des Text field Box Watcher ( code TextChanged Handler , Ġfocus Management , Ġ 0 ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġ` when Ġsets Ġdirty Ġcharacter `() Ġ{ ĊĠĠĠĠĠĠĠ Ġeditable . insert ( 0 , ĠDIR TY _ CHARACTER ) ĊĠĠĠĠĠĠĠ Ġtext field Box Watcher . before TextChanged ("", Ġ 0 , Ġ 0 , Ġ 1 ) ĊĠĠĠĠĠĠĠ Ġtext field Box Watcher . on TextChanged ( DIR TY _ CHARACTER , Ġ 0 , Ġ 0 , Ġ 0 ) ĊĠĠĠĠĠĠĠ Ġtext field Box Watcher . after TextChanged ( editable ) ĊĠĠĠĠĠĠĠ Ġverify Zero Interactions ( code TextChanged Handler ) ĊĠĠĠĠĠĠĠ Ġverify Zero Interactions ( focus Management ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġ` when Ġsets Ġdirty Ġcharacter Ġwith Ġvalid Ġcharacter `() Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġtext Change Ġ= Ġ" 1 " ĊĠĠĠĠĠĠĠ Ġval Ġeditable Text Ġ= ĠDIR TY _ CHARACTER Ġ+ Ġtext Change ĊĠĠĠĠĠĠĠ Ġval Ġcapt or Ġ= Ġargument Captor < CharSequence >() ĊĠĠĠĠĠĠĠ Ġeditable . insert ( 0 , Ġeditable Text ) ĊĊĠĠĠĠĠĠĠ Ġtext field Box Watcher . before TextChanged ( DIR TY _ CHARACTER , Ġ 0 , Ġ 1 , Ġ 2 ) ĊĠĠĠĠĠĠĠ Ġtext field Box Watcher . on TextChanged ( editable Text , Ġ 0 , Ġ 0 , Ġ 0 ) ĊĠĠĠĠĠĠĠ Ġtext field Box Watcher . after TextChanged ( editable ) ĊĊĠĠĠĠĠĠĠ Ġverify ( code TextChanged Handler ). on TextChanged ( capt or . capture (), Ġany ()) ĊĠĠĠĠĠĠĠ ĠassertEquals ( text Change , Ġcapt or . first Value . toString ()) ĊĠĠĠĠĠĠĠ Ġverify ( focus Management ). goTo Next Focus () ĊĠĠĠĠĠĠĠ Ġverify No More Interactions ( focus Management ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġ` when Ġsets Ġonly Ġvalid Ġcharacter `() Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġexpected Ġ= Ġ" 1 " ĊĠĠĠĠĠĠĠ Ġval Ġcapt or Ġ= Ġargument Captor < CharSequence >() ĊĠĠĠĠĠĠĠ Ġeditable . insert ( 0 , Ġexpected ) ĊĊĠĠĠĠĠĠĠ Ġtext field Box Watcher . before TextChanged ("", Ġ 0 , Ġ 1 , Ġ 2 ) ĊĠĠĠĠĠĠĠ Ġtext field Box Watcher . on TextChanged ( expected , Ġ 0 , Ġ 0 , Ġ 0 ) ĊĠĠĠĠĠĠĠ Ġtext field Box Watcher . after TextChanged ( editable ) ĊĊĠĠĠĠĠĠĠ Ġverify ( code TextChanged Handler ). on TextChanged ( capt or . capture (), Ġany ()) ĊĠĠĠĠĠĠĠ ĠassertEquals ( expected , Ġcapt or . first Value . toString ()) ĊĠĠĠĠĠĠĠ Ġverify ( focus Management ). goTo Next Focus () ĊĠĠĠĠĠĠĠ Ġverify No More Interactions ( focus Management ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġ` when Ġdelete Ġvalid Ġcharacter Ġwith Ġdirty Ġcharacter `() Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġexpected Ġ= Ġ"" ĊĠĠĠĠĠĠĠ Ġval Ġcapt or Ġ= Ġargument Captor < CharSequence >() ĊĊĠĠĠĠĠĠĠ Ġeditable . insert ( 0 , ĠDIR TY _ CHARACTER ) ĊĊĠĠĠĠĠĠĠ Ġtext field Box Watcher . before TextChanged ( DIR TY _ CHARACTER Ġ+ Ġ" 1 ", Ġ 0 , Ġ 2 , Ġ 1 ) ĊĠĠĠĠĠĠĠ Ġtext field Box Watcher . on TextChanged ( DIR TY _ CHARACTER , Ġ 0 , Ġ 0 , Ġ 0 ) ĊĠĠĠĠĠĠĠ Ġtext field Box Watcher . after TextChanged ( editable ) ĊĊĠĠĠĠĠĠĠ Ġverify ( code TextChanged Handler ). on TextChanged ( capt or . capture (), Ġany ()) ĊĠĠĠĠĠĠĠ ĠassertEquals ( expected , Ġcapt or . first Value . toString ()) ĊĠĠĠĠĠĠĠ Ġverify Zero Interactions ( focus Management ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġ` when Ġdelete Ġdirty Ġcharacter `() Ġ{ ĊĠĠĠĠĠĠĠ Ġtext field Box Watcher Ġ= ĠAn des Text field Box Watcher ( code TextChanged Handler , Ġfocus Management , Ġ 1 ) ĊĠĠĠĠĠĠĠ Ġval Ġexpected Ġ= Ġ"" ĊĠĠĠĠĠĠĠ Ġeditable . insert ( 0 , Ġexpected ) ĊĊĠĠĠĠĠĠĠ Ġtext field Box Watcher . before TextChanged ( DIR TY _ CHARACTER , Ġ 0 , Ġ 1 , Ġ 0 ) ĊĠĠĠĠĠĠĠ Ġtext field Box Watcher . on TextChanged ( expected , Ġ 0 , Ġ 0 , Ġ 0 ) ĊĠĠĠĠĠĠĠ Ġtext field Box Watcher . after TextChanged ( editable ) ĊĊĠĠĠĠĠĠĠ Ġverify Zero Interactions ( code TextChanged Handler ) ĊĠĠĠĠĠĠĠ Ġverify ( focus Management ). goTo Previous Focus () ĊĠĠĠĠĠĠĠ Ġverify No More Interactions ( focus Management ) ĊĠĠĠ Ġ} Ċ }