Use a better method to generate a random ID in IvfFileWriterTest.

It was generating a random ID using the test case's "this" pointer
and the current time. However, the current time may be imprecise. And
the "this" pointer may have repeatable values.

BUG=webrtc:5898

Review-Url: https://codereview.webrtc.org/2190533004
Cr-Commit-Position: refs/heads/master@{#13560}
This commit is contained in:
deadbeef
2016-07-28 10:51:10 -07:00
committed by Commit bot
parent 59c1ad58e6
commit 55b0b37554

View File

@ -13,6 +13,7 @@
#include <memory>
#include "testing/gtest/include/gtest/gtest.h"
#include "webrtc/base/helpers.h"
#include "webrtc/base/logging.h"
#include "webrtc/base/thread.h"
#include "webrtc/base/timeutils.h"
@ -31,15 +32,14 @@ static const int kMaxFileRetries = 5;
class IvfFileWriterTest : public ::testing::Test {
protected:
void SetUp() override {
const int64_t start_id =
reinterpret_cast<int64_t>(this) ^ rtc::TimeMicros();
int64_t id = start_id;
const uint64_t start_id = rtc::CreateRandomId64();
uint64_t id = start_id;
do {
std::ostringstream oss;
oss << test::OutputPath() << "ivf_test_file_" << id++ << ".ivf";
file_name_ = oss.str();
} while (id < start_id + 100 && FileExists(false));
ASSERT_LT(id, start_id + 100);
} while ((id - start_id) < 100u && FileExists(false));
ASSERT_LT(id - start_id, 100u);
}
bool WriteDummyTestFrames(int width,