Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1726)

Side by Side Diff: webrtc/base/simulatedclock.h

Issue 1895933003: Adding the ability to use a simulated clock for unit tests. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 /*
2 * Copyright 2016 The WebRTC project authors. All Rights Reserved.
3 *
4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree.
9 */
10
11 #ifndef WEBRTC_BASE_SIMULATEDCLOCK_H_
12 #define WEBRTC_BASE_SIMULATEDCLOCK_H_
13
14 #include "webrtc/base/criticalsection.h"
15 #include "webrtc/base/timeutils.h"
16
17 namespace rtc {
18
19 // Simulated clock for use with unit tests, which does not tick on its own.
20 // Starts at time 0.
21 class SimulatedClock : public ClockInterface {
juberti2 2016/04/25 20:18:23 Should this be FakeClock, to match our other fakes
Taylor Brandstetter 2016/04/26 01:22:32 Done.
22 public:
23 ~SimulatedClock() override {}
24
25 // ClockInterface implementation.
26 uint64_t TimeNanos() const override;
27
28 // Methods that can be used by the test to control the time.
29
30 // Should only be used to set a time in the future.
31 void SetTimeNanos(uint64_t nanos);
32
33 void AdvanceTimeNanos(uint64_t nanos);
34
35 void AdvanceTimeMicros(uint64_t micros);
36
37 void AdvanceTimeMillis(uint64_t millis);
38
39 void AdvanceTimeSeconds(uint64_t seconds);
40
41 private:
42 CriticalSection lock_;
43 uint64_t time_ GUARDED_BY(lock_) = 0u;
44 };
45
46 } // namespace rtc
47
48 #endif // WEBRTC_BASE_SIMULATEDCLOCK_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698