OLD | NEW |
| (Empty) |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef REMOTING_HOST_MOCK_CALLBACK_H_ | |
6 #define REMOTING_HOST_MOCK_CALLBACK_H_ | |
7 | |
8 // TODO(lukasza): If possible, move this header file to base/mock_callback.h | |
9 | |
10 #include "base/bind.h" | |
11 #include "base/bind_helpers.h" | |
12 #include "base/callback.h" | |
13 | |
14 #include "testing/gmock/include/gmock/gmock.h" | |
15 | |
16 namespace remoting { | |
17 | |
18 template <typename Sig> | |
19 class MockCallback; | |
20 | |
21 template <typename R> | |
22 class MockCallback<R()> { | |
23 public: | |
24 MOCK_CONST_METHOD0_T(Run, R()); | |
25 | |
26 MockCallback() { | |
27 } | |
28 | |
29 // Caller of GetCallback has to guarantee that the returned callback | |
30 // will not be run after |this| is destroyed. | |
31 base::Callback<R()> GetCallback() { | |
32 return base::Bind(&MockCallback<R()>::Run, base::Unretained(this)); | |
33 } | |
34 | |
35 private: | |
36 DISALLOW_COPY_AND_ASSIGN(MockCallback); | |
37 }; | |
38 | |
39 typedef MockCallback<void(void)> MockClosure; | |
40 | |
41 } // namespace remoting | |
42 | |
43 #endif // REMOTING_HOST_MOCK_CALLBACK_H_ | |
OLD | NEW |