package Ġunit Test . tasks Ċ Ċ import Ġcom . android . dd m lib . Android Debug Bridge Ċ import Ġcom . android . dd m lib . I Device Ċ import Ġcom . n ha ar man . mockito _ kotlin . given Ċ 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 . then Ċ import Ġinternal . Animation Sca les Persistence Helper Ċ import Ġinternal . Device Com municator Ċ import Ġinternal . Output Receiver Provider Ċ import Ġorg . gradle . api . Project Ċ import Ġorg . gradle . test fixtures . Project Builder Ċ import Ġorg . junit . Before Ċ import Ġorg . junit . Rule Ċ import Ġorg . junit . Test Ċ import Ġorg . junit . rules . Temporary Folder Ċ import Ġtasks . Disable And Persist Animations Task Ċ import Ġtasks . internal . Animation Sca les Switch Ċ import Ġjava . io . File ĊĊ Ċ class ĠDisable And Persist Animations Task Test Ġ{ ĊĊĠĠĠ Ġ@ Rule ĊĠĠĠ Ġ@ Jvm Field ĊĠĠĠ Ġval Ġtemporary Folder Ġ= ĠTemporary Folder () ĊĊĠĠĠ Ġprivate Ġval Ġdevice : ĠI Device Ġ= Ġmock () ĊĠĠĠ Ġprivate Ġval Ġbridge : ĠAndroid Debug Bridge Ġ= Ġmock () ĊĠĠĠ Ġprivate Ġval Ġoutput Receiver Provider : ĠOutput Receiver Provider Ġ= Ġmock () ĊĠĠĠ Ġprivate Ġval Ġpersistence Helper : ĠAnimation Sca les Persistence Helper Ġ= Ġmock () ĊĠĠĠ Ġprivate Ġval Ġanimation Sca les Switch : ĠAnimation Sca les Switch Ġ= Ġmock () ĊĊĠĠĠ Ġprivate Ġval Ġdevice Com municator Ġ= ĠDevice Com municator ( bridge , Ġoutput Receiver Provider ) ĊĠĠĠ Ġprivate Ġval Ġdevices Ġ= ĠarrayOf ( device ) ĊĊĠĠĠ Ġlateinit Ġvar Ġproject Dir : ĠFile ĊĠĠĠ Ġlateinit Ġvar Ġproject : ĠProject ĊĠĠĠ Ġlateinit Ġvar Ġtask : ĠDisable And Persist Animations Task ĊĊĠĠĠ Ġ@ Before ĊĠĠĠ Ġfun Ġsetup () Ġ{ ĊĠĠĠĠĠĠĠ Ġproject Dir Ġ= Ġtemporary Folder . root ĊĠĠĠĠĠĠĠ Ġproject Dir . mkdir s () ĊĊĠĠĠĠĠĠĠ Ġproject Ġ= ĠProject Builder . builder (). with Project Dir ( project Dir ). build () ĊĠĠĠĠĠĠĠ Ġtask Ġ= Ġproject . tasks . create (" Disable Animations Task ", ĠDisable And Persist Animations Task :: class . java ) ĊĊĠĠĠĠĠĠĠ Ġtask . com municator Ġ= Ġdevice Com municator ĊĠĠĠĠĠĠĠ Ġtask . persistence Helper Ġ= Ġpersistence Helper ĊĠĠĠĠĠĠĠ Ġtask . animation Sca les Switch Ġ= Ġanimation Sca les Switch ĊĊĠĠĠĠĠĠĠ Ġgiven ( bridge . devices ). willReturn ( devices ) ĊĠĠĠĠĠĠĠ Ġgiven ( persistence Helper . has ConfigFile ()). willReturn ( true ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġ` can Ġcheck Ġpersistence `() Ġ{ ĊĠĠĠĠĠĠĠ Ġtask . run Task 1 () ĊĊĠĠĠĠĠĠĠ Ġthen ( persistence Helper ). should (). has ConfigFile () ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġ` output Ġdirectory Ġcan Ġbe Ġcreated `() Ġ{ ĊĠĠĠĠĠĠĠ Ġtask . run Task 1 () ĊĊĠĠĠĠĠĠĠ Ġthen ( persistence Helper ). should ( never ()). create ConfigFile In Path () ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġ` config Ġfile Ġcan Ġbe Ġcreated `() Ġ{ ĊĠĠĠĠĠĠĠ Ġgiven ( persistence Helper . has ConfigFile ()). willReturn ( false ) ĊĊĠĠĠĠĠĠĠ Ġtask . run Task 1 () ĊĊĠĠĠĠĠĠĠ Ġthen ( persistence Helper ). should (). create ConfigFile In Path () ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġ` animations Ġcan Ġbe Ġdisabled Ġby Ġanimation Sca les Switch `() Ġ{ ĊĠĠĠĠĠĠĠ Ġtask . run Task 2 ( device ) ĊĊĠĠĠĠĠĠĠ Ġthen ( animation Sca les Switch ). should (). disable Animations () ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġ` should Ġcheck Ġfor Ġconfig Ġfile Ġin Ġtask Ġ 3 `() Ġ{ ĊĠĠĠĠĠĠĠ Ġtask . run Task 3 () ĊĊĠĠĠĠĠĠĠ Ġthen ( persistence Helper ). should (). has ConfigFile () ĊĠĠĠ Ġ} Ċ Ċ }