package Ġcom . tw ilio . con versations . app . ui Ċ Ċ 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 . matches Ċ import Ġandroidx . test . espress o . matcher . View Matchers .* Ċ import Ġandroidx . test . ext . junit . runners . Android JUnit 4 Ċ import Ġandroidx . test . internal . runner . junit 4 . statement . Ui Thread Statement Ċ import Ġandroidx . test . platform . app . Instrumentation Registry Ċ import Ġandroidx . test . rule . Activity Test Rule Ċ import Ġcom . google . android . material . bottom sheet . Bottom Sheet Behavior Ċ import Ġcom . tw ilio . con versations . app . R Ċ import Ġcom . tw ilio . con versations . app . common . enums . Con versations Error Ċ import Ġcom . tw ilio . con versations . app . common . setup Test Injector Ċ import Ġcom . tw ilio . con versations . app . create Test Conversation Details View Item Ċ import Ġcom . tw ilio . con versations . app . data . Con versations Client Wrapper Ċ import Ġcom . tw ilio . con versations . app . test Util . WaitFor View Matcher Ċ import Ġcom . tw ilio . con versations . app . test Util . wait Until Popup StateChanged Ċ import Ġcom . tw ilio . con versations . app . viewModel . Conversation Details ViewModel Ċ import Ġkotlinx . android . synt hetic . main . activity _ conversation _ details .* Ċ import Ġorg . hamcrest . Core Matchers . all Of Ċ import Ġorg . junit . Before Ċ import Ġorg . junit . BeforeClass Ċ import Ġorg . junit . Rule Ċ import Ġorg . junit . Test Ċ import Ġorg . junit . runner . RunWith Ċ Ċ @ RunWith ( Android JUnit 4 :: class ) Ċ class ĠCon versation Details Activity Test Ġ{ ĊĊĠĠĠ Ġ@ get : Rule ĊĠĠĠ Ġvar Ġactivity Rule : ĠActivity Test Rule < Conversation Details Activity > Ġ= ĠActivity Test Rule ( Conversation Details Activity :: class . java , Ġfalse , Ġfalse ) ĊĊĠĠĠ Ġprivate Ġlateinit Ġvar Ġconversation Details ViewModel : ĠCon versation Details ViewModel ĊĊĠĠĠ Ġprivate Ġval Ġconversation Sid Ġ= Ġ" conversation Sid " ĊĠĠĠ Ġprivate Ġval Ġparticipant Sid Ġ= Ġ" participant Sid " ĊĠĠĠ Ġprivate Ġval Ġparticipant Phone Ġ= Ġ" 1 1 1 " ĊĠĠĠ Ġprivate Ġval Ġparticipant Proxy Phone Ġ= Ġ" 2 2 2 " ĊĊĠĠĠ Ġ@ Before ĊĠĠĠ Ġfun ĠsetUp () Ġ{ ĊĠĠĠĠĠĠĠ Ġactivity Rule . launch Activity ( Conversation Details Activity . getStart Intent ( Instrumentation Registry . get Instrumentation (). target Context , Ġconversation Sid )) ĊĠĠĠĠĠĠĠ Ġval Ġcontext Ġ= ĠInstrument ation Registry . get Instrumentation (). target Context ĊĠĠĠĠĠĠĠ ĠCon versations Client Wrapper . re create Instance ( context ) ĊĠĠĠĠĠĠĠ Ġconversation Details ViewModel Ġ= Ġactivity Rule . activity . conversation Details ViewModel ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġadd Chat Participant Success () Ġ{ ĊĠĠĠĠĠĠĠ ĠWaitFor View Matcher . perform On View ( with Id ( R . id . add _ chat _ participant _ button ), Ġclick ()) ĊĠĠĠĠĠĠĠ ĠBottom Sheet Behavior . from ( activity Rule . activity . add _ chat _ participant _ sheet ). wait Until Popup StateChanged ( Bottom Sheet Behavior . STATE _ EXP AN DED ) ĊĠĠĠĠĠĠĠ ĠWaitFor View Matcher . perform On View ( with Id ( R . id . add _ chat _ participant _ id _ input ), Ġreplace Text ( participant Sid ), Ġclose Soft Keyboard ()) ĊĠĠĠĠĠĠĠ ĠWaitFor View Matcher . perform On View ( with Id ( R . id . add _ chat _ participant _ id _ cancel _ button ), Ġclick ()) ĊĊĠĠĠĠĠĠĠ ĠUi Thread Statement . run On Ui Thread Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġconversation Details ViewModel . on Participant Added . value Ġ= Ġparticipant Sid ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠ Ġon View ( with Text ( activity Rule . activity . getString ( R . string . participant _ added _ message , Ġparticipant Sid ))) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. check ( matches ( with Effective Visibility ( Visibility . VISIBLE ))) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġadd Non Chat Participant Success () Ġ{ ĊĠĠĠĠĠĠĠ ĠWaitFor View Matcher . perform On View ( with Id ( R . id . add _ non _ chat _ participant _ button ), Ġclick ()) ĊĠĠĠĠĠĠĠ ĠBottom Sheet Behavior . from ( activity Rule . activity . add _ non _ chat _ participant _ sheet ). wait Until Popup StateChanged ( Bottom Sheet Behavior . STATE _ EXP AN DED ) ĊĠĠĠĠĠĠĠ ĠWaitFor View Matcher . perform On View ( with Id ( R . id . add _ non _ chat _ participant _ phone _ input ), Ġreplace Text ( participant Phone ), Ġclose Soft Keyboard ()) ĊĠĠĠĠĠĠĠ ĠWaitFor View Matcher . perform On View ( with Id ( R . id . add _ non _ chat _ participant _ proxy _ input ), Ġreplace Text ( participant Proxy Phone ), Ġclose Soft Keyboard ()) ĊĠĠĠĠĠĠĠ ĠWaitFor View Matcher . perform On View ( with Id ( R . id . add _ non _ chat _ participant _ id _ cancel _ button ), Ġclick ()) ĊĊĠĠĠĠĠĠĠ ĠUi Thread Statement . run On Ui Thread Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġconversation Details ViewModel . on Participant Added . value Ġ= Ġparticipant Phone ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠ Ġon View ( with Text ( activity Rule . activity . getString ( R . string . participant _ added _ message , Ġparticipant Phone ))) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. check ( matches ( with Effective Visibility ( Visibility . VISIBLE ))) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġadd Participant Failed () Ġ{ ĊĠĠĠĠĠĠĠ ĠUi Thread Statement . run On Ui Thread Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġconversation Details ViewModel . on Details Error . value Ġ= ĠCon versations Error . P ARTIC IP ANT _ ADD _ FAILED ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠ Ġon View ( with Text ( R . string . err _ failed _ to _ add _ participant )) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. check ( matches ( with Effective Visibility ( Visibility . VISIBLE ))) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġrename Conversation Success () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġupdated Conversation Name Ġ= Ġ" updated Conversation Name " ĊĠĠĠĠĠĠĠ Ġval Ġconversation Author Ġ= Ġ" UIT ester " ĊĠĠĠĠĠĠĠ Ġval Ġconversation Created Date Ġ= Ġ" 2 3 ĠMay Ġ 2 0 2 0 " ĊĠĠĠĠĠĠĠ ĠWaitFor View Matcher . perform On View ( with Id ( R . id . conversation _ rename _ button ), Ġscroll To (), Ġclick ()) ĊĠĠĠĠĠĠĠ ĠBottom Sheet Behavior . from ( activity Rule . activity . rename _ conversation _ sheet ). wait Until Popup StateChanged ( Bottom Sheet Behavior . STATE _ EXP AN DED ) ĊĠĠĠĠĠĠĠ ĠWaitFor View Matcher . perform On View ( with Id ( R . id . rename _ conversation _ input ), Ġreplace Text ( updated Conversation Name ), Ġclose Soft Keyboard ()) ĊĠĠĠĠĠĠĠ ĠWaitFor View Matcher . perform On View ( with Id ( R . id . rename _ conversation _ cancel _ button ), Ġclick ()) ĊĠĠĠĠĠĠĠ ĠUi Thread Statement . run On Ui Thread Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġconversation Details ViewModel . conversation Details . value Ġ= Ġcreate Test Conversation Details View Item ( conversation Name Ġ= Ġupdated Conversation Name , ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġcreated By Ġ= Ġconversation Author , Ġcreated On Ġ= Ġconversation Created Date ) ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠ ĠWaitFor View Matcher . assert On View ( all Of ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġwith Id ( R . id . conversation _ details _ holder ), ĊĠĠĠĠĠĠĠĠĠĠĠ Ġhas Desc endant ( with Text ( updated Conversation Name )), ĊĠĠĠĠĠĠĠĠĠĠĠ Ġhas Desc endant ( with Text ( activity Rule . activity . getString ( R . string . details _ created _ by , Ġconversation Author ))), ĊĠĠĠĠĠĠĠĠĠĠĠ Ġhas Desc endant ( with Text ( activity Rule . activity . getString ( R . string . details _ created _ date , Ġconversation Created Date ))) ĊĠĠĠĠĠĠĠ Ġ), Ġmatches ( with Effective Visibility ( Visibility . VISIBLE ))) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġrename Conversation Failed () Ġ{ ĊĠĠĠĠĠĠĠ ĠUi Thread Statement . run On Ui Thread Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġconversation Details ViewModel . on Details Error . value Ġ= ĠCon versations Error . CONVER S ATION _ RE NAME _ FAILED ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠ Ġon View ( with Text ( R . string . err _ failed _ to _ rename _ conversation )) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. check ( matches ( with Effective Visibility ( Visibility . VISIBLE ))) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġmute Conversation Success () Ġ{ ĊĠĠĠĠĠĠĠ ĠUi Thread Statement . run On Ui Thread Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġconversation Details ViewModel . conversation Details . value Ġ= Ġcreate Test Conversation Details View Item ( is Mut ed Ġ= Ġtrue ) ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠ ĠWaitFor View Matcher . assert On View ( with Text ( R . string . details _ un mute _ conversation ), Ġmatches ( with Effective Visibility ( Visibility . VISIBLE ))) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġun mute Conversation Success () Ġ{ ĊĠĠĠĠĠĠĠ ĠUi Thread Statement . run On Ui Thread Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġconversation Details ViewModel . conversation Details . value Ġ= Ġcreate Test Conversation Details View Item ( is Mut ed Ġ= Ġfalse ) ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠ Ġon View ( with Text ( R . string . details _ mute _ conversation )) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. check ( matches ( with Effective Visibility ( Visibility . VISIBLE ))) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġmute Conversation Failed () Ġ{ ĊĠĠĠĠĠĠĠ ĠUi Thread Statement . run On Ui Thread Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġconversation Details ViewModel . on Details Error . value Ġ= ĠCon versations Error . CONVER S ATION _ M UTE _ FAILED ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠ Ġon View ( with Text ( R . string . err _ failed _ to _ mute _ con versations )) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. check ( matches ( with Effective Visibility ( Visibility . VISIBLE ))) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġun mute Conversation Failed () Ġ{ ĊĠĠĠĠĠĠĠ ĠUi Thread Statement . run On Ui Thread Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġconversation Details ViewModel . on Details Error . value Ġ= ĠCon versations Error . CONVER S ATION _ UN M UTE _ FAILED ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠ Ġon View ( with Text ( R . string . err _ failed _ to _ un mute _ conversation )) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. check ( matches ( with Effective Visibility ( Visibility . VISIBLE ))) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġdelete Conversation Success () Ġ{ ĊĠĠĠĠĠĠĠ ĠUi Thread Statement . run On Ui Thread Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġconversation Details ViewModel . on Conversation Removed . value Ġ= ĠUnit ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠ Ġassert ( activity Rule . activity . is Finish ing ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġdelete Conversation Failed () Ġ{ ĊĠĠĠĠĠĠĠ ĠUi Thread Statement . run On Ui Thread Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġconversation Details ViewModel . on Details Error . value Ġ= ĠCon versations Error . CONVER S ATION _ REMOVE _ FAILED ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠ Ġon View ( with Text ( R . string . err _ failed _ to _ remove _ conversation )) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. check ( matches ( with Effective Visibility ( Visibility . VISIBLE ))) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġcompanion Ġobject Ġ{ ĊĠĠĠĠĠĠĠ Ġ@ BeforeClass ĊĠĠĠĠĠĠĠ Ġ@ Jvm Static ĊĠĠĠĠĠĠĠ Ġfun Ġsetup Injector () Ġ= Ġsetup Test Injector () ĊĠĠĠ Ġ} Ċ } Ċ