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. |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
74 MOCK_METHOD1(Stop, void(FilterCallback* callback)); | 74 MOCK_METHOD1(Stop, void(FilterCallback* callback)); |
75 MOCK_METHOD1(SetPlaybackRate, void(float playback_rate)); | 75 MOCK_METHOD1(SetPlaybackRate, void(float playback_rate)); |
76 MOCK_METHOD2(Seek, void(base::TimeDelta time, FilterCallback* callback)); | 76 MOCK_METHOD2(Seek, void(base::TimeDelta time, FilterCallback* callback)); |
77 MOCK_METHOD0(OnAudioRendererDisabled, void()); | 77 MOCK_METHOD0(OnAudioRendererDisabled, void()); |
78 | 78 |
79 // DataSource implementation. | 79 // DataSource implementation. |
80 MOCK_METHOD0(media_format, const MediaFormat&()); | 80 MOCK_METHOD0(media_format, const MediaFormat&()); |
81 MOCK_METHOD4(Read, void(int64 position, size_t size, uint8* data, | 81 MOCK_METHOD4(Read, void(int64 position, size_t size, uint8* data, |
82 DataSource::ReadCallback* callback)); | 82 DataSource::ReadCallback* callback)); |
83 MOCK_METHOD1(GetSize, bool(int64* size_out)); | 83 MOCK_METHOD1(GetSize, bool(int64* size_out)); |
| 84 MOCK_METHOD1(SetPreload, void(Preload preload)); |
84 MOCK_METHOD0(IsStreaming, bool()); | 85 MOCK_METHOD0(IsStreaming, bool()); |
85 | 86 |
86 // Sets the TotalBytes & BufferedBytes values to be sent to host() when | 87 // Sets the TotalBytes & BufferedBytes values to be sent to host() when |
87 // the set_host() is called. | 88 // the set_host() is called. |
88 void SetTotalAndBufferedBytes(int64 total_bytes, int64 buffered_bytes); | 89 void SetTotalAndBufferedBytes(int64 total_bytes, int64 buffered_bytes); |
89 | 90 |
90 protected: | 91 protected: |
91 virtual ~MockDataSource(); | 92 virtual ~MockDataSource(); |
92 | 93 |
93 private: | 94 private: |
94 int64 total_bytes_; | 95 int64 total_bytes_; |
95 int64 buffered_bytes_; | 96 int64 buffered_bytes_; |
96 | 97 |
97 DISALLOW_COPY_AND_ASSIGN(MockDataSource); | 98 DISALLOW_COPY_AND_ASSIGN(MockDataSource); |
98 }; | 99 }; |
99 | 100 |
100 class MockDemuxer : public Demuxer { | 101 class MockDemuxer : public Demuxer { |
101 public: | 102 public: |
102 MockDemuxer(); | 103 MockDemuxer(); |
103 // Filter implementation. | 104 // Filter implementation. |
104 virtual void set_host(FilterHost* host); | 105 virtual void set_host(FilterHost* host); |
105 MOCK_METHOD1(Stop, void(FilterCallback* callback)); | 106 MOCK_METHOD1(Stop, void(FilterCallback* callback)); |
106 MOCK_METHOD1(SetPlaybackRate, void(float playback_rate)); | 107 MOCK_METHOD1(SetPlaybackRate, void(float playback_rate)); |
| 108 MOCK_METHOD1(SetPreload, void(Preload preload)); |
107 MOCK_METHOD2(Seek, void(base::TimeDelta time, FilterCallback* callback)); | 109 MOCK_METHOD2(Seek, void(base::TimeDelta time, FilterCallback* callback)); |
108 MOCK_METHOD0(OnAudioRendererDisabled, void()); | 110 MOCK_METHOD0(OnAudioRendererDisabled, void()); |
109 | 111 |
110 // Demuxer implementation. | 112 // Demuxer implementation. |
111 MOCK_METHOD2(Initialize, void(DataSource* data_source, | 113 MOCK_METHOD2(Initialize, void(DataSource* data_source, |
112 FilterCallback* callback)); | 114 FilterCallback* callback)); |
113 MOCK_METHOD1(GetStream, scoped_refptr<DemuxerStream>(DemuxerStream::Type)); | 115 MOCK_METHOD1(GetStream, scoped_refptr<DemuxerStream>(DemuxerStream::Type)); |
114 | 116 |
115 // Sets the TotalBytes, BufferedBytes, & Duration values to be sent to host() | 117 // Sets the TotalBytes, BufferedBytes, & Duration values to be sent to host() |
116 // when set_host() is called. | 118 // when set_host() is called. |
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
348 public: | 350 public: |
349 MockStatisticsCallback(); | 351 MockStatisticsCallback(); |
350 ~MockStatisticsCallback(); | 352 ~MockStatisticsCallback(); |
351 | 353 |
352 MOCK_METHOD1(OnStatistics, void(const media::PipelineStatistics& statistics)); | 354 MOCK_METHOD1(OnStatistics, void(const media::PipelineStatistics& statistics)); |
353 }; | 355 }; |
354 | 356 |
355 } // namespace media | 357 } // namespace media |
356 | 358 |
357 #endif // MEDIA_BASE_MOCK_FILTERS_H_ | 359 #endif // MEDIA_BASE_MOCK_FILTERS_H_ |
OLD | NEW |