Use a fake clock for rtc::Thread::PostDelayedTask test
The test would flake using a real clock since time may pass between calls to PostDelayedTask which would result in the tasks running out of the expected order. Bug: webrtc:11208, webrtc:11219 Change-Id: Ice5fe6ec4e9bf2ce89f00c6de7ed06b89dbe88cc Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/162100 Reviewed-by: Yves Gerey <yvesg@google.com> Commit-Queue: Steve Anton <steveanton@webrtc.org> Cr-Commit-Position: refs/heads/master@{#30101}
This commit is contained in:
@ -920,6 +920,7 @@ TEST(ThreadPostDelayedTaskTest, InvokesAsynchronously) {
|
||||
}
|
||||
|
||||
TEST(ThreadPostDelayedTaskTest, InvokesInDelayOrder) {
|
||||
ScopedFakeClock clock;
|
||||
std::unique_ptr<rtc::Thread> background_thread(rtc::Thread::Create());
|
||||
background_thread->Start();
|
||||
|
||||
@ -940,8 +941,9 @@ TEST(ThreadPostDelayedTaskTest, InvokesInDelayOrder) {
|
||||
|
||||
// All tasks have been posted before the first one is unblocked.
|
||||
first.Set();
|
||||
// Only if the chain is invoked in posted order will the last event be set.
|
||||
fourth.Wait(Event::kForever);
|
||||
// Only if the chain is invoked in delay order will the last event be set.
|
||||
clock.AdvanceTime(webrtc::TimeDelta::ms(11));
|
||||
EXPECT_TRUE(fourth.Wait(0));
|
||||
}
|
||||
|
||||
class ThreadFactory : public webrtc::TaskQueueFactory {
|
||||
|
Reference in New Issue
Block a user