package Ġcom . dar sh an . e zy login Ċ Ċ import Ġcom . android . dd m lib . I Device Ċ import Ġcom . dar sh an . e zy login . preference . accessor . InMemory Preference Accessor Ċ import Ġcom . dar sh an . e zy login . adb . Bridge Ċ import Ġcom . dar sh an . e zy login . adb . Fake Device Ċ import Ġcom . dar sh an . e zy login . adb . Use Same Devices Helper Ċ import Ġcom . dar sh an . e zy login . preference . Project Preferences Ċ import Ġcom . google . common . truth . Truth . assertThat Ċ import Ġorg . junit . Test Ċ Ċ class ĠUse Same Devices Helper Test Ġ{ ĊĊĠĠĠ Ġval Ġplugin Prefs Ġ= ĠProject Preferences ( InMemory Preference Accessor ()) ĊĠĠĠ Ġval Ġbridge Ġ= ĠFake Bridge () ĊĠĠĠ Ġval Ġhelper : ĠUse Same Devices Helper Ġ= ĠUse Same Devices Helper ( plugin Prefs , Ġbridge ) ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġon First Run _ should Not Try To Return Devices () Ġ{ ĊĠĠĠĠĠĠĠ ĠassertThat ( helper . get Remember ed Devices ()). isEmpty () ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġwhen As king To Remember Devices _ should Return Devices In Shared Prefs () Ġ{ ĊĠĠĠĠĠĠĠ Ġbridge . willReturn (" 1 ", Ġ" 2 ", Ġ" 3 ", Ġ" 4 ") ĊĠĠĠĠĠĠĠ Ġplugin Prefs . willReturn (" 1 ", Ġ" 2 ") ĊĊĠĠĠĠĠĠĠ Ġhelper . remember Devices () ĊĠĠĠĠĠĠĠ Ġassert Remember ed Devices (" 1 ", Ġ" 2 ") ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġwhen The Connected Devices Changes _ should Not Use Same Device () Ġ{ ĊĠĠĠĠĠĠĠ Ġbridge . willReturn (" 1 ", Ġ" 2 ", Ġ" 3 ") ĊĠĠĠĠĠĠĠ Ġplugin Prefs . willReturn (" 1 ", Ġ" 2 ") ĊĊĠĠĠĠĠĠĠ Ġhelper . remember Devices () ĊĠĠĠĠĠĠĠ Ġassert Remember ed Devices (" 1 ", Ġ" 2 ") ĊĊĠĠĠĠĠĠĠ Ġbridge . willReturn (" 1 ", Ġ" 2 ") ĊĠĠĠĠĠĠĠ Ġassert No Remember ed Devices () ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġwhen Shared Prefs Are Empty _ should Not Use Same Device () Ġ{ ĊĠĠĠĠĠĠĠ Ġbridge . willReturn (" 1 ", Ġ" 2 ", Ġ" 3 ") ĊĊĠĠĠĠĠĠĠ Ġhelper . remember Devices () ĊĠĠĠĠĠĠĠ Ġassert No Remember ed Devices () ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġwhen Shared Prefs And Helper Are Not Sync ed _ should Not Use Same Device () Ġ{ ĊĠĠĠĠĠĠĠ Ġbridge . willReturn (" 1 ", Ġ" 2 ", Ġ" 3 ", Ġ" 4 ") ĊĠĠĠĠĠĠĠ Ġplugin Prefs . willReturn (" 2 ", Ġ" 4 ") ĊĊĠĠĠĠĠĠĠ Ġhelper . remember Devices () ĊĊĠĠĠĠĠĠĠ Ġassert Remember ed Devices (" 2 ", Ġ" 4 ") ĊĊĠĠĠĠĠĠĠ Ġplugin Prefs . willReturn (" 2 ", Ġ" id _ of _ device _ not _ connected _ right _ now ") ĊĠĠĠĠĠĠĠ Ġassert No Remember ed Devices () ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġfun Ġassert No Remember ed Devices () Ġ{ ĊĠĠĠĠĠĠĠ ĠassertThat ( helper . get Remember ed Devices ()). isEmpty () ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġfun Ġassert Remember ed Devices ( var arg Ġids : ĠString ) Ġ{ ĊĠĠĠĠĠĠĠ ĠassertThat ( helper . get Remember ed Devices ()). isEqualTo ( ids . map (:: Fake Device ). toList ()) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġclass ĠFake Bridge Ġ: ĠBridge Ġ{ ĊĠĠĠĠĠĠĠ Ġvar Ġready Ġ= Ġtrue ĊĠĠĠĠĠĠĠ Ġvar Ġdevices : ĠList < I Device > Ġ= Ġempty List () ĊĊĠĠĠĠĠĠĠ Ġoverride Ġfun Ġis Ready (): ĠBoolean Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġreturn Ġready ĊĠĠĠĠĠĠĠ Ġ} ĊĊĠĠĠĠĠĠĠ Ġoverride Ġfun Ġconnected Devices (): ĠList < I Device > Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġreturn Ġdevices ĊĠĠĠĠĠĠĠ Ġ} ĊĊĠĠĠĠĠĠĠ Ġfun Ġwill Return ( var arg Ġids : ĠString ) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġdevices Ġ= Ġids . map (:: Fake Device ) ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġprivate Ġfun ĠProject Preferences . willReturn ( var arg Ġids : ĠString ) Ġ= Ġsave Selected Device Serial s ( ids . asList ()) Ċ }