Fix frame_editing_unittest reference file handling.
This test was initializing strings for reference video files in a static context, which makes is against the style guide and also makes the paths become invalid when the test is launched from a working directory outside the checkout. Moving the initialization into the test fixture solves this. BUG=none TEST=Local execution launched from a directory outside the checkout tree on Win, Mac and Linux + trybots (for compilation as they don't yet run the tools_unittests). Review URL: https://webrtc-codereview.appspot.com/1178004 git-svn-id: http://webrtc.googlecode.com/svn/trunk@3647 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
parent
0ef22c24c0
commit
3de314615f
@ -25,21 +25,22 @@ namespace test {
|
||||
const int kWidth = 352;
|
||||
const int kHeight = 288;
|
||||
const int kFrameSize = CalcBufferSize(kI420, kWidth, kHeight);
|
||||
const std::string kRefVideo = ResourcePath("foreman_cif", "yuv");
|
||||
const std::string kTestVideo = OutputPath() + "testvideo.yuv";
|
||||
|
||||
class FrameEditingTest : public ::testing::Test {
|
||||
protected:
|
||||
virtual void SetUp() {
|
||||
original_fid_ = fopen(kRefVideo.c_str(), "rb");
|
||||
reference_video_ = ResourcePath("foreman_cif", "yuv");
|
||||
test_video_ = OutputPath() + "testvideo.yuv";
|
||||
|
||||
original_fid_ = fopen(reference_video_.c_str(), "rb");
|
||||
ASSERT_TRUE(original_fid_ != NULL);
|
||||
|
||||
// Ensure the output file exists on disk.
|
||||
std::ofstream(kTestVideo.c_str(), std::ios::out);
|
||||
std::ofstream(test_video_.c_str(), std::ios::out);
|
||||
// Open the output file for reading.
|
||||
// TODO(holmer): Figure out why this file has to be opened here (test fails
|
||||
// if it's opened after the write operation performed in EditFrames).
|
||||
edited_fid_ = fopen(kTestVideo.c_str(), "rb");
|
||||
edited_fid_ = fopen(test_video_.c_str(), "rb");
|
||||
ASSERT_TRUE(edited_fid_ != NULL);
|
||||
|
||||
original_buffer_.reset(new int[kFrameSize]);
|
||||
@ -72,9 +73,10 @@ class FrameEditingTest : public ::testing::Test {
|
||||
// There should not be anything left in either stream.
|
||||
EXPECT_EQ(!feof(test_video_fid), !feof(ref_video_fid));
|
||||
}
|
||||
std::string reference_video_;
|
||||
std::string test_video_;
|
||||
FILE* original_fid_;
|
||||
FILE* edited_fid_;
|
||||
int kFrameSize_;
|
||||
int num_bytes_read_;
|
||||
scoped_array<int> original_buffer_;
|
||||
scoped_array<int> edited_buffer_;
|
||||
@ -86,8 +88,9 @@ TEST_F(FrameEditingTest, ValidInPath) {
|
||||
const int kInterval = -1;
|
||||
const int kLastFrameToProcess = 240;
|
||||
|
||||
int result = EditFrames(kRefVideo, kWidth, kHeight, kFirstFrameToProcess,
|
||||
kInterval, kLastFrameToProcess, kTestVideo);
|
||||
int result = EditFrames(reference_video_, kWidth, kHeight,
|
||||
kFirstFrameToProcess, kInterval, kLastFrameToProcess,
|
||||
test_video_);
|
||||
EXPECT_EQ(0, result);
|
||||
|
||||
for (int i = 1; i < kFirstFrameToProcess; ++i) {
|
||||
@ -116,20 +119,21 @@ TEST_F(FrameEditingTest, EmptySetToCut) {
|
||||
const int kInterval = -1;
|
||||
const int kLastFrameToProcess = 1;
|
||||
|
||||
int result = EditFrames(kRefVideo, kWidth, kHeight, kFirstFrameToProcess,
|
||||
kInterval, kLastFrameToProcess, kTestVideo);
|
||||
int result = EditFrames(reference_video_, kWidth, kHeight,
|
||||
kFirstFrameToProcess, kInterval, kLastFrameToProcess,
|
||||
test_video_);
|
||||
EXPECT_EQ(-10, result);
|
||||
}
|
||||
|
||||
TEST_F(FrameEditingTest, InValidInPath) {
|
||||
const std::string kRefVideo = "PATH/THAT/DOES/NOT/EXIST";
|
||||
const std::string kRefVideo_ = "PATH/THAT/DOES/NOT/EXIST";
|
||||
|
||||
const int kFirstFrameToProcess = 30;
|
||||
const int kInterval = 1;
|
||||
const int kLastFrameToProcess = 120;
|
||||
|
||||
int result = EditFrames(kRefVideo, kWidth, kHeight, kFirstFrameToProcess,
|
||||
kInterval, kLastFrameToProcess, kTestVideo);
|
||||
int result = EditFrames(kRefVideo_, kWidth, kHeight, kFirstFrameToProcess,
|
||||
kInterval, kLastFrameToProcess, test_video_);
|
||||
EXPECT_EQ(-11, result);
|
||||
}
|
||||
|
||||
@ -138,8 +142,9 @@ TEST_F(FrameEditingTest, DeletingEverySecondFrame) {
|
||||
const int kInterval = -2;
|
||||
const int kLastFrameToProcess = 10000;
|
||||
// Set kLastFrameToProcess to a large value so that all frame are processed.
|
||||
int result = EditFrames(kRefVideo, kWidth, kHeight, kFirstFrameToProcess,
|
||||
kInterval, kLastFrameToProcess, kTestVideo);
|
||||
int result = EditFrames(reference_video_, kWidth, kHeight,
|
||||
kFirstFrameToProcess, kInterval, kLastFrameToProcess,
|
||||
test_video_);
|
||||
EXPECT_EQ(0, result);
|
||||
|
||||
while (!feof(original_fid_) && !feof(edited_fid_)) {
|
||||
@ -172,8 +177,9 @@ TEST_F(FrameEditingTest, RepeatFrames) {
|
||||
const int kInterval = 2;
|
||||
const int kLastFrameToProcess = 240;
|
||||
|
||||
int result = EditFrames(kRefVideo, kWidth, kHeight, kFirstFrameToProcess,
|
||||
kInterval, kLastFrameToProcess, kTestVideo);
|
||||
int result = EditFrames(reference_video_, kWidth, kHeight,
|
||||
kFirstFrameToProcess, kInterval, kLastFrameToProcess,
|
||||
test_video_);
|
||||
EXPECT_EQ(0, result);
|
||||
|
||||
for (int i = 1; i < kFirstFrameToProcess; ++i) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user