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

Unified Diff: webrtc/base/timeutils_unittest.cc

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: Addressing comments. 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
« webrtc/base/timeutils.h ('K') | « webrtc/base/timeutils.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webrtc/base/timeutils_unittest.cc
diff --git a/webrtc/base/timeutils_unittest.cc b/webrtc/base/timeutils_unittest.cc
index f183684e6ccf41d3c1e9801ac987da55f7f1426e..fbd27d8ac08164150855b272b3f7c700d2b58cce 100644
--- a/webrtc/base/timeutils_unittest.cc
+++ b/webrtc/base/timeutils_unittest.cc
@@ -359,24 +359,25 @@ TEST(FakeClock, SettingTimeWakesThreads) {
message_handler_dispatched.Set();
};
FunctorMessageHandler<void, decltype(functor)> handler(functor);
- worker.PostDelayed(10000, &handler);
+ worker.PostDelayed(60000, &handler);
// Wait for a bit for the worker thread to be started and enter its socket
- // select().
+ // select(). Otherwise this test would be trivial since the worker thread
+ // would process the event as soon as it was started.
Thread::Current()->SleepMs(1000);
tommi 2016/06/02 07:59:01 A whole second seems like a lot. Can we synchroni
Taylor Brandstetter 2016/06/02 17:19:54 I picked a long time so that it's guaranteed to be
// Advance the fake clock, expecting the worker thread to wake up
- // and dispatch the message quickly.
- clock.AdvanceTime(TimeDelta::FromSeconds(10u));
- message_handler_dispatched.Wait(Event::kForever);
+ // and dispatch the message instantly.
+ clock.AdvanceTime(TimeDelta::FromSeconds(60u));
+ EXPECT_TRUE(message_handler_dispatched.Wait(0));
worker.Stop();
SetClock(nullptr);
- // The message should have been dispatched long before the 10 seconds fully
- // elapsed.
+ // The message should have been dispatched long before the 60 seconds fully
+ // elapsed (just a sanity check).
int64_t real_end_time_ms = TimeMillis();
- EXPECT_LT(real_end_time_ms - real_start_time_ms, 2000);
+ EXPECT_LT(real_end_time_ms - real_start_time_ms, 10000);
}
} // namespace rtc
« webrtc/base/timeutils.h ('K') | « webrtc/base/timeutils.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698