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

Side by Side Diff: media/filters/ffmpeg_glue_unittest.cc

Issue 165176: Merge 21999 - BufferedDataSource to support server without range request supp... (Closed) Base URL: svn://chrome-svn/chrome/branches/195/src/
Patch Set: Created 11 years, 4 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 | Annotate | Revision Log
« no previous file with comments | « media/filters/ffmpeg_glue.cc ('k') | media/filters/file_data_source.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Property Changes:
Modified: svn:mergeinfo
Merged /trunk/src/media/filters/ffmpeg_glue_unittest.cc:r21999
OLDNEW
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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 "media/base/mock_ffmpeg.h" 5 #include "media/base/mock_ffmpeg.h"
6 #include "media/base/mock_filters.h" 6 #include "media/base/mock_filters.h"
7 #include "media/filters/ffmpeg_common.h" 7 #include "media/filters/ffmpeg_common.h"
8 #include "media/filters/ffmpeg_glue.h" 8 #include "media/filters/ffmpeg_glue.h"
9 #include "testing/gtest/include/gtest/gtest.h" 9 #include "testing/gtest/include/gtest/gtest.h"
10 10
11 using ::testing::_; 11 using ::testing::_;
12 using ::testing::DoAll; 12 using ::testing::DoAll;
13 using ::testing::InSequence; 13 using ::testing::InSequence;
14 using ::testing::Return; 14 using ::testing::Return;
15 using ::testing::SetArgumentPointee; 15 using ::testing::SetArgumentPointee;
16 using ::testing::StrictMock; 16 using ::testing::StrictMock;
17 17
18 namespace media { 18 namespace media {
19 19
20 class MockProtocol : public FFmpegURLProtocol { 20 class MockProtocol : public FFmpegURLProtocol {
21 public: 21 public:
22 MockProtocol() { 22 MockProtocol() {
23 } 23 }
24 24
25 MOCK_METHOD2(Read, int(int size, uint8* data)); 25 MOCK_METHOD2(Read, int(int size, uint8* data));
26 MOCK_METHOD1(GetPosition, bool(int64* position_out)); 26 MOCK_METHOD1(GetPosition, bool(int64* position_out));
27 MOCK_METHOD1(SetPosition, bool(int64 position)); 27 MOCK_METHOD1(SetPosition, bool(int64 position));
28 MOCK_METHOD1(GetSize, bool(int64* size_out)); 28 MOCK_METHOD1(GetSize, bool(int64* size_out));
29 MOCK_METHOD0(IsStreamed, bool()); 29 MOCK_METHOD0(IsStreaming, bool());
30 30
31 private: 31 private:
32 DISALLOW_COPY_AND_ASSIGN(MockProtocol); 32 DISALLOW_COPY_AND_ASSIGN(MockProtocol);
33 }; 33 };
34 34
35 class FFmpegGlueTest : public ::testing::Test { 35 class FFmpegGlueTest : public ::testing::Test {
36 public: 36 public:
37 FFmpegGlueTest() { 37 FFmpegGlueTest() {
38 MockFFmpeg::set(&mock_ffmpeg_); 38 MockFFmpeg::set(&mock_ffmpeg_);
39 } 39 }
40 40
41 virtual ~FFmpegGlueTest() { 41 virtual ~FFmpegGlueTest() {
42 MockFFmpeg::set(NULL); 42 MockFFmpeg::set(NULL);
43 } 43 }
44 44
45 // Helper to open a URLContext pointing to the given mocked protocol. 45 // Helper to open a URLContext pointing to the given mocked protocol.
46 // Callers are expected to close the context at the end of their test. 46 // Callers are expected to close the context at the end of their test.
47 virtual void OpenContext(MockProtocol* protocol, URLContext* context) { 47 virtual void OpenContext(MockProtocol* protocol, URLContext* context) {
48 // IsStreamed() is called when opening. 48 // IsStreaming() is called when opening.
49 EXPECT_CALL(*protocol, IsStreamed()).WillOnce(Return(true)); 49 EXPECT_CALL(*protocol, IsStreaming()).WillOnce(Return(true));
50 50
51 // Add the protocol to the glue layer and open a context. 51 // Add the protocol to the glue layer and open a context.
52 std::string key = FFmpegGlue::get()->AddProtocol(protocol); 52 std::string key = FFmpegGlue::get()->AddProtocol(protocol);
53 memset(context, 0, sizeof(*context)); 53 memset(context, 0, sizeof(*context));
54 EXPECT_EQ(0, protocol_->url_open(context, key.c_str(), 0)); 54 EXPECT_EQ(0, protocol_->url_open(context, key.c_str(), 0));
55 FFmpegGlue::get()->RemoveProtocol(protocol); 55 FFmpegGlue::get()->RemoveProtocol(protocol);
56 } 56 }
57 57
58 protected: 58 protected:
59 // Fixture members. 59 // Fixture members.
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
137 mock_ffmpeg_.CheckPoint(0); 137 mock_ffmpeg_.CheckPoint(0);
138 } 138 }
139 139
140 TEST_F(FFmpegGlueTest, OpenClose) { 140 TEST_F(FFmpegGlueTest, OpenClose) {
141 // Prepare testing data. 141 // Prepare testing data.
142 FFmpegGlue* glue = FFmpegGlue::get(); 142 FFmpegGlue* glue = FFmpegGlue::get();
143 143
144 // Create our protocol and add them to the glue layer. 144 // Create our protocol and add them to the glue layer.
145 scoped_ptr<StrictMock<Destroyable<MockProtocol> > > protocol( 145 scoped_ptr<StrictMock<Destroyable<MockProtocol> > > protocol(
146 new StrictMock<Destroyable<MockProtocol> >()); 146 new StrictMock<Destroyable<MockProtocol> >());
147 EXPECT_CALL(*protocol, IsStreamed()).WillOnce(Return(true)); 147 EXPECT_CALL(*protocol, IsStreaming()).WillOnce(Return(true));
148 std::string key = glue->AddProtocol(protocol.get()); 148 std::string key = glue->AddProtocol(protocol.get());
149 149
150 // Prepare FFmpeg URLContext structure. 150 // Prepare FFmpeg URLContext structure.
151 URLContext context; 151 URLContext context;
152 memset(&context, 0, sizeof(context)); 152 memset(&context, 0, sizeof(context));
153 153
154 // Test opening a URLContext with a protocol that doesn't exist. 154 // Test opening a URLContext with a protocol that doesn't exist.
155 EXPECT_EQ(AVERROR_IO, protocol_->url_open(&context, "foobar", 0)); 155 EXPECT_EQ(AVERROR_IO, protocol_->url_open(&context, "foobar", 0));
156 156
157 // Test opening a URLContext with our protocol. 157 // Test opening a URLContext with our protocol.
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after
316 316
317 // Remove our own reference, we shouldn't be destroyed yet. 317 // Remove our own reference, we shouldn't be destroyed yet.
318 mock_ffmpeg_.CheckPoint(0); 318 mock_ffmpeg_.CheckPoint(0);
319 protocol.reset(); 319 protocol.reset();
320 320
321 // ~FFmpegGlue() will be called when this unit test finishes execution. By 321 // ~FFmpegGlue() will be called when this unit test finishes execution. By
322 // leaving something inside FFmpegGlue's map we get to test our cleanup code. 322 // leaving something inside FFmpegGlue's map we get to test our cleanup code.
323 } 323 }
324 324
325 } // namespace media 325 } // namespace media
OLDNEW
« no previous file with comments | « media/filters/ffmpeg_glue.cc ('k') | media/filters/file_data_source.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698