diff --git a/webrtc/base/BUILD.gn b/webrtc/base/BUILD.gn index bcc6ad901e..ed40a42280 100644 --- a/webrtc/base/BUILD.gn +++ b/webrtc/base/BUILD.gn @@ -675,6 +675,7 @@ if (rtc_include_tests) { "fakesslidentity.h", "faketaskrunner.h", "gunit.h", + "test/faketiming.h", "testbase64.h", "testechoserver.h", "testutils.h", diff --git a/webrtc/base/base_tests.gyp b/webrtc/base/base_tests.gyp index e1d5bc0496..6940a66696 100644 --- a/webrtc/base/base_tests.gyp +++ b/webrtc/base/base_tests.gyp @@ -21,6 +21,7 @@ 'fakesslidentity.h', 'faketaskrunner.h', 'gunit.h', + 'test/faketiming.h', 'testbase64.h', 'testechoserver.h', 'testutils.h', diff --git a/webrtc/base/test/faketiming.h b/webrtc/base/test/faketiming.h new file mode 100644 index 0000000000..388a535d9c --- /dev/null +++ b/webrtc/base/test/faketiming.h @@ -0,0 +1,33 @@ +/* + * Copyright 2016 The WebRTC project authors. All Rights Reserved. + * + * Use of this source code is governed by a BSD-style license + * that can be found in the LICENSE file in the root of the source + * tree. An additional intellectual property rights grant can be found + * in the file PATENTS. All contributing project authors may + * be found in the AUTHORS file in the root of the source tree. + */ + +#ifndef WEBRTC_BASE_TEST_FAKETIMING_H_ +#define WEBRTC_BASE_TEST_FAKETIMING_H_ + +#include "webrtc/base/timing.h" +#include "webrtc/base/timeutils.h" + +namespace rtc { + +class FakeTiming : public Timing { + public: + // Starts at Jan 1, 1983 (UTC). + FakeTiming() : now_(410227200.0) {} + double TimerNow() override { return now_; } + void AdvanceTimeSecs(double seconds) { now_ += seconds; } + void AdvanceTimeMillisecs(double ms) { now_ += (ms / kNumMillisecsPerSec); } + + private: + double now_; +}; + +} // namespace rtc + +#endif // WEBRTC_BASE_TEST_FAKETIMING_H_