Files
android/libwvdrmengine/cdm/core/test/mock_clock.h
Kyle Zhang 642965c678 Merge latest oemcrypto-v17 change
No-Typo-Check: Not related to this change.

Bug: 161477208
Change-Id: I99e4780f6855b7045aa0cd5a49c13d2d0d51ed64
2022-01-27 20:07:15 -08:00

34 lines
899 B
C++

// Copyright 2018 Google LLC. All Rights Reserved. This file and proprietary
// source code may only be used and distributed under the Widevine License
// Agreement.
#ifndef CDM_TEST_MOCK_CLOCK_H_
#define CDM_TEST_MOCK_CLOCK_H_
#include <gmock/gmock.h>
#include "clock.h"
namespace wvcdm {
class MockClock : public wvutil::Clock {
public:
MOCK_METHOD(int64_t, GetCurrentTime, (), (override));
};
// Frozen clock will always return the same value for the current time.
// Intended to be used for testing where using the actual time would
// cause flaky tests.
class FrozenClock : public wvutil::Clock {
int64_t always_time_;
public:
FrozenClock(int64_t always_time = 0) : always_time_(always_time) {}
int64_t GetCurrentTime() override { return always_time_; }
void SetTime(int64_t new_time) { always_time_ = new_time; }
};
} // namespace wvcdm
#endif // CDM_TEST_MOCK_CLOCK_H_