package Ġcom . example . login ses ame čĊč Ċ import Ġandroid . app . Activity č Ċ import Ġandroid . content . Context č Ċ import Ġandroidx . room . Room č Ċ import Ġandroidx . test . core . app . Application Provider č Ċ import Ġandroidx . test . espress o . Esp ress o č Ċ import Ġandroidx . test . espress o . Esp ress o . close Soft Keyboard č Ċ import Ġandroidx . test . espress o . Esp ress o . on View č Ċ import Ġandroidx . test . espress o . action . View Actions č Ċ import Ġandroidx . test . espress o . assertion . View Assertions č Ċ import Ġandroidx . test . espress o . intent . Intent s č Ċ import Ġandroidx . test . espress o . matcher . View Matchers č Ċ import Ġandroidx . test . ext . junit . rules . Activity Scenario Rule č Ċ import Ġandroidx . test . ext . junit . runners . Android JUnit 4 č Ċ import Ġandroidx . test . platform . app . Instrumentation Registry č Ċ import Ġandroidx . test . runner . lifecycle . Activity Lifecycle Monitor Registry č Ċ import Ġandroidx . test . runner . lifecycle . Stage č Ċ import Ġcom . example . login ses ame . data . User č Ċ import Ġcom . example . login ses ame . data . User Database č Ċ import Ġcom . example . login ses ame . data . UserRepository č Ċ import Ġcom . example . login ses ame . data . Vault Entry č Ċ import Ġcom . example . login ses ame . helper . Log Assert č Ċ import Ġkotlinx . coroutines . Global Scope č Ċ import Ġkotlinx . coroutines . launch č Ċ import Ġorg . junit . After č Ċ import Ġorg . junit . Before č Ċ import Ġorg . junit . Rule č Ċ import Ġorg . junit . Test č Ċ import Ġorg . junit . runner . RunWith č Ċ import Ġjava . io . IOException čĊč Ċ @ RunWith ( Android JUnit 4 :: class ) č Ċ class ĠTest Edit Password č Ċ { čĊčĊĠĠĠ Ġprivate Ġlateinit Ġvar Ġdb : ĠUser Database čĊĠĠĠ Ġprivate Ġlateinit Ġvar Ġrepository : ĠUser Repository čĊĠĠĠ Ġprivate Ġvar Ġcurrent Activity : ĠActivity ? Ġ= Ġnull čĊčĊĠĠĠ Ġ@ Rule čĊĠĠĠ Ġ@ Jvm Field čĊĠĠĠ Ġval Ġrule : ĠActivity Scenario Rule < MainActivity > Ġ= ĠActivity Scenario Rule ( MainActivity :: class . java ) čĊčĊĠĠĠ Ġ@ Before čĊĠĠĠ Ġfun Ġinit Db () Ġ{ čĊĠĠĠĠĠĠĠ ĠInt ents . init () čĊĠĠĠĠĠĠĠ Ġval Ġcontext Ġ= ĠApplication Provider . getApplicationContext < Context >() čĊĠĠĠĠĠĠĠ Ġdb Ġ= ĠUser Database . init Db ( context ) čĊĠĠĠĠĠĠĠ Ġrepository Ġ= ĠUser Repository ( db . getUser Dao (), Ġdb . get Vault Entry Dao ()) čĊĠĠĠĠĠĠĠ Ġrepository . delete All Users () čĊĠĠĠĠĠĠĠ Ġrepository . delete All Entries () čĊčĊĠĠĠĠĠĠĠ ĠGlobal Scope . launch Ġ{ čĊĠĠĠĠĠĠĠĠĠĠĠ Ġval Ġuser Ġ= ĠUser ( 1 , Ġ" Max ĠM uster man ", Ġ" test @ mail . com ", Ġ" 1 2 3 4 5 6 7 8 9 ") čĊĠĠĠĠĠĠĠĠĠĠĠ Ġrepository . insert User ( user ) čĊčĊĠĠĠĠĠĠĠĠĠĠĠ Ġval Ġentity 1 Ġ= ĠVault Entry ( 1 , Ġ" account _ a ", Ġ" user _ a ", Ġ" url ", Ġ" password ") čĊĠĠĠĠĠĠĠĠĠĠĠ Ġrepository . insert Vault Entry ( entity 1 ) čĊĠĠĠĠĠĠĠĠĠĠĠ Ġval Ġentity 2 Ġ= ĠVault Entry ( 2 , Ġ" account _ b ", Ġ" user _ b ", Ġ" url ", Ġ" password ") čĊĠĠĠĠĠĠĠĠĠĠĠ Ġrepository . insert Vault Entry ( entity 2 ) čĊĠĠĠĠĠĠĠĠĠĠĠ Ġval Ġentity 3 Ġ= ĠVault Entry ( 3 , Ġ" account _ c ", Ġ" user _ c ", Ġ" url ", Ġ" password ") čĊĠĠĠĠĠĠĠĠĠĠĠ Ġrepository . insert Vault Entry ( entity 3 ) čĊĠĠĠĠĠĠĠĠĠĠĠ Ġval Ġentity 4 Ġ= ĠVault Entry ( 4 , Ġ" account _ d ", Ġ" user _ d ", Ġ" url ", Ġ" password ") čĊĠĠĠĠĠĠĠĠĠĠĠ Ġrepository . insert Vault Entry ( entity 4 ) čĊĠĠĠĠĠĠĠĠĠĠĠ Ġval Ġentity 5 Ġ= ĠVault Entry ( 5 , Ġ" account _ e ", Ġ" user _ e ", Ġ" url ", Ġ" password ") čĊĠĠĠĠĠĠĠĠĠĠĠ Ġrepository . insert Vault Entry ( entity 5 ) čĊĠĠĠĠĠĠĠ Ġ} čĊĠĠĠ Ġ} čĊčĊĠĠĠ Ġ@ After čĊĠĠĠ Ġ@ Throws ( IOException :: class ) čĊĠĠĠ Ġfun Ġcleanup () Ġ{ čĊĠĠĠĠĠĠĠ ĠInt ents . release () čĊĠĠĠĠĠĠĠ Ġrepository . delete All Entries () čĊĠĠĠĠĠĠĠ Ġrepository . delete All Users () čĊĠĠĠĠĠĠĠ Ġcurrent Activity Ġ= Ġnull čĊĠĠĠ Ġ} čĊčĊĠĠĠ Ġ@ Test čĊĠĠĠ Ġfun Ġtest Open Editor (){ čĊĠĠĠĠĠĠĠ Ġval Ġlog Assert Ġ= ĠLog Assert () čĊčĊĠĠĠĠĠĠĠ Ġon View ( View Matchers . with Id ( R . id . et Input Password )). perform ( View Actions . type Text (" 1 2 3 4 5 6 7 8 9 ")) čĊĠĠĠĠĠĠĠ Ġclose Soft Keyboard () čĊčĊĠĠĠĠĠĠĠ Ġon View ( View Matchers . with Id ( R . id . btn Input Password OK )). perform ( View Actions . click ()) čĊčĊĠĠĠĠĠĠĠ Ġon View ( View Matchers . with Text (" account _ b ")). perform ( View Actions . click ()) čĊĠĠĠĠĠĠĠ ĠThread . sleep ( 2 0 0 0 ) čĊĠĠĠĠĠĠĠ Ġval Ġassert Arr Ġ= ĠarrayOf (" Recycler ĠP ressed ĠPosition Ġ 1 ") čĊĠĠĠĠĠĠĠ Ġlog Assert . assert Logs Exist ( assert Arr ) čĊčĊčĊĠĠĠĠĠĠĠ Ġval Ġcurrent Activity Ġ= ĠgetActivity Instance () čĊĠĠĠĠĠĠĠ Ġval Ġcurrent Activity Name Ġ= Ġcurrent Activity ?. component Name ?. className čĊĠĠĠĠĠĠĠ Ġassert ( current Activity Name . toString (). equals (" com . example . login ses ame . Edit Vault Entry ")) čĊĠĠĠ Ġ} čĊčĊĠĠĠ Ġ@ Test čĊĠĠĠ Ġfun Ġtest Open Editor ViewData (){ čĊĠĠĠĠĠĠĠ Ġval Ġlog Assert Ġ= ĠLog Assert () čĊčĊĠĠĠĠĠĠĠ Ġon View ( View Matchers . with Id ( R . id . et Input Password )). perform ( View Actions . type Text (" 1 2 3 4 5 6 7 8 9 ")) čĊĠĠĠĠĠĠĠ Ġclose Soft Keyboard () čĊčĊĠĠĠĠĠĠĠ Ġon View ( View Matchers . with Id ( R . id . btn Input Password OK )). perform ( View Actions . click ()) čĊčĊĠĠĠĠĠĠĠ Ġon View ( View Matchers . with Text (" account _ b ")). perform ( View Actions . click ()) čĊĠĠĠĠĠĠĠ ĠThread . sleep ( 2 0 0 0 ) čĊĠĠĠĠĠĠĠ Ġval Ġassert Arr Ġ= ĠarrayOf (" Recycler ĠP ressed ĠPosition Ġ 1 ") čĊĠĠĠĠĠĠĠ Ġlog Assert . assert Logs Exist ( assert Arr ) čĊčĊĠĠĠĠĠĠĠ Ġ// check Ġif Ġdata Ġis Ġcorrect čĊĠĠĠĠĠĠĠ Ġon View ( View Matchers . with Id ( R . id . vault URL )) čĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. check ( View Assertions . matches ( View Matchers . with Text (" url "))) čĊĠĠĠĠĠĠĠ Ġon View ( View Matchers . with Id ( R . id . vault Username )) čĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. check ( View Assertions . matches ( View Matchers . with Text (" user _ b "))) čĊĠĠĠĠĠĠĠ Ġon View ( View Matchers . with Id ( R . id . vault name Entry )) čĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. check ( View Assertions . matches ( View Matchers . with Text (" account _ b "))) čĊĠĠĠĠĠĠĠ Ġon View ( View Matchers . with Id ( R . id . vault Password )) čĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. check ( View Assertions . matches ( View Matchers . with Text (" password "))) čĊčĊĠĠĠ Ġ} čĊčĊĠĠĠ Ġ@ Test čĊĠĠĠ Ġfun Ġtest SaveChanges (){ čĊĠĠĠĠĠĠĠ Ġon View ( View Matchers . with Id ( R . id . et Input Password )). perform ( View Actions . type Text (" 1 2 3 4 5 6 7 8 9 ")) čĊĠĠĠĠĠĠĠ Ġclose Soft Keyboard () čĊčĊĠĠĠĠĠĠĠ Ġon View ( View Matchers . with Id ( R . id . btn Input Password OK )). perform ( View Actions . click ()) čĊčĊĠĠĠĠĠĠĠ Ġon View ( View Matchers . with Text (" account _ b ")). perform ( View Actions . click ()) čĊĠĠĠĠĠĠĠ ĠThread . sleep ( 2 0 0 0 ) čĊčĊĠĠĠĠĠĠĠ Ġ// check Ġif Ġdata Ġis Ġcorrect čĊĠĠĠĠĠĠĠ Ġon View ( View Matchers . with Id ( R . id . vault URL )) čĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. check ( View Assertions . matches ( View Matchers . with Text (" url "))) čĊĠĠĠĠĠĠĠ Ġon View ( View Matchers . with Id ( R . id . vault Username )) čĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. check ( View Assertions . matches ( View Matchers . with Text (" user _ b "))) čĊĠĠĠĠĠĠĠ Ġon View ( View Matchers . with Id ( R . id . vault name Entry )) čĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. check ( View Assertions . matches ( View Matchers . with Text (" account _ b "))) čĊĠĠĠĠĠĠĠ Ġon View ( View Matchers . with Id ( R . id . vault Password )) čĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. check ( View Assertions . matches ( View Matchers . with Text (" password "))) čĊčĊĠĠĠĠĠĠĠ Ġ// overwrite Ġdata čĊĠĠĠĠĠĠĠ Ġon View ( View Matchers . with Id ( R . id . vault URL )) čĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. perform ( View Actions . clear Text ()). perform ( View Actions . type Text (" new ĠURL ")) čĊĠĠĠĠĠĠĠ Ġclose Soft Keyboard () čĊĠĠĠĠĠĠĠ Ġon View ( View Matchers . with Id ( R . id . vault Username )) čĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. perform ( View Actions . clear Text ()). perform ( View Actions . type Text (" new Ġuser Ġname ")) čĊĠĠĠĠĠĠĠ Ġclose Soft Keyboard () čĊĠĠĠĠĠĠĠ Ġon View ( View Matchers . with Id ( R . id . vault name Entry )) čĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. perform ( View Actions . clear Text ()). perform ( View Actions . type Text (" new Ġentry ")) čĊĠĠĠĠĠĠĠ Ġclose Soft Keyboard () čĊĠĠĠĠĠĠĠ Ġon View ( View Matchers . with Id ( R . id . vault Password )) čĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. perform ( View Actions . clear Text ()). perform ( View Actions . type Text (" new Ġpassword ")) čĊĠĠĠĠĠĠĠ Ġclose Soft Keyboard () čĊčĊĠĠĠĠĠĠĠ Ġ// save čĊĠĠĠĠĠĠĠ Ġon View ( View Matchers . with Id ( R . id . btn Vault Save )). perform ( View Actions . click ()) čĊčĊĠĠĠĠĠĠĠ Ġ// go Ġback Ġto ĠMain čĊĠĠĠĠĠĠĠ Ġon View ( View Matchers . with Text (" new Ġentry ")). perform ( View Actions . click ()) čĊčĊĠĠĠĠĠĠĠ Ġ// check Ġchanged Ġdata čĊĠĠĠĠĠĠĠ Ġon View ( View Matchers . with Id ( R . id . vault URL )) čĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. check ( View Assertions . matches ( View Matchers . with Text (" new ĠURL "))) čĊĠĠĠĠĠĠĠ Ġon View ( View Matchers . with Id ( R . id . vault Username )) čĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. check ( View Assertions . matches ( View Matchers . with Text (" new Ġuser Ġname "))) čĊĠĠĠĠĠĠĠ Ġon View ( View Matchers . with Id ( R . id . vault name Entry )) čĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. check ( View Assertions . matches ( View Matchers . with Text (" new Ġentry "))) čĊĠĠĠĠĠĠĠ Ġon View ( View Matchers . with Id ( R . id . vault Password )) čĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. check ( View Assertions . matches ( View Matchers . with Text (" new Ġpassword "))) čĊĠĠĠ Ġ} čĊčĊĠĠĠ Ġ@ Test čĊĠĠĠ Ġfun Ġtest SaveChanges No Password (){ čĊĠĠĠĠĠĠĠ Ġon View ( View Matchers . with Id ( R . id . et Input Password )). perform ( View Actions . type Text (" 1 2 3 4 5 6 7 8 9 ")) čĊĠĠĠĠĠĠĠ Ġclose Soft Keyboard () čĊčĊĠĠĠĠĠĠĠ Ġon View ( View Matchers . with Id ( R . id . btn Input Password OK )). perform ( View Actions . click ()) čĊčĊĠĠĠĠĠĠĠ Ġon View ( View Matchers . with Text (" account _ b ")). perform ( View Actions . click ()) čĊĠĠĠĠĠĠĠ ĠThread . sleep ( 2 0 0 0 ) čĊčĊĠĠĠĠĠĠĠ Ġ// overwrite Ġdata čĊĠĠĠĠĠĠĠ Ġon View ( View Matchers . with Id ( R . id . vault Password )) čĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. perform ( View Actions . clear Text ()) čĊčĊĠĠĠĠĠĠĠ Ġ// save čĊĠĠĠĠĠĠĠ Ġclose Soft Keyboard () čĊĠĠĠĠĠĠĠ Ġon View ( View Matchers . with Id ( R . id . btn Vault Save )). perform ( View Actions . click ()) čĊčĊĠĠĠĠĠĠĠ Ġ// check Ġchanged Ġdata čĊĠĠĠĠĠĠĠ Ġon View ( View Matchers . with Text ( R . string . vault _ save _ changes _ alert )). check ( čĊĠĠĠĠĠĠĠĠĠĠĠ ĠView Assertions . matches ( View Matchers . with Text (" Please Ġenter Ġa ĠPassword Ġto ĠSave Ġthe ĠChanges "))) čĊĠĠĠ Ġ} čĊčĊĠĠĠ Ġ@ Test čĊĠĠĠ Ġfun Ġtest Cancel No Changes (){ čĊĠĠĠĠĠĠĠ Ġon View ( View Matchers . with Id ( R . id . et Input Password )). perform ( View Actions . type Text (" 1 2 3 4 5 6 7 8 9 ")) čĊĠĠĠĠĠĠĠ Ġclose Soft Keyboard () čĊčĊĠĠĠĠĠĠĠ Ġon View ( View Matchers . with Id ( R . id . btn Input Password OK )). perform ( View Actions . click ()) čĊčĊĠĠĠĠĠĠĠ Ġon View ( View Matchers . with Text (" account _ b ")). perform ( View Actions . click ()) čĊĠĠĠĠĠĠĠ ĠThread . sleep ( 2 0 0 0 ) čĊčĊčĊĠĠĠĠĠĠĠ Ġ// cancel čĊĠĠĠĠĠĠĠ Ġclose Soft Keyboard () čĊĠĠĠĠĠĠĠ Ġon View ( View Matchers . with Id ( R . id . btn Vault Cancel )). perform ( View Actions . click ()) čĊčĊĠĠĠĠĠĠĠ Ġ// check čĊĠĠĠĠĠĠĠ Ġval Ġcurrent Activity Ġ= ĠgetActivity Instance () čĊĠĠĠĠĠĠĠ Ġval Ġcurrent Activity Name Ġ= Ġcurrent Activity ?. component Name ?. className čĊĠĠĠĠĠĠĠ Ġassert ( current Activity Name . toString (). equals (" com . example . login ses ame . MainActivity ")) čĊĠĠĠ Ġ} čĊčĊĠĠĠ Ġ@ Test čĊĠĠĠ Ġfun Ġtest Cancel With Changes No (){ čĊĠĠĠĠĠĠĠ Ġon View ( View Matchers . with Id ( R . id . et Input Password )). perform ( View Actions . type Text (" 1 2 3 4 5 6 7 8 9 ")) čĊĠĠĠĠĠĠĠ Ġclose Soft Keyboard () čĊčĊĠĠĠĠĠĠĠ Ġon View ( View Matchers . with Id ( R . id . btn Input Password OK )). perform ( View Actions . click ()) čĊčĊĠĠĠĠĠĠĠ Ġon View ( View Matchers . with Text (" account _ b ")). perform ( View Actions . click ()) čĊĠĠĠĠĠĠĠ ĠThread . sleep ( 2 0 0 0 ) čĊčĊĠĠĠĠĠĠĠ Ġ// change Ġdata čĊĠĠĠĠĠĠĠ Ġon View ( View Matchers . with Id ( R . id . vault URL )) čĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. perform ( View Actions . clear Text ()). perform ( View Actions . type Text (" new ĠURL ")) čĊčĊĠĠĠĠĠĠĠ Ġ// cancel čĊĠĠĠĠĠĠĠ Ġclose Soft Keyboard () čĊĠĠĠĠĠĠĠ Ġon View ( View Matchers . with Id ( R . id . btn Vault Cancel )). perform ( View Actions . click ()) čĊčĊĠĠĠĠĠĠĠ Ġ// check čĊĠĠĠĠĠĠĠ Ġon View ( View Matchers . with Text ( R . string . vault _ cancel _ changes _ alert )). check ( čĊĠĠĠĠĠĠĠĠĠĠĠ ĠView Assertions . matches ( View Matchers . with Text (" Are Ġyou Ġsure Ġyou Ġwant Ġto Ġdiscard Ġthe Ġchanges ? "))) čĊčĊĠĠĠĠĠĠĠ Ġon View ( View Matchers . with Text ( R . string . response _ negative )). perform ( View Actions . click ()) čĊčĊĠĠĠĠĠĠĠ Ġval Ġcurrent Activity Ġ= ĠgetActivity Instance () čĊĠĠĠĠĠĠĠ Ġval Ġcurrent Activity Name Ġ= Ġcurrent Activity ?. component Name ?. className čĊĠĠĠĠĠĠĠ Ġassert ( current Activity Name . toString (). equals (" com . example . login ses ame . Edit Vault Entry ")) čĊĠĠĠ Ġ} čĊčĊĠĠĠ Ġ@ Test čĊĠĠĠ Ġfun Ġtest Cancel With Changes Yes (){ čĊĠĠĠĠĠĠĠ Ġon View ( View Matchers . with Id ( R . id . et Input Password )). perform ( View Actions . type Text (" 1 2 3 4 5 6 7 8 9 ")) čĊĠĠĠĠĠĠĠ Ġclose Soft Keyboard () čĊčĊĠĠĠĠĠĠĠ Ġon View ( View Matchers . with Id ( R . id . btn Input Password OK )). perform ( View Actions . click ()) čĊčĊĠĠĠĠĠĠĠ Ġon View ( View Matchers . with Text (" account _ b ")). perform ( View Actions . click ()) čĊĠĠĠĠĠĠĠ ĠThread . sleep ( 2 0 0 0 ) čĊčĊĠĠĠĠĠĠĠ Ġ// change Ġdata čĊĠĠĠĠĠĠĠ Ġon View ( View Matchers . with Id ( R . id . vault URL )) čĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. perform ( View Actions . clear Text ()). perform ( View Actions . type Text (" new ĠURL ")) čĊčĊĠĠĠĠĠĠĠ Ġ// cancel čĊĠĠĠĠĠĠĠ Ġclose Soft Keyboard () čĊĠĠĠĠĠĠĠ Ġon View ( View Matchers . with Id ( R . id . btn Vault Cancel )). perform ( View Actions . click ()) čĊčĊĠĠĠĠĠĠĠ Ġ// check čĊĠĠĠĠĠĠĠ Ġon View ( View Matchers . with Text ( R . string . vault _ cancel _ changes _ alert )). check ( čĊĠĠĠĠĠĠĠĠĠĠĠ ĠView Assertions . matches ( View Matchers . with Text (" Are Ġyou Ġsure Ġyou Ġwant Ġto Ġdiscard Ġthe Ġchanges ? "))) čĊčĊĠĠĠĠĠĠĠ Ġon View ( View Matchers . with Text ( R . string . response _ positive )). perform ( View Actions . click ()) čĊčĊĠĠĠĠĠĠĠ Ġval Ġcurrent Activity Ġ= ĠgetActivity Instance () čĊĠĠĠĠĠĠĠ Ġval Ġcurrent Activity Name Ġ= Ġcurrent Activity ?. component Name ?. className čĊĠĠĠĠĠĠĠ Ġassert ( current Activity Name . toString (). equals (" com . example . login ses ame . MainActivity ")) čĊčĊĠĠĠĠĠĠĠ Ġ// go Ġback Ġto ĠMain čĊĠĠĠĠĠĠĠ Ġon View ( View Matchers . with Text (" account _ b ")). perform ( View Actions . click ()) čĊĠĠĠĠĠĠĠ ĠThread . sleep ( 1 0 0 0 ) čĊčĊĠĠĠĠĠĠĠ Ġ// check Ġunchanged Ġdata čĊĠĠĠĠĠĠĠ Ġon View ( View Matchers . with Id ( R . id . vault URL )) čĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. check ( View Assertions . matches ( View Matchers . with Text (" url "))) čĊĠĠĠĠĠĠĠ Ġon View ( View Matchers . with Id ( R . id . vault Username )) čĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. check ( View Assertions . matches ( View Matchers . with Text (" user _ b "))) čĊĠĠĠĠĠĠĠ Ġon View ( View Matchers . with Id ( R . id . vault name Entry )) čĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. check ( View Assertions . matches ( View Matchers . with Text (" account _ b "))) čĊĠĠĠĠĠĠĠ Ġon View ( View Matchers . with Id ( R . id . vault Password )) čĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. check ( View Assertions . matches ( View Matchers . with Text (" password "))) čĊĠĠĠ Ġ} čĊčĊĠĠĠ Ġ@ Test čĊĠĠĠ Ġfun Ġtest Back With Changed Data (){ čĊĠĠĠĠĠĠĠ Ġon View ( View Matchers . with Id ( R . id . et Input Password )). perform ( View Actions . type Text (" 1 2 3 4 5 6 7 8 9 ")) čĊĠĠĠĠĠĠĠ Ġclose Soft Keyboard () čĊčĊĠĠĠĠĠĠĠ Ġon View ( View Matchers . with Id ( R . id . btn Input Password OK )). perform ( View Actions . click ()) čĊčĊĠĠĠĠĠĠĠ Ġon View ( View Matchers . with Text (" account _ b ")). perform ( View Actions . click ()) čĊĠĠĠĠĠĠĠ ĠThread . sleep ( 2 0 0 0 ) čĊčĊĠĠĠĠĠĠĠ Ġ// change Ġdata čĊĠĠĠĠĠĠĠ Ġon View ( View Matchers . with Id ( R . id . vault URL )) čĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. perform ( View Actions . clear Text ()). perform ( View Actions . type Text (" new ĠURL ")) čĊčĊĠĠĠĠĠĠĠ Ġ// back Ġbutton čĊĠĠĠĠĠĠĠ Ġclose Soft Keyboard () čĊĠĠĠĠĠĠĠ ĠThread . sleep ( 1 0 0 0 ) čĊĠĠĠĠĠĠĠ ĠE sp ress o . press Back () čĊčĊĠĠĠĠĠĠĠ Ġ// check čĊĠĠĠĠĠĠĠ Ġon View ( View Matchers . with Text ( R . string . vault _ cancel _ changes _ alert )). check ( čĊĠĠĠĠĠĠĠĠĠĠĠ ĠView Assertions . matches ( View Matchers . with Text (" Are Ġyou Ġsure Ġyou Ġwant Ġto Ġdiscard Ġthe Ġchanges ? "))) čĊčĊĠĠĠĠĠĠĠ Ġon View ( View Matchers . with Text ( R . string . response _ negative )). perform ( View Actions . click ()) čĊčĊĠĠĠĠĠĠĠ Ġval Ġcurrent Activity Ġ= ĠgetActivity Instance () čĊĠĠĠĠĠĠĠ Ġval Ġcurrent Activity Name Ġ= Ġcurrent Activity ?. component Name ?. className čĊĠĠĠĠĠĠĠ Ġassert ( current Activity Name . toString (). equals (" com . example . login ses ame . Edit Vault Entry ")) čĊĠĠĠ Ġ} čĊčĊĠĠĠ Ġprivate Ġfun ĠgetActivity Instance (): ĠActivity ? Ġ{ čĊĠĠĠĠĠĠĠ ĠInstrument ation Registry . get Instrumentation (). run On Main Sync Ġ{ čĊĠĠĠĠĠĠĠĠĠĠĠ Ġval Ġres umed Activities : ĠCollection < *> Ġ= čĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠActivity Lifecycle Monitor Registry . getInstance (). get Activities In Stage ( Stage . RE SU MED ) čĊĠĠĠĠĠĠĠĠĠĠĠ Ġif Ġ( res umed Activities . iterator (). hasNext ()) Ġ{ čĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġcurrent Activity Ġ= Ġres umed Activities . iterator (). next () Ġas ĠActivity ? čĊĠĠĠĠĠĠĠĠĠĠĠ Ġ} čĊĠĠĠĠĠĠĠ Ġ} čĊĠĠĠĠĠĠĠ Ġreturn Ġcurrent Activity čĊĠĠĠ Ġ} čĊč Ċ } čĊ