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