| Index: remoting/host/mock_callback.h
|
| diff --git a/remoting/host/mock_callback.h b/remoting/host/mock_callback.h
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..431c4e278f03c96557e09577cf9a97a194403800
|
| --- /dev/null
|
| +++ b/remoting/host/mock_callback.h
|
| @@ -0,0 +1,43 @@
|
| +// Copyright 2014 The Chromium Authors. All rights reserved.
|
| +// Use of this source code is governed by a BSD-style license that can be
|
| +// found in the LICENSE file.
|
| +
|
| +#ifndef REMOTING_HOST_MOCK_CALLBACK_H_
|
| +#define REMOTING_HOST_MOCK_CALLBACK_H_
|
| +
|
| +// TODO(lukasza): If possible, move this header file to base/mock_callback.h
|
| +
|
| +#include "base/bind.h"
|
| +#include "base/callback_forward.h"
|
| +#include "base/memory/weak_ptr.h"
|
| +
|
| +#include "testing/gmock/include/gmock/gmock.h"
|
| +
|
| +namespace remoting {
|
| +
|
| +template <typename Sig>
|
| +class MockCallback;
|
| +
|
| +template <typename R>
|
| +class MockCallback<R()> {
|
| + public:
|
| + MOCK_CONST_METHOD0_T(Run, R());
|
| +
|
| + MockCallback() : weak_factory_(this) {
|
| + }
|
| +
|
| + base::Callback<R()> GetCallback() {
|
| + return base::Bind(&MockCallback<R()>::Run, weak_factory_.GetWeakPtr());
|
| + }
|
| +
|
| + private:
|
| + base::WeakPtrFactory<MockCallback<R()>> weak_factory_;
|
| +
|
| + DISALLOW_COPY_AND_ASSIGN(MockCallback);
|
| +};
|
| +
|
| +typedef MockCallback<void(void)> MockClosure;
|
| +
|
| +} // namespace remoting
|
| +
|
| +#endif // REMOTING_HOST_MOCK_CALLBACK_H_
|
|
|