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

Side by Side Diff: webrtc/test/testsupport/frame_writer_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_writer.cc ('k') | webrtc/test/testsupport/y4m_frame_writer.cc » ('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_writer.h"
12
13 #include "webrtc/test/gtest.h"
14 #include "webrtc/test/testsupport/fileutils.h"
15
16 namespace webrtc {
17 namespace test {
18
19 const size_t kFrameLength = 1000;
20
21 class FrameWriterTest: public testing::Test {
22 protected:
23 FrameWriterTest() {}
24 virtual ~FrameWriterTest() {}
25 void SetUp() {
26 temp_filename_ = webrtc::test::TempFilename(webrtc::test::OutputPath(),
27 "frame_writer_unittest");
28 frame_writer_ = new FrameWriterImpl(temp_filename_, kFrameLength);
29 ASSERT_TRUE(frame_writer_->Init());
30 }
31 void TearDown() {
32 delete frame_writer_;
33 // Cleanup the temporary file.
34 remove(temp_filename_.c_str());
35 }
36 FrameWriter* frame_writer_;
37 std::string temp_filename_;
38 };
39
40 TEST_F(FrameWriterTest, InitSuccess) {
41 FrameWriterImpl frame_writer(temp_filename_, kFrameLength);
42 ASSERT_TRUE(frame_writer.Init());
43 ASSERT_EQ(kFrameLength, frame_writer.FrameLength());
44 }
45
46 TEST_F(FrameWriterTest, WriteFrame) {
47 uint8_t buffer[kFrameLength];
48 memset(buffer, 9, kFrameLength); // Write lots of 9s to the buffer
49 bool result = frame_writer_->WriteFrame(buffer);
50 ASSERT_TRUE(result); // success
51 // Close the file and verify the size.
52 frame_writer_->Close();
53 ASSERT_EQ(kFrameLength, GetFileSize(temp_filename_));
54 }
55
56 TEST_F(FrameWriterTest, WriteFrameUninitialized) {
57 uint8_t buffer[3];
58 FrameWriterImpl frame_writer(temp_filename_, kFrameLength);
59 ASSERT_FALSE(frame_writer.WriteFrame(buffer));
60 }
61
62 } // namespace test
63 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/test/testsupport/frame_writer.cc ('k') | webrtc/test/testsupport/y4m_frame_writer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698