package Ġca . c ply on . co int ime . ui Ċ Ċ import Ġandroidx . test . espress o . Esp ress o . on View Ċ import Ġandroidx . test . espress o . action . View Actions . click Ċ import Ġandroidx . test . espress o . assertion . View Assertions . does NotExist Ċ import Ġandroidx . test . espress o . assertion . View Assertions . matches Ċ import Ġandroidx . test . espress o . matcher . View Matchers . is Displayed Ċ import Ġandroidx . test . espress o . matcher . View Matchers . isEnabled Ċ import Ġandroidx . test . espress o . matcher . View Matchers . with Id Ċ import Ġandroidx . test . ext . junit . rules . Activity Scenario Rule Ċ import Ġandroidx . test . ext . junit . runners . Android JUnit 4 Ċ import Ġandroidx . test . filters . Large Test Ċ import Ġca . c ply on . co int ime . MainActivity Ċ import Ġca . c ply on . co int ime . R Ċ import Ġorg . hamcrest . Matchers . not Ċ import Ġorg . junit . Rule Ċ import Ġorg . junit . Test Ċ import Ġorg . junit . runner . RunWith Ċ Ċ @ RunWith ( Android JUnit 4 :: class ) Ċ @ Large Test Ċ class ĠMainActivity Esp ress o Test Ġ{ ĊĠĠĠ Ġ@ get : Rule ĊĠĠĠ Ġval Ġactivity Rule Ġ= ĠActivity Scenario Rule ( MainActivity :: class . java ) ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġsearch _ menu _ item _ exists _ test () Ġ{ ĊĠĠĠĠĠĠĠ Ġ// Ġensure Ġthe Ġsearch Ġmenu Ġis Ġpresent Ġon Ġthe Ġlist Ġview ĊĠĠĠĠĠĠĠ Ġon View ( with Id ( R . id . action _ search )). check ( matches ( is Displayed ())) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġsave _ menu _ item _ exists _ test () Ġ{ ĊĠĠĠĠĠĠĠ Ġ// Ġopen Ġthe Ġdetail Ġview Ġby Ġtriggering Ġthe ĠF AB Ġ( new Ġcoin ) ĊĠĠĠĠĠĠĠ Ġ// Ġensure Ġthe Ġsave Ġmenu Ġitem Ġis Ġpresent Ġand Ġenabled ĊĠĠĠĠĠĠĠ Ġon View ( with Id ( R . id . add _ coin _ fab )). perform ( click ()) ĊĠĠĠĠĠĠĠ Ġon View ( with Id ( R . id . action _ save )). check ( matches ( is Displayed ())) ĊĠĠĠĠĠĠĠ Ġon View ( with Id ( R . id . action _ save )). check ( matches ( isEnabled ())) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġedit _ menu _ item _ exists _ test () Ġ{ ĊĠĠĠĠĠĠĠ Ġ// Ġopen Ġthe Ġdetail Ġview Ġby Ġtriggering Ġthe ĠF AB Ġ( new Ġcoin ) ĊĠĠĠĠĠĠĠ Ġ// Ġensure Ġthe Ġedit Ġmenu Ġitem Ġis Ġnot Ġpresent ĊĠĠĠĠĠĠĠ Ġon View ( with Id ( R . id . add _ coin _ fab )). perform ( click ()) ĊĠĠĠĠĠĠĠ Ġon View ( with Id ( R . id . action _ edit )). check ( does NotExist ()) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġdelete _ menu _ item _ exists _ test () Ġ{ ĊĠĠĠĠĠĠĠ Ġ// Ġopen Ġthe Ġdetail Ġview Ġby Ġtriggering Ġthe ĠF AB Ġ( new Ġcoin ) ĊĠĠĠĠĠĠĠ Ġ// Ġensure Ġthe Ġdelete Ġmenu Ġitem Ġis Ġpresent Ġand Ġenabled ĊĠĠĠĠĠĠĠ Ġon View ( with Id ( R . id . add _ coin _ fab )). perform ( click ()) ĊĠĠĠĠĠĠĠ Ġon View ( with Id ( R . id . action _ delete )). check ( matches ( is Displayed ())) ĊĠĠĠĠĠĠĠ Ġon View ( with Id ( R . id . action _ delete )). check ( matches ( not ( isEnabled ()))) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ// ĠTODO : Ġenable Ġtest Ġdatabase Ġfor ĠE sp ress o Ġtests Ċ /* ĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġverify _ new _ coin _ added _ deleted _ test () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġcountry Ġ= Ġ" ES PRESS O " ĊĠĠĠĠĠĠĠ Ġval Ġdenom ination Ġ= Ġ" 2 5 Ġcent s " ĊĠĠĠĠĠĠĠ Ġval Ġyear Ġ= Ġ" 2 0 2 0 " ĊĠĠĠĠĠĠĠ Ġval Ġmint Mark Ġ= Ġ" D " ĊĠĠĠĠĠĠĠ Ġval Ġnotes Ġ= Ġ" quarter " ĊĊĠĠĠĠĠĠĠ Ġ// Ġon Ġlist Ġview ĊĠĠĠĠĠĠĠ Ġon View ( with Id ( R . id . add _ coin _ fab )). perform ( click ()) ĊĊĠĠĠĠĠĠĠ Ġ// Ġon Ġdetail Ġview ĊĠĠĠĠĠĠĠ Ġon View ( with Id ( R . id . coin Country )). perform ( type Text ( country )) ĊĠĠĠĠĠĠĠ Ġon View ( with Id ( R . id . coin Denom ination )). perform ( type Text ( denom ination )) ĊĠĠĠĠĠĠĠ Ġon View ( with Id ( R . id . coin Year )). perform ( type Text ( year )) ĊĠĠĠĠĠĠĠ Ġon View ( with Id ( R . id . coin Mint Mark )). perform ( type Text ( mint Mark )) ĊĠĠĠĠĠĠĠ Ġon View ( with Id ( R . id . coin Notes )). perform ( type Text ( notes )) ĊĠĠĠĠĠĠĠ Ġon View ( with Id ( R . id . action _ save )). perform ( click ()) ĊĊĠĠĠĠĠĠĠ Ġ// Ġon Ġlist Ġview ĊĠĠĠĠĠĠĠ Ġon View ( with Id ( R . id . recyclerview )). perform ( RecyclerView Actions . scrollTo < RecyclerView . ViewHolder >( has Desc endant ( with Text ( country )))) ĊĠĠĠĠĠĠĠ Ġon View ( with Id ( R . id . recyclerview )). perform ( ĊĠĠĠĠĠĠĠĠĠĠĠ ĠRecyclerView Actions . action On Item < RecyclerView . ViewHolder >( ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġhas Desc endant ( with Text ( country )), ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġclick () ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠĠĠ Ġ) ĊĊĠĠĠĠĠĠĠ Ġ// Ġon Ġdetail Ġview ĊĠĠĠĠĠĠĠ Ġon View ( with Id ( R . id . coin Country )). check ( matches ( with Text ( country ))) ĊĠĠĠĠĠĠĠ Ġon View ( with Id ( R . id . action _ delete )). perform ( click ()) ĊĊĠĠĠĠĠĠĠ Ġ// Ġon Ġlist Ġview ĊĠĠĠĠĠĠĠ Ġon View ( with Id ( R . id . recyclerview )). perform ( RecyclerView Actions . scrollTo < RecyclerView . ViewHolder >( not ( has Desc endant ( with Text ( country ))))) ĊĠĠĠ Ġ} Ċ */ ĊĠĠĠ Ġ// ĠTODO : Ġfigure Ġout Ġhow Ġto Ġvalidate Ġimages Ġare Ġthe Ġsame Ġusing ĠE sp ress o Ċ /* ĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġob verse _ camera _ intent _ launch _ test () Ġ{ ĊĠĠĠĠĠĠĠ ĠInt ents . init () ĊĠĠĠĠĠĠĠ Ġval Ġresult Data Ġ= ĠIntent () ĊĠĠĠĠĠĠĠ Ġval Ġdrawable Ġ= ĠContext Compat . get Drawable ( Instrumentation Registry . get Instrumentation (). target Context , ĠR . drawable . ic _ add ) !! ĊĠĠĠĠĠĠĠ Ġval Ġbitmap Ġ= ĠBitmap . create Bitmap ( drawable . intrinsic Width , Ġdrawable . intrinsic Height , ĠBitmap . Config . ARGB _ 8 8 8 8 ) ĊĠĠĠĠĠĠĠ Ġresult Data . putExtra (" data ", Ġbitmap ) ĊĠĠĠĠĠĠĠ Ġval Ġresult Ġ= ĠInstrument ation . Activity Result ( Activity . RESULT _ OK , Ġresult Data ) ĊĠĠĠĠĠĠĠ Ġint ending ( has Action ( Media Store . ACTION _ IMAGE _ CAPTURE )). respond With ( result ) ĊĠĠĠĠĠĠĠ Ġon View ( with Id ( R . id . add _ coin _ fab )). perform ( click ()) ĊĠĠĠĠĠĠĠ Ġon View ( with Id ( R . id . ob verse )). perform ( click ()) ĊĠĠĠĠĠĠĠ ĠInt ents . release () ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġreverse _ camera _ intent _ launch _ test () Ġ{ ĊĠĠĠĠĠĠĠ ĠInt ents . init () ĊĠĠĠĠĠĠĠ Ġval Ġresult Data Ġ= ĠIntent () ĊĠĠĠĠĠĠĠ Ġval Ġdrawable Ġ= ĠContext Compat . get Drawable ( Instrumentation Registry . get Instrumentation (). target Context , ĠR . drawable . ic _ add ) !! ĊĠĠĠĠĠĠĠ Ġval Ġbitmap Ġ= ĠBitmap . create Bitmap ( drawable . intrinsic Width , Ġdrawable . intrinsic Height , ĠBitmap . Config . ARGB _ 8 8 8 8 ) ĊĠĠĠĠĠĠĠ Ġresult Data . putExtra (" data ", Ġbitmap ) ĊĠĠĠĠĠĠĠ Ġval Ġresult Ġ= ĠInstrument ation . Activity Result ( Activity . RESULT _ OK , Ġresult Data ) ĊĠĠĠĠĠĠĠ Ġint ending ( has Action ( Media Store . ACTION _ IMAGE _ CAPTURE )). respond With ( result ) ĊĠĠĠĠĠĠĠ Ġon View ( with Id ( R . id . add _ coin _ fab )). perform ( click ()) ĊĠĠĠĠĠĠĠ Ġon View ( with Id ( R . id . reverse )). perform ( click ()) ĊĠĠĠĠĠĠĠ ĠInt ents . release () ĊĠĠĠ Ġ} ĊĠĠĠ Ġ*/ Ċ } Ċ