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 (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 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
77 | 77 |
78 MOCK_METHOD1(Stop, void(const base::Closure& callback)); | 78 MOCK_METHOD1(Stop, void(const base::Closure& callback)); |
79 MOCK_METHOD1(SetPlaybackRate, void(float playback_rate)); | 79 MOCK_METHOD1(SetPlaybackRate, void(float playback_rate)); |
80 MOCK_METHOD2(Seek, void(base::TimeDelta time, const PipelineStatusCB& cb)); | 80 MOCK_METHOD2(Seek, void(base::TimeDelta time, const PipelineStatusCB& cb)); |
81 MOCK_METHOD0(OnAudioRendererDisabled, void()); | 81 MOCK_METHOD0(OnAudioRendererDisabled, void()); |
82 | 82 |
83 // DataSource implementation. | 83 // DataSource implementation. |
84 MOCK_METHOD4(Read, void(int64 position, size_t size, uint8* data, | 84 MOCK_METHOD4(Read, void(int64 position, size_t size, uint8* data, |
85 const DataSource::ReadCB& callback)); | 85 const DataSource::ReadCB& callback)); |
86 MOCK_METHOD1(GetSize, bool(int64* size_out)); | 86 MOCK_METHOD1(GetSize, bool(int64* size_out)); |
87 MOCK_METHOD1(SetPreload, void(Preload preload)); | |
88 MOCK_METHOD1(SetBitrate, void(int bitrate)); | 87 MOCK_METHOD1(SetBitrate, void(int bitrate)); |
89 MOCK_METHOD0(IsStreaming, bool()); | 88 MOCK_METHOD0(IsStreaming, bool()); |
90 | 89 |
91 // Sets the TotalBytes & BufferedBytes values to be sent to host() when | 90 // Sets the TotalBytes & BufferedBytes values to be sent to host() when |
92 // the set_host() is called. | 91 // the set_host() is called. |
93 void SetTotalAndBufferedBytes(int64 total_bytes, int64 buffered_bytes); | 92 void SetTotalAndBufferedBytes(int64 total_bytes, int64 buffered_bytes); |
94 | 93 |
95 protected: | 94 protected: |
96 virtual ~MockDataSource(); | 95 virtual ~MockDataSource(); |
97 | 96 |
98 private: | 97 private: |
99 int64 total_bytes_; | 98 int64 total_bytes_; |
100 int64 buffered_bytes_; | 99 int64 buffered_bytes_; |
101 | 100 |
102 DISALLOW_COPY_AND_ASSIGN(MockDataSource); | 101 DISALLOW_COPY_AND_ASSIGN(MockDataSource); |
103 }; | 102 }; |
104 | 103 |
105 class MockDemuxer : public Demuxer { | 104 class MockDemuxer : public Demuxer { |
106 public: | 105 public: |
107 MockDemuxer(); | 106 MockDemuxer(); |
108 | 107 |
109 virtual void set_host(DemuxerHost* demuxer_host); | 108 virtual void set_host(DemuxerHost* demuxer_host); |
110 MOCK_METHOD1(Stop, void(const base::Closure& callback)); | 109 MOCK_METHOD1(Stop, void(const base::Closure& callback)); |
111 MOCK_METHOD1(SetPlaybackRate, void(float playback_rate)); | 110 MOCK_METHOD1(SetPlaybackRate, void(float playback_rate)); |
112 MOCK_METHOD1(SetPreload, void(Preload preload)); | |
113 MOCK_METHOD2(Seek, void(base::TimeDelta time, const PipelineStatusCB& cb)); | 111 MOCK_METHOD2(Seek, void(base::TimeDelta time, const PipelineStatusCB& cb)); |
114 MOCK_METHOD0(OnAudioRendererDisabled, void()); | 112 MOCK_METHOD0(OnAudioRendererDisabled, void()); |
115 MOCK_METHOD0(GetBitrate, int()); | 113 MOCK_METHOD0(GetBitrate, int()); |
116 MOCK_METHOD0(IsLocalSource, bool()); | 114 MOCK_METHOD0(IsLocalSource, bool()); |
117 MOCK_METHOD0(IsSeekable, bool()); | 115 MOCK_METHOD0(IsSeekable, bool()); |
118 | 116 |
119 // Demuxer implementation. | 117 // Demuxer implementation. |
120 MOCK_METHOD2(Initialize, void(DataSource* data_source, | 118 MOCK_METHOD2(Initialize, void(DataSource* data_source, |
121 const base::Closure& callback)); | 119 const base::Closure& callback)); |
122 MOCK_METHOD1(GetStream, scoped_refptr<DemuxerStream>(DemuxerStream::Type)); | 120 MOCK_METHOD1(GetStream, scoped_refptr<DemuxerStream>(DemuxerStream::Type)); |
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
345 public: | 343 public: |
346 MockStatisticsCB(); | 344 MockStatisticsCB(); |
347 ~MockStatisticsCB(); | 345 ~MockStatisticsCB(); |
348 | 346 |
349 MOCK_METHOD1(OnStatistics, void(const media::PipelineStatistics& statistics)); | 347 MOCK_METHOD1(OnStatistics, void(const media::PipelineStatistics& statistics)); |
350 }; | 348 }; |
351 | 349 |
352 } // namespace media | 350 } // namespace media |
353 | 351 |
354 #endif // MEDIA_BASE_MOCK_FILTERS_H_ | 352 #endif // MEDIA_BASE_MOCK_FILTERS_H_ |
OLD | NEW |