package Ġcom . w ada 8 1 1 . pubsub messenger . test Ċ Ċ import Ġandroid . os . Build Ċ import Ġandroidx . lifecycle . Lifecycle Ċ import Ġandroidx . lifecycle . Lifecycle . Event Ċ import Ġandroidx . lifecycle . Lifecycle . Event . ON _ CREATE Ċ import Ġandroidx . lifecycle . Lifecycle . Event . ON _ DESTROY Ċ import Ġandroidx . lifecycle . Lifecycle . Event . ON _ PAUSE Ċ import Ġandroidx . lifecycle . Lifecycle . Event . ON _ RE SU ME Ċ import Ġandroidx . lifecycle . Lifecycle . Event . ON _ START Ċ import Ġandroidx . lifecycle . Lifecycle . Event . ON _ STOP Ċ import Ġandroidx . test . core . app . Activity Scenario Ċ import Ġcom . google . common . truth . Truth Ċ import Ġorg . junit . Test Ċ import Ġorg . junit . runner . RunWith Ċ import Ġorg . ro bo lectric . Parameterized Ro bo lectric TestRunner Ċ import Ġorg . ro bo lectric . annotation . Config Ċ Ċ @ Config ( sdk Ġ= Ġ[ Build . VERSION _ CODES . P ]) Ċ @ RunWith ( Parameterized Ro bo lectric TestRunner :: class ) Ċ class ĠDialog Activity Test ( ĊĠĠĠ Ġprivate Ġval Ġsubscribe Lifecycle Events : ĠList < Event >, ĊĠĠĠ Ġprivate Ġval Ġpublish Lifecycle Events : ĠList < Event >, ĊĠĠĠ Ġprivate Ġval Ġexpected Lifecycle Events : ĠList < Event > Ċ ) Ġ{ ĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġtest () Ġ{ ĊĠĠĠĠĠĠĠ Ġvar Ġactivity : ĠTest Dialog Activity ? Ġ= Ġnull ĊĠĠĠĠĠĠĠ ĠActivity Scenario . launch < Test Dialog Activity >( Test Dialog Activity . create Intent ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġsubscribe Lifecycle Events , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġpublish Lifecycle Events ĊĠĠĠĠĠĠĠ Ġ )). use Ġ{ Ġscenario Ġ-> ĊĠĠĠĠĠĠĠĠĠĠĠ Ġscenario . on Activity Ġ{ Ġactivity Ġ= Ġit Ġ} ĊĠĠĠĠĠĠĠĠĠĠĠ Ġscenario . moveTo State ( Lifecycle . State . DESTROY ED ) ĊĠĠĠĠĠĠĠĠĠĠĠ ĠTr uth . assertThat ( activity !!. lifecycle Events ). contains Exactly (* expected Lifecycle Events . to Typed Array ()). in Order () ĊĠĠĠĠĠĠĠĠĠĠĠ Ġactivity Ġ= Ġnull ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġcompanion Ġobject Ġ{ ĊĠĠĠĠĠĠĠ Ġ@ Suppress (" unused ") ĊĠĠĠĠĠĠĠ Ġ@ Jvm Static ĊĠĠĠĠĠĠĠ Ġ@ Parameterized Ro bo lectric TestRunner . Parameters ( name Ġ= Ġ" subscribe : Ġ{ 0 }, Ġpublish : Ġ{ 1 }, Ġexpected : Ġ{ 2 }") ĊĠĠĠĠĠĠĠ Ġfun Ġparameters (): ĠIterable < Array < Any >> Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġval Ġparameters Ġ= Ġmutable ListOf < Array < Any >>() ĊĠĠĠĠĠĠĠĠĠĠĠ Ġparameters . add ( array Of ( listOf ( ON _ CREATE ), ĠlistOf ( ON _ CREATE ), ĠlistOf ( ON _ CREATE ))) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġparameters . add ( array Of ( listOf ( ON _ CREATE ), ĠlistOf ( ON _ START ), ĠlistOf ( ON _ START ))) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġparameters . add ( array Of ( listOf ( ON _ CREATE ), ĠlistOf ( ON _ RE SU ME ), ĠlistOf ( ON _ RE SU ME ))) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġparameters . add ( array Of ( listOf ( ON _ CREATE ), ĠlistOf ( ON _ PAUSE ), ĠlistOf ( ON _ PAUSE ))) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġparameters . add ( array Of ( listOf ( ON _ CREATE ), ĠlistOf ( ON _ STOP ), ĠlistOf < Event > ())) Ġ// Ġpublish Ġafter ĠON _ STOP ĊĠĠĠĠĠĠĠĠĠĠĠ Ġparameters . add ( array Of ( listOf ( ON _ CREATE ), ĠlistOf ( ON _ DESTROY ), ĠlistOf < Event > ())) Ġ// Ġpublish Ġafter ĠON _ STOP ĊĠĠĠĠĠĠĠĠĠĠĠ Ġreturn Ġparameters ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} Ċ }