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

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

Issue 2700493006: Add optional visualization file writers to VideoProcessor tests. (Closed)
Patch Set: kjellander comments 2. 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
« no previous file with comments | « webrtc/test/testsupport/frame_reader.cc ('k') | webrtc/test/testsupport/frame_writer.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 /*
2 * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved.
3 *
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
6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree.
9 */
10
11 #include "webrtc/test/testsupport/frame_reader.h"
12
13 #include "webrtc/api/video/i420_buffer.h"
14 #include "webrtc/test/gtest.h"
15 #include "webrtc/test/testsupport/fileutils.h"
16
17 namespace webrtc {
18 namespace test {
19
20 const std::string kInputFileContents = "baz";
21 const size_t kFrameLength = 3;
22
23 class FrameReaderTest: public testing::Test {
24 protected:
25 FrameReaderTest() {}
26 virtual ~FrameReaderTest() {}
27 void SetUp() {
28 // Create a dummy input file.
29 temp_filename_ = webrtc::test::TempFilename(webrtc::test::OutputPath(),
30 "frame_reader_unittest");
31 FILE* dummy = fopen(temp_filename_.c_str(), "wb");
32 fprintf(dummy, "%s", kInputFileContents.c_str());
33 fclose(dummy);
34
35 frame_reader_ = new FrameReaderImpl(temp_filename_, 1, 1);
36 ASSERT_TRUE(frame_reader_->Init());
37 }
38 void TearDown() {
39 delete frame_reader_;
40 // Cleanup the dummy input file.
41 remove(temp_filename_.c_str());
42 }
43 FrameReader* frame_reader_;
44 std::string temp_filename_;
45 };
46
47 TEST_F(FrameReaderTest, InitSuccess) {
48 FrameReaderImpl frame_reader(temp_filename_, 1, 1);
49 ASSERT_TRUE(frame_reader.Init());
50 ASSERT_EQ(kFrameLength, frame_reader.FrameLength());
51 ASSERT_EQ(1, frame_reader.NumberOfFrames());
52 }
53
54 TEST_F(FrameReaderTest, ReadFrame) {
55 rtc::scoped_refptr<VideoFrameBuffer> buffer;
56 buffer = frame_reader_->ReadFrame();
57 ASSERT_TRUE(buffer);
58 ASSERT_EQ(kInputFileContents[0], buffer->DataY()[0]);
59 ASSERT_EQ(kInputFileContents[1], buffer->DataU()[0]);
60 ASSERT_EQ(kInputFileContents[2], buffer->DataV()[0]);
61 ASSERT_FALSE(frame_reader_->ReadFrame()); // End of file
62 }
63
64 TEST_F(FrameReaderTest, ReadFrameUninitialized) {
65 FrameReaderImpl file_reader(temp_filename_, 1, 1);
66 ASSERT_FALSE(file_reader.ReadFrame());
67 }
68
69 } // namespace test
70 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/test/testsupport/frame_reader.cc ('k') | webrtc/test/testsupport/frame_writer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698