| OLD | NEW |
| 1 // Copyright (c) 2011 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 // 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 (i.e., copying data to the | 6 // actions if you need interesting side-effects (i.e., copying data to the |
| 7 // buffer passed into MockDataSource::Read()). | 7 // buffer passed into MockDataSource::Read()). |
| 8 // | 8 // |
| 9 // Don't forget you can use StrictMock<> and NiceMock<> if you want the mock | 9 // Don't forget you can use StrictMock<> and NiceMock<> if you want the mock |
| 10 // filters to fail the test or do nothing when an unexpected method is called. | 10 // filters to fail the test or do nothing when an unexpected method is called. |
| 11 // http://code.google.com/p/googlemock/wiki/CookBook#Nice_Mocks_and_Strict_Mocks | 11 // http://code.google.com/p/googlemock/wiki/CookBook#Nice_Mocks_and_Strict_Mocks |
| 12 | 12 |
| 13 #ifndef MEDIA_BASE_MOCK_FILTERS_H_ | 13 #ifndef MEDIA_BASE_MOCK_FILTERS_H_ |
| 14 #define MEDIA_BASE_MOCK_FILTERS_H_ | 14 #define MEDIA_BASE_MOCK_FILTERS_H_ |
| 15 | 15 |
| 16 #include <string> | 16 #include <string> |
| 17 | 17 |
| 18 #include "base/callback.h" | 18 #include "base/callback.h" |
| 19 #include "media/base/audio_decoder_config.h" | 19 #include "media/base/audio_decoder_config.h" |
| 20 #include "media/base/demuxer.h" | 20 #include "media/base/demuxer.h" |
| 21 #include "media/base/filters.h" | 21 #include "media/base/filters.h" |
| 22 #include "media/base/filter_collection.h" | 22 #include "media/base/filter_collection.h" |
| 23 #include "media/base/pipeline.h" | 23 #include "media/base/pipeline.h" |
| 24 #include "media/base/video_decoder_config.h" |
| 24 #include "media/base/video_frame.h" | 25 #include "media/base/video_frame.h" |
| 25 #include "testing/gmock/include/gmock/gmock.h" | 26 #include "testing/gmock/include/gmock/gmock.h" |
| 26 | 27 |
| 27 namespace media { | 28 namespace media { |
| 28 | 29 |
| 29 // Use this template to test for object destruction by setting expectations on | 30 // Use this template to test for object destruction by setting expectations on |
| 30 // the method OnDestroy(). | 31 // the method OnDestroy(). |
| 31 // | 32 // |
| 32 // TODO(scherkus): not sure about the naming... perhaps contribute this back | 33 // TODO(scherkus): not sure about the naming... perhaps contribute this back |
| 33 // to gmock itself! | 34 // to gmock itself! |
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 154 DISALLOW_COPY_AND_ASSIGN(MockDemuxerFactory); | 155 DISALLOW_COPY_AND_ASSIGN(MockDemuxerFactory); |
| 155 }; | 156 }; |
| 156 | 157 |
| 157 class MockDemuxerStream : public DemuxerStream { | 158 class MockDemuxerStream : public DemuxerStream { |
| 158 public: | 159 public: |
| 159 MockDemuxerStream(); | 160 MockDemuxerStream(); |
| 160 | 161 |
| 161 // DemuxerStream implementation. | 162 // DemuxerStream implementation. |
| 162 MOCK_METHOD0(type, Type()); | 163 MOCK_METHOD0(type, Type()); |
| 163 MOCK_METHOD1(Read, void(const ReadCallback& read_callback)); | 164 MOCK_METHOD1(Read, void(const ReadCallback& read_callback)); |
| 164 MOCK_METHOD0(GetAVStream, AVStream*()); | |
| 165 MOCK_METHOD0(audio_decoder_config, const AudioDecoderConfig&()); | 165 MOCK_METHOD0(audio_decoder_config, const AudioDecoderConfig&()); |
| 166 MOCK_METHOD0(video_decoder_config, const VideoDecoderConfig&()); |
| 166 MOCK_METHOD0(EnableBitstreamConverter, void()); | 167 MOCK_METHOD0(EnableBitstreamConverter, void()); |
| 167 | 168 |
| 168 protected: | 169 protected: |
| 169 virtual ~MockDemuxerStream(); | 170 virtual ~MockDemuxerStream(); |
| 170 | 171 |
| 171 private: | 172 private: |
| 172 DISALLOW_COPY_AND_ASSIGN(MockDemuxerStream); | 173 DISALLOW_COPY_AND_ASSIGN(MockDemuxerStream); |
| 173 }; | 174 }; |
| 174 | 175 |
| 175 class MockVideoDecoder : public VideoDecoder { | 176 class MockVideoDecoder : public VideoDecoder { |
| (...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 351 public: | 352 public: |
| 352 MockStatisticsCallback(); | 353 MockStatisticsCallback(); |
| 353 ~MockStatisticsCallback(); | 354 ~MockStatisticsCallback(); |
| 354 | 355 |
| 355 MOCK_METHOD1(OnStatistics, void(const media::PipelineStatistics& statistics)); | 356 MOCK_METHOD1(OnStatistics, void(const media::PipelineStatistics& statistics)); |
| 356 }; | 357 }; |
| 357 | 358 |
| 358 } // namespace media | 359 } // namespace media |
| 359 | 360 |
| 360 #endif // MEDIA_BASE_MOCK_FILTERS_H_ | 361 #endif // MEDIA_BASE_MOCK_FILTERS_H_ |
| OLD | NEW |