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 <kwiberg@webrtc.org>
Reviewed-by: Niels Moller <nisse@webrtc.org>
Reviewed-by: Jonas Oreland <jonaso@webrtc.org>
Commit-Queue: Yves Gerey <yvesg@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#25042}
diff --git a/media/engine/webrtcvideoengine_unittest.cc b/media/engine/webrtcvideoengine_unittest.cc
index e87f63f..5724bfa 100644
--- a/media/engine/webrtcvideoengine_unittest.cc
+++ b/media/engine/webrtcvideoengine_unittest.cc
@@ -6905,16 +6905,20 @@
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};