Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(301)

Side by Side Diff: webrtc/test/testsupport/frame_reader_unittest.cc

Issue 2700493006: Add optional visualization file writers to VideoProcessor tests. (Closed)
Patch Set: Add optional visualization file writers to VideoProcessor tests. Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source 5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
(...skipping 14 matching lines...) Expand all
25 FrameReaderTest() {} 25 FrameReaderTest() {}
26 virtual ~FrameReaderTest() {} 26 virtual ~FrameReaderTest() {}
27 void SetUp() { 27 void SetUp() {
28 // Create a dummy input file. 28 // Create a dummy input file.
29 temp_filename_ = webrtc::test::TempFilename(webrtc::test::OutputPath(), 29 temp_filename_ = webrtc::test::TempFilename(webrtc::test::OutputPath(),
30 "frame_reader_unittest"); 30 "frame_reader_unittest");
31 FILE* dummy = fopen(temp_filename_.c_str(), "wb"); 31 FILE* dummy = fopen(temp_filename_.c_str(), "wb");
32 fprintf(dummy, "%s", kInputFileContents.c_str()); 32 fprintf(dummy, "%s", kInputFileContents.c_str());
33 fclose(dummy); 33 fclose(dummy);
34 34
35 frame_reader_ = new FrameReaderImpl(temp_filename_, 1, 1); 35 frame_reader_ = new YuvFrameReaderImpl(temp_filename_, 1, 1);
36 ASSERT_TRUE(frame_reader_->Init()); 36 ASSERT_TRUE(frame_reader_->Init());
37 } 37 }
38 void TearDown() { 38 void TearDown() {
39 delete frame_reader_; 39 delete frame_reader_;
40 // Cleanup the dummy input file. 40 // Cleanup the dummy input file.
41 remove(temp_filename_.c_str()); 41 remove(temp_filename_.c_str());
42 } 42 }
43 FrameReader* frame_reader_; 43 FrameReader* frame_reader_;
44 std::string temp_filename_; 44 std::string temp_filename_;
45 }; 45 };
46 46
47 TEST_F(FrameReaderTest, InitSuccess) { 47 TEST_F(FrameReaderTest, InitSuccess) {
48 FrameReaderImpl frame_reader(temp_filename_, 1, 1); 48 YuvFrameReaderImpl frame_reader(temp_filename_, 1, 1);
49 ASSERT_TRUE(frame_reader.Init()); 49 ASSERT_TRUE(frame_reader.Init());
50 ASSERT_EQ(kFrameLength, frame_reader.FrameLength()); 50 ASSERT_EQ(kFrameLength, frame_reader.FrameLength());
51 ASSERT_EQ(1, frame_reader.NumberOfFrames()); 51 ASSERT_EQ(1, frame_reader.NumberOfFrames());
52 } 52 }
53 53
54 TEST_F(FrameReaderTest, ReadFrame) { 54 TEST_F(FrameReaderTest, ReadFrame) {
55 rtc::scoped_refptr<VideoFrameBuffer> buffer; 55 rtc::scoped_refptr<VideoFrameBuffer> buffer;
56 buffer = frame_reader_->ReadFrame(); 56 buffer = frame_reader_->ReadFrame();
57 ASSERT_TRUE(buffer); 57 ASSERT_TRUE(buffer);
58 ASSERT_EQ(kInputFileContents[0], buffer->DataY()[0]); 58 ASSERT_EQ(kInputFileContents[0], buffer->DataY()[0]);
59 ASSERT_EQ(kInputFileContents[1], buffer->DataU()[0]); 59 ASSERT_EQ(kInputFileContents[1], buffer->DataU()[0]);
60 ASSERT_EQ(kInputFileContents[2], buffer->DataV()[0]); 60 ASSERT_EQ(kInputFileContents[2], buffer->DataV()[0]);
61 ASSERT_FALSE(frame_reader_->ReadFrame()); // End of file 61 ASSERT_FALSE(frame_reader_->ReadFrame()); // End of file
62 } 62 }
63 63
64 TEST_F(FrameReaderTest, ReadFrameUninitialized) { 64 TEST_F(FrameReaderTest, ReadFrameUninitialized) {
65 FrameReaderImpl file_reader(temp_filename_, 1, 1); 65 YuvFrameReaderImpl file_reader(temp_filename_, 1, 1);
66 ASSERT_FALSE(file_reader.ReadFrame()); 66 ASSERT_FALSE(file_reader.ReadFrame());
67 } 67 }
68 68
69 } // namespace test 69 } // namespace test
70 } // namespace webrtc 70 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698