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

Unified Diff: webrtc/base/fakeclock.h

Issue 2024813004: Improving the fake clock and using it to fix a flaky STUN timeout test. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Revising comments etc. Created 4 years, 7 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 side-by-side diff with in-line comments
Download patch
Index: webrtc/base/fakeclock.h
diff --git a/webrtc/base/fakeclock.h b/webrtc/base/fakeclock.h
index 2b3afdde05f684926621bcc95c2f917bfb7bd60f..da41d8dec4a7e65755004fda0f195d712ccafcfc 100644
--- a/webrtc/base/fakeclock.h
+++ b/webrtc/base/fakeclock.h
@@ -19,6 +19,8 @@ namespace rtc {
// Fake clock for use with unit tests, which does not tick on its own.
// Starts at time 0.
+//
+// TODO(deadbeef): Unify with webrtc::SimulatedClock.
class FakeClock : public ClockInterface {
public:
~FakeClock() override {}
@@ -38,6 +40,20 @@ class FakeClock : public ClockInterface {
uint64_t time_ GUARDED_BY(lock_) = 0u;
};
+// Helper class which creates and sets a fake clock as the global clock in
+// its constructor, and unsets and deletes it in its destructor.
+class ScopedFakeClock {
pthatcher1 2016/06/01 22:38:14 Does this work in C++? class ScopedFakeClock : Fa
Taylor Brandstetter 2016/06/01 23:28:37 Done.
+ public:
+ ScopedFakeClock() { SetClock(&clock_); }
+
+ ~ScopedFakeClock() { SetClock(nullptr); }
pthatcher1 2016/06/01 22:38:14 Should we do this? public: ScopedFakeClock() { o
Taylor Brandstetter 2016/06/01 23:28:37 I hadn't *intended* for there to be multiple fake
+
+ FakeClock& clock() { return clock_; }
+
+ private:
+ FakeClock clock_;
+};
+
} // namespace rtc
#endif // WEBRTC_BASE_FAKECLOCK_H_
« no previous file with comments | « webrtc/base/base_tests.gyp ('k') | webrtc/base/fakeclock.cc » ('j') | webrtc/base/gunit.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698