package Ġap pt ent ive . com . android . feedback . rating . interaction Ċ Ċ import Ġandroid . content . Context Ċ import Ġandroidx . test . ext . junit . runners . Android JUnit 4 Ċ import Ġandroidx . test . platform . app . Instrumentation Registry Ċ import Ġap pt ent ive . com . android . TestCase Ċ import Ġap pt ent ive . com . android . concurrent . Executors Ċ import Ġap pt ent ive . com . android . concurrent . Immediate Executor Ċ import Ġap pt ent ive . com . android . feedback . Eng agement Result Ċ import Ġap pt ent ive . com . android . feedback . eng agement . Eng agement Callback Ċ import Ġap pt ent ive . com . android . feedback . eng agement . Eng agement Context Ċ import Ġap pt ent ive . com . android . feedback . eng agement . Mock Eng agement Context Ċ import Ġap pt ent ive . com . android . feedback . eng agement . Payload Sender Callback Ċ import Ġap pt ent ive . com . android . feedback . eng agement . inter actions . Interaction Id Ċ import Ġap pt ent ive . com . android . feedback . rating . review manager . In App Review Callback Ċ import Ġap pt ent ive . com . android . feedback . rating . review manager . In App Review Manager Ċ import Ġap pt ent ive . com . android . feedback . rating . review manager . In App Review ManagerFactory Ċ import Ġorg . junit . Test Ċ import Ġorg . junit . runner . RunWith Ċ import Ġjava . lang . AssertionError Ċ Ċ @ RunWith ( Android JUnit 4 :: class ) Ċ class ĠIn App Review Interaction Launcher Test Ġ: ĠTestCase () Ġ{ ĊĊĠĠĠ Ġ// ĠContext Ġof Ġthe Ġapp Ġunder Ġtest . ĊĠĠĠ Ġprivate Ġvar Ġapp Context Ġ= ĠInstrument ation Registry . get Instrumentation (). target Context ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġtest In App Review NotSupported () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġlauncher : ĠIn App Review Interaction Launcher Ġ= ĊĠĠĠĠĠĠĠĠĠĠĠ ĠIn App Review Interaction Launcher ( Mock In App Review ManagerFactory ( Mock In App Review Manager . un Supported ())) ĊĠĠĠĠĠĠĠ Ġlauncher . launch Interaction ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcreate Eng agement Context ( on Eng age Ġ= Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġadd Result (" eng age Ġ${ it . event }") ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠEng agement Result . Interaction Shown ( it . interaction Id Ġas ĠInteraction Id ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ}), ĊĠĠĠĠĠĠĠĠĠĠĠ ĠIn App Review Interaction (" 5 8 eeb bf 2 1 2 7 0 9 6 7 0 4 e 0 0 0 0 d 0 ") ĊĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠĠĠ Ġassert Results ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ" eng age Ġcom . ap pt ent ive # In App Rating Dialog # launch ", ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ" eng age Ġcom . ap pt ent ive # In App Rating Dialog # request ", ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ" eng age Ġcom . ap pt ent ive # In App Rating Dialog # not _ supported " ĊĠĠĠĠĠĠĠ Ġ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġtest In App Review Failed () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġlauncher : ĠIn App Review Interaction Launcher Ġ= ĊĠĠĠĠĠĠĠĠĠĠĠ ĠIn App Review Interaction Launcher ( Mock In App Review ManagerFactory ( Mock In App Review Manager . failed (" Something Ġwent Ġwrong "))) ĊĠĠĠĠĠĠĠ Ġlauncher . launch Interaction ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcreate Eng agement Context ( on Eng age Ġ= Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġadd Result (" eng age Ġ${ it . event }") ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠEng agement Result . Interaction Not Shown (" Something Ġwent Ġwrong ") ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ}), ĊĠĠĠĠĠĠĠĠĠĠĠ ĠIn App Review Interaction (" 5 8 eeb bf 2 1 2 7 0 9 6 7 0 4 e 0 0 0 0 d 0 ") ĊĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠĠĠ Ġassert Results ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ" eng age Ġcom . ap pt ent ive # In App Rating Dialog # launch ", ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ" eng age Ġcom . ap pt ent ive # In App Rating Dialog # request ", ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ" eng age Ġcom . ap pt ent ive # In App Rating Dialog # not _ shown " ĊĠĠĠĠĠĠĠ Ġ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġtest In App Review Supported Launch Suc ceed () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġlauncher : ĠIn App Review Interaction Launcher Ġ= ĊĠĠĠĠĠĠĠĠĠĠĠ ĠIn App Review Interaction Launcher ( Mock In App Review ManagerFactory ( Mock In App Review Manager . successful ())) ĊĠĠĠĠĠĠĠ Ġlauncher . launch Interaction ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcreate Eng agement Context ( context Ġ= Ġapp Context , Ġon Eng age Ġ= Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġadd Result (" eng age Ġ${ it . event }") ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠEng agement Result . Interaction Shown ( it . interaction Id Ġas ĠInteraction Id ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ}), ĊĠĠĠĠĠĠĠĠĠĠĠ ĠIn App Review Interaction (" 5 8 eeb bf 2 1 2 7 0 9 6 7 0 4 e 0 0 0 0 d 0 ") ĊĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠĠĠ Ġassert Results ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ" eng age Ġcom . ap pt ent ive # In App Rating Dialog # launch ", ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ" eng age Ġcom . ap pt ent ive # In App Rating Dialog # request ", ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ" eng age Ġcom . ap pt ent ive # In App Rating Dialog # shown " ĊĠĠĠĠĠĠĠ Ġ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġprivate Ġfun Ġcreate Eng agement Context ( context : ĠContext Ġ= Ġapp Context , Ġon Eng age : ĠEng agement Callback ?): ĠEng agement Context Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġmock Eng agement Context Ġ= Ġcreate Mock Eng agement Context ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġon Eng age Ġ= Ġon Eng age ĊĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠĠĠ Ġreturn ĠEng agement Context ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġeng agement Ġ= Ġmock Eng agement Context . get Eng agement (), ĊĠĠĠĠĠĠĠĠĠĠĠ Ġpayload Sender Ġ= Ġmock Eng agement Context . get Payload Sender (), ĊĠĠĠĠĠĠĠĠĠĠĠ Ġexec utors Ġ= ĠExec utors ( Immediate Executor , ĠIm mediate Executor ) ĊĠĠĠĠĠĠĠ Ġ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġprivate Ġfun Ġcreate Mock Eng agement Context ( ĊĠĠĠĠĠĠĠ Ġon Eng age : ĠEng agement Callback ? Ġ= Ġnull , ĊĠĠĠĠĠĠĠ Ġon Send Payload : ĠPayload Sender Callback ? Ġ= Ġnull ĊĠĠĠ Ġ) Ġ= ĠMock Eng agement Context ( ĊĠĠĠĠĠĠĠ Ġon Eng age Ġ= Ġon Eng age Ġ?: Ġ{ Ġargs Ġ-> ĊĠĠĠĠĠĠĠĠĠĠĠ Ġadd Result ( args ) ĊĠĠĠĠĠĠĠĠĠĠĠ ĠEng agement Result . Interaction Shown ( args . interaction Id Ġas ĠInteraction Id ) ĊĠĠĠĠĠĠĠ Ġ}, ĊĠĠĠĠĠĠĠ Ġon Send Payload Ġ= Ġon Send Payload Ġ?: Ġ{ Ġpayload Ġ-> ĊĠĠĠĠĠĠĠĠĠĠĠ Ġadd Result ( payload . toJson ()) ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ) Ċ } Ċ Ċ class ĠMock In App Review Manager ( val Ġsupported : ĠBoolean , Ġval ĠerrorMessage : ĠString ?) Ġ: ĊĠĠĠ ĠIn App Review Manager Ġ{ ĊĠĠĠ Ġoverride Ġfun Ġstart Review Flow ( callback : ĠIn App Review Callback ) Ġ{ ĊĠĠĠĠĠĠĠ Ġif Ġ( supported ) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġif Ġ( errorMessage Ġ!= Ġnull ) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġcallback . on Review Flow Failed ( errorMessage ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ} Ġelse Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġcallback . on Review Complete () ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠ Ġ} Ġelse Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġthrow ĠAssertionError (" Should Ġnot Ġget Ġthere ") ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġoverride Ġfun ĠisIn App Review Supported (): ĠBoolean Ġ= Ġsupported ĊĊĠĠĠ Ġcompanion Ġobject Ġ{ ĊĠĠĠĠĠĠĠ Ġfun Ġsuccessful (): ĠIn App Review Manager Ġ= ĠMock In App Review Manager ( true , Ġnull ) ĊĊĠĠĠĠĠĠĠ Ġfun Ġfailed ( errorMessage : ĠString ): ĠIn App Review Manager Ġ= ĠMock In App Review Manager ( true , ĠerrorMessage ) ĊĊĠĠĠĠĠĠĠ Ġfun Ġun Supported (): ĠIn App Review Manager Ġ= ĠMock In App Review Manager ( false , Ġnull ) ĊĠĠĠ Ġ} Ċ } Ċ Ċ class ĠMock In App Review ManagerFactory ( private Ġval Ġmanager : ĠIn App Review Manager ) Ġ: ĊĠĠĠ ĠIn App Review ManagerFactory Ġ{ ĊĠĠĠ Ġoverride Ġfun Ġcreate Review Manager ( context : ĠContext ): ĠIn App Review Manager Ġ= Ġmanager Ċ } Ċ