package Ġcom . as mit ta . talk in . ui Ċ Ċ import Ġandroid . content . Context Ċ import Ġandroidx . lifecycle . Mutable LiveData Ċ import Ġandroidx . lifecycle . ViewModel Provider Ċ 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 . matches Ċ import Ġandroidx . test . espress o . contrib . RecyclerView Actions . action On Item At Position Ċ import Ġandroidx . test . espress o . matcher . View Matchers . has Child Count Ċ import Ġandroidx . test . espress o . matcher . View Matchers . is Displayed Ċ 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 . as mit ta . talk in . R Ċ import Ġcom . as mit ta . talk in . data . model . Chat Ċ import Ġcom . as mit ta . talk in . ui . util . ViewModel Factory Ċ import Ġcom . as mit ta . talk in . ui . util . at Position Ċ import Ġcom . as mit ta . talk in . ui . util . launch Fragment In H ilt Container Ċ import Ġcom . as mit ta . talk in . util . any Ċ import Ġcom . as mit ta . talk in . util . mock Ċ import Ġcom . as mit ta . talk in . util . nullable Ċ import Ġcom . as mit ta . talk in . view . Firebase ViewModel Ċ import Ġcom . as mit ta . talk in . view . chat Rooms . Chat ListAdapter Ċ import Ġcom . as mit ta . talk in . view . chat Rooms . Start Fragment Ċ import Ġdagger . h ilt . android . testing . H ilt Android Rule Ċ import Ġdagger . h ilt . android . testing . H ilt Android Test Ċ import Ġorg . junit . Before Ċ import Ġorg . junit . Rule Ċ import Ġorg . junit . Test Ċ import Ġorg . junit . runner . RunWith Ċ import Ġorg . mockito . Mockito Ċ import Ġorg . mockito . Mockito .` when ` Ċ import Ġorg . mockito . Mockito . times Ċ import Ġorg . mockito . Mockito . verify Ċ Ċ @ RunWith ( Android JUnit 4 :: class ) Ċ @ H ilt Android Test Ċ class ĠStart Fragment Test Ġ{ ĊĊĠĠĠ Ġcompanion Ġobject Ġ{ ĊĠĠĠĠĠĠĠ Ġval ĠviewModel : ĠFirebase ViewModel Ġ= Ġmock () ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġprivate Ġval Ġchat Room List Ġ= ĠMutable LiveData < List < Chat >>() ĊĠĠĠ Ġprivate Ġlateinit Ġvar Ġapp Context : ĠContext ĊĊĠĠĠ Ġ@ get : Rule ĊĠĠĠ Ġvar Ġh ilt Rule Ġ= ĠH ilt Android Rule ( this ) ĊĊĠĠĠ Ġ@ Before ĊĠĠĠ Ġfun Ġinit () Ġ{ ĊĠĠĠĠĠĠĠ ĠMockito . reset ( viewModel ) ĊĠĠĠĠĠĠĠ Ġapp Context Ġ= ĠInstrument ation Registry . get Instrumentation (). context ĊĠĠĠĠĠĠĠ Ġ` when `( viewModel . chat Room List ). thenReturn ( chat Room List ) ĊĠĠĠĠĠĠĠ Ġlaunch Fragment In H ilt Container < Start Fragment Test >() ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġchat Room List () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġchat Ġ= ĠChat (" 1 _ 2 ", Ġ" 2 ", Ġ" 3 ", Ġtrue ) ĊĠĠĠĠĠĠĠ Ġval Ġchat List Ġ= Ġmutable ListOf ( chat , Ġchat , Ġchat ) ĊĠĠĠĠĠĠĠ Ġchat Room List . post Value ( chat List ) ĊĠĠĠĠĠĠĠ Ġon View ( with Id ( R . id . re cyclerView )). check ( matches ( has Child Count ( chat List . size ))) ĊĠĠĠĠĠĠĠ Ġval Ġrv Ġ= Ġon View (( with Id ( R . id . re cyclerView ))) ĊĠĠĠĠĠĠĠ Ġrv . check ( matches ( at Position ( 0 , ĠR . id . photo ImageView , Ġis Displayed ()))) ĊĠĠĠĠĠĠĠ Ġrv . check ( matches ( at Position ( 0 , ĠR . id . online Dot , Ġis Displayed ()))) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġchat ListAdapter Item Click () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġchat Ġ= ĠChat (" 1 _ 2 ", Ġ" 2 ", Ġ" 3 ", Ġtrue ) ĊĠĠĠĠĠĠĠ Ġval Ġchat List Ġ= Ġmutable ListOf ( chat , Ġchat , Ġchat ) ĊĠĠĠĠĠĠĠ Ġchat Room List . post Value ( chat List ) ĊĠĠĠĠĠĠĠ Ġon View ( with Id ( R . id . re cyclerView )). perform ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġaction On Item At Position < Chat ListAdapter . Msg ViewHolder >( 0 , Ġclick ()) ĊĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠĠĠ Ġverify ( viewModel ). set Receiver ( nullable ()) ĊĠĠĠĠĠĠĠ Ġverify ( viewModel , Ġtimes ( 2 )). set Fragment State ( any (), Ġany ()) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġclass ĠStart Fragment Test Ġ: ĠStart Fragment () Ġ{ ĊĠĠĠĠĠĠĠ Ġoverride Ġfun ĠgetDefault ViewModel Provider Factory (): ĠViewModel Provider . Factory Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġreturn ĠViewModel Factory ( viewModel ) ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} Ċ }