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 #ifndef MEDIA_BASE_GMOCK_CALLBACK_SUPPORT_H_ | 5 #ifndef MEDIA_BASE_GMOCK_CALLBACK_SUPPORT_H_ |
6 #define MEDIA_BASE_GMOCK_CALLBACK_SUPPORT_H_ | 6 #define MEDIA_BASE_GMOCK_CALLBACK_SUPPORT_H_ |
7 | 7 |
8 #include "testing/gmock/include/gmock/gmock.h" | 8 #include "testing/gmock/include/gmock/gmock.h" |
9 | 9 |
10 namespace media { | 10 namespace media { |
(...skipping 10 matching lines...) Expand all Loading... |
21 | 21 |
22 // The RunClosure<N>() action invokes Run() method on the N-th (0-based) | 22 // The RunClosure<N>() action invokes Run() method on the N-th (0-based) |
23 // argument of the mock function. | 23 // argument of the mock function. |
24 | 24 |
25 ACTION_TEMPLATE(RunClosure, | 25 ACTION_TEMPLATE(RunClosure, |
26 HAS_1_TEMPLATE_PARAMS(int, k), | 26 HAS_1_TEMPLATE_PARAMS(int, k), |
27 AND_0_VALUE_PARAMS()) { | 27 AND_0_VALUE_PARAMS()) { |
28 ::std::tr1::get<k>(args).Run(); | 28 ::std::tr1::get<k>(args).Run(); |
29 } | 29 } |
30 | 30 |
| 31 ACTION_P(RunClosure, closure) { |
| 32 closure.Run(); |
| 33 } |
| 34 |
31 // Various overloads for RunCallback<N>(). | 35 // Various overloads for RunCallback<N>(). |
32 // | 36 // |
33 // The RunCallback<N>(p1, p2, ..., p_k) action invokes Run() method on the N-th | 37 // The RunCallback<N>(p1, p2, ..., p_k) action invokes Run() method on the N-th |
34 // (0-based) argument of the mock function, with arguments p1, p2, ..., p_k. | 38 // (0-based) argument of the mock function, with arguments p1, p2, ..., p_k. |
35 // | 39 // |
36 // Notes: | 40 // Notes: |
37 // | 41 // |
38 // 1. The arguments are passed by value by default. If you need to | 42 // 1. The arguments are passed by value by default. If you need to |
39 // pass an argument by reference, wrap it inside ByRef(). For example, | 43 // pass an argument by reference, wrap it inside ByRef(). For example, |
40 // | 44 // |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
98 | 102 |
99 ACTION_TEMPLATE(RunCallback, | 103 ACTION_TEMPLATE(RunCallback, |
100 HAS_1_TEMPLATE_PARAMS(int, k), | 104 HAS_1_TEMPLATE_PARAMS(int, k), |
101 AND_7_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6)) { | 105 AND_7_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6)) { |
102 return ::std::tr1::get<k>(args).Run(p0, p1, p2, p3, p4, p5, p6); | 106 return ::std::tr1::get<k>(args).Run(p0, p1, p2, p3, p4, p5, p6); |
103 } | 107 } |
104 | 108 |
105 } // namespace media | 109 } // namespace media |
106 | 110 |
107 #endif // MEDIA_BASE_GMOCK_CALLBACK_SUPPORT_H_ | 111 #endif // MEDIA_BASE_GMOCK_CALLBACK_SUPPORT_H_ |
OLD | NEW |