+90
−83
Loading
Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more
The unit tests will become easier to write when validating callbacks and when having delayed behaviors. This is done by 1: using an executor instead of a handler so that we only need to check if the execute mock is invoked and 2: a custom executor interface that supports delayed execution. Executors are preferred so that this interface will be more consistent with public api guidelines and also because post/send methods in Handler are final so it's impossible to decouple a subclass/mocked Handler's behavior from the current Looper. Finally the test clock implementation takes the custom executor in the constructor so it can tell the executor when time changes so it can execute delayed runnables. Test: AppOpsUidStateTrackerTest Bug: 247111208 Change-Id: I930e7e56630408440f6ca03b4c2ab84b19b20eb9