/* Ċ Ġ* ĠCopyright Ġ( c ) Ġ 2 0 1 9 ĠD uck Duck Go Ċ Ġ* Ċ Ġ* ĠLicensed Ġunder Ġthe ĠApache ĠLicense , ĠVersion Ġ 2 . 0 Ġ( the Ġ" License "); Ċ Ġ* Ġyou Ġmay Ġnot Ġuse Ġthis Ġfile Ġexcept Ġin Ġcompliance Ġwith Ġthe ĠLicense . Ċ Ġ* ĠYou Ġmay Ġobtain Ġa Ġcopy Ġof Ġthe ĠLicense Ġat Ċ Ġ* Ċ Ġ* ĠĠĠĠ Ġhttp :// www . apache . org / licenses / LICENSE - 2 . 0 Ċ Ġ* Ċ Ġ* ĠUnless Ġrequired Ġby Ġapplicable Ġlaw Ġor Ġagreed Ġto Ġin Ġwriting , Ġsoftware Ċ Ġ* Ġdistributed Ġunder Ġthe ĠLicense Ġis Ġdistributed Ġon Ġan Ġ" AS ĠIS " ĠBASIS , Ċ Ġ* ĠWITHOUT ĠWARRANTIES ĠOR ĠCONDITIONS ĠOF ĠANY ĠKIND , Ġeither Ġexpress Ġor Ġimplied . Ċ Ġ* ĠSee Ġthe ĠLicense Ġfor Ġthe Ġspecific Ġlanguage Ġgoverning Ġpermissions Ġand Ċ Ġ* Ġlimitations Ġunder Ġthe ĠLicense . Ċ Ġ*/ Ċ Ċ package Ġcom . duck duck go . app . browser . rating . db Ċ Ċ import Ġandroidx . room . Room Ċ import Ġandroidx . test . platform . app . Instrumentation Registry Ċ import Ġcom . duck duck go . app . Coroutine Test Rule Ċ import Ġcom . duck duck go . app . global . db . App Database Ċ import Ġcom . duck duck go . app . global . rating . Prompt Count Ċ import Ġkotlinx . coroutines . Experimental Cor outines Api Ċ import Ġkotlinx . coroutines . test . run Test Ċ import Ġorg . junit . After Ċ import Ġorg . junit . Assert . assertFalse Ċ import Ġorg . junit . Assert . assertTrue Ċ import Ġorg . junit . Before Ċ import Ġorg . junit . Rule Ċ import Ġorg . junit . Test Ċ Ċ @ Experimental Cor outines Api Ċ @ Suppress (" Remove Explicit Type Arguments ") Ċ class ĠApp En joy ment Database Repository Test Ġ{ ĊĊĠĠĠ Ġ@ Experimental Cor outines Api ĊĠĠĠ Ġ@ get : Rule ĊĠĠĠ Ġvar Ġcor outines Test Rule Ġ= ĠCor outine Test Rule () ĊĊĠĠĠ Ġprivate Ġlateinit Ġvar Ġtest ee : ĠApp En joy ment Database Repository ĊĊĠĠĠ Ġprivate Ġlateinit Ġvar Ġdatabase : ĠApp Database ĊĠĠĠ Ġprivate Ġlateinit Ġvar Ġdao : ĠApp En joy ment Dao ĊĊĠĠĠ Ġ@ Before ĊĠĠĠ Ġfun Ġsetup () Ġ{ ĊĠĠĠĠĠĠĠ Ġdatabase Ġ= ĠRoom . in Memory Database Builder ( Instrumentation Registry . get Instrumentation (). target Context , ĠApp Database :: class . java ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. allow MainThread Queries () ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. build () ĊĊĠĠĠĠĠĠĠ Ġdao Ġ= Ġdatabase . app En joy ment Dao () ĊĠĠĠĠĠĠĠ Ġtest ee Ġ= ĠApp En joy ment Database Repository ( dao ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ After ĊĠĠĠ Ġfun Ġafter () Ġ{ ĊĠĠĠĠĠĠĠ Ġdatabase . close () ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġwhen First Created Then Prompt 1 Can Be Shown () Ġ= Ġrun Test Ġ{ ĊĠĠĠĠĠĠĠ ĠassertTrue ( test ee . can User Be Shown First Prompt ()) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġwhen User G ave Feedback For Prompt 1 Then Prompt 1 Cannot Be Shown () Ġ= Ġrun Test Ġ{ ĊĠĠĠĠĠĠĠ Ġtest ee . on User Selected To Give Feedback ( FIRST _ PROMPT ) ĊĠĠĠĠĠĠĠ ĠassertFalse ( test ee . can User Be Shown First Prompt ()) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġwhen User Decl ined To Give Feedback For Prompt 1 Then Prompt 1 Cannot Be Shown () Ġ= Ġrun Test Ġ{ ĊĠĠĠĠĠĠĠ Ġtest ee . on User Decl ined To Give Feedback ( FIRST _ PROMPT ) ĊĠĠĠĠĠĠĠ ĠassertFalse ( test ee . can User Be Shown First Prompt ()) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġwhen User G ave Rating For Prompt 1 Then Prompt 1 Cannot Be Shown () Ġ= Ġrun Test Ġ{ ĊĠĠĠĠĠĠĠ Ġtest ee . on User Selected To Rate App ( FIRST _ PROMPT ) ĊĠĠĠĠĠĠĠ ĠassertFalse ( test ee . can User Be Shown First Prompt ()) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġwhen User Decl ined Rating For Prompt 1 Then Prompt 1 Cannot Be Shown () Ġ= Ġrun Test Ġ{ ĊĠĠĠĠĠĠĠ Ġtest ee . on User Decl ined To Rate App ( FIRST _ PROMPT ) ĊĠĠĠĠĠĠĠ ĠassertFalse ( test ee . can User Be Shown First Prompt ()) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġwhen User Decl ined ToS ay Whether En joy ing For Prompt 1 Then Prompt 1 Cannot Be Shown () Ġ= Ġrun Test Ġ{ ĊĠĠĠĠĠĠĠ Ġtest ee . on User Decl ined ToS ay If En joy ing App ( FIRST _ PROMPT ) ĊĠĠĠĠĠĠĠ ĠassertFalse ( test ee . can User Be Shown First Prompt ()) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġwhen User G ave Feedback For Prompt 2 Then Prompt 2 Cannot Be Shown Again () Ġ= Ġrun Test Ġ{ ĊĠĠĠĠĠĠĠ Ġtest ee . on User Selected To Give Feedback ( SECOND _ PROMPT ) ĊĠĠĠĠĠĠĠ ĠassertFalse ( test ee . can User Be Shown Second Prompt ()) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġwhen User Decl ined To Give Feedback For Prompt 2 Then Prompt 2 Cannot Be Shown Again () Ġ= Ġrun Test Ġ{ ĊĠĠĠĠĠĠĠ Ġtest ee . on User Decl ined To Give Feedback ( SECOND _ PROMPT ) ĊĠĠĠĠĠĠĠ ĠassertFalse ( test ee . can User Be Shown Second Prompt ()) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġwhen User G ave Rating For Prompt 2 Then Prompt 2 Cannot Be Shown Again () Ġ= Ġrun Test Ġ{ ĊĠĠĠĠĠĠĠ Ġtest ee . on User Selected To Rate App ( SECOND _ PROMPT ) ĊĠĠĠĠĠĠĠ ĠassertFalse ( test ee . can User Be Shown Second Prompt ()) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġwhen User Decl ined Rating For Prompt 2 Then Prompt 2 Cannot Be Shown Again () Ġ= Ġrun Test Ġ{ ĊĠĠĠĠĠĠĠ Ġtest ee . on User Decl ined To Rate App ( SECOND _ PROMPT ) ĊĠĠĠĠĠĠĠ ĠassertFalse ( test ee . can User Be Shown Second Prompt ()) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġwhen User Decl ined ToS ay Whether En joy ing For Prompt 2 Then Prompt 2 Cannot Be Shown Again () Ġ= Ġrun Test Ġ{ ĊĠĠĠĠĠĠĠ Ġtest ee . on User Decl ined ToS ay If En joy ing App ( SECOND _ PROMPT ) ĊĠĠĠĠĠĠĠ ĠassertFalse ( test ee . can User Be Shown Second Prompt ()) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġcompanion Ġobject Ġ{ ĊĠĠĠĠĠĠĠ Ġprivate Ġval ĠFIRST _ PROMPT Ġ= ĠPrompt Count ( 1 ) ĊĠĠĠĠĠĠĠ Ġprivate Ġval ĠSE COND _ PROMPT Ġ= ĠPrompt Count ( 2 ) ĊĠĠĠ Ġ} Ċ } Ċ