/* Ċ Ġ* ĠCopyright Ġ( c ) Ġ 2 0 1 7 Ġ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 Ċ Ċ import Ġandroid . arch . core . executor . testing . Instant Task Executor Rule Ċ import Ġandroid . arch . lifecycle . Mutable LiveData Ċ import Ġandroid . arch . lifecycle . Observer Ċ import Ġandroid . arch . persistence . room . Room Ċ import Ġandroid . support . test . Instrumentation Registry Ċ import Ġandroid . view . MenuItem Ċ import Ġandroid . view . View Ċ import Ġcom . duck duck go . app . Instant Schedulers Rule Ċ import Ġcom . duck duck go . app . autocomplete . api . Auto Complete Api Ċ import Ġcom . duck duck go . app . bookmarks . db . Bookmark Entity Ċ import Ġcom . duck duck go . app . bookmarks . db . Book marks Dao Ċ import Ġcom . duck duck go . app . browser . Browser Tab ViewModel . Command Ċ import Ġcom . duck duck go . app . browser . Browser Tab ViewModel . Command . Display Message Ċ import Ġcom . duck duck go . app . browser . Browser Tab ViewModel . Command . Navigate Ċ import Ġcom . duck duck go . app . browser . Long Press Handler . Required Action . Download File Ċ import Ġcom . duck duck go . app . browser . Long Press Handler . Required Action . Open In New Tab Ċ import Ġcom . duck duck go . app . browser . addTo Home . AddTo Home Capability Detector Ċ import Ġcom . duck duck go . app . browser . favicon . Fav icon Downloader Ċ import Ġcom . duck duck go . app . browser . om nib ar . O mn ib ar Entry Converter Ċ import Ġcom . duck duck go . app . browser . session . WebView Session Storage Ċ import Ġcom . duck duck go . app . global . db . App Configuration Dao Ċ import Ġcom . duck duck go . app . global . db . App Configuration Entity Ċ import Ġcom . duck duck go . app . global . db . App Database Ċ import Ġcom . duck duck go . app . global . model . Site Factory Ċ import Ġcom . duck duck go . app . privacy . db . Network Leader board Dao Ċ import Ġcom . duck duck go . app . privacy . db . Network Leader board Entry Ċ import Ġcom . duck duck go . app . privacy . db . Site Vis ited Entity Ċ import Ġcom . duck duck go . app . privacy . model . Privacy Grade Ċ import Ġcom . duck duck go . app . privacy . model . Privacy Pract ices Ċ import Ġcom . duck duck go . app . privacy . store . Pre val ence Store Ċ import Ġcom . duck duck go . app . privacy . store . Terms Of Service Store Ċ import Ġcom . duck duck go . app . settings . db . Settings DataStore Ċ import Ġcom . duck duck go . app . statistics . api . Statistics Updater Ċ import Ġcom . duck duck go . app . tabs . model . Tab Repository Ċ import Ġcom . duck duck go . app . tracker detection . model . Tracker Network Ċ import Ġcom . duck duck go . app . tracker detection . model . Tracker Networks Ċ import Ġcom . duck duck go . app . tracker detection . model . Tracking Event Ċ import Ġcom . n ha ar man . mockito _ kotlin .* Ċ import Ġorg . junit . After Ċ import Ġorg . junit . Assert .* Ċ import Ġorg . junit . Before Ċ import Ġorg . junit . Rule Ċ import Ġorg . junit . Test Ċ import Ġorg . mockito .* Ċ import Ġorg . mockito . Argument Matchers . any String Ċ import Ġorg . mockito . Mockito . never Ċ import Ġorg . mockito . Mockito . verify Ċ Ċ class ĠBrowser Tab 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 () ĊĊĠĠĠ Ġ@ Mock ĊĠĠĠ Ġprivate Ġlateinit Ġvar Ġmock Pre val ence Store : ĠPre val ence Store ĊĊĠĠĠ Ġ@ Mock ĊĠĠĠ Ġprivate Ġlateinit Ġvar Ġmock Tracker Networks : ĠTracker Networks ĊĊĠĠĠ Ġ@ Mock ĊĠĠĠ Ġprivate Ġlateinit Ġvar Ġmock Network Leader board Dao : ĠNetwork Leader board Dao ĊĊĠĠĠ Ġ@ Mock ĊĠĠĠ Ġprivate Ġlateinit Ġvar Ġmock Statistics Updater : ĠStatistics Updater ĊĊĠĠĠ Ġ@ Mock ĊĠĠĠ Ġprivate Ġlateinit Ġvar Ġmock Query Observer : ĠObserver < String > ĊĊĠĠĠ Ġ@ Mock ĊĠĠĠ Ġprivate Ġlateinit Ġvar Ġmock Command Observer : ĠObserver < Command > ĊĊĠĠĠ Ġ@ Mock ĊĠĠĠ Ġprivate Ġlateinit Ġvar Ġmock Privacy Pract ices : ĠPrivacy Pract ices ĊĊĠĠĠ Ġ@ Mock ĊĠĠĠ Ġprivate Ġlateinit Ġvar Ġmock Settings Store : ĠSettings DataStore ĊĊĠĠĠ Ġ@ Mock ĊĠĠĠ Ġprivate Ġlateinit Ġvar Ġmock Auto Complete Api : ĠAuto Complete Api ĊĊĠĠĠ Ġ@ Mock ĊĠĠĠ Ġprivate Ġlateinit Ġvar Ġbook marks Dao : ĠBook marks Dao ĊĊĠĠĠ Ġ@ Mock ĊĠĠĠ Ġprivate Ġlateinit Ġvar Ġmock Long Press Handler : ĠLong Press Handler ĊĊĠĠĠ Ġ@ Mock ĊĠĠĠ Ġprivate Ġlateinit Ġvar Ġmock O mn ib ar Converter : ĠO mn ib ar Entry Converter ĊĊĠĠĠ Ġ@ Mock ĊĠĠĠ Ġprivate Ġlateinit Ġvar Ġmock Tabs Repository : ĠTab Repository ĊĊĠĠĠ Ġ@ Mock ĊĠĠĠ Ġprivate Ġlateinit Ġvar ĠwebView Session Storage : ĠWebView Session Storage ĊĊĠĠĠ Ġ@ Mock ĊĠĠĠ Ġprivate Ġlateinit Ġvar Ġmock Fav icon Downloader : ĠF av icon Downloader ĊĊĠĠĠ Ġ@ Mock ĊĠĠĠ Ġprivate Ġlateinit Ġvar Ġmock AddTo Home Capability Detector : ĠAdd To Home Capability Detector ĊĊĠĠĠ Ġ@ Captor ĊĠĠĠ Ġprivate Ġlateinit Ġvar Ġcommand Captor : ĠArgument Captor < Command > ĊĊĠĠĠ Ġprivate Ġlateinit Ġvar Ġdb : ĠApp Database ĊĊĠĠĠ Ġprivate Ġlateinit Ġvar Ġapp Configuration Dao : ĠApp Configuration Dao ĊĊĠĠĠ Ġprivate Ġlateinit Ġvar Ġtest ee : ĠBrowser Tab ViewModel ĊĊĠĠĠ Ġ@ Before ĊĠĠĠ Ġfun Ġbefore () Ġ{ ĊĠĠĠĠĠĠĠ ĠMockito Annotations . init Mocks ( this ) ĊĊĠĠĠĠĠĠĠ Ġdb Ġ= ĠRoom . in Memory Database Builder ( Instrumentation Registry . getContext (), ĠApp Database :: class . java ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. allow MainThread Queries () ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. build () ĊĠĠĠĠĠĠĠ Ġapp Configuration Dao Ġ= Ġdb . app Configuration Dao () ĊĊĠĠĠĠĠĠĠ Ġval Ġsite Factory Ġ= ĠSite Factory ( mock Privacy Pract ices , Ġmock Tracker Networks , Ġpre val ence Store Ġ= Ġmock Pre val ence Store ) ĊĊĠĠĠĠĠĠĠ Ġwhenever ( mock Tabs Repository . retrieve Site Data ( any ())). thenReturn ( Mutable LiveData ()) ĊĠĠĠĠĠĠĠ Ġwhenever ( mock Privacy Pract ices . privacy Pract ices For ( any ())). thenReturn ( Privacy Pract ices . UNKNOWN ) ĊĊĠĠĠĠĠĠĠ Ġtest ee Ġ= ĠBrowser Tab ViewModel ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġstatistics Updater Ġ= Ġmock Statistics Updater , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġquery Url Converter Ġ= Ġmock O mn ib ar Converter , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġdu ck Duck Go Url Detector Ġ= ĠD uck Duck Go Url Detector (), ĊĠĠĠĠĠĠĠĠĠĠĠ Ġsite Factory Ġ= Ġsite Factory , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġtab Repository Ġ= Ġmock Tabs Repository , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġnetwork Leader board Dao Ġ= Ġmock Network Leader board Dao , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġauto Complete Api Ġ= Ġmock Auto Complete Api , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġapp Settings Preferences Store Ġ= Ġmock Settings Store , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġbook marks Dao Ġ= Ġbook marks Dao , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġlong Press Handler Ġ= Ġmock Long Press Handler , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġapp Configuration Dao Ġ= Ġapp Configuration Dao , ĊĠĠĠĠĠĠĠĠĠĠĠ ĠwebView Session Storage Ġ= ĠwebView Session Storage , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġspecial Url Detector Ġ= ĠSpecial Url Detector Impl (), ĊĠĠĠĠĠĠĠĠĠĠĠ Ġfav icon Downloader Ġ= Ġmock Fav icon Downloader , ĊĠĠĠĠĠĠĠĠĠĠĠ ĠaddTo Home Capability Detector Ġ= Ġmock AddTo Home Capability Detector ĊĠĠĠĠĠĠĠ Ġ) ĊĊĠĠĠĠĠĠĠ Ġtest ee . load Data (" abc ", Ġnull ) ĊĠĠĠĠĠĠĠ Ġtest ee . url . observe Fore ver ( mock Query Observer ) ĊĠĠĠĠĠĠĠ Ġtest ee . command . observe Fore ver ( mock Command Observer ) ĊĊĠĠĠĠĠĠĠ Ġwhenever ( mock O mn ib ar Converter . convert Query To Url ( any ())). thenReturn (" duck duck go . com ") ĊĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ After ĊĠĠĠ Ġfun Ġafter () Ġ{ ĊĠĠĠĠĠĠĠ Ġtest ee . on Cle ared () ĊĠĠĠĠĠĠĠ Ġdb . close () ĊĠĠĠĠĠĠĠ Ġtest ee . url . remove Observer ( mock Query Observer ) ĊĠĠĠĠĠĠĠ Ġtest ee . command . remove Observer ( mock Command Observer ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġwhen Open In New Background Requested Then Tab Repository Updated And Command Iss ued () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġurl Ġ= Ġ" http :// www . example . com " ĊĠĠĠĠĠĠĠ Ġtest ee . open In New Background Tab ( url ) ĊĊĠĠĠĠĠĠĠ Ġverify ( mock Command Observer , Ġat Least Once ()). on Changed ( command Captor . capture ()) ĊĠĠĠĠĠĠĠ ĠassertTrue ( command Captor . last Value Ġis ĠCommand . Open In New Background Tab ) ĊĊĠĠĠĠĠĠĠ Ġverify ( mock Tabs Repository ). add New Tab After Existing Tab ( url , Ġ" abc ") ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġwhen View Be come s Visible With Active Site Then Keyboard Hidden () Ġ{ ĊĠĠĠĠĠĠĠ Ġtest ee . url . value Ġ= Ġ" http :// ex map le . com " ĊĠĠĠĠĠĠĠ Ġtest ee . on View Visible () ĊĠĠĠĠĠĠĠ Ġverify ( mock Command Observer , Ġat Least Once ()). on Changed ( command Captor . capture ()) ĊĠĠĠĠĠĠĠ ĠassertTrue ( command Captor . last Value Ġis ĠCommand . Hide Keyboard ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġwhen View Be come s Visible Without Active Site Then Keyboard Shown () Ġ{ ĊĠĠĠĠĠĠĠ Ġtest ee . url . value Ġ= Ġnull ĊĠĠĠĠĠĠĠ Ġtest ee . on View Visible () ĊĠĠĠĠĠĠĠ Ġverify ( mock Command Observer , Ġat Least Once ()). on Changed ( command Captor . capture ()) ĊĠĠĠĠĠĠĠ ĠassertTrue ( command Captor . last Value Ġis ĠCommand . Show Keyboard ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġwhen Submitted Query Has Whitespace It Is Trim med () Ġ{ ĊĠĠĠĠĠĠĠ Ġtest ee . on User Submitted Query (" Ġny times . com Ġ") ĊĠĠĠĠĠĠĠ ĠassertEquals (" ny times . com ", Ġomn ib ar ViewState (). om nib ar Text ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġwhen Url Present Then Add Bookmark Button Enabled () Ġ{ ĊĠĠĠĠĠĠĠ Ġtest ee . url Changed (" www . example . com ") ĊĠĠĠĠĠĠĠ ĠassertTrue ( browser ViewState (). can Add Book marks ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġwhen No Url Then Add Bookmark Button Disabled () Ġ{ ĊĠĠĠĠĠĠĠ Ġtest ee . url Changed ( null ) ĊĠĠĠĠĠĠĠ ĠassertFalse ( browser ViewState (). can Add Book marks ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġwhen Bookmark Added Then Dao Is Updated And User Not ified () Ġ{ ĊĠĠĠĠĠĠĠ Ġtest ee . on Bookmark Saved ( null , Ġ" A Ġtitle ", Ġ" www . example . com ") ĊĠĠĠĠĠĠĠ Ġverify ( bookmarks Dao ). insert ( Bookmark Entity ( title Ġ= Ġ" A Ġtitle ", Ġurl Ġ= Ġ" www . example . com ")) ĊĠĠĠĠĠĠĠ Ġverify ( mock Command Observer , Ġat Least Once ()). on Changed ( command Captor . capture ()) ĊĠĠĠĠĠĠĠ ĠassertTrue ( command Captor . last Value Ġis ĠDisplay Message ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġwhen Tracker Detected Then Network Leader board Updated () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġevent Ġ= ĠTracking Event (" http :// www . example . com ", Ġ" http :// www . tracker . com / tracker . js ", ĠTracker Network (" Network 1 ", Ġ" www . tracker . com "), Ġfalse ) ĊĠĠĠĠĠĠĠ Ġtest ee . tracker Detected ( event ) ĊĠĠĠĠĠĠĠ Ġverify ( mock Network Leader board Dao ). insert ( Network Leader board Entry (" Network 1 ", Ġ" www . example . com ")) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġwhen Empty Input Query Then No Query Made Available To Activity () Ġ{ ĊĠĠĠĠĠĠĠ Ġtest ee . on User Submitted Query ("") ĊĠĠĠĠĠĠĠ Ġverify ( mock Query Observer , Ġnever ()). on Changed ( Argument Matchers . any String ()) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġwhen Blank Input Query Then No Query Made Available To Activity () Ġ{ ĊĠĠĠĠĠĠĠ Ġtest ee . on User Submitted Query (" ĠĠĠĠ Ġ") ĊĠĠĠĠĠĠĠ Ġverify ( mock Query Observer , Ġnever ()). on Changed ( Argument Matchers . any String ()) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġwhen Non Empty Input Then Query Made Available To Activity () Ġ{ ĊĠĠĠĠĠĠĠ Ġtest ee . on User Submitted Query (" foo ") ĊĠĠĠĠĠĠĠ Ġverify ( mock Query Observer ). on Changed ( Argument Matchers . any String ()) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġwhen ViewModel Not ified That WebView Is Loading Then ViewState Is Updated () Ġ{ ĊĠĠĠĠĠĠĠ Ġtest ee . loading Started () ĊĠĠĠĠĠĠĠ ĠassertTrue ( loading ViewState (). isLoading ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġwhen ViewModel Not ified That WebView Has Finished Loading Then ViewState Is Updated () Ġ{ ĊĠĠĠĠĠĠĠ Ġtest ee . loading Finished ( null ) ĊĠĠĠĠĠĠĠ ĠassertFalse ( loading ViewState (). isLoading ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġwhen Loading Finished With Url Then Site Vis ited Entry Added To Leader board Dao () Ġ{ ĊĠĠĠĠĠĠĠ Ġtest ee . url . value Ġ= Ġ" http :// example . com / abc " ĊĠĠĠĠĠĠĠ Ġtest ee . loading Finished ( null ) ĊĠĠĠĠĠĠĠ Ġverify ( mock Network Leader board Dao ). insert ( Site Vis ited Entity (" example . com ")) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġwhen Loading Finished With Url Then O mn ib ar Text Updated To Match () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġexample Url Ġ= Ġ" http :// example . com / abc " ĊĠĠĠĠĠĠĠ Ġtest ee . loading Finished ( example Url ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( example Url , Ġomn ib ar ViewState (). om nib ar Text ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġwhen Loading Finished With Query Url Then O mn ib ar Text Updated To Show Query () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġquery Url Ġ= Ġ" http :// duck duck go . com ? q = test " ĊĠĠĠĠĠĠĠ Ġtest ee . loading Finished ( query Url ) ĊĠĠĠĠĠĠĠ ĠassertEquals (" test ", Ġomn ib ar ViewState (). om nib ar Text ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġwhen Loading Finished With No Url Then O mn ib ar Text Updated To Match () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġexample Url Ġ= Ġ" http :// example . com / abc " ĊĠĠĠĠĠĠĠ Ġtest ee . url Changed ( example Url ) ĊĠĠĠĠĠĠĠ Ġtest ee . loading Finished ( null ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( example Url , Ġomn ib ar ViewState (). om nib ar Text ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġwhen Loading Finished With No Url Then Site Vis ited Entry Not Added To Leader board Dao () Ġ{ ĊĠĠĠĠĠĠĠ Ġtest ee . loading Finished ( null ) ĊĠĠĠĠĠĠĠ Ġverify ( mock Network Leader board Dao , Ġnever ()). insert ( Site Vis ited Entity (" example . com ")) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġwhen Tracker Detected Then Site Vis ited Entry Added To Leader board Dao () Ġ{ ĊĠĠĠĠĠĠĠ Ġtest ee . tracker Detected ( Tracking Event (" http :// example . com / abc ", Ġ" http :// tracker . com ", ĠTracker Network (" Network ", Ġ" http :// Ġnet w ot k . com "), Ġtrue )) ĊĠĠĠĠĠĠĠ Ġverify ( mock Network Leader board Dao ). insert ( Site Vis ited Entity (" example . com ")) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġwhen ViewModel Not ified That Url Got Focus Then ViewState Is Updated () Ġ{ ĊĠĠĠĠĠĠĠ Ġtest ee . on O mn ib ar Input StateChanged ("", Ġtrue ) ĊĠĠĠĠĠĠĠ ĠassertTrue ( om nib ar ViewState (). is Editing ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġwhen ViewModel Not ified That Url Lost Focus Then ViewState Is Updated () Ġ{ ĊĠĠĠĠĠĠĠ Ġtest ee . on O mn ib ar Input StateChanged ("", Ġfalse ) ĊĠĠĠĠĠĠĠ ĠassertFalse ( om nib ar ViewState (). is Editing ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġwhen No O mn ib ar Text E ver Entered Then ViewState Has EmptyString () Ġ{ ĊĠĠĠĠĠĠĠ ĠassertEquals ("", Ġomn ib ar ViewState (). om nib ar Text ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġwhen Url Changed Then ViewState Is Updated () Ġ{ ĊĠĠĠĠĠĠĠ Ġtest ee . url Changed (" duck duck go . com ") ĊĠĠĠĠĠĠĠ ĠassertEquals (" duck duck go . com ", Ġomn ib ar ViewState (). om nib ar Text ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġwhen Url Changed With Duck Duck Go Url Containing Query Then Url Rew rit ten To Contain Query () Ġ{ ĊĠĠĠĠĠĠĠ Ġtest ee . url Changed (" http :// duck duck go . com ? q = test ") ĊĠĠĠĠĠĠĠ ĠassertEquals (" test ", Ġomn ib ar ViewState (). om nib ar Text ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġwhen Url Changed With Duck Duck Go Url Containing Query Then At b Ref reshed () Ġ{ ĊĠĠĠĠĠĠĠ Ġtest ee . url Changed (" http :// duck duck go . com ? q = test ") ĊĠĠĠĠĠĠĠ Ġverify ( mock Statistics Updater ). refresh Retention At b () ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġwhen Url Changed With Duck Duck Go Url Not Containing Query Then Full Url Shown () Ġ{ ĊĠĠĠĠĠĠĠ Ġtest ee . url Changed (" http :// duck duck go . com ") ĊĠĠĠĠĠĠĠ ĠassertEquals (" http :// duck duck go . com ", Ġomn ib ar ViewState (). om nib ar Text ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġwhen Url Changed With Non Duck Duck Go Url Then Full Url Shown () Ġ{ ĊĠĠĠĠĠĠĠ Ġtest ee . url Changed (" http :// example . com ") ĊĠĠĠĠĠĠĠ ĠassertEquals (" http :// example . com ", Ġomn ib ar ViewState (). om nib ar Text ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġwhen ViewModel Gets Progress Update Then ViewState Is Updated () Ġ{ ĊĠĠĠĠĠĠĠ Ġtest ee . progress Changed ( 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( 0 , Ġloading ViewState (). progress ) ĊĊĠĠĠĠĠĠĠ Ġtest ee . progress Changed ( 5 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( 5 0 , Ġloading ViewState (). progress ) ĊĊĠĠĠĠĠĠĠ Ġtest ee . progress Changed ( 1 0 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( 1 0 0 , Ġloading ViewState (). progress ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġwhen Loading Started Then Privacy Grade Is Cle ared () Ġ{ ĊĠĠĠĠĠĠĠ Ġtest ee . loading Started () ĊĠĠĠĠĠĠĠ ĠassertNull ( test ee . privacy Grade . value ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġwhen Url Changed Then Privacy Grade Is Reset () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġgrade Ġ= Ġtest ee . privacy Grade . value ĊĠĠĠĠĠĠĠ Ġtest ee . url Changed (" https :// example . com ") ĊĠĠĠĠĠĠĠ Ġassert Not Equals ( grade , Ġtest ee . privacy Grade . value ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġwhen En ough Track ers Detected Then Privacy Grade Is Updated () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġgrade Ġ= Ġtest ee . privacy Grade . value ĊĠĠĠĠĠĠĠ Ġtest ee . url Changed (" https :// example . com ") ĊĠĠĠĠĠĠĠ Ġfor Ġ( i Ġin Ġ 1 .. 1 0 ) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġtest ee . tracker Detected ( Tracking Event (" https :// example . com ", Ġ"", Ġnull , Ġfalse )) ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠ Ġassert Not Equals ( grade , Ġtest ee . privacy Grade . value ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġwhen Initial ised Then Privacy Grade IsNot Shown () Ġ{ ĊĠĠĠĠĠĠĠ ĠassertFalse ( browser ViewState (). show Privacy Grade ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġwhen Url Updated After Config Download Then Privacy Grade Is Shown () Ġ{ ĊĠĠĠĠĠĠĠ Ġtest ee . app Configuration Observer . on Changed ( App Configuration Entity ( app Configuration Downloaded Ġ= Ġtrue )) ĊĠĠĠĠĠĠĠ Ġtest ee . url Changed ((" ")) ĊĠĠĠĠĠĠĠ ĠassertTrue ( browser ViewState (). show Privacy Grade ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġwhen Url Updated Before Config Download Then Privacy Grade Is Shown () Ġ{ ĊĠĠĠĠĠĠĠ Ġtest ee . app Configuration Observer . on Changed ( App Configuration Entity ( app Configuration Downloaded Ġ= Ġfalse )) ĊĠĠĠĠĠĠĠ Ġtest ee . url Changed ((" ")) ĊĠĠĠĠĠĠĠ ĠassertFalse ( browser ViewState (). show Privacy Grade ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġwhen O mn ib ar Input DoesNot Have Focus And AppConfig Downloaded And Browser Shown Then Privacy Grade Is Shown () Ġ{ ĊĠĠĠĠĠĠĠ Ġtest ee . on User Submitted Query (" foo ") ĊĠĠĠĠĠĠĠ Ġtest ee . app Configuration Observer . on Changed ( App Configuration Entity ( app Configuration Downloaded Ġ= Ġtrue )) ĊĠĠĠĠĠĠĠ Ġtest ee . on O mn ib ar Input StateChanged ( query Ġ= Ġ"", Ġhas Focus Ġ= Ġfalse ) ĊĠĠĠĠĠĠĠ ĠassertTrue ( browser ViewState (). show Privacy Grade ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġwhen O mn ib ar Input DoesNot Have Focus And AppConfig Downloaded But Browser Not Shown Then Privacy Grade Is Hidden () Ġ{ ĊĠĠĠĠĠĠĠ Ġtest ee . app Configuration Observer . on Changed ( App Configuration Entity ( app Configuration Downloaded Ġ= Ġtrue )) ĊĠĠĠĠĠĠĠ Ġtest ee . on O mn ib ar Input StateChanged ( query Ġ= Ġ"", Ġhas Focus Ġ= Ġfalse ) ĊĠĠĠĠĠĠĠ ĠassertFalse ( browser ViewState (). show Privacy Grade ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġwhen O mn ib ar Input DoesNot Have Focus And AppConfig Not Downloaded Then Privacy Grade IsNot Shown () Ġ{ ĊĠĠĠĠĠĠĠ Ġtest ee . app Configuration Observer . on Changed ( App Configuration Entity ( app Configuration Downloaded Ġ= Ġfalse )) ĊĠĠĠĠĠĠĠ Ġtest ee . on O mn ib ar Input StateChanged ("", Ġfalse ) ĊĠĠĠĠĠĠĠ ĠassertFalse ( browser ViewState (). show Privacy Grade ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġwhen O mn ib ar Input Has Focus Then Privacy Grade IsNot Shown () Ġ{ ĊĠĠĠĠĠĠĠ Ġtest ee . on O mn ib ar Input StateChanged ("", Ġtrue ) ĊĠĠĠĠĠĠĠ ĠassertFalse ( browser ViewState (). show Privacy Grade ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġwhen Initial ised Then Fire Button Is Shown () Ġ{ ĊĠĠĠĠĠĠĠ ĠassertTrue ( browser ViewState (). show Fire Button ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġwhen O mn ib ar Input DoesNot Have Focus And Has Query Then Fire Button Is Shown () Ġ{ ĊĠĠĠĠĠĠĠ Ġtest ee . on O mn ib ar Input StateChanged (" query ", Ġfalse ) ĊĠĠĠĠĠĠĠ ĠassertTrue ( browser ViewState (). show Fire Button ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġwhen O mn ib ar Input DoesNot Have Focus Or Query Then Fire Button Is Shown () Ġ{ ĊĠĠĠĠĠĠĠ Ġtest ee . on O mn ib ar Input StateChanged ("", Ġfalse ) ĊĠĠĠĠĠĠĠ ĠassertTrue ( browser ViewState (). show Fire Button ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġwhen O mn ib ar Input Has Focus And No Query Then Fire Button Is Shown () Ġ{ ĊĠĠĠĠĠĠĠ Ġtest ee . on O mn ib ar Input StateChanged ("", Ġtrue ) ĊĠĠĠĠĠĠĠ ĠassertTrue ( browser ViewState (). show Fire Button ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġwhen O mn ib ar Input Has Focus And Query Then Fire Button Is Hidden () Ġ{ ĊĠĠĠĠĠĠĠ Ġtest ee . on O mn ib ar Input StateChanged (" query ", Ġtrue ) ĊĠĠĠĠĠĠĠ ĠassertFalse ( browser ViewState (). show Fire Button ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġwhen Initial ised Then Tabs Button Is Shown () Ġ{ ĊĠĠĠĠĠĠĠ ĠassertTrue ( browser ViewState (). show Tabs Button ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġwhen O mn ib ar Input DoesNot Have Focus Or Query Then Tabs Button Is Shown () Ġ{ ĊĠĠĠĠĠĠĠ Ġtest ee . on O mn ib ar Input StateChanged ("", Ġfalse ) ĊĠĠĠĠĠĠĠ ĠassertTrue ( browser ViewState (). show Tabs Button ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġwhen O mn ib ar Input DoesNot Have Focus And Has Query Then Tabs Button Is Shown () Ġ{ ĊĠĠĠĠĠĠĠ Ġtest ee . on O mn ib ar Input StateChanged (" query ", Ġfalse ) ĊĠĠĠĠĠĠĠ ĠassertTrue ( browser ViewState (). show Tabs Button ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġwhen O mn ib ar Input Has Focus And No Query Then Tabs Button Is Shown () Ġ{ ĊĠĠĠĠĠĠĠ Ġtest ee . on O mn ib ar Input StateChanged ("", Ġtrue ) ĊĠĠĠĠĠĠĠ ĠassertTrue ( browser ViewState (). show Tabs Button ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġwhen O mn ib ar Input Has Focus And Query Then Tabs Button Is Hidden () Ġ{ ĊĠĠĠĠĠĠĠ Ġtest ee . on O mn ib ar Input StateChanged (" query ", Ġtrue ) ĊĠĠĠĠĠĠĠ ĠassertFalse ( browser ViewState (). show Tabs Button ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġwhen Initial ised Then Menu Button Is Shown () Ġ{ ĊĠĠĠĠĠĠĠ ĠassertTrue ( browser ViewState (). show Menu Button ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġwhen O mn ib ar Input DoesNot Have Focus Or Query Then Menu Button Is Shown () Ġ{ ĊĠĠĠĠĠĠĠ Ġtest ee . on O mn ib ar Input StateChanged ("", Ġfalse ) ĊĠĠĠĠĠĠĠ ĠassertTrue ( browser ViewState (). show Menu Button ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġwhen O mn ib ar Input DoesNot Have Focus And Has Query Then Menu Button Is Shown () Ġ{ ĊĠĠĠĠĠĠĠ Ġtest ee . on O mn ib ar Input StateChanged (" query ", Ġfalse ) ĊĠĠĠĠĠĠĠ ĠassertTrue ( browser ViewState (). show Menu Button ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġwhen O mn ib ar Input Has Focus And No Query Then Menu Button Is Shown () Ġ{ ĊĠĠĠĠĠĠĠ Ġtest ee . on O mn ib ar Input StateChanged ("", Ġtrue ) ĊĠĠĠĠĠĠĠ ĠassertTrue ( browser ViewState (). show Menu Button ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġwhen O mn ib ar Input Has Focus And Query Then Menu Button Is Hidden () Ġ{ ĊĠĠĠĠĠĠĠ Ġtest ee . on O mn ib ar Input StateChanged (" query ", Ġtrue ) ĊĠĠĠĠĠĠĠ ĠassertFalse ( browser ViewState (). show Menu Button ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġwhen Enter ing Query With Auto Complete Enabled Then Auto Complete Suggestions Shown () Ġ{ ĊĠĠĠĠĠĠĠ Ġdo Return ( true ). wh enever ( mock Settings Store ). auto Complete Suggestions Enabled ĊĠĠĠĠĠĠĠ Ġtest ee . on O mn ib ar Input StateChanged (" foo ", Ġtrue ) ĊĠĠĠĠĠĠĠ ĠassertTrue ( auto Complete ViewState (). show Suggestions ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġwhen Enter ing Query With Auto Complete Disabled Then Auto Complete Suggestions Not Shown () Ġ{ ĊĠĠĠĠĠĠĠ Ġdo Return ( false ). wh enever ( mock Settings Store ). auto Complete Suggestions Enabled ĊĠĠĠĠĠĠĠ Ġtest ee . on O mn ib ar Input StateChanged (" foo ", Ġtrue ) ĊĠĠĠĠĠĠĠ ĠassertFalse ( auto Complete ViewState (). show Suggestions ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġwhen Enter ing Empty Query With Auto Complete Enabled Then Auto Complete Suggestions Not Shown () Ġ{ ĊĠĠĠĠĠĠĠ Ġdo Return ( true ). wh enever ( mock Settings Store ). auto Complete Suggestions Enabled ĊĠĠĠĠĠĠĠ Ġtest ee . on O mn ib ar Input StateChanged ("", Ġtrue ) ĊĠĠĠĠĠĠĠ ĠassertFalse ( auto Complete ViewState (). show Suggestions ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġwhen Enter ing Empty Query With Auto Complete Disabled Then Auto Complete Suggestions Not Shown () Ġ{ ĊĠĠĠĠĠĠĠ Ġdo Return ( false ). wh enever ( mock Settings Store ). auto Complete Suggestions Enabled ĊĠĠĠĠĠĠĠ Ġtest ee . on O mn ib ar Input StateChanged ("", Ġtrue ) ĊĠĠĠĠĠĠĠ ĠassertFalse ( auto Complete ViewState (). show Suggestions ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġwhen Enter ing Empty Query Then Hide Keyboard Command Not Iss ued () Ġ{ ĊĠĠĠĠĠĠĠ Ġtest ee . on User Submitted Query ("") ĊĠĠĠĠĠĠĠ Ġverify ( mock Command Observer , Ġnever ()). on Changed ( Mockito . any ( Command . Hide Keyboard . java Class )) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġwhen Enter ing Non Empty Query Then Hide Keyboard Command Iss ued () Ġ{ ĊĠĠĠĠĠĠĠ Ġtest ee . on User Submitted Query (" foo ") ĊĠĠĠĠĠĠĠ Ġverify ( mock Command Observer , ĠMockito . at Least Once ()). on Changed ( command Captor . capture ()) ĊĠĠĠĠĠĠĠ ĠassertTrue ( command Captor . value Ġ== ĠCommand . Hide Keyboard ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġwhen Not ified Enter ing FullScreen Then ViewState Updated With FullScreen Flag () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġstub View Ġ= ĠView ( Instrumentation Registry . getTarget Context ()) ĊĠĠĠĠĠĠĠ Ġtest ee . go FullScreen ( stub View ) ĊĠĠĠĠĠĠĠ ĠassertTrue ( browser ViewState (). is FullScreen ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġwhen Not ified Enter ing FullScreen Then Enter FullScreen Command Iss ued () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġstub View Ġ= ĠView ( Instrumentation Registry . getTarget Context ()) ĊĠĠĠĠĠĠĠ Ġtest ee . go FullScreen ( stub View ) ĊĠĠĠĠĠĠĠ Ġverify ( mock Command Observer , ĠMockito . at Least Once ()). on Changed ( command Captor . capture ()) ĊĠĠĠĠĠĠĠ ĠassertTrue ( command Captor . last Value Ġis ĠCommand . Show FullScreen ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġwhen Not ified Le aving FullScreen Then ViewState Updated With FullScreen Flag Disabled () Ġ{ ĊĠĠĠĠĠĠĠ Ġtest ee . exit FullScreen () ĊĠĠĠĠĠĠĠ ĠassertFalse ( browser ViewState (). is FullScreen ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġwhen ViewModel Initial ised Then FullScreen Flag Is Disabled () Ġ{ ĊĠĠĠĠĠĠĠ ĠassertFalse ( browser ViewState (). is FullScreen ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġwhen User Select s Download Image Option From ContextMenu Then Download File Command Iss ued () Ġ{ ĊĠĠĠĠĠĠĠ Ġwhenever ( mock Long Press Handler . user Selected MenuItem ( any String (), Ġany ())) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. thenReturn ( Download File (" example . com ")) ĊĊĠĠĠĠĠĠĠ Ġval Ġmock MenuItem : ĠMenuItem Ġ= Ġmock () ĊĠĠĠĠĠĠĠ Ġtest ee . user SelectedItem From Long Press Menu (" example . com ", Ġmock MenuItem ) ĊĠĠĠĠĠĠĠ Ġverify ( mock Command Observer , ĠMockito . at Least Once ()). on Changed ( command Captor . capture ()) ĊĠĠĠĠĠĠĠ ĠassertTrue ( command Captor . last Value Ġis ĠCommand . Download Image ) ĊĊĠĠĠĠĠĠĠ Ġval Ġlast Command Ġ= Ġcommand Captor . last Value Ġas ĠCommand . Download Image ĊĠĠĠĠĠĠĠ ĠassertEquals (" example . com ", Ġlast Command . url ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġwhen User Types Search Term Then ViewState Updated To Den ote User Is Finding In Page () Ġ{ ĊĠĠĠĠĠĠĠ Ġtest ee . user Finding In Page (" foo ") ĊĠĠĠĠĠĠĠ ĠassertTrue ( find In Page ViewState (). visible ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġwhen User Types Search Term Then ViewState Updated To Contain Search Term () Ġ{ ĊĠĠĠĠĠĠĠ Ġtest ee . user Finding In Page (" foo ") ĊĠĠĠĠĠĠĠ ĠassertEquals (" foo ", Ġfind In Page ViewState (). search Term ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġwhen User Dis mis ses Find In Page Then ViewState Updated To Den ote User IsNot Finding In Page () Ġ{ ĊĠĠĠĠĠĠĠ Ġtest ee . dismiss Find In View () ĊĠĠĠĠĠĠĠ ĠassertFalse ( find In Page ViewState (). visible ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġwhen User Dis mis ses Find In Page Then ViewState Updated To Clear Search Term () Ġ{ ĊĠĠĠĠĠĠĠ Ġtest ee . user Finding In Page (" foo ") ĊĠĠĠĠĠĠĠ Ġtest ee . dismiss Find In View () ĊĠĠĠĠĠĠĠ ĠassertEquals ("", Ġfind In Page ViewState (). search Term ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġwhen User Select s Desktop Site Then Desktop Mode State Updated () Ġ{ ĊĠĠĠĠĠĠĠ Ġtest ee . desktop Site Mode Toggle d (" http :// example . com ", Ġdesktop Site Requested Ġ= Ġtrue ) ĊĠĠĠĠĠĠĠ Ġverify ( mock Command Observer , ĠMockito . at Least Once ()). on Changed ( command Captor . capture ()) ĊĠĠĠĠĠĠĠ ĠassertTrue ( browser ViewState (). is Desktop B rowsing Mode ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġwhen User Select s Mobile Site Then Mobile Mode State Updated () Ġ{ ĊĠĠĠĠĠĠĠ Ġtest ee . desktop Site Mode Toggle d (" http :// example . com ", Ġdesktop Site Requested Ġ= Ġfalse ) ĊĠĠĠĠĠĠĠ ĠassertFalse ( browser ViewState (). is Desktop B rowsing Mode ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġwhen User Select s Desktop Site When On Mobile Specific Site Then Url Modified () Ġ{ ĊĠĠĠĠĠĠĠ Ġtest ee . desktop Site Mode Toggle d (" http :// m . example . com ", Ġdesktop Site Requested Ġ= Ġtrue ) ĊĠĠĠĠĠĠĠ Ġverify ( mock Command Observer , ĠMockito . at Least Once ()). on Changed ( command Captor . capture ()) ĊĠĠĠĠĠĠĠ Ġval Ġult imate Command Ġ= Ġcommand Captor . last Value Ġas ĠNavigate ĊĠĠĠĠĠĠĠ ĠassertEquals (" http :// example . com ", Ġult imate Command . url ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġwhen User Select s Desktop Site When Not On Mobile Specific Site Then Url Not Modified () Ġ{ ĊĠĠĠĠĠĠĠ Ġtest ee . desktop Site Mode Toggle d (" http :// example . com ", Ġdesktop Site Requested Ġ= Ġtrue ) ĊĠĠĠĠĠĠĠ Ġverify ( mock Command Observer , ĠMockito . at Least Once ()). on Changed ( command Captor . capture ()) ĊĠĠĠĠĠĠĠ Ġval Ġult imate Command Ġ= Ġcommand Captor . last Value ĊĠĠĠĠĠĠĠ ĠassertTrue ( ult imate Command Ġ== ĠCommand . Refresh ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġwhen User Select s Mobile Site When On Mobile Specific Site Then Url Not Modified () Ġ{ ĊĠĠĠĠĠĠĠ Ġtest ee . desktop Site Mode Toggle d (" http :// m . example . com ", Ġdesktop Site Requested Ġ= Ġfalse ) ĊĠĠĠĠĠĠĠ Ġverify ( mock Command Observer , ĠMockito . at Least Once ()). on Changed ( command Captor . capture ()) ĊĠĠĠĠĠĠĠ Ġval Ġult imate Command Ġ= Ġcommand Captor . last Value ĊĠĠĠĠĠĠĠ ĠassertTrue ( ult imate Command Ġ== ĠCommand . Refresh ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġwhen User Select s Mobile Site When Not On Mobile Specific Site Then Url Not Modified () Ġ{ ĊĠĠĠĠĠĠĠ Ġtest ee . desktop Site Mode Toggle d (" http :// example . com ", Ġdesktop Site Requested Ġ= Ġfalse ) ĊĠĠĠĠĠĠĠ Ġverify ( mock Command Observer , ĠMockito . at Least Once ()). on Changed ( command Captor . capture ()) ĊĠĠĠĠĠĠĠ Ġval Ġult imate Command Ġ= Ġcommand Captor . last Value ĊĠĠĠĠĠĠĠ ĠassertTrue ( ult imate Command Ġ== ĠCommand . Refresh ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġwhen User Select s Open Tab Then Tab Command Sent () Ġ{ ĊĠĠĠĠĠĠĠ Ġwhenever ( mock Long Press Handler . user Selected MenuItem ( any (), Ġany ())). thenReturn ( Open In New Tab (" http :// example . com ")) ĊĠĠĠĠĠĠĠ Ġval Ġmock Men Item : ĠMenuItem Ġ= Ġmock () ĊĠĠĠĠĠĠĠ Ġtest ee . user SelectedItem From Long Press Menu (" http :// example . com ", Ġmock Men Item ) ĊĠĠĠĠĠĠĠ Ġval Ġcommand Ġ= Ġcapture Commands (). value Ġas ĠCommand . Open In New Tab ĊĠĠĠĠĠĠĠ ĠassertEquals (" http :// example . com ", Ġcommand . query ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġwhen User Select sTo Share Link Then Share Link Command Sent () Ġ{ ĊĠĠĠĠĠĠĠ Ġtest ee . user Sharing Link (" foo ") ĊĠĠĠĠĠĠĠ Ġval Ġcommand Ġ= Ġcapture Commands (). value Ġas ĠCommand . Share Link ĊĠĠĠĠĠĠĠ ĠassertEquals (" foo ", Ġcommand . url ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġwhen On Site And Broken Site Selected Then Broken Site Feedback Command Sent With Url () Ġ{ ĊĠĠĠĠĠĠĠ Ġtest ee . url Changed (" foo . com ") ĊĠĠĠĠĠĠĠ Ġtest ee . on Broken Site Selected () ĊĠĠĠĠĠĠĠ Ġval Ġcommand Ġ= Ġcapture Commands (). value Ġas ĠCommand . Broken Site Feedback ĊĠĠĠĠĠĠĠ ĠassertEquals (" foo . com ", Ġcommand . url ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġwhen No Site And Broken Site Selected Then Broken Site Feedback Command Sent Without Url () Ġ{ ĊĠĠĠĠĠĠĠ Ġtest ee . on Broken Site Selected () ĊĠĠĠĠĠĠĠ Ġval Ġcommand Ġ= Ġcapture Commands (). value Ġas ĠCommand . Broken Site Feedback ĊĠĠĠĠĠĠĠ ĠassertNull ( command . url ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġwhen User Select sTo Share Link With Null Url Then Share Link Command Not Sent () Ġ{ ĊĠĠĠĠĠĠĠ Ġtest ee . user Sharing Link ( null ) ĊĠĠĠĠĠĠĠ Ġverify ( mock Command Observer , Ġnever ()). on Changed ( any ()) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġwhen Web Session Restore d Then Global Layout Sw itched To Showing Browser () Ġ{ ĊĠĠĠĠĠĠĠ Ġtest ee . on Web Session Restore d () ĊĠĠĠĠĠĠĠ ĠassertFalse ( global Layout ViewState (). isNew Tab State ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġwhen WebView Session Is ToBe Saved Then Under lying Session Stored Called () Ġ{ ĊĠĠĠĠĠĠĠ Ġtest ee . save WebView State ( null , Ġ"") ĊĠĠĠĠĠĠĠ Ġverify ( web View Session Storage ). save Session ( any OrNull (), Ġany String ()) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġwhen Rest oring WebView Session Not Rest orable Then Previous Url Loaded () Ġ{ ĊĠĠĠĠĠĠĠ Ġwhenever ( mock O mn ib ar Converter . convert Query To Url (" foo . com ")). thenReturn (" foo . com ") ĊĠĠĠĠĠĠĠ Ġwhenever ( web View Session Storage . restore Session ( any OrNull (), Ġany String ())). thenReturn ( false ) ĊĠĠĠĠĠĠĠ Ġtest ee . restore WebView State ( null , Ġ" foo . com ") ĊĠĠĠĠĠĠĠ ĠassertEquals (" foo . com ", Ġtest ee . url . value ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġwhen Rest oring WebView Session Not Rest orable And No Previous Url Then No Url Loaded () Ġ{ ĊĠĠĠĠĠĠĠ Ġwhenever ( web View Session Storage . restore Session ( any OrNull (), Ġany String ())). thenReturn ( false ) ĊĠĠĠĠĠĠĠ Ġtest ee . restore WebView State ( null , Ġ"") ĊĠĠĠĠĠĠĠ ĠassertNull ( test ee . url . value ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġwhen WebView Session Rest orable Then Session Restore d () Ġ{ ĊĠĠĠĠĠĠĠ Ġwhenever ( web View Session Storage . restore Session ( any OrNull (), Ġany String ())). thenReturn ( true ) ĊĠĠĠĠĠĠĠ Ġtest ee . restore WebView State ( null , Ġ"") ĊĠĠĠĠĠĠĠ ĠassertFalse ( global Layout ViewState (). isNew Tab State ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġprivate Ġfun Ġcapture Commands (): ĠArgument Captor < Command > Ġ{ ĊĠĠĠĠĠĠĠ Ġverify ( mock Command Observer , ĠMockito . at Least Once ()). on Changed ( command Captor . capture ()) ĊĠĠĠĠĠĠĠ Ġreturn Ġcommand Captor ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġprivate Ġfun Ġbrowser ViewState () Ġ= Ġtest ee . browser ViewState . value !! ĊĠĠĠ Ġprivate Ġfun Ġomn ib ar ViewState () Ġ= Ġtest ee . om nib ar ViewState . value !! ĊĠĠĠ Ġprivate Ġfun Ġloading ViewState () Ġ= Ġtest ee . loading ViewState . value !! ĊĠĠĠ Ġprivate Ġfun Ġauto Complete ViewState () Ġ= Ġtest ee . auto Complete ViewState . value !! ĊĠĠĠ Ġprivate Ġfun Ġfind In Page ViewState () Ġ= Ġtest ee . find In Page ViewState . value !! ĊĠĠĠ Ġprivate Ġfun Ġglobal Layout ViewState () Ġ= Ġtest ee . global Layout State . value !! Ċ } Ċ