package Ġuk . co . sentinel web . c uer . app . ui . share . scan Ċ Ċ import Ġandroidx . test . espress o . Esp ress o . on View Ċ import Ġandroidx . test . espress o . assertion . View Assertions . matches Ċ import Ġandroidx . test . espress o . matcher . View Matchers Ċ import Ġandroidx . test . espress o . matcher . View Matchers . is Displayed Ċ import Ġandroidx . test . espress o . matcher . View Matchers . with Id Ċ import Ġcom . flex trade . j fixture . J Fixture Ċ import Ġorg . hamcrest . Core Matchers Ċ import Ġorg . mockito . Mockito Ċ import Ġorg . mockito . Mockito . verify Ċ import Ġuk . co . sentinel web . c uer . app . R Ċ import Ġuk . co . sentinel web . c uer . tools . provider . Fragment Scenario Provider Ċ import Ġuk . co . sentinel web . c uer . tools . test . matchers . drawable Matches ĊĊ Ċ class ĠScan Fragment Shared Test Ġconstructor ( ĊĠĠĠ Ġval Ġscenario : ĠFragment Scenario Provider < Scan Fragment >, ĊĠĠĠ Ġval Ġmock Presenter : ĠScan Contract . Presenter Ċ ) Ġ{ ĊĠĠĠ Ġprivate Ġval Ġfixture Ġ= ĠJ Fixture () ĊĊĠĠĠ Ġfun Ġfrom Share Url () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġfix t Url Ġ= Ġfixture . create ( String :: class . java ) ĊĊĠĠĠĠĠĠĠ Ġscenario . get (). on Fragment Ġ{ Ġit . from Share Url ( fix t Url ) Ġ} ĊĠĠĠĠĠĠĠ Ġon View ( with Id ( R . id . scan _ progress )). check ( matches ( is Displayed ())) ĊĠĠĠĠĠĠĠ Ġon View ( with Id ( R . id . scan _ result )). check ( matches ( Core Matchers . not ( is Displayed ()))) ĊĠĠĠĠĠĠĠ Ġverify ( mock Presenter ). from Share Url ( fix t Url ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġfun Ġset Model _ isLoading () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġfix t Model Ġ= Ġfixture . create ( Scan Contract . Model :: class . java ). copy ( ĊĠĠĠĠĠĠĠĠĠĠĠ ĠisLoading Ġ= Ġtrue ĊĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠĠĠ Ġscenario . get (). on Fragment Ġ{ Ġit . setModel ( fix t Model ) Ġ} ĊĠĠĠĠĠĠĠ Ġon View ( with Id ( R . id . scan _ progress )). check ( matches ( is Displayed ())) ĊĠĠĠĠĠĠĠ Ġon View ( with Id ( R . id . scan _ result )). check ( matches ( Core Matchers . not ( is Displayed ()))) ĊĠĠĠĠĠĠĠ Ġon View ( with Id ( R . id . scan _ text )). check ( matches ( is Displayed ())) ĊĠĠĠĠĠĠĠ Ġon View ( with Id ( R . id . scan _ text )). check ( matches ( View Matchers . with Text ( fix t Model . text ))) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġfun Ġset Model _ isNot Loading () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġfix t Model Ġ= Ġfixture . create ( Scan Contract . Model :: class . java ). copy ( ĊĠĠĠĠĠĠĠĠĠĠĠ ĠisLoading Ġ= Ġfalse , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġresult Icon Ġ= ĠR . drawable . ic _ item _ tick _ white ĊĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠĠĠ Ġscenario . get (). on Fragment Ġ{ Ġit . setModel ( fix t Model ) Ġ} ĊĠĠĠĠĠĠĠ Ġon View ( with Id ( R . id . scan _ progress )). check ( matches ( Core Matchers . not ( is Displayed ()))) ĊĠĠĠĠĠĠĠ Ġon View ( with Id ( R . id . scan _ result )). check ( matches ( is Displayed ())) ĊĠĠĠĠĠĠĠ Ġon View ( with Id ( R . id . scan _ text )). check ( matches ( is Displayed ())) ĊĠĠĠĠĠĠĠ Ġon View ( with Id ( R . id . scan _ text )). check ( matches ( View Matchers . with Text ( fix t Model . text ))) ĊĠĠĠĠĠĠĠ Ġon View ( with Id ( R . id . scan _ result )). check ( matches ( drawable Matches ( R . drawable . ic _ item _ tick _ white ))) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġfun Ġset Result () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġfix t Result Ġ= Ġfixture . create ( Scan Contract . Result :: class . java ) ĊĠĠĠĠĠĠĠ Ġval Ġmock Listener Ġ= ĠMockito . mock ( Scan Contract . Listener :: class . java ) ĊĠĠĠĠĠĠĠ Ġscenario . get (). apply Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġon Fragment Ġ{ Ġit . listener Ġ= Ġmock Listener Ġ} ĊĠĠĠĠĠĠĠĠĠĠĠ Ġon Fragment Ġ{ Ġit . set Result ( fix t Result ) Ġ} ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠ Ġverify ( mock Listener ). scan Result ( fix t Result ) ĊĠĠĠ Ġ} Ċ }