package Ġcom . stripe . android . view Ċ Ċ import Ġandroid . widget . Auto Complete TextView Ċ import Ġcom . stripe . android . R Ċ import Ġjava . util . Locale Ċ import Ġkotlin . test . After Test Ċ import Ġkotlin . test . Before Test Ċ import Ġkotlin . test . Test Ċ import Ġkotlin . test . assertEquals Ċ import Ġkotlin . test . assertFalse Ċ import Ġkotlin . test . assertNot Equals Ċ import Ġkotlin . test . assertNull Ċ import Ġkotlin . test . assertTrue Ċ import Ġorg . junit . runner . RunWith Ċ import Ġorg . mockito . Mockito Annotations Ċ import Ġorg . ro bo lectric . Ro bo lectric TestRunner Ċ Ċ /** Ċ Ġ* ĠTest Ġclass Ġfor Ġ[ Country Auto Complete TextView ] Ċ Ġ*/ Ċ @ RunWith ( Ro bo lectric TestRunner :: class ) Ċ class ĠCountry Auto Complete TextView Test Ġ: ĠBase View Test < Shipping Info Test Activity >( ĊĠĠĠ ĠSh ipping Info Test Activity :: class . java Ċ ) Ġ{ ĊĠĠĠ Ġprivate Ġlateinit Ġvar Ġcountry Auto Complete TextView : ĠCountry Auto Complete TextView ĊĠĠĠ Ġprivate Ġlateinit Ġvar Ġauto Complete TextView : ĠAuto Complete TextView ĊĊĠĠĠ Ġ@ Before Test ĊĠĠĠ Ġfun Ġsetup () Ġ{ ĊĠĠĠĠĠĠĠ ĠMockito Annotations . init Mocks ( this ) ĊĠĠĠĠĠĠĠ ĠLocale . setDefault ( Locale . US ) ĊĠĠĠĠĠĠĠ Ġcountry Auto Complete TextView Ġ= Ġcreate Started Activity () ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. findViewById ( R . id . country _ autocomplete _ a aw ) ĊĠĠĠĠĠĠĠ Ġauto Complete TextView Ġ= Ġcountry Auto Complete TextView ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. findViewById ( R . id . autocomplete _ country _ cat ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġcountry Auto Complete TextView _ when Initialized _ display s Default Locale DisplayName () Ġ{ ĊĠĠĠĠĠĠĠ ĠassertEquals ( Locale . US . country , Ġcountry Auto Complete TextView . selected CountryCode ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( Locale . US . display Country , Ġauto Complete TextView . text . toString ()) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġupdate UI For Country Entered _ when Invalid Country _ re verts To Last Country () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġprevious Valid CountryCode Ġ= Ġcountry Auto Complete TextView . selected CountryCode . or Empty () ĊĠĠĠĠĠĠĠ Ġcountry Auto Complete TextView . set Country Selected (" FA KE ĠCOUN TRY ĠCODE ") ĊĠĠĠĠĠĠĠ ĠassertNull ( auto Complete TextView . error ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( auto Complete TextView . text . toString (), ĊĠĠĠĠĠĠĠĠĠĠĠ ĠLocale ("", Ġprevious Valid CountryCode ). display Country ) ĊĠĠĠĠĠĠĠ Ġcountry Auto Complete TextView . set Country Selected ( Locale . UK . country ) ĊĠĠĠĠĠĠĠ Ġassert Not Equals ( auto Complete TextView . text . toString (), ĊĠĠĠĠĠĠĠĠĠĠĠ ĠLocale ("", Ġprevious Valid CountryCode ). display Country ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( auto Complete TextView . text . toString (), ĠLocale . UK . display Country ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġupdate UI For Country Entered _ when Valid Country _ UI Updates () Ġ{ ĊĠĠĠĠĠĠĠ ĠassertEquals ( Locale . US . country , Ġcountry Auto Complete TextView . selected CountryCode ) ĊĠĠĠĠĠĠĠ Ġcountry Auto Complete TextView . set Country Selected ( Locale . UK . country ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( Locale . UK . country , Ġcountry Auto Complete TextView . selected CountryCode ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġcountry Auto Complete TextView _ on Input Focus _ display DropDown () Ġ{ ĊĠĠĠĠĠĠĠ Ġauto Complete TextView . clear Focus () ĊĠĠĠĠĠĠĠ ĠassertFalse ( auto Complete TextView . is Popup Showing ) ĊĠĠĠĠĠĠĠ Ġauto Complete TextView . request Focus () ĊĠĠĠĠĠĠĠ ĠassertTrue ( auto Complete TextView . is Popup Showing ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġupdate UI For Country Entered _ when Country Selected Null And No Locale _ does Not Crash () Ġ{ ĊĠĠĠĠĠĠĠ ĠLocale . setDefault ( Locale . CH INA ) ĊĠĠĠĠĠĠĠ Ġcountry Auto Complete TextView . selected CountryCode Ġ= Ġnull ĊĠĠĠĠĠĠĠ Ġcountry Auto Complete TextView . update Ui For Country Entered ( null ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ After Test ĊĠĠĠ Ġfun Ġteardown () Ġ{ ĊĠĠĠĠĠĠĠ ĠLocale . setDefault ( Locale . US ) ĊĠĠĠ Ġ} Ċ } Ċ