package Ġcom . k ome y ama . offline . chat Ċ Ċ import Ġandroid . os . System Clock . sleep Ċ import Ġandroidx . arch . core . executor . testing . Count ing Task Executor Rule Ċ import Ġandroidx . lifecycle . Mutable LiveData Ċ import Ġandroidx . test . core . app . Activity Scenario Ċ import Ġandroidx . test . espress o . matcher . View Matchers . with Id Ċ import Ġandroidx . test . ext . junit . runners . Android JUnit 4 Ċ import Ġandroidx . test . platform . app . Instrumentation Registry Ċ import Ġcom . k ome y ama . offline . chat . domain . Active User Ċ import Ġcom . k ome y ama . offline . chat . near by client . Near by Client Ċ import Ġcom . k ome y ama . offline . chat . ui . MainActivity Ċ import Ġorg . junit . Before Ċ import Ġorg . junit . Test Ċ import Ġorg . junit . runner . RunWith Ċ import Ġjavax . inject . Inject Ċ import Ġandroidx . recyclerview . widget . RecyclerView Ċ import Ġandroidx . test . espress o . Esp ress o . on View Ċ import Ġandroidx . test . espress o . action . View Actions Ċ import Ġandroidx . test . espress o . action . View Actions . click Ċ import Ġandroidx . test . espress o . contrib . Drawer Actions . close Ċ import Ġandroidx . test . espress o . contrib . RecyclerView Actions Ċ import Ġandroidx . test . espress o . matcher . View Matchers . is Root Ċ import Ġandroidx . test . rule . Activity Test Rule Ċ import Ġcom . google . android . material . bottomnavigation . Bottom Navigation View Ċ import Ġcom . k ome y ama . offline . chat . near by client . Connection Type Ċ import Ġcom . k ome y ama . offline . chat . near by client . Request Result Ċ import Ġcom . k ome y ama . offline . chat . service . User Information Service Ċ import Ġkotlinx . coroutines . run Blocking Ċ import Ġorg . junit . After Ċ import Ġorg . junit . Rule Ċ import Ġjava . util . concurrent . TimeUnit Ċ Ċ @ RunWith ( Android JUnit 4 :: class ) Ċ class ĠMenu Screen Transition Test Ġ{ ĊĊĠĠĠ Ġ@ Rule ĊĠĠĠ Ġ@ Jvm Field ĊĠĠĠ Ġvar Ġactivity Test Rule Ġ= ĠActivity Test Rule ( MainActivity :: class . java ) ĊĊĠĠĠ Ġ@ Rule ĊĠĠĠ Ġ@ Jvm Field ĊĠĠĠ Ġval Ġcounting Task Executor Rule Ġ= ĠCount ing Task Executor Rule () ĊĊĠĠĠ Ġprivate Ġvar Ġconfirm Ui Design Ġ= Ġtrue ĊĊĠĠĠ Ġprivate Ġlateinit Ġvar Ġtest App Component : ĠTest App Component ĊĠĠĠ Ġ@ Inject Ġlateinit Ġvar Ġnearby Client : ĠN ear by Client ĊĠĠĠ Ġ@ Inject Ġlateinit Ġvar Ġuser Information Service : ĠUser Information Service ĊĠĠĠ Ġprivate Ġlateinit Ġvar Ġbottom Navigation View : ĠBottom Navigation View ĊĠĠĠ Ġprivate Ġlateinit Ġvar Ġinv ited Endpoint Info : ĠMutable LiveData < Iterable <* >> ĊĠĠĠ Ġprivate Ġlateinit Ġvar Ġaround Endpoint Info : ĠMutable LiveData < List < Active User >> ĊĠĠĠ Ġprivate Ġlateinit Ġvar Ġrequest Result : ĠMutable LiveData < Request Result > ĊĊĠĠĠ Ġ@ Before ĊĠĠĠ Ġfun ĠsetUp () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġapp Context Ġ= ĠInstrument ation Registry . get Instrumentation (). target Context . application Context Ġas ĠMain Application ĊĠĠĠĠĠĠĠ Ġtest App Component Ġ= ĠD agger Test App Component . factory (). create ( app Context ) ĊĠĠĠĠĠĠĠ Ġapp Context . app Component Ġ= Ġtest App Component ĊĠĠĠĠĠĠĠ Ġtest App Component . injection Menu Screen Transition Test ( this ) ĊĠĠĠĠĠĠĠ ĠActivity Scenario . launch ( MainActivity :: class . java ) ĊĠĠĠĠĠĠĠ Ġbottom Navigation View Ġ= Ġactivity Test Rule . activity . findViewById ( R . id . bottom _ navigation ) ĊĊĠĠĠĠĠĠĠ Ġval Ġaround Endpoint Info File d Ġ= ĠN ear by Client :: class . java . getDeclared Field ("_ around Endpoint Info ") ĊĠĠĠĠĠĠĠ Ġaround Endpoint Info File d . is Accessible Ġ= Ġtrue ĊĠĠĠĠĠĠĠ Ġaround Endpoint Info Ġ= Ġaround Endpoint Info File d . get ( near by Client ) Ġas ĠMutable LiveData < List < Active User >> ĊĊĠĠĠĠĠĠĠ Ġval Ġinv ited Endpoint Info File d Ġ= ĠN ear by Client :: class . java . getDeclared Field ("_ invite Endpoint Info ") ĊĠĠĠĠĠĠĠ Ġinv ited Endpoint Info File d . is Accessible Ġ= Ġtrue ĊĠĠĠĠĠĠĠ Ġinv ited Endpoint Info Ġ= Ġinv ited Endpoint Info File d . get ( near by Client ) Ġas ĠMutable LiveData < Iterable <* >> ĊĊĠĠĠĠĠĠĠ Ġval Ġrequested Endpoint Info File d Ġ= ĠN ear by Client :: class . java . getDeclared Field ("_ request Result ") ĊĠĠĠĠĠĠĠ Ġrequested Endpoint Info File d . is Accessible Ġ= Ġtrue ĊĠĠĠĠĠĠĠ Ġrequest Result Ġ= Ġrequested Endpoint Info File d . get ( near by Client ) Ġas ĠMutable LiveData < Request Result > ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġrun App () Ġ{ ĊĠĠĠĠĠĠĠ Ġvar Ġis Exist User Information Ġ= Ġfalse ĊĠĠĠĠĠĠĠ Ġrun Blocking Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġis Exist User Information Ġ= Ġuser Information Service . exists User Information () ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠ Ġif Ġ(! is Exist User Information ) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġon View ( with Id ( R . id . initial _ name _ editor )). perform ( View Actions . type Text (" k ome y ama "), ĠView Actions . close Soft Keyboard ()) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġon View ( with Id ( R . id . initial _ name _ decision )). perform ( click ()) ĊĠĠĠĠĠĠĠ Ġ} ĊĊĠĠĠĠĠĠĠ Ġval Ġsetting Fragment Id Ġ= Ġbottom Navigation View . menu . find Item ( R . id . Setting Fragment ). itemId ĊĠĠĠĠĠĠĠ Ġon View ( with Id ( setting Fragment Id )). perform ( click ()) ĊĠĠĠĠĠĠĠ Ġcounting Task Executor Rule . drain Tasks ( 3 , ĠTimeUnit . SECONDS ) ĊĠĠĠĠĠĠĠ Ġinv ited Endpoint Info . post Value ( listOf ( Active User (" 1 2 3 4 5 a ", Ġ" near by Ġtest 0 ", Ġ" dummy 0 "), Connection Type . RECE IVER )) ĊĠĠĠĠĠĠĠ Ġwait Next Process ( 1 ) ĊĠĠĠĠĠĠĠ Ġon View ( with Id ( android . R . id . button 1 )). perform ( click ()) ĊĠĠĠĠĠĠĠ Ġwait Next Process ( 1 ) ĊĠĠĠĠĠĠĠ Ġon View ( is Root ()). perform ( View Actions . press Back ()) ĊĠĠĠĠĠĠĠ Ġwait Next Process ( 1 ) ĊĠĠĠĠĠĠĠ Ġon View ( with Id ( android . R . id . button 1 )). perform ( click ()) ĊĠĠĠĠĠĠĠ Ġwait Next Process ( 1 ) ĊĊĠĠĠĠĠĠĠ Ġval Ġcommunication History List Fragment Id Ġ= Ġbottom Navigation View . menu . find Item ( R . id . Communication History List Fragment ). itemId ĊĠĠĠĠĠĠĠ Ġon View ( with Id ( communication History List Fragment Id )). perform ( click ()) ĊĠĠĠĠĠĠĠ Ġcounting Task Executor Rule . drain Tasks ( 3 , ĠTimeUnit . SECONDS ) ĊĠĠĠĠĠĠĠ Ġinv ited Endpoint Info . post Value ( listOf ( Active User (" 1 2 3 4 5 a ", Ġ" near by Ġtest 0 ", Ġ" dummy 0 "), Connection Type . RECE IVER )) ĊĠĠĠĠĠĠĠ Ġwait Next Process ( 1 ) ĊĠĠĠĠĠĠĠ Ġon View ( with Id ( android . R . id . button 1 )). perform ( click ()) ĊĠĠĠĠĠĠĠ Ġwait Next Process ( 1 ) ĊĠĠĠĠĠĠĠ Ġon View ( is Root ()). perform ( View Actions . press Back ()) ĊĠĠĠĠĠĠĠ Ġwait Next Process ( 1 ) ĊĠĠĠĠĠĠĠ Ġon View ( with Id ( android . R . id . button 1 )). perform ( click ()) ĊĠĠĠĠĠĠĠ Ġwait Next Process ( 1 ) ĊĊĠĠĠĠĠĠĠ Ġval Ġcommunic able UserList Fragment Id Ġ= Ġbottom Navigation View . menu . find Item ( R . id . Com munic able UserList Fragment ). itemId ĊĠĠĠĠĠĠĠ Ġon View ( with Id ( com munic able UserList Fragment Id )). perform ( click ()) ĊĠĠĠĠĠĠĠ Ġcounting Task Executor Rule . drain Tasks ( 3 , ĠTimeUnit . SECONDS ) ĊĠĠĠĠĠĠĠ Ġinv ited Endpoint Info . post Value ( listOf ( Active User (" 1 2 3 4 5 a ", Ġ" near by Ġtest 0 ", Ġ" dummy 0 "), Connection Type . RECE IVER )) ĊĠĠĠĠĠĠĠ Ġwait Next Process ( 1 ) ĊĠĠĠĠĠĠĠ Ġon View ( with Id ( android . R . id . button 1 )). perform ( click ()) ĊĠĠĠĠĠĠĠ Ġwait Next Process ( 1 ) ĊĠĠĠĠĠĠĠ Ġon View ( is Root ()). perform ( View Actions . press Back ()) ĊĠĠĠĠĠĠĠ Ġwait Next Process ( 1 ) ĊĠĠĠĠĠĠĠ Ġon View ( with Id ( android . R . id . button 1 )). perform ( click ()) ĊĠĠĠĠĠĠĠ Ġwait Next Process ( 1 ) ĊĊĠĠĠĠĠĠĠ Ġval Ġcurrent Active Us r List Ġ= Ġmutable ListOf < Active User >() ĊĠĠĠĠĠĠĠ Ġcurrent Active Us r List . add ( ĊĠĠĠĠĠĠĠĠĠĠĠ ĠActive User (" 1 2 3 4 5 a ", Ġ" near by Ġtest 0 ", Ġ" dummy 0 ") ĊĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠĠĠ Ġcurrent Active Us r List . add ( ĊĠĠĠĠĠĠĠĠĠĠĠ ĠActive User (" 1 2 3 4 5 b ", Ġ" near by Ġtest 1 ", Ġ" dummy 1 ") ĊĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠĠĠ Ġcurrent Active Us r List . add ( ĊĠĠĠĠĠĠĠĠĠĠĠ ĠActive User (" 1 2 3 4 5 c ", Ġ" near by Ġtest 2 ", Ġ" dummy 2 ") ĊĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠĠĠ Ġaround Endpoint Info . post Value ( current Active Us r List ) ĊĠĠĠĠĠĠĠ Ġwait Next Process ( 2 ) ĊĠĠĠĠĠĠĠ Ġcounting Task Executor Rule . drain Tasks ( 3 , ĠTimeUnit . SECONDS ) ĊĠĠĠĠĠĠĠ Ġon View ( with Id ( R . id . recycler _ view )) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. perform ( RecyclerView Actions . action On Item At Position < RecyclerView . ViewHolder >( 1 , Ġclick ())) ĊĠĠĠĠĠĠĠ Ġwait Next Process ( 1 ) ĊĠĠĠĠĠĠĠ Ġon View ( with Id ( android . R . id . button 1 )). perform ( click ()) ĊĠĠĠĠĠĠĠ Ġwait Next Process ( 3 ) ĊĠĠĠĠĠĠĠ Ġrequest Result . post Value ( Request Result . SUCCESS ) ĊĠĠĠĠĠĠĠ Ġcounting Task Executor Rule . drain Tasks ( 3 , ĠTimeUnit . SECONDS ) ĊĠĠĠĠĠĠĠ Ġwait Next Process ( 3 ) ĊĠĠĠĠĠĠĠ Ġon View ( is Root ()). perform ( View Actions . press Back ()) ĊĠĠĠĠĠĠĠ Ġwait Next Process ( 2 ) ĊĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ After ĊĠĠĠ Ġfun Ġcleanup () Ġ{ ĊĠĠĠĠĠĠĠ Ġclose () ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ// ĠBecause Ġof Ġchecking Ġdialog Ġdesign . ĠBut ĠI Ġwant Ġto Ġchange Ġthis Ġlater . ĊĠĠĠ Ġfun Ġwait Next Process ( second : Long ) Ġ{ ĊĠĠĠĠĠĠĠ Ġvar Ġmilli Second Ġ= Ġ 0 L ĊĠĠĠĠĠĠĠ Ġif Ġ( confirm Ui Design ) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġmilli Second Ġ= Ġsecond Ġ* Ġ 1 0 0 0 L ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠ Ġsleep ( milli Second ) ĊĠĠĠ Ġ} Ċ Ċ }