From b6a8942fb4b2b156021efeaf5baa04d410e2535d Mon Sep 17 00:00:00 2001 From: Yves Gerey Date: Mon, 8 Oct 2018 10:08:32 +0200 Subject: [PATCH] Fix race condition for GetContributingSources test. Bug: webrtc:9813 Change-Id: I44f50f9858217c8303862f3820db11dbd8736b6c Reviewed-on: https://webrtc-review.googlesource.com/c/104121 Reviewed-by: Karl Wiberg Reviewed-by: Niels Moller Reviewed-by: Jonas Oreland Commit-Queue: Yves Gerey Cr-Commit-Position: refs/heads/master@{#25042} --- media/engine/webrtcvideoengine_unittest.cc | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/media/engine/webrtcvideoengine_unittest.cc b/media/engine/webrtcvideoengine_unittest.cc index e87f63ff4a..5724bfa101 100644 --- a/media/engine/webrtcvideoengine_unittest.cc +++ b/media/engine/webrtcvideoengine_unittest.cc @@ -6905,16 +6905,20 @@ TEST_F(WebRtcVideoChannelSimulcastTest, false); } -// The fake clock needs to be initialize before the call. -// So defer creating call in base class. -class WebRtcVideoChannelTestWithClock : public WebRtcVideoChannelBaseTest { +class WebRtcVideoFakeClock { public: - WebRtcVideoChannelTestWithClock() { + WebRtcVideoFakeClock() { fake_clock_.AdvanceTime(webrtc::TimeDelta::ms(1)); // avoid time=0 } rtc::ScopedFakeClock fake_clock_; }; +// The fake clock needs to be initialized before the call, and not +// destroyed until after all threads spawned by the test have been stopped. +// This mixin ensures that. +class WebRtcVideoChannelTestWithClock : public WebRtcVideoFakeClock, + public WebRtcVideoChannelBaseTest {}; + TEST_F(WebRtcVideoChannelTestWithClock, GetSources) { uint8_t data1[] = {0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};