package Ġcom . d roid h ats . camp us compass . views Ċ Ċ import Ġandroidx . navigation . testing . Test Nav Host Controller Ċ import Ġandroidx . test . core . app . Application Provider Ċ import Ġandroidx . test . espress o . Esp ress o Ċ import Ġandroidx . test . espress o . assertion . View Assertions Ċ import Ġandroidx . test . espress o . matcher . View Matchers Ċ import Ġandroidx . test . internal . runner . junit 4 . Android JUnit 4 Class Runner Ċ import Ġandroidx . test . platform . app . Instrumentation Registry . get Instrumentation Ċ import Ġandroidx . test . rule . Activity Test Rule Ċ import Ġandroidx . test . rule . Grant Permission Rule Ċ import Ġandroidx . test . uia utom ator . By Ċ import Ġandroidx . test . uia utom ator . Ui Device Ċ import Ġandroidx . test . uia utom ator . Ui Selector Ċ import Ġandroidx . test . uia utom ator . Direction Ċ import Ġcom . d roid h ats . camp us compass . MainActivity Ċ import Ġcom . d roid h ats . camp us compass . R Ċ import Ġorg . junit . Assert Ċ import Ġorg . junit . Before Ċ import Ġorg . junit . Rule Ċ import Ġorg . junit . Test Ċ import Ġorg . junit . runner . RunWith Ċ Ċ /** Ċ Ġ* ĠTest Ġfor Ġbuild ings Ġinitial s Ġ( Markers ) Ġin Ġthe Ġmap Ġof Ġthe ĠMap Fragment Ġclass . Ċ Ġ*/ Ċ @ RunWith ( Android JUnit 4 Class Runner :: class ) Ċ class ĠMarker Test Ġ{ ĊĠĠĠ Ġ@ get : Rule ĊĠĠĠ Ġvar Ġactivity Rule : ĠActivity Test Rule < MainActivity > Ġ= ĠActivity Test Rule ( MainActivity :: class . java ) ĊĊĠĠĠ Ġ@ Rule ĊĠĠĠ Ġ@ Jvm Field ĊĠĠĠ Ġvar Ġm Grant Permission Rule : ĠGrant Permission Rule Ġ= ĊĠĠĠĠĠĠĠ ĠGrant Permission Rule . grant ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ" android . permission . ACCESS _ F INE _ LOCATION " ĊĠĠĠĠĠĠĠ Ġ) ĊĠĠĠ Ġprivate Ġlateinit Ġvar Ġnav Controller : ĠTest Nav Host Controller ĊĊĠĠĠ Ġ@ Before ĊĠĠĠ Ġfun ĠsetUp () Ġ{ ĊĠĠĠĠĠĠĠ Ġnav Controller Ġ= ĠTest Nav Host Controller ( ĊĠĠĠĠĠĠĠĠĠĠĠ ĠApplication Provider . getApplicationContext ()) ĊĠĠĠĠĠĠĠ Ġ// needs Ġto Ġbe Ġhere Ġto Ġsee Ġwhich Ġfragment Ġis Ġbeing Ġopened ĊĠĠĠĠĠĠĠ Ġnav Controller . set Graph ( R . navigation . navigation ) ĊĊĠĠĠĠĠĠĠ Ġ// Ens uring Ġthe Ġapp Ġstarts Ġwith Ġsplash _ fragment ĊĠĠĠĠĠĠĠ Ġif Ġ( nav Controller . current Destination ?. id Ġ== ĠR . id . splash _ fragment ) Ġ{ ĊĊĠĠĠĠĠĠĠĠĠĠĠ Ġ// navig ating Ġto Ġmap _ fragment Ġ- ĠYou Ġcan Ġput Ġeither Ġaction Ġid Ġor Ġdestination Ġid . ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ// I Ġchose Ġthe Ġaction Ġid Ġso ĠI Ġcan Ġcheck Ġthat Ġit Ġindeed Ġtakes Ġyou Ġthe Ġspecified Ġdestination Ġid . ĊĠĠĠĠĠĠĠĠĠĠĠ Ġnav Controller . navigate ( R . id . action _ splash Fragment _ to _ maps Activity ) ĊĊĠĠĠĠĠĠĠĠĠĠĠ Ġ// Checking Ġif Ġaction Ġid Ġindeed Ġtook Ġyou Ġto Ġthe Ġcorrect Ġdestination Ġid ĊĠĠĠĠĠĠĠĠĠĠĠ ĠAssert . assertEquals ( nav Controller . current Destination ?. id !! , ĠR . id . map _ fragment ) ĊĊĠĠĠĠĠĠĠĠĠĠĠ Ġ// Waiting Ġ 5 Ġseconds Ġfor Ġsplash Ġscreen Ġto Ġload ĊĠĠĠĠĠĠĠĠĠĠĠ ĠThread . sleep ( 5 0 0 0 ) ĊĊĠĠĠĠĠĠĠĠĠĠĠ Ġ// Checking Ġif Ġthat Ġaction Ġid Ġdid Ġtake Ġyou Ġto Ġmap _ fragment Ġview ĊĠĠĠĠĠĠĠĠĠĠĠ ĠE sp ress o . on View ( View Matchers . with Id ( R . id . coordinate _ layout )) ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ. check ( View Assertions . matches ( View Matchers . is Displayed ())) ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġtest Building Markers (){ ĊĠĠĠĠĠĠĠ Ġval Ġdevice Ġ= ĠUi Device . getInstance ( get Instrumentation ()) ĊĊĠĠĠĠĠĠĠ Ġ// Allow Ġdow nt own Ġmap Ġto Ġfully Ġload ĊĠĠĠĠĠĠĠ ĠThread . sleep ( 2 0 0 0 ) ĊĊĠĠĠĠĠĠĠ Ġdevice . find Object ( Ui Selector (). description Contains (" H en ry ĠF . ĠHall ĠBuilding . Ġ" )). click () ĊĊĠĠĠĠĠĠĠ Ġ// Retrieve Ġbottom Ġsheet Ġonce Ġit Ġis Ġin Ġthe Ġview ĊĠĠĠĠĠĠĠ Ġval Ġbottom Sheet Ġ= Ġdevice . find Object ( By . res (" com . d roid h ats . camp us compass : id / bottom _ sheet ")) ĊĠĠĠĠĠĠĠ Ġ// Click Ġon Ġthe Ġmap Ġto Ġdismiss Ġbottom Ġsheet Ġfor Ġcoverage ĊĠĠĠĠĠĠĠ ĠUi Device . getInstance ( get Instrumentation ()). click ( 1 2 0 0 , Ġ 6 0 0 ) ĊĊĠĠĠĠĠĠĠ Ġdevice . find Object ( Ui Selector (). description Contains (" P av illion ĠJ . W . ĠMc Conn ell ĠBuilding . Ġ" )). click () ĊĠĠĠĠĠĠĠ Ġ// Expand Ġbottom Ġsheet Ġfully Ġfor Ġcoverage ĊĠĠĠĠĠĠĠ Ġbottom Sheet . swipe ( Direction . UP , Ġ 1 . 0 f ) ĊĠĠĠĠĠĠĠ Ġbottom Sheet . swipe ( Direction . DOWN , Ġ 1 . 0 f ) ĊĊĠĠĠĠĠĠĠ Ġdevice . find Object ( Ui Selector (). description Contains (" Visual ĠAr ts ĠBuilding . Ġ" )). click () ĊĠĠĠĠĠĠĠ Ġbottom Sheet . swipe ( Direction . DOWN , Ġ 1 . 0 f ) ĊĊĠĠĠĠĠĠĠ Ġdevice . find Object ( Ui Selector (). description Contains (" GS ĠBuilding . Ġ" )). click () ĊĠĠĠĠĠĠĠ Ġbottom Sheet . swipe ( Direction . DOWN , Ġ 1 . 0 f ) ĊĊĠĠĠĠĠĠĠ Ġdevice . find Object ( Ui Selector (). description Contains (" Learning ĠSquare . Ġ" )). click () ĊĠĠĠĠĠĠĠ Ġbottom Sheet . swipe ( Direction . DOWN , Ġ 1 . 0 f ) ĊĊĠĠĠĠĠĠĠ Ġdevice . find Object ( Ui Selector (). description Contains (" EV ĠBuilding . Ġ" )). click () ĊĠĠĠĠĠĠĠ Ġbottom Sheet . swipe ( Direction . DOWN , Ġ 1 . 0 f ) ĊĊĠĠĠĠĠĠĠ Ġdevice . find Object ( Ui Selector (). description Contains (" John ĠMol son ĠSchool Ġof ĠBusiness . Ġ" )). click () ĊĠĠĠĠĠĠĠ Ġbottom Sheet . swipe ( Direction . DOWN , Ġ 1 . 0 f ) ĊĊĠĠĠĠĠĠĠ Ġdevice . find Object ( Ui Selector (). description Contains (" Fa ub our g ĠBuilding . Ġ" )). click () ĊĠĠĠĠĠĠĠ Ġbottom Sheet . swipe ( Direction . DOWN , Ġ 1 . 0 f ) ĊĊĠĠĠĠĠĠĠ Ġdevice . find Object ( Ui Selector (). description Contains (" Grey ĠN uns ĠBuilding . Ġ" )). click () ĊĠĠĠĠĠĠĠ Ġbottom Sheet . swipe ( Direction . DOWN , Ġ 1 . 0 f ) ĊĊĠĠĠĠĠĠĠ Ġdevice . find Object ( Ui Selector (). description Contains (" Fa ub our g ĠS aint - C ather ine ĠBuilding . Ġ" )). click () ĊĠĠĠĠĠĠĠ Ġbottom Sheet . swipe ( Direction . DOWN , Ġ 1 . 0 f ) ĊĊĠĠĠĠĠĠĠ Ġdevice . find Object ( Ui Selector (). description Contains (" Gu y - De ĠMa ison ne uve ĠBuilding . Ġ" )). click Top Left () ĊĠĠĠĠĠĠĠ Ġbottom Sheet . swipe ( Direction . DOWN , Ġ 1 . 0 f ) ĊĊĠĠĠĠĠĠĠ ĠThread . sleep ( 2 0 0 0 ) ĊĊĠĠĠĠĠĠĠ Ġ// ĠSwitch Ġto ĠLo y ola Ġcamp us ĊĠĠĠĠĠĠĠ Ġdevice . find Object ( By . res (" com . d roid h ats . camp us compass : id / toggle Button ")). click () ĊĊĠĠĠĠĠĠĠ ĠThread . sleep ( 2 0 0 0 ) ĊĊĠĠĠĠĠĠĠ Ġdevice . find Object ( Ui Selector (). description Contains (" J es uit ĠRes idence . Ġ" )). click () ĊĠĠĠĠĠĠĠ Ġbottom Sheet . swipe ( Direction . DOWN , Ġ 1 . 0 f ) ĊĊĠĠĠĠĠĠĠ Ġdevice . find Object ( Ui Selector (). description Contains (" Rich ard ĠJ . ĠR ena ud ĠScience ĠComplex . Ġ" )). click () ĊĠĠĠĠĠĠĠ Ġbottom Sheet . swipe ( Direction . DOWN , Ġ 1 . 0 f ) ĊĊĠĠĠĠĠĠĠ Ġdevice . find Object ( Ui Selector (). description Contains (" Communication ĠSt udies Ġand ĠJournal ism ĠBuilding . Ġ" )). click () ĊĠĠĠĠĠĠĠ Ġbottom Sheet . swipe ( Direction . DOWN , Ġ 1 . 0 f ) ĊĊĠĠĠĠĠĠĠ Ġdevice . find Object ( Ui Selector (). description Contains (" PER FORM ĠCent re . Ġ" )). click () ĊĠĠĠĠĠĠĠ Ġbottom Sheet . swipe ( Direction . DOWN , Ġ 1 . 0 f ) ĊĊĠĠĠĠĠĠĠ Ġdevice . find Object ( Ui Selector (). description Contains (" St inger ĠD ome . Ġ" )). click () ĊĠĠĠĠĠĠĠ Ġbottom Sheet . swipe ( Direction . DOWN , Ġ 1 . 0 f ) ĊĊĠĠĠĠĠĠĠ Ġdevice . find Object ( Ui Selector (). description Contains (" Physical ĠServices ĠBuilding . Ġ" )). click () ĊĠĠĠĠĠĠĠ Ġbottom Sheet . swipe ( Direction . DOWN , Ġ 1 . 0 f ) ĊĊĠĠĠĠĠĠĠ Ġdevice . find Object ( Ui Selector (). description Contains (" Van ier ĠExtension . ")). click () ĊĠĠĠĠĠĠĠ Ġbottom Sheet . swipe ( Direction . DOWN , Ġ 1 . 0 f ) ĊĊĠĠĠĠĠĠĠ Ġdevice . find Object ( Ui Selector (). description Contains (" P sy cho logy ĠBuilding . Ġ" )). click () ĊĠĠĠĠĠĠĠ Ġbottom Sheet . swipe ( Direction . DOWN , Ġ 1 . 0 f ) ĊĊĠĠĠĠĠĠĠ Ġdevice . find Object ( Ui Selector (). description Contains (" F . C . ĠSmith ĠBuilding . Ġ" )). click () ĊĠĠĠĠĠĠĠ Ġbottom Sheet . swipe ( Direction . DOWN , Ġ 1 . 0 f ) ĊĊĠĠĠĠĠĠĠ Ġdevice . find Object ( Ui Selector (). description Contains (" Lo y ola ĠJes uit Ġand ĠConference ĠCent re . Ġ" )). click () ĊĠĠĠĠĠĠĠ Ġbottom Sheet . swipe ( Direction . DOWN , Ġ 1 . 0 f ) ĊĊĠĠĠĠĠĠĠ Ġdevice . find Object ( Ui Selector (). description Contains (" Central ĠBuilding . Ġ" )). click () ĊĠĠĠĠĠĠĠ Ġbottom Sheet . swipe ( Direction . DOWN , Ġ 1 . 0 f ) ĊĊĠĠĠĠĠĠĠ Ġdevice . find Object ( Ui Selector (). description Contains (" Administration ĠBuilding . Ġ" )). click () ĊĠĠĠĠĠĠĠ Ġbottom Sheet . swipe ( Direction . DOWN , Ġ 1 . 0 f ) ĊĊĠĠĠĠĠĠĠ Ġdevice . find Object ( Ui Selector (). description Contains (" Osc ar ĠPet erson ĠCon cert ĠHall . Ġ" )). click () ĊĠĠĠĠĠĠĠ Ġbottom Sheet . swipe ( Direction . DOWN , Ġ 1 . 0 f ) ĊĊĠĠĠĠĠĠĠ Ġdevice . find Object ( Ui Selector (). description Contains (" Van ier ĠLibrary ĠBuilding . Ġ" )). click () ĊĠĠĠĠĠĠĠ Ġbottom Sheet . swipe ( Direction . DOWN , Ġ 1 . 0 f ) ĊĊĠĠĠĠĠĠĠ Ġdevice . find Object ( Ui Selector (). description Contains (" Student ĠCent re . Ġ" )). click () ĊĠĠĠĠĠĠĠ Ġbottom Sheet . swipe ( Direction . DOWN , Ġ 1 . 0 f ) ĊĠĠĠ Ġ} Ċ }