Fix frame_editing_unittest.cc

The test fails since it's assuming out/testfile.yuv exists when running the test. Just opening the file at a later time than the SetUp function seems to break the test so that's not a viable solution. This CL uses a simple workaround that simply truncates the file before opening it, which works.

BUG=none
TEST=tools_unittests in Debug+Release on Mac, Win and Linux + memcheck, tsan, asan.

Review URL: https://webrtc-codereview.appspot.com/1067004

git-svn-id: http://webrtc.googlecode.com/svn/trunk@3401 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
kjellander@webrtc.org 2013-01-22 22:45:59 +00:00
parent a812a3acee
commit 8126602e26

View File

@ -11,6 +11,7 @@
#include <stdio.h>
#include <cstdlib>
#include <fstream>
#include "gtest/gtest.h"
#include "webrtc/common_video/libyuv/include/webrtc_libyuv.h"
@ -32,8 +33,15 @@ class FrameEditingTest : public ::testing::Test {
virtual void SetUp() {
original_fid_ = fopen(kRefVideo.c_str(), "rb");
ASSERT_TRUE(original_fid_ != NULL);
// Ensure the output file exists on disk.
std::ofstream(kTestVideo.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");
ASSERT_TRUE(edited_fid_ != NULL);
original_buffer_.reset(new int[kFrameSize]);
edited_buffer_.reset(new int[kFrameSize]);
num_frames_read_ = 0;