OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include <deque> | 5 #include <deque> |
6 | 6 |
7 #include "media/base/mock_ffmpeg.h" | 7 #include "media/base/mock_ffmpeg.h" |
8 #include "media/ffmpeg/ffmpeg_common.h" | 8 #include "media/ffmpeg/ffmpeg_common.h" |
9 #include "media/filters/bitstream_converter.h" | 9 #include "media/filters/bitstream_converter.h" |
10 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
11 | 11 |
12 using ::testing::DoAll; | 12 using ::testing::DoAll; |
13 using ::testing::Mock; | 13 using ::testing::Mock; |
14 using ::testing::Return; | 14 using ::testing::Return; |
15 using ::testing::ReturnNull; | 15 using ::testing::ReturnNull; |
16 using ::testing::SetArgumentPointee; | 16 using ::testing::SetArgumentPointee; |
17 using ::testing::StrEq; | 17 using ::testing::StrEq; |
18 using ::testing::StrictMock; | 18 using ::testing::StrictMock; |
19 using ::testing::_; | 19 using ::testing::_; |
20 | 20 |
21 namespace media { | 21 namespace media { |
22 | 22 |
23 class BitstreamConverterTest : public testing::Test { | 23 class BitstreamConverterTest : public testing::Test { |
24 protected: | 24 protected: |
25 BitstreamConverterTest() { | 25 BitstreamConverterTest() { |
26 // Initialize MockFFmpeg. | |
27 MockFFmpeg::set(&mock_ffmpeg_); | |
28 | |
29 memset(&test_stream_context_, 0, sizeof(test_stream_context_)); | 26 memset(&test_stream_context_, 0, sizeof(test_stream_context_)); |
30 memset(&test_filter_, 0, sizeof(test_filter_)); | 27 memset(&test_filter_, 0, sizeof(test_filter_)); |
31 memset(&test_packet_, 0, sizeof(test_packet_)); | 28 memset(&test_packet_, 0, sizeof(test_packet_)); |
32 test_packet_.data = kData1; | 29 test_packet_.data = kData1; |
33 test_packet_.size = kTestSize1; | 30 test_packet_.size = kTestSize1; |
34 } | 31 } |
35 | 32 |
36 virtual ~BitstreamConverterTest() { | 33 virtual ~BitstreamConverterTest() {} |
37 // Reset MockFFmpeg. | |
38 MockFFmpeg::set(NULL); | |
39 } | |
40 | 34 |
41 AVCodecContext test_stream_context_; | 35 AVCodecContext test_stream_context_; |
42 AVBitStreamFilterContext test_filter_; | 36 AVBitStreamFilterContext test_filter_; |
43 AVPacket test_packet_; | 37 AVPacket test_packet_; |
44 | 38 |
45 StrictMock<MockFFmpeg> mock_ffmpeg_; | 39 StrictMock<MockFFmpeg> mock_ffmpeg_; |
46 | 40 |
47 static const char kTestFilterName[]; | 41 static const char kTestFilterName[]; |
48 static uint8_t kData1[]; | 42 static uint8_t kData1[]; |
49 static uint8_t kData2[]; | 43 static uint8_t kData2[]; |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
160 EXPECT_EQ(kData1, test_packet_.data); | 154 EXPECT_EQ(kData1, test_packet_.data); |
161 EXPECT_EQ(kTestSize1, test_packet_.size); | 155 EXPECT_EQ(kTestSize1, test_packet_.size); |
162 EXPECT_TRUE(test_packet_.destruct == NULL); | 156 EXPECT_TRUE(test_packet_.destruct == NULL); |
163 | 157 |
164 // Uninject mock filter instance to avoid cleanup code on destruction of | 158 // Uninject mock filter instance to avoid cleanup code on destruction of |
165 // converter. | 159 // converter. |
166 converter.stream_filter_ = NULL; | 160 converter.stream_filter_ = NULL; |
167 } | 161 } |
168 | 162 |
169 } // namespace media | 163 } // namespace media |
OLD | NEW |