Index: webrtc/modules/remote_bitrate_estimator/remote_bitrate_estimators_test.cc |
diff --git a/webrtc/modules/remote_bitrate_estimator/remote_bitrate_estimators_test.cc b/webrtc/modules/remote_bitrate_estimator/remote_bitrate_estimators_test.cc |
index d6f049f6ac13f6ca49eaf16d581f300f4818c5c8..2ce144129b0b76ca02b40662a60ee601bf41c12e 100644 |
--- a/webrtc/modules/remote_bitrate_estimator/remote_bitrate_estimators_test.cc |
+++ b/webrtc/modules/remote_bitrate_estimator/remote_bitrate_estimators_test.cc |
@@ -13,8 +13,10 @@ |
#include <unistd.h> |
#endif |
+#include <algorithm> |
#include <sstream> |
+#include "webrtc/base/random.h" |
#include "webrtc/modules/remote_bitrate_estimator/include/remote_bitrate_estimator.h" |
#include "webrtc/modules/remote_bitrate_estimator/test/bwe_test.h" |
#include "webrtc/modules/remote_bitrate_estimator/test/packet_receiver.h" |
@@ -242,18 +244,20 @@ class BweFeedbackTest |
: public BweTest, |
public ::testing::TestWithParam<BandwidthEstimatorType> { |
public: |
- BweFeedbackTest() : BweTest() {} |
+#ifdef WEBRTC_WIN |
+ BweFeedbackTest() |
+ : BweTest(), random_(Clock::GetRealTimeClock()->TimeInMicroseconds()) {} |
+#else |
+ BweFeedbackTest() |
+ : BweTest(), |
+ // Multiply the time by a random-ish odd number derived from the PID. |
+ random_((getpid() | 1) * |
+ Clock::GetRealTimeClock()->TimeInMicroseconds()) {} |
+#endif |
virtual ~BweFeedbackTest() {} |
protected: |
- void SetUp() override { |
- unsigned int seed = Clock::GetRealTimeClock()->TimeInMicroseconds(); |
-#ifndef WEBRTC_WIN |
- seed *= getpid(); |
-#endif |
- srand(seed); |
- BweTest::SetUp(); |
- } |
+ Random random_; |
private: |
RTC_DISALLOW_COPY_AND_ASSIGN(BweFeedbackTest); |
@@ -356,7 +360,7 @@ TEST_P(BweFeedbackTest, PacedSelfFairness50msTest) { |
const int kNumRmcatFlows = 4; |
int64_t offset_ms[kNumRmcatFlows]; |
for (int i = 0; i < kNumRmcatFlows; ++i) { |
- offset_ms[i] = std::max(0, 5000 * i + rand() % 2001 - 1000); |
+ offset_ms[i] = std::max(0, 5000 * i + random_.Rand(-1000, 1000)); |
} |
RunFairnessTest(GetParam(), kNumRmcatFlows, 0, 300, 3000, 50, kRttMs, |
@@ -370,7 +374,7 @@ TEST_P(BweFeedbackTest, PacedSelfFairness500msTest) { |
const int kNumRmcatFlows = 4; |
int64_t offset_ms[kNumRmcatFlows]; |
for (int i = 0; i < kNumRmcatFlows; ++i) { |
- offset_ms[i] = std::max(0, 5000 * i + rand() % 2001 - 1000); |
+ offset_ms[i] = std::max(0, 5000 * i + random_.Rand(-1000, 1000)); |
} |
RunFairnessTest(GetParam(), kNumRmcatFlows, 0, 300, 3000, 500, kRttMs, |
@@ -384,7 +388,7 @@ TEST_P(BweFeedbackTest, PacedSelfFairness1000msTest) { |
const int kNumRmcatFlows = 4; |
int64_t offset_ms[kNumRmcatFlows]; |
for (int i = 0; i < kNumRmcatFlows; ++i) { |
- offset_ms[i] = std::max(0, 5000 * i + rand() % 2001 - 1000); |
+ offset_ms[i] = std::max(0, 5000 * i + random_.Rand(-1000, 1000)); |
} |
RunFairnessTest(GetParam(), kNumRmcatFlows, 0, 300, 3000, 1000, kRttMs, |
@@ -397,7 +401,7 @@ TEST_P(BweFeedbackTest, TcpFairness50msTest) { |
int64_t offset_ms[2]; // One TCP, one RMCAT flow. |
for (int i = 0; i < 2; ++i) { |
- offset_ms[i] = std::max(0, 5000 * i + rand() % 2001 - 1000); |
+ offset_ms[i] = std::max(0, 5000 * i + random_.Rand(-1000, 1000)); |
} |
RunFairnessTest(GetParam(), 1, 1, 300, 2000, 50, kRttMs, kMaxJitterMs, |
@@ -410,7 +414,7 @@ TEST_P(BweFeedbackTest, TcpFairness500msTest) { |
int64_t offset_ms[2]; // One TCP, one RMCAT flow. |
for (int i = 0; i < 2; ++i) { |
- offset_ms[i] = std::max(0, 5000 * i + rand() % 2001 - 1000); |
+ offset_ms[i] = std::max(0, 5000 * i + random_.Rand(-1000, 1000)); |
} |
RunFairnessTest(GetParam(), 1, 1, 300, 2000, 500, kRttMs, kMaxJitterMs, |
@@ -423,7 +427,7 @@ TEST_P(BweFeedbackTest, TcpFairness1000msTest) { |
int64_t offset_ms[2]; // One TCP, one RMCAT flow. |
for (int i = 0; i < 2; ++i) { |
- offset_ms[i] = std::max(0, 5000 * i + rand() % 2001 - 1000); |
+ offset_ms[i] = std::max(0, 5000 * i + random_.Rand(-1000, 1000)); |
} |
RunFairnessTest(GetParam(), 1, 1, 300, 2000, 1000, kRttMs, kMaxJitterMs, |