• Oleg Davydov's avatar
    Use WallClockTimer in DeviceOffHoursController · c7b9696e
    Oleg Davydov authored
    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: default avatarMaksim Ivanov <emaxx@chromium.org>
    Reviewed-by: default avatarSergey Poromov <poromov@chromium.org>
    Commit-Queue: Oleg Davydov <burunduk@chromium.org>
    Cr-Commit-Position: refs/heads/master@{#809873}
    c7b9696e
device_settings_test_helper.h 3.33 KB