| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 // A new breed of mock media filters, this time using gmock! Feel free to add | 5 // A new breed of mock media filters, this time using gmock! Feel free to add |
| 6 // actions if you need interesting side-effects. | 6 // actions if you need interesting side-effects. |
| 7 // | 7 // |
| 8 // Don't forget you can use StrictMock<> and NiceMock<> if you want the mock | 8 // Don't forget you can use StrictMock<> and NiceMock<> if you want the mock |
| 9 // filters to fail the test or do nothing when an unexpected method is called. | 9 // filters to fail the test or do nothing when an unexpected method is called. |
| 10 // http://code.google.com/p/googlemock/wiki/CookBook#Nice_Mocks_and_Strict_Mocks | 10 // http://code.google.com/p/googlemock/wiki/CookBook#Nice_Mocks_and_Strict_Mocks |
| 11 | 11 |
| 12 #ifndef MEDIA_BASE_MOCK_FILTERS_H_ | 12 #ifndef MEDIA_BASE_MOCK_FILTERS_H_ |
| 13 #define MEDIA_BASE_MOCK_FILTERS_H_ | 13 #define MEDIA_BASE_MOCK_FILTERS_H_ |
| 14 | 14 |
| 15 #include <string> | 15 #include <string> |
| 16 | 16 |
| 17 #include "base/callback.h" | 17 #include "base/callback.h" |
| 18 #include "media/base/audio_decoder.h" | 18 #include "media/base/audio_decoder.h" |
| 19 #include "media/base/audio_decoder_config.h" | 19 #include "media/base/audio_decoder_config.h" |
| 20 #include "media/base/audio_renderer.h" | 20 #include "media/base/audio_renderer.h" |
| 21 #include "media/base/decryptor_client.h" |
| 21 #include "media/base/demuxer.h" | 22 #include "media/base/demuxer.h" |
| 22 #include "media/base/filters.h" | 23 #include "media/base/filters.h" |
| 23 #include "media/base/filter_collection.h" | 24 #include "media/base/filter_collection.h" |
| 24 #include "media/base/pipeline.h" | 25 #include "media/base/pipeline.h" |
| 25 #include "media/base/video_decoder.h" | 26 #include "media/base/video_decoder.h" |
| 26 #include "media/base/video_decoder_config.h" | 27 #include "media/base/video_decoder_config.h" |
| 27 #include "media/base/video_frame.h" | 28 #include "media/base/video_frame.h" |
| 28 #include "media/base/video_renderer.h" | 29 #include "media/base/video_renderer.h" |
| 29 #include "media/crypto/decryptor_client.h" | |
| 30 #include "testing/gmock/include/gmock/gmock.h" | 30 #include "testing/gmock/include/gmock/gmock.h" |
| 31 | 31 |
| 32 namespace media { | 32 namespace media { |
| 33 | 33 |
| 34 // Use this template to test for object destruction by setting expectations on | 34 // Use this template to test for object destruction by setting expectations on |
| 35 // the method OnDestroy(). | 35 // the method OnDestroy(). |
| 36 // | 36 // |
| 37 // TODO(scherkus): not sure about the naming... perhaps contribute this back | 37 // TODO(scherkus): not sure about the naming... perhaps contribute this back |
| 38 // to gmock itself! | 38 // to gmock itself! |
| 39 template<class MockClass> | 39 template<class MockClass> |
| (...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 210 DISALLOW_COPY_AND_ASSIGN(MockAudioRenderer); | 210 DISALLOW_COPY_AND_ASSIGN(MockAudioRenderer); |
| 211 }; | 211 }; |
| 212 | 212 |
| 213 class MockDecryptorClient : public DecryptorClient { | 213 class MockDecryptorClient : public DecryptorClient { |
| 214 public: | 214 public: |
| 215 MockDecryptorClient(); | 215 MockDecryptorClient(); |
| 216 virtual ~MockDecryptorClient(); | 216 virtual ~MockDecryptorClient(); |
| 217 | 217 |
| 218 MOCK_METHOD2(KeyAdded, void(const std::string&, const std::string&)); | 218 MOCK_METHOD2(KeyAdded, void(const std::string&, const std::string&)); |
| 219 MOCK_METHOD4(KeyError, void(const std::string&, const std::string&, | 219 MOCK_METHOD4(KeyError, void(const std::string&, const std::string&, |
| 220 AesDecryptor::KeyError, int)); | 220 Decryptor::KeyError, int)); |
| 221 // TODO(xhwang): This is a workaround of the issue that move-only parameters | 221 // TODO(xhwang): This is a workaround of the issue that move-only parameters |
| 222 // are not supported in mocked methods. Remove this when the issue is fixed | 222 // are not supported in mocked methods. Remove this when the issue is fixed |
| 223 // (http://code.google.com/p/googletest/issues/detail?id=395) or when we use | 223 // (http://code.google.com/p/googletest/issues/detail?id=395) or when we use |
| 224 // std::string instead of scoped_array<uint8> (http://crbug.com/130689). | 224 // std::string instead of scoped_array<uint8> (http://crbug.com/130689). |
| 225 MOCK_METHOD5(KeyMessageMock, void(const std::string& key_system, | 225 MOCK_METHOD5(KeyMessageMock, void(const std::string& key_system, |
| 226 const std::string& session_id, | 226 const std::string& session_id, |
| 227 const uint8* message, | 227 const uint8* message, |
| 228 int message_length, | 228 int message_length, |
| 229 const std::string& default_url)); | 229 const std::string& default_url)); |
| 230 MOCK_METHOD4(NeedKeyMock, void(const std::string& key_system, | 230 MOCK_METHOD4(NeedKeyMock, void(const std::string& key_system, |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 307 public: | 307 public: |
| 308 MockStatisticsCB(); | 308 MockStatisticsCB(); |
| 309 ~MockStatisticsCB(); | 309 ~MockStatisticsCB(); |
| 310 | 310 |
| 311 MOCK_METHOD1(OnStatistics, void(const media::PipelineStatistics& statistics)); | 311 MOCK_METHOD1(OnStatistics, void(const media::PipelineStatistics& statistics)); |
| 312 }; | 312 }; |
| 313 | 313 |
| 314 } // namespace media | 314 } // namespace media |
| 315 | 315 |
| 316 #endif // MEDIA_BASE_MOCK_FILTERS_H_ | 316 #endif // MEDIA_BASE_MOCK_FILTERS_H_ |
| OLD | NEW |