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

Side by Side Diff: webrtc/test/testsupport/yuv_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/yuv_frame_writer.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2017 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
11 #include "webrtc/test/testsupport/frame_writer.h" 11 #include <memory>
12 12
13 #include "webrtc/test/gtest.h" 13 #include "webrtc/test/gtest.h"
14 #include "webrtc/test/testsupport/fileutils.h" 14 #include "webrtc/test/testsupport/fileutils.h"
15 #include "webrtc/test/testsupport/frame_writer.h"
15 16
16 namespace webrtc { 17 namespace webrtc {
17 namespace test { 18 namespace test {
18 19
19 const size_t kFrameLength = 1000; 20 namespace {
21 const size_t kFrameWidth = 50;
22 const size_t kFrameHeight = 20;
23 const size_t kFrameLength = 3 * kFrameWidth * kFrameHeight / 2; // I420.
24 } // namespace
20 25
21 class FrameWriterTest: public testing::Test { 26 class YuvFrameWriterTest : public testing::Test {
22 protected: 27 protected:
23 FrameWriterTest() {} 28 YuvFrameWriterTest() = default;
24 virtual ~FrameWriterTest() {} 29 ~YuvFrameWriterTest() override = default;
25 void SetUp() { 30
31 void SetUp() override {
26 temp_filename_ = webrtc::test::TempFilename(webrtc::test::OutputPath(), 32 temp_filename_ = webrtc::test::TempFilename(webrtc::test::OutputPath(),
27 "frame_writer_unittest"); 33 "yuv_frame_writer_unittest");
28 frame_writer_ = new FrameWriterImpl(temp_filename_, kFrameLength); 34 frame_writer_.reset(
35 new YuvFrameWriterImpl(temp_filename_, kFrameWidth, kFrameHeight));
29 ASSERT_TRUE(frame_writer_->Init()); 36 ASSERT_TRUE(frame_writer_->Init());
30 } 37 }
31 void TearDown() { 38
32 delete frame_writer_; 39 void TearDown() override { remove(temp_filename_.c_str()); }
33 // Cleanup the temporary file. 40
34 remove(temp_filename_.c_str()); 41 std::unique_ptr<FrameWriter> frame_writer_;
35 }
36 FrameWriter* frame_writer_;
37 std::string temp_filename_; 42 std::string temp_filename_;
38 }; 43 };
39 44
40 TEST_F(FrameWriterTest, InitSuccess) { 45 TEST_F(YuvFrameWriterTest, InitSuccess) {}
41 FrameWriterImpl frame_writer(temp_filename_, kFrameLength); 46
42 ASSERT_TRUE(frame_writer.Init()); 47 TEST_F(YuvFrameWriterTest, FrameLength) {
43 ASSERT_EQ(kFrameLength, frame_writer.FrameLength()); 48 EXPECT_EQ(kFrameLength, frame_writer_->FrameLength());
44 } 49 }
45 50
46 TEST_F(FrameWriterTest, WriteFrame) { 51 TEST_F(YuvFrameWriterTest, WriteFrame) {
47 uint8_t buffer[kFrameLength]; 52 uint8_t buffer[kFrameLength];
48 memset(buffer, 9, kFrameLength); // Write lots of 9s to the buffer 53 memset(buffer, 9, kFrameLength); // Write lots of 9s to the buffer.
49 bool result = frame_writer_->WriteFrame(buffer); 54 bool result = frame_writer_->WriteFrame(buffer);
50 ASSERT_TRUE(result); // success 55 ASSERT_TRUE(result);
51 // Close the file and verify the size. 56
52 frame_writer_->Close(); 57 frame_writer_->Close();
53 ASSERT_EQ(kFrameLength, GetFileSize(temp_filename_)); 58 EXPECT_EQ(kFrameLength, GetFileSize(temp_filename_));
54 } 59 }
55 60
56 TEST_F(FrameWriterTest, WriteFrameUninitialized) { 61 TEST_F(YuvFrameWriterTest, WriteFrameUninitialized) {
57 uint8_t buffer[3]; 62 uint8_t buffer[kFrameLength];
58 FrameWriterImpl frame_writer(temp_filename_, kFrameLength); 63 YuvFrameWriterImpl frame_writer(temp_filename_, kFrameWidth, kFrameHeight);
59 ASSERT_FALSE(frame_writer.WriteFrame(buffer)); 64 EXPECT_FALSE(frame_writer.WriteFrame(buffer));
60 } 65 }
61 66
62 } // namespace test 67 } // namespace test
63 } // namespace webrtc 68 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/test/testsupport/yuv_frame_writer.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698