Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2010 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" |
| (...skipping 18 matching lines...) Expand all Loading... | |
| 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 } | |
| 41 | 40 |
| 42 virtual void SetUp() { | 41 virtual void SetUp() { |
| 43 MockFFmpeg::set(&mock_ffmpeg_); | |
| 44 | |
| 45 // Singleton should initialize FFmpeg. | 42 // Singleton should initialize FFmpeg. |
| 46 CHECK(FFmpegGlue::GetInstance()); | 43 CHECK(FFmpegGlue::GetInstance()); |
| 47 | 44 |
| 48 // Assign our static copy of URLProtocol for the rest of the tests. | 45 // Assign our static copy of URLProtocol for the rest of the tests. |
| 49 protocol_ = MockFFmpeg::protocol(); | 46 protocol_ = MockFFmpeg::protocol(); |
| 50 CHECK(protocol_); | 47 CHECK(protocol_); |
| 51 } | 48 } |
| 52 | 49 |
| 53 virtual void TearDown() { | 50 virtual void TearDown() {} |
|
acolwell GONE FROM CHROMIUM
2011/02/18 00:41:55
Can we remove this?
scherkus (not reviewing)
2011/02/18 20:48:12
Sure can!
| |
| 54 MockFFmpeg::set(NULL); | |
| 55 } | |
| 56 | 51 |
| 57 // Helper to open a URLContext pointing to the given mocked protocol. | 52 // Helper to open a URLContext pointing to the given mocked protocol. |
| 58 // Callers are expected to close the context at the end of their test. | 53 // Callers are expected to close the context at the end of their test. |
| 59 virtual void OpenContext(MockProtocol* protocol, URLContext* context) { | 54 virtual void OpenContext(MockProtocol* protocol, URLContext* context) { |
| 60 // IsStreaming() is called when opening. | 55 // IsStreaming() is called when opening. |
| 61 EXPECT_CALL(*protocol, IsStreaming()).WillOnce(Return(true)); | 56 EXPECT_CALL(*protocol, IsStreaming()).WillOnce(Return(true)); |
| 62 | 57 |
| 63 // Add the protocol to the glue layer and open a context. | 58 // Add the protocol to the glue layer and open a context. |
| 64 std::string key = FFmpegGlue::GetInstance()->AddProtocol(protocol); | 59 std::string key = FFmpegGlue::GetInstance()->AddProtocol(protocol); |
| 65 memset(context, 0, sizeof(*context)); | 60 memset(context, 0, sizeof(*context)); |
| (...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 321 | 316 |
| 322 // Remove our own reference, we shouldn't be destroyed yet. | 317 // Remove our own reference, we shouldn't be destroyed yet. |
| 323 mock_ffmpeg_.CheckPoint(0); | 318 mock_ffmpeg_.CheckPoint(0); |
| 324 protocol.reset(); | 319 protocol.reset(); |
| 325 | 320 |
| 326 // ~FFmpegGlue() will be called when this unit test finishes execution. By | 321 // ~FFmpegGlue() will be called when this unit test finishes execution. By |
| 327 // 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. |
| 328 } | 323 } |
| 329 | 324 |
| 330 } // namespace media | 325 } // namespace media |
| OLD | NEW |