package Ġcom . l bb ento . pitch up we ar . main Ċ Ċ import Ġcom . l bb ento . pitch up core . T uning Status . DEFAULT Ċ import Ġcom . l bb ento . pitch up core . T uning Status . TOO _ LOW Ċ import Ġcom . l bb ento . pitch upt uner . G uit ar T uner Reactive Ċ import Ġcom . l bb ento . pitch upt uner . service . T uner Result Ċ import Ġcom . l bb ento . pitch up we ar . common . Stub App Scheduler Ċ import Ġcom . l bb ento . pitch up we ar . util . Permission Helper Ċ import Ġcom . n ha ar man . mockito _ kotlin . mock Ċ import Ġcom . n ha ar man . mockito _ kotlin . never Ċ import Ġcom . n ha ar man . mockito _ kotlin . verify Ċ import Ġcom . n ha ar man . mockito _ kotlin . wh enever Ċ import Ġorg . junit . Before Ċ import Ġorg . junit . Test Ċ import Ġrx . Observable Ċ import Ġrx . Observable . just Ċ Ċ class ĠMain Presenter Test Ġ{ ĊĊĠĠĠ Ġval Ġmock Permission Helper : ĠPermission Helper Ġ= Ġmock () ĊĠĠĠ Ġval Ġmock View : ĠMain View Ġ= Ġmock () ĊĠĠĠ Ġval Ġmock G uit ar T uner Reactive : ĠG uit ar T uner Reactive Ġ= Ġmock () ĊĠĠĠ Ġval Ġmock Mapper : ĠT uner Service Mapper Ġ= Ġmock () ĊĠĠĠ Ġval Ġstub App Schedulers Ġ= ĠStub App Scheduler () ĊĠĠĠ Ġval Ġmain Presenter Ġ= ĠMain Presenter ( stub App Schedulers , Ġmock Permission Helper , Ġmock G uit ar T uner Reactive , Ġmock Mapper ) ĊĊĠĠĠ Ġ@ Before ĊĠĠĠ Ġfun Ġsetup () Ġ{ ĊĠĠĠĠĠĠĠ Ġmain Presenter . on Attached To Window ( mock View ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġshould Set Ambient Enabled On Create () Ġ{ ĊĠĠĠĠĠĠĠ Ġmain Presenter . on Created () ĊĊĠĠĠĠĠĠĠ Ġverify ( mock View ). set Ambient Enabled () ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġshould Setup Gauge On Create () Ġ{ ĊĠĠĠĠĠĠĠ Ġmain Presenter . on Created () ĊĊĠĠĠĠĠĠĠ Ġverify ( mock View ). setup Gauge () ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġshould Do Nothing When No Audio Permissions () Ġ{ ĊĠĠĠĠĠĠĠ Ġwhenever ( mock Permission Helper . handle Micro phone Permission ()). thenReturn ( false ) ĊĊĠĠĠĠĠĠĠ Ġmain Presenter . on View Res uming () ĊĊĠĠĠĠĠĠĠ Ġverify ( mock Permission Helper ). handle Micro phone Permission () ĊĠĠĠĠĠĠĠ Ġverify ( mock G uit ar T uner Reactive , Ġnever ()). listen To Notes () ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġshould Update To Default Status () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġt uner Result : ĠT uner Result Ġ= Ġmock () ĊĠĠĠĠĠĠĠ Ġval Ġt uner ViewModel : ĠT uner ViewModel Ġ= Ġmock Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġwhenever ( it . tuning Status ). thenReturn ( DEFAULT ) ĊĠĠĠĠĠĠĠ Ġ} ĊĊĠĠĠĠĠĠĠ Ġwhenever ( mock Permission Helper . handle Micro phone Permission ()). thenReturn ( true ) ĊĠĠĠĠĠĠĠ Ġwhenever ( mock G uit ar T uner Reactive . listen To Notes ()). thenReturn ( just ( tun er Result )) ĊĠĠĠĠĠĠĠ Ġwhenever ( mock Mapper . tun er Result To ViewModel ( tun er Result )). thenReturn ( tun er ViewModel ) ĊĊĠĠĠĠĠĠĠ Ġmain Presenter . on View Res uming () ĊĊĠĠĠĠĠĠĠ Ġverify ( mock View ). update To Default Status () ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġshould Update Frequency If Status IsNot Default () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġt uner Result : ĠT uner Result Ġ= Ġmock () ĊĠĠĠĠĠĠĠ Ġval Ġt uner ViewModel : ĠT uner ViewModel Ġ= Ġmock Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġwhenever ( it . tuning Status ). thenReturn ( TOO _ LOW ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġwhenever ( it . expected Frequency ). thenReturn ( 1 0 . 0 ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġwhenever ( it . diff Frequency ). thenReturn ( 1 . 0 ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġwhenever ( it . diff In C ents ). thenReturn ( 1 1 . 0 ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġwhenever ( it . note ). thenReturn (" A ") ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠ Ġval Ġset Freq To Ġ= Ġ( tun er ViewModel . expected Frequency Ġ+ Ġ( tun er ViewModel . diff Frequency Ġ* Ġ- 1 )). toFloat () ĊĊĠĠĠĠĠĠĠ Ġwhenever ( mock Permission Helper . handle Micro phone Permission ()). thenReturn ( true ) ĊĠĠĠĠĠĠĠ Ġwhenever ( mock G uit ar T uner Reactive . listen To Notes ()). thenReturn ( just ( tun er Result )) ĊĠĠĠĠĠĠĠ Ġwhenever ( mock Mapper . tun er Result To ViewModel ( tun er Result )). thenReturn ( tun er ViewModel ) ĊĊĠĠĠĠĠĠĠ Ġmain Presenter . on View Res uming () ĊĊĠĠĠĠĠĠĠ Ġverify ( mock View ). update Indicator (- 1 1 f ) ĊĠĠĠĠĠĠĠ Ġverify ( mock View ). update Note ( tun er ViewModel . note ) ĊĠĠĠĠĠĠĠ Ġverify ( mock View ). update Current Frequency ( set Freq To ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġshould Update T uner View When Received Error From Service () Ġ{ ĊĠĠĠĠĠĠĠ Ġwhenever ( mock Permission Helper . handle Micro phone Permission ()). thenReturn ( true ) ĊĠĠĠĠĠĠĠ Ġwhenever ( mock G uit ar T uner Reactive . listen To Notes ()). thenReturn ( Observable . error ( IllegalStateException ())) ĊĊĠĠĠĠĠĠĠ Ġmain Presenter . on View Res uming () ĊĊĠĠĠĠĠĠĠ Ġverify ( mock Permission Helper ). handle Micro phone Permission () ĊĠĠĠĠĠĠĠ Ġverify ( mock G uit ar T uner Reactive ). listen To Notes () ĊĠĠĠĠĠĠĠ Ġverify ( mock View ). inform Error () ĊĠĠĠ Ġ} Ċ } Ċ