Chromium Code Reviews| Index: base/test/mock_callback.cc |
| diff --git a/media/base/mock_callback.h b/base/test/mock_callback.cc |
| similarity index 40% |
| copy from media/base/mock_callback.h |
| copy to base/test/mock_callback.cc |
| index 00d8276067cb441763d23544f8eff69ba0d43159..b2520733c86edc296332e8f7a8d0a1ba58357302 100644 |
| --- a/media/base/mock_callback.h |
| +++ b/base/test/mock_callback.cc |
| @@ -2,35 +2,36 @@ |
| // Use of this source code is governed by a BSD-style license that can be |
| // found in the LICENSE file. |
| -#ifndef MEDIA_BASE_MOCK_CALLBACK_H_ |
| -#define MEDIA_BASE_MOCK_CALLBACK_H_ |
| +#include "base/test/mock_callback.h" |
| +#include "base/bind.h" |
| #include "base/callback.h" |
| -#include "media/base/pipeline_status.h" |
| +#include "base/memory/ref_counted.h" |
| #include "testing/gmock/include/gmock/gmock.h" |
| -namespace media { |
| +namespace { |
| -// Utility mock for testing methods expecting Closures. See |
| -// NewExpectedClosure() below for a helper suitable when expectation order is |
| -// not checked (or when the expectation can be set at mock construction time). |
| class MockClosure : public base::RefCountedThreadSafe<MockClosure> { |
| public: |
| - MockClosure(); |
| - MOCK_METHOD0(Run, void()); |
| + MockClosure() {} |
| + MOCK_METHOD0(OnRun, void()); |
| - protected: |
| + private: |
| friend class base::RefCountedThreadSafe<MockClosure>; |
| - virtual ~MockClosure(); |
| + virtual ~MockClosure() {} |
| - private: |
| DISALLOW_COPY_AND_ASSIGN(MockClosure); |
|
mmenke
2012/10/26 19:06:20
You should include basictypes.h for this.
engedy
2012/10/29 14:37:56
Done.
|
| }; |
| -// Return a callback that expects to be run once. |
| -base::Closure NewExpectedClosure(); |
| -base::Callback<void(PipelineStatus)> NewExpectedStatusCB(PipelineStatus status); |
| +} // namespace |
| + |
| +namespace base { |
| + |
| +base::Closure NewExpectedClosure() { |
| + MockClosure* mock_closure = new MockClosure(); |
| + EXPECT_CALL(*mock_closure, OnRun()); |
| + return base::Bind(&MockClosure::OnRun, mock_closure); |
| +} |
| -} // namespace media |
| +} // namespace base |
| -#endif // MEDIA_BASE_MOCK_CALLBACK_H_ |