package Ġcom . duck duck go . app . feedback . ui Ċ Ċ import Ġandroidx . arch . core . executor . testing . Instant Task Executor Rule Ċ import Ġandroidx . lifecycle . Observer Ċ import Ġcom . duck duck go . app . Instant Schedulers Rule Ċ import Ġcom . duck duck go . app . broken site . Broken Site ViewModel Ċ import Ġcom . duck duck go . app . broken site . Broken Site ViewModel . Command Ċ import Ġcom . duck duck go . app . broken site . api . Broken Site Sender Ċ import Ġcom . duck duck go . app . broken site . model . Broken Site Ċ import Ġcom . duck duck go . app . pixels . App Pixel Name Ċ import Ġcom . duck duck go . app . statistics . pixels . Pixel Ċ import Ġorg . mockito . kotlin . mock Ċ import Ġorg . mockito . kotlin . verify Ċ import Ġorg . junit . After Ċ import Ġorg . junit . Assert .* Ċ import Ġorg . junit . Before Ċ import Ġorg . junit . Rule Ċ import Ġorg . junit . Test Ċ import Ġorg . mockito . Mockito . never Ċ import Ġorg . mockito . Mockito Annotations Ċ Ċ class ĠBroken Site ViewModel Test Ġ{ ĊĊĠĠĠ Ġ@ get : Rule ĊĠĠĠ Ġ@ Suppress (" unused ") ĊĠĠĠ Ġvar Ġinstant Task Executor Rule Ġ= ĠInstant Task Executor Rule () ĊĊĠĠĠ Ġ@ get : Rule ĊĠĠĠ Ġ@ Suppress (" unused ") ĊĠĠĠ Ġval Ġs chedulers Ġ= ĠInstant Schedulers Rule () ĊĊĠĠĠ Ġprivate Ġval Ġmock Pixel : ĠPixel Ġ= Ġmock () ĊĊĠĠĠ Ġprivate Ġval Ġmock Broken Site Sender : ĠBroken Site Sender Ġ= Ġmock () ĊĊĠĠĠ Ġprivate Ġval Ġmock Command Observer : ĠObserver < Command > Ġ= Ġmock () ĊĊĠĠĠ Ġprivate Ġlateinit Ġvar Ġtest ee : ĠBroken Site ViewModel ĊĊĠĠĠ Ġprivate Ġval Ġview State : ĠBroken Site ViewModel . ViewState ĊĠĠĠĠĠĠĠ Ġget () Ġ= Ġtest ee . view State . value !! ĊĊĠĠĠ Ġ@ Before ĊĠĠĠ Ġfun Ġbefore () Ġ{ ĊĠĠĠĠĠĠĠ ĠMockito Annotations . open Mocks ( this ) ĊĠĠĠĠĠĠĠ Ġtest ee Ġ= ĠBroken Site ViewModel ( mock Pixel , Ġmock Broken Site Sender ) ĊĠĠĠĠĠĠĠ Ġtest ee . command . observe Fore ver ( mock Command Observer ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ After ĊĠĠĠ Ġfun Ġafter () Ġ{ ĊĠĠĠĠĠĠĠ Ġtest ee . command . remove Observer ( mock Command Observer ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġwhen Initialized Then Cannot Submit () Ġ{ ĊĠĠĠĠĠĠĠ ĠassertFalse ( view State . submit Allowed ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġwhen Category Selected Then Can Submit () Ġ{ ĊĠĠĠĠĠĠĠ Ġselect And Accept Category () ĊĠĠĠĠĠĠĠ ĠassertTrue ( view State . submit Allowed ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġwhen Category Changed But Not Selected Then Cannot Submit () Ġ{ ĊĠĠĠĠĠĠĠ Ġtest ee . on Category Index Changed ( 0 ) ĊĠĠĠĠĠĠĠ ĠassertFalse ( view State . submit Allowed ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġwhen No Category Selected Then Cannot Submit () Ġ{ ĊĠĠĠĠĠĠĠ Ġselect And Accept Category (- 1 ) ĊĠĠĠĠĠĠĠ ĠassertFalse ( view State . submit Allowed ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġwhen Category Selected But Not Changed Then Return Old Category () Ġ{ ĊĠĠĠĠĠĠĠ Ġtest ee . on Category Index Changed ( 0 ) ĊĠĠĠĠĠĠĠ Ġtest ee . on Category Accepted () ĊĠĠĠĠĠĠĠ Ġtest ee . on Category Index Changed ( 1 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( 0 , Ġview State . index Selected ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġwhen Category Accepted And Incorrect Index Then Return Null Category () Ġ{ ĊĠĠĠĠĠĠĠ Ġselect And Accept Category (- 1 ) ĊĠĠĠĠĠĠĠ ĠassertNull ( view State . category Selected ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġwhen Category Accepted And Correct Index Then Return Category () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġindex Selected Ġ= Ġ 0 ĊĠĠĠĠĠĠĠ Ġselect And Accept Category ( index Selected ) ĊĊĠĠĠĠĠĠĠ Ġval Ġcategory Expected Ġ= Ġtest ee . categories [ index Selected ] ĊĠĠĠĠĠĠĠ ĠassertEquals ( category Expected , Ġview State . category Selected ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġwhen Can Submit Broken Site And Url NotNull And Submit Pressed Then Report And Pixel Submitted () Ġ{ ĊĠĠĠĠĠĠĠ Ġtest ee . setInitial Broken Site ( url , Ġ"", Ġ"", Ġfalse ) ĊĠĠĠĠĠĠĠ Ġselect And Accept Category () ĊĠĠĠĠĠĠĠ Ġtest ee . on Submit Pressed (" web View Version ") ĊĊĠĠĠĠĠĠĠ Ġval Ġbroken Site Expected Ġ= ĠBroken Site ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcategory Ġ= Ġtest ee . categories [ 0 ]. key , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġsite Url Ġ= Ġurl , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġupgrade Https Ġ= Ġfalse , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġblocked Track ers Ġ= Ġ"", ĊĠĠĠĠĠĠĠĠĠĠĠ Ġsur rog ates Ġ= Ġ"", ĊĠĠĠĠĠĠĠĠĠĠĠ ĠwebView Version Ġ= Ġ" web View Version ", ĊĠĠĠĠĠĠĠĠĠĠĠ Ġsite Type Ġ= ĠBroken Site ViewModel . DE SK TOP _ SITE ĊĠĠĠĠĠĠĠ Ġ) ĊĊĠĠĠĠĠĠĠ Ġverify ( mock Pixel ). fire ( App Pixel Name . BRO KEN _ SITE _ REPORT ED , Ġmap Of (" url " Ġto Ġurl )) ĊĠĠĠĠĠĠĠ Ġverify ( mock Broken Site Sender ). submit Broken Site Feedback ( broken Site Expected ) ĊĠĠĠĠĠĠĠ Ġverify ( mock Command Observer ). on Changed ( Command . Confirm And Finish ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġwhen Can Submit Broken Site And Url IsEmpty And Submit Pressed Then DoNot Submit () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġnull Url Ġ= Ġ"" ĊĠĠĠĠĠĠĠ Ġtest ee . setInitial Broken Site ( null Url , Ġ"", Ġ"", Ġfalse ) ĊĠĠĠĠĠĠĠ Ġselect And Accept Category () ĊĠĠĠĠĠĠĠ Ġtest ee . on Submit Pressed (" web View Version ") ĊĊĠĠĠĠĠĠĠ Ġval Ġbroken Site Expected Ġ= ĠBroken Site ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcategory Ġ= Ġtest ee . categories [ 0 ]. key , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġsite Url Ġ= Ġnull Url , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġupgrade Https Ġ= Ġfalse , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġblocked Track ers Ġ= Ġ"", ĊĠĠĠĠĠĠĠĠĠĠĠ Ġsur rog ates Ġ= Ġ"", ĊĠĠĠĠĠĠĠĠĠĠĠ ĠwebView Version Ġ= Ġ" web View Version ", ĊĠĠĠĠĠĠĠĠĠĠĠ Ġsite Type Ġ= ĠBroken Site ViewModel . DE SK TOP _ SITE ĊĠĠĠĠĠĠĠ Ġ) ĊĊĠĠĠĠĠĠĠ Ġverify ( mock Pixel , Ġnever ()). fire ( App Pixel Name . BRO KEN _ SITE _ REPORT ED , Ġmap Of (" url " Ġto Ġnull Url )) ĊĠĠĠĠĠĠĠ Ġverify ( mock Broken Site Sender , Ġnever ()). submit Broken Site Feedback ( broken Site Expected ) ĊĠĠĠĠĠĠĠ Ġverify ( mock Command Observer ). on Changed ( Command . Confirm And Finish ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġwhen Url Is Desktop Then Send Desktop Parameter () Ġ{ ĊĠĠĠĠĠĠĠ Ġtest ee . setInitial Broken Site ( url , Ġ"", Ġ"", Ġfalse ) ĊĠĠĠĠĠĠĠ Ġselect And Accept Category () ĊĊĠĠĠĠĠĠĠ Ġval Ġbroken Site Expected Ġ= Ġtest ee . get Broken Site ("") ĊĠĠĠĠĠĠĠ ĠassertEquals ( Broken Site ViewModel . DE SK TOP _ SITE , Ġbroken Site Expected . site Type ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġwhen Url Is Mobile Then Send Mobile Parameter () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġurl Ġ= Ġ" http :// m . example . com " ĊĠĠĠĠĠĠĠ Ġtest ee . setInitial Broken Site ( url , Ġ"", Ġ"", Ġfalse ) ĊĠĠĠĠĠĠĠ Ġselect And Accept Category () ĊĊĠĠĠĠĠĠĠ Ġval Ġbroken Site Expected Ġ= Ġtest ee . get Broken Site ("") ĊĠĠĠĠĠĠĠ ĠassertEquals ( Broken Site ViewModel . MOB ILE _ SITE , Ġbroken Site Expected . site Type ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġwhen Get Broken Site Then Return Correct Category () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġurl Ġ= Ġ" http :// m . example . com " ĊĠĠĠĠĠĠĠ Ġval Ġcategory Index Ġ= Ġ 0 ĊĠĠĠĠĠĠĠ Ġtest ee . setInitial Broken Site ( url , Ġ"", Ġ"", Ġfalse ) ĊĠĠĠĠĠĠĠ Ġselect And Accept Category ( category Index ) ĊĊĠĠĠĠĠĠĠ Ġval Ġcategory Expected Ġ= Ġtest ee . categories [ category Index ]. key ĊĠĠĠĠĠĠĠ Ġval Ġbroken Site Expected Ġ= Ġtest ee . get Broken Site ("") ĊĠĠĠĠĠĠĠ ĠassertEquals ( category Expected , Ġbroken Site Expected . category ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġwhen Cancel Selection Then Assign Old Index Value () Ġ{ ĊĠĠĠĠĠĠĠ Ġtest ee . setInitial Broken Site ("", Ġ"", Ġ"", Ġfalse ) ĊĠĠĠĠĠĠĠ Ġselect And Accept Category ( 0 ) ĊĠĠĠĠĠĠĠ Ġtest ee . on Category Index Changed ( 1 ) ĊĠĠĠĠĠĠĠ Ġtest ee . on Category Selection Cancelled () ĊĊĠĠĠĠĠĠĠ ĠassertEquals ( 0 , Ġtest ee . index Selected ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġwhen Cancel Selection And No Previous Value Then Assign Minus One () Ġ{ ĊĠĠĠĠĠĠĠ Ġtest ee . setInitial Broken Site ("", Ġ"", Ġ"", Ġfalse ) ĊĠĠĠĠĠĠĠ Ġtest ee . on Category Index Changed ( 1 ) ĊĠĠĠĠĠĠĠ Ġtest ee . on Category Selection Cancelled () ĊĊĠĠĠĠĠĠĠ ĠassertEquals (- 1 , Ġtest ee . index Selected ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġprivate Ġfun Ġselect And Accept Category ( index Selected : ĠInt Ġ= Ġ 0 ) Ġ{ ĊĠĠĠĠĠĠĠ Ġtest ee . on Category Index Changed ( index Selected ) ĊĠĠĠĠĠĠĠ Ġtest ee . on Category Accepted () ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġcompanion Ġobject ĠConstants Ġ{ ĊĠĠĠĠĠĠĠ Ġprivate Ġconst Ġval Ġurl Ġ= Ġ" http :// example . com " ĊĠĠĠ Ġ} Ċ } Ċ