Use WallClockTimer in DeviceOffHoursController
DeviceOffHours policy operates with a "real" clock: it has to know the exact time (day, hours, minutes) to make a decision. One of things which affect real clock is suspend: from software's perspective it's a jump into future. Therefore DeviceOffHoursController caught OnSuspendDone event from the power manager to reschedule its timer. WallClockTimer is the class which automatically reschedules after suspend, therefore instead of duplicating this logic in DeviceOffHoursController we can just reuse WallClockTimer. Also this CL makes a number of changes in tests: * An access method for fake power manager client is removed from DeviceSettingsTestBase, as tests for DeviceOffHoursController were the ones which used it. * DeviceSettingsTestBase now has an additional constructor to override time source (mocked or system) for task environment it creates. This is needed because we have to mock time to test suspend, but not all other tests support mocked time. More on that in https://crbug.com/1129894. * CheckSendSuspendDone test for DeviceOffHoursController is renamed to CheckUnderSuspend, since it simulates suspend, not only checks that sending OnSuspentEvent to DeviceOffHoursController may trigger the update. Bug: b:160682243 Change-Id: I403964452e5eeb7470fd731e6760b7b0dec27456 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2418816Reviewed-by:Maksim Ivanov <emaxx@chromium.org> Reviewed-by:
Sergey Poromov <poromov@chromium.org> Commit-Queue: Oleg Davydov <burunduk@chromium.org> Cr-Commit-Position: refs/heads/master@{#809873}
Showing
Please register or sign in to comment