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

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

Issue 6541037: Revert 75444 - Move MockFFmpeg instance setting into the constructor/destruct... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 9 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 "base/logging.h" 5 #include "base/logging.h"
6 #include "base/scoped_ptr.h" 6 #include "base/scoped_ptr.h"
7 #include "media/base/mock_ffmpeg.h" 7 #include "media/base/mock_ffmpeg.h"
8 #include "media/base/mock_filters.h" 8 #include "media/base/mock_filters.h"
9 #include "media/ffmpeg/ffmpeg_common.h" 9 #include "media/ffmpeg/ffmpeg_common.h"
10 #include "media/filters/ffmpeg_glue.h" 10 #include "media/filters/ffmpeg_glue.h"
11 #include "testing/gtest/include/gtest/gtest.h" 11 #include "testing/gtest/include/gtest/gtest.h"
(...skipping 17 matching lines...) Expand all
29 MOCK_METHOD1(SetPosition, bool(int64 position)); 29 MOCK_METHOD1(SetPosition, bool(int64 position));
30 MOCK_METHOD1(GetSize, bool(int64* size_out)); 30 MOCK_METHOD1(GetSize, bool(int64* size_out));
31 MOCK_METHOD0(IsStreaming, bool()); 31 MOCK_METHOD0(IsStreaming, bool());
32 32
33 private: 33 private:
34 DISALLOW_COPY_AND_ASSIGN(MockProtocol); 34 DISALLOW_COPY_AND_ASSIGN(MockProtocol);
35 }; 35 };
36 36
37 class FFmpegGlueTest : public ::testing::Test { 37 class FFmpegGlueTest : public ::testing::Test {
38 public: 38 public:
39 FFmpegGlueTest() {} 39 FFmpegGlueTest() {
40 }
40 41
41 virtual void SetUp() { 42 virtual void SetUp() {
43 MockFFmpeg::set(&mock_ffmpeg_);
44
42 // Singleton should initialize FFmpeg. 45 // Singleton should initialize FFmpeg.
43 CHECK(FFmpegGlue::GetInstance()); 46 CHECK(FFmpegGlue::GetInstance());
44 47
45 // Assign our static copy of URLProtocol for the rest of the tests. 48 // Assign our static copy of URLProtocol for the rest of the tests.
46 protocol_ = MockFFmpeg::protocol(); 49 protocol_ = MockFFmpeg::protocol();
47 CHECK(protocol_); 50 CHECK(protocol_);
48 } 51 }
49 52
53 virtual void TearDown() {
54 MockFFmpeg::set(NULL);
55 }
56
50 // Helper to open a URLContext pointing to the given mocked protocol. 57 // Helper to open a URLContext pointing to the given mocked protocol.
51 // Callers are expected to close the context at the end of their test. 58 // Callers are expected to close the context at the end of their test.
52 virtual void OpenContext(MockProtocol* protocol, URLContext* context) { 59 virtual void OpenContext(MockProtocol* protocol, URLContext* context) {
53 // IsStreaming() is called when opening. 60 // IsStreaming() is called when opening.
54 EXPECT_CALL(*protocol, IsStreaming()).WillOnce(Return(true)); 61 EXPECT_CALL(*protocol, IsStreaming()).WillOnce(Return(true));
55 62
56 // Add the protocol to the glue layer and open a context. 63 // Add the protocol to the glue layer and open a context.
57 std::string key = FFmpegGlue::GetInstance()->AddProtocol(protocol); 64 std::string key = FFmpegGlue::GetInstance()->AddProtocol(protocol);
58 memset(context, 0, sizeof(*context)); 65 memset(context, 0, sizeof(*context));
59 EXPECT_EQ(0, protocol_->url_open(context, key.c_str(), 0)); 66 EXPECT_EQ(0, protocol_->url_open(context, key.c_str(), 0));
(...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after
314 321
315 // Remove our own reference, we shouldn't be destroyed yet. 322 // Remove our own reference, we shouldn't be destroyed yet.
316 mock_ffmpeg_.CheckPoint(0); 323 mock_ffmpeg_.CheckPoint(0);
317 protocol.reset(); 324 protocol.reset();
318 325
319 // ~FFmpegGlue() will be called when this unit test finishes execution. By 326 // ~FFmpegGlue() will be called when this unit test finishes execution. By
320 // leaving something inside FFmpegGlue's map we get to test our cleanup code. 327 // leaving something inside FFmpegGlue's map we get to test our cleanup code.
321 } 328 }
322 329
323 } // namespace media 330 } // namespace media
OLDNEW
« no previous file with comments | « media/filters/ffmpeg_demuxer_unittest.cc ('k') | media/filters/ffmpeg_h264_bitstream_converter_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698