package Ġcom . link 1 8 4 . deleg ates Ċ Ċ import Ġandroidx . lifecycle . Lifecycle Ċ import Ġandroidx . lifecycle . Lifecycle Owner Ċ import Ġandroidx . lifecycle . Lifecycle Registry Ċ import Ġorg . junit . After Ċ import Ġorg . junit . Test Ċ import Ġorg . junit . runner . RunWith Ċ import Ġorg . junit . runners . JUnit 4 Ċ import Ġkotlin . test . assertEquals Ċ Ċ private Ġconst Ġval ĠINITIAL _ STRING Ġ= Ġ" initial Ġstring " Ċ Ċ private Ġconst Ġval ĠPA USED _ STATE Ġ= Ġ" paused " Ċ private Ġconst Ġval ĠRES U MED _ STATE Ġ= Ġ" res umed " Ċ private Ġconst Ġval ĠSTART ED _ STATE Ġ= Ġ" started " Ċ private Ġconst Ġval ĠSTOP PED _ STATE Ġ= Ġ" stopped " Ċ private Ġconst Ġval ĠDEST ROY ED _ STATE Ġ= Ġ" destroy " Ċ private Ġconst Ġval ĠCRE ATED _ STATE Ġ= Ġ" created " Ċ Ċ @ RunWith ( JUnit 4 :: class ) Ċ class ĠLifecycle Lazy Re le as able Delegate Test Ġ: ĠLifecycle Owner Ġby ĠTest Lifecycle Owner Ġ{ ĊĠĠĠ Ġprivate Ġval Ġlifecycle Registry Ġ= Ġlifecycle Ġas ĠLifecycle Registry ĊĊĠĠĠ Ġprivate Ġvar Ġcurrent State : ĠString Ġ= Ġ"" ĊĠĠĠ Ġprivate Ġval Ġpause able String Ġby Ġlazy Pause able ({ ĊĠĠĠĠĠĠĠ ĠINITIAL _ STRING ĊĠĠĠ Ġ}, Ġ{ ĊĠĠĠĠĠĠĠ Ġcurrent State Ġ= ĠPA USED _ STATE ĊĠĠĠ Ġ}) ĊĊĠĠĠ Ġ@ After ĊĠĠĠ Ġfun ĠtearDown () Ġ{ ĊĠĠĠĠĠĠĠ Ġlifecycle Registry . handle Lifecycle Event ( Lifecycle . Event . ON _ DESTROY ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġ` test Ġpause able Ġbehavior `() Ġ{ ĊĠĠĠĠĠĠĠ Ġlifecycle Registry . handle Lifecycle Event ( Lifecycle . Event . ON _ CREATE ) ĊĠĠĠĠĠĠĠ Ġlifecycle Registry . handle Lifecycle Event ( Lifecycle . Event . ON _ RE SU ME ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( INITIAL _ STRING , Ġpause able String ) ĊĊĠĠĠĠĠĠĠ Ġlifecycle Registry . handle Lifecycle Event ( Lifecycle . Event . ON _ PAUSE ) ĊĊĠĠĠĠĠĠĠ ĠassertEquals ( PA USED _ STATE , Ġcurrent State ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġprivate Ġval Ġpause able Res um able String Ġby Ġlazy Pause able Res um able ({ ĊĠĠĠĠĠĠĠ ĠINITIAL _ STRING ĊĠĠĠ Ġ}, Ġ{ ĊĠĠĠĠĠĠĠ Ġcurrent State Ġ= ĠPA USED _ STATE ĊĠĠĠ Ġ}, Ġ{ ĊĠĠĠĠĠĠĠ Ġcurrent State Ġ= ĠRES U MED _ STATE ĊĠĠĠ Ġ}) ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġ` test Ġpause able Ġres um able Ġbehavior `() Ġ{ ĊĠĠĠĠĠĠĠ ĠassertEquals ( INITIAL _ STRING , Ġpause able Res um able String ) ĊĠĠĠĠĠĠĠ Ġlifecycle Registry . handle Lifecycle Event ( Lifecycle . Event . ON _ CREATE ) ĊĠĠĠĠĠĠĠ Ġlifecycle Registry . handle Lifecycle Event ( Lifecycle . Event . ON _ RE SU ME ) ĊĊĠĠĠĠĠĠĠ ĠassertEquals ( RE SU MED _ STATE , Ġcurrent State ) ĊĊĠĠĠĠĠĠĠ Ġlifecycle Registry . handle Lifecycle Event ( Lifecycle . Event . ON _ PAUSE ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( PA USED _ STATE , Ġcurrent State ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġprivate Ġval Ġresume able String Ġby Ġlazy Resume able ({ ĠINITIAL _ STRING Ġ}, Ġ{ ĊĠĠĠĠĠĠĠ Ġcurrent State Ġ= ĠRES U MED _ STATE ĊĠĠĠ Ġ}) ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġ` test Ġresume able Ġbehavior `() Ġ{ ĊĠĠĠĠĠĠĠ ĠassertEquals ( INITIAL _ STRING , Ġresume able String ) ĊĠĠĠĠĠĠĠ Ġlifecycle Registry . handle Lifecycle Event ( Lifecycle . Event . ON _ CREATE ) ĊĠĠĠĠĠĠĠ Ġlifecycle Registry . handle Lifecycle Event ( Lifecycle . Event . ON _ RE SU ME ) ĊĊĠĠĠĠĠĠĠ ĠassertEquals ( RE SU MED _ STATE , Ġcurrent State ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġprivate Ġval Ġstart able String Ġby Ġlazy Start able ({ ĠINITIAL _ STRING Ġ}, Ġ{ ĊĠĠĠĠĠĠĠ Ġcurrent State Ġ= ĠSTART ED _ STATE ĊĠĠĠ Ġ}) ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġ` test Ġstart able Ġbehavior `() Ġ{ ĊĠĠĠĠĠĠĠ ĠassertEquals ( INITIAL _ STRING , Ġstart able String ) ĊĠĠĠĠĠĠĠ Ġlifecycle Registry . handle Lifecycle Event ( Lifecycle . Event . ON _ CREATE ) ĊĠĠĠĠĠĠĠ Ġlifecycle Registry . handle Lifecycle Event ( Lifecycle . Event . ON _ RE SU ME ) ĊĊĠĠĠĠĠĠĠ ĠassertEquals ( STARTED _ STATE , Ġcurrent State ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġprivate Ġval Ġstop p able String Ġby Ġlazy Sto pp able ({ ĠINITIAL _ STRING Ġ}, Ġ{ ĊĠĠĠĠĠĠĠ Ġcurrent State Ġ= ĠSTOP PED _ STATE ĊĠĠĠ Ġ}) ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġ` test Ġstop p able Ġbehavior `() Ġ{ ĊĠĠĠĠĠĠĠ Ġlifecycle Registry . handle Lifecycle Event ( Lifecycle . Event . ON _ CREATE ) ĊĠĠĠĠĠĠĠ Ġlifecycle Registry . handle Lifecycle Event ( Lifecycle . Event . ON _ RE SU ME ) ĊĊĠĠĠĠĠĠĠ ĠassertEquals ( INITIAL _ STRING , Ġstop p able String ) ĊĊĠĠĠĠĠĠĠ Ġlifecycle Registry . handle Lifecycle Event ( Lifecycle . Event . ON _ STOP ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( STOP PED _ STATE , Ġcurrent State ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġprivate Ġval Ġstop p able Start able String Ġby Ġlazy Sto pp able Start able ({ ĠINITIAL _ STRING Ġ}, Ġ{ ĊĠĠĠĠĠĠĠ Ġcurrent State Ġ= ĠSTART ED _ STATE ĊĠĠĠ Ġ}, Ġ{ ĊĠĠĠĠĠĠĠ Ġcurrent State Ġ= ĠSTOP PED _ STATE ĊĠĠĠ Ġ}) ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġ` test Ġstop p able Ġstart able Ġbehavior `() Ġ{ ĊĠĠĠĠĠĠĠ ĠassertEquals ( INITIAL _ STRING , Ġstop p able Start able String ) ĊĠĠĠĠĠĠĠ Ġlifecycle Registry . handle Lifecycle Event ( Lifecycle . Event . ON _ CREATE ) ĊĠĠĠĠĠĠĠ Ġlifecycle Registry . handle Lifecycle Event ( Lifecycle . Event . ON _ START ) ĊĠĠĠĠĠĠĠ Ġlifecycle Registry . handle Lifecycle Event ( Lifecycle . Event . ON _ RE SU ME ) ĊĊĠĠĠĠĠĠĠ ĠassertEquals ( STARTED _ STATE , Ġcurrent State ) ĊĊĠĠĠĠĠĠĠ Ġlifecycle Registry . handle Lifecycle Event ( Lifecycle . Event . ON _ STOP ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( STOP PED _ STATE , Ġcurrent State ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġprivate Ġval Ġdestroy able String Ġby Ġlazy Destroy able ({ ĠINITIAL _ STRING Ġ}, Ġ{ ĊĠĠĠĠĠĠĠ Ġcurrent State Ġ= ĠDEST ROY ED _ STATE ĊĠĠĠ Ġ}) ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġ` test Ġdestroy able Ġbehavior `() Ġ{ ĊĠĠĠĠĠĠĠ ĠassertEquals ( INITIAL _ STRING , Ġdestroy able String ) ĊĠĠĠĠĠĠĠ Ġlifecycle Registry . handle Lifecycle Event ( Lifecycle . Event . ON _ CREATE ) ĊĠĠĠĠĠĠĠ Ġlifecycle Registry . handle Lifecycle Event ( Lifecycle . Event . ON _ RE SU ME ) ĊĊĠĠĠĠĠĠĠ Ġlifecycle Registry . handle Lifecycle Event ( Lifecycle . Event . ON _ DESTROY ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( DESTROY ED _ STATE , Ġcurrent State ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġprivate Ġval Ġcre atable String Ġby Ġlazy Cre atable ({ ĠINITIAL _ STRING Ġ}, Ġ{ ĊĠĠĠĠĠĠĠ Ġcurrent State Ġ= ĠCRE ATED _ STATE ĊĠĠĠ Ġ}) ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġ` test Ġcre atable Ġbehavior `() Ġ{ ĊĠĠĠĠĠĠĠ ĠassertEquals ( INITIAL _ STRING , Ġcre atable String ) ĊĠĠĠĠĠĠĠ Ġlifecycle Registry . handle Lifecycle Event ( Lifecycle . Event . ON _ CREATE ) ĊĠĠĠĠĠĠĠ Ġlifecycle Registry . handle Lifecycle Event ( Lifecycle . Event . ON _ RE SU ME ) ĊĊĠĠĠĠĠĠĠ Ġlifecycle Registry . handle Lifecycle Event ( Lifecycle . Event . ON _ DESTROY ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( CREATED _ STATE , Ġcurrent State ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġprivate Ġval Ġcre atable Destroy able String Ġby Ġlazy Cre atable Destroy able ({ ĠINITIAL _ STRING Ġ}, Ġ{ ĊĠĠĠĠĠĠĠ Ġcurrent State Ġ= ĠCRE ATED _ STATE ĊĠĠĠ Ġ}, Ġ{ ĊĠĠĠĠĠĠĠ Ġcurrent State Ġ= ĠDEST ROY ED _ STATE ĊĠĠĠ Ġ}) ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġ` test Ġcre atable Ġdestroy able Ġbehavior `() Ġ{ ĊĠĠĠĠĠĠĠ ĠassertEquals ( INITIAL _ STRING , Ġcre atable Destroy able String ) ĊĠĠĠĠĠĠĠ Ġlifecycle Registry . handle Lifecycle Event ( Lifecycle . Event . ON _ CREATE ) ĊĠĠĠĠĠĠĠ Ġlifecycle Registry . handle Lifecycle Event ( Lifecycle . Event . ON _ RE SU ME ) ĊĊĠĠĠĠĠĠĠ ĠassertEquals ( CREATED _ STATE , Ġcurrent State ) ĊĊĠĠĠĠĠĠĠ Ġlifecycle Registry . handle Lifecycle Event ( Lifecycle . Event . ON _ DESTROY ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( DESTROY ED _ STATE , Ġcurrent State ) ĊĠĠĠ Ġ} Ċ }