OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. Use of this | 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. Use of this |
2 // source code is governed by a BSD-style license that can be found in the | 2 // source code is governed by a BSD-style license that can be found in the |
3 // LICENSE file. | 3 // LICENSE file. |
4 | 4 // |
5 // The corresponding FilterHost implementation for MockPipeline. Maintains a | 5 // A FilterHost implementation based on gmock. Combined with setting a message |
6 // reference to the parent MockPipeline and a reference to the Filter its | 6 // loop on a filter, permits single-threaded testing of filters without |
7 // hosting. Common usage is to check if the hosted filter has initialized by | 7 // requiring a pipeline. |
8 // calling IsInitialized(). | 8 // |
| 9 // TODO(scherkus): Remove old_mocks::MockFilterHost as soon as other tests have |
| 10 // transitioned over to the new gmock-based MockFilterHost. |
9 | 11 |
10 #ifndef MEDIA_BASE_MOCK_FILTER_HOST_H_ | 12 #ifndef MEDIA_BASE_MOCK_FILTER_HOST_H_ |
11 #define MEDIA_BASE_MOCK_FILTER_HOST_H_ | 13 #define MEDIA_BASE_MOCK_FILTER_HOST_H_ |
12 | 14 |
13 #include <string> | 15 #include <string> |
14 | 16 |
15 #include "base/scoped_ptr.h" | 17 #include "base/scoped_ptr.h" |
16 #include "base/waitable_event.h" | 18 #include "base/waitable_event.h" |
17 #include "media/base/factory.h" | 19 #include "media/base/factory.h" |
18 #include "media/base/filter_host.h" | 20 #include "media/base/filter_host.h" |
19 #include "media/base/filters.h" | 21 #include "media/base/filters.h" |
20 #include "media/base/media_format.h" | 22 #include "media/base/media_format.h" |
21 #include "media/base/mock_pipeline.h" | 23 #include "media/base/mock_pipeline.h" |
| 24 #include "testing/gmock/include/gmock/gmock.h" |
22 #include "testing/gtest/include/gtest/gtest.h" | 25 #include "testing/gtest/include/gtest/gtest.h" |
23 | 26 |
24 namespace media { | 27 namespace media { |
25 | 28 |
| 29 class MockFilterHost : public FilterHost { |
| 30 public: |
| 31 MockFilterHost() {} |
| 32 |
| 33 // FilterHost implementation. |
| 34 MOCK_METHOD0(InitializationComplete, void()); |
| 35 MOCK_METHOD1(Error, void(PipelineError error)); |
| 36 MOCK_CONST_METHOD0(GetTime, base::TimeDelta()); |
| 37 MOCK_METHOD1(SetTime, void(base::TimeDelta time)); |
| 38 MOCK_METHOD1(SetDuration, void(base::TimeDelta duration)); |
| 39 MOCK_METHOD1(SetBufferedTime, void(base::TimeDelta buffered_time)); |
| 40 MOCK_METHOD1(SetTotalBytes, void(int64 total_bytes)); |
| 41 MOCK_METHOD1(SetBufferedBytes, void(int64 buffered_bytes)); |
| 42 MOCK_METHOD2(SetVideoSize, void(size_t width, size_t height)); |
| 43 |
| 44 private: |
| 45 DISALLOW_COPY_AND_ASSIGN(MockFilterHost); |
| 46 }; |
| 47 |
| 48 namespace old_mocks { |
| 49 |
| 50 // This version is deprecated. |
26 template <class Filter> | 51 template <class Filter> |
27 class MockFilterHost : public FilterHost { | 52 class MockFilterHost : public FilterHost { |
28 public: | 53 public: |
29 MockFilterHost(MockPipeline* mock_pipeline, Filter* filter) | 54 MockFilterHost(MockPipeline* mock_pipeline, Filter* filter) |
30 : mock_pipeline_(mock_pipeline), | 55 : mock_pipeline_(mock_pipeline), |
31 filter_(filter), | 56 filter_(filter), |
32 initialized_(false), | 57 initialized_(false), |
33 error_(PIPELINE_OK), | 58 error_(PIPELINE_OK), |
34 wait_for_initialized_(false, false), | 59 wait_for_initialized_(false, false), |
35 wait_for_error_(false, false) { | 60 wait_for_error_(false, false) { |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
114 // Tracks the last pipeline error set by the filter. | 139 // Tracks the last pipeline error set by the filter. |
115 PipelineError error_; | 140 PipelineError error_; |
116 | 141 |
117 // Allows unit tests to wait for particular conditions before asserting. | 142 // Allows unit tests to wait for particular conditions before asserting. |
118 base::WaitableEvent wait_for_initialized_; | 143 base::WaitableEvent wait_for_initialized_; |
119 base::WaitableEvent wait_for_error_; | 144 base::WaitableEvent wait_for_error_; |
120 | 145 |
121 DISALLOW_COPY_AND_ASSIGN(MockFilterHost); | 146 DISALLOW_COPY_AND_ASSIGN(MockFilterHost); |
122 }; | 147 }; |
123 | 148 |
| 149 } // namespace old_mocks |
| 150 |
124 } // namespace media | 151 } // namespace media |
125 | 152 |
126 #endif // MEDIA_BASE_MOCK_FILTER_HOST_H_ | 153 #endif // MEDIA_BASE_MOCK_FILTER_HOST_H_ |
OLD | NEW |