OLD | NEW |
| (Empty) |
1 // Copyright (c) 2006-2009 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 #ifndef CHROME_FRAME_TEST_HELPER_GMOCK_H_ | |
5 #define CHROME_FRAME_TEST_HELPER_GMOCK_H_ | |
6 // The intention of this file is to make possible using GMock actions in | |
7 // all of its syntactic beauty. Classes and helper functions could be used as | |
8 // more generic variants of Task and Callback classes (see base/task.h) | |
9 // Mutant supports both pre-bound arguments (like Task) and call-time arguments | |
10 // (like Callback) - hence the name. :-) | |
11 // DispatchToMethod supporting two sets of arguments - | |
12 // pre-bound (P) and call-time (C) as well as return value type is templatized | |
13 // It will also try to call the selected method even if provided pre-bound args | |
14 // does not match exactly with the function signature - hence the X1, X2 | |
15 // parameters in CreateFunctor. | |
16 | |
17 #include "base/linked_ptr.h" | |
18 #include "base/task.h" // for CallBackStorage | |
19 #include "base/tuple.h" // for Tuple | |
20 | |
21 | |
22 // 0 - 0 | |
23 template <typename R, typename T, typename Method> | |
24 inline R DispatchToMethod(T* obj, Method method, | |
25 const Tuple0& p, | |
26 const Tuple0& c) { | |
27 return (obj->*method)(); | |
28 } | |
29 | |
30 // 0 - 1 | |
31 template <typename R, typename T, typename Method, typename C1> | |
32 inline R DispatchToMethod(T* obj, Method method, | |
33 const Tuple0& p, | |
34 const Tuple1<C1>& c) { | |
35 return (obj->*method)(c.a); | |
36 } | |
37 | |
38 // 0 - 2 | |
39 template <typename R, typename T, typename Method, typename C1, typename C2> | |
40 inline R DispatchToMethod(T* obj, Method method, | |
41 const Tuple0& p, | |
42 const Tuple2<C1, C2>& c) { | |
43 return (obj->*method)(c.a, c.b); | |
44 } | |
45 | |
46 // 0 - 3 | |
47 template <typename R, typename T, typename Method, typename C1, typename C2, | |
48 typename C3> | |
49 inline R DispatchToMethod(T* obj, Method method, | |
50 const Tuple0& p, | |
51 const Tuple3<C1, C2, C3>& c) { | |
52 return (obj->*method)(c.a, c.b, c.c); | |
53 } | |
54 | |
55 // 0 - 4 | |
56 template <typename R, typename T, typename Method, typename C1, typename C2, | |
57 typename C3, typename C4> | |
58 inline R DispatchToMethod(T* obj, Method method, | |
59 const Tuple0& p, | |
60 const Tuple4<C1, C2, C3, C4>& c) { | |
61 return (obj->*method)(c.a, c.b, c.c, c.d); | |
62 } | |
63 | |
64 // 1 - 0 | |
65 template <typename R, typename T, typename Method, typename P1> | |
66 inline R DispatchToMethod(T* obj, Method method, | |
67 const Tuple1<P1>& p, | |
68 const Tuple0& c) { | |
69 return (obj->*method)(p.a); | |
70 } | |
71 | |
72 // 1 - 1 | |
73 template <typename R, typename T, typename Method, typename P1, typename C1> | |
74 inline R DispatchToMethod(T* obj, Method method, | |
75 const Tuple1<P1>& p, | |
76 const Tuple1<C1>& c) { | |
77 return (obj->*method)(p.a, c.a); | |
78 } | |
79 | |
80 // 1 - 2 | |
81 template <typename R, typename T, typename Method, typename P1, typename C1, | |
82 typename C2> | |
83 inline R DispatchToMethod(T* obj, Method method, | |
84 const Tuple1<P1>& p, | |
85 const Tuple2<C1, C2>& c) { | |
86 return (obj->*method)(p.a, c.a, c.b); | |
87 } | |
88 | |
89 // 1 - 3 | |
90 template <typename R, typename T, typename Method, typename P1, typename C1, | |
91 typename C2, typename C3> | |
92 inline R DispatchToMethod(T* obj, Method method, | |
93 const Tuple1<P1>& p, | |
94 const Tuple3<C1, C2, C3>& c) { | |
95 return (obj->*method)(p.a, c.a, c.b, c.c); | |
96 } | |
97 | |
98 // 1 - 4 | |
99 template <typename R, typename T, typename Method, typename P1, typename C1, | |
100 typename C2, typename C3, typename C4> | |
101 inline R DispatchToMethod(T* obj, Method method, | |
102 const Tuple1<P1>& p, | |
103 const Tuple4<C1, C2, C3, C4>& c) { | |
104 return (obj->*method)(p.a, c.a, c.b, c.c, c.d); | |
105 } | |
106 | |
107 // 2 - 0 | |
108 template <typename R, typename T, typename Method, typename P1, typename P2> | |
109 inline R DispatchToMethod(T* obj, Method method, | |
110 const Tuple2<P1, P2>& p, | |
111 const Tuple0& c) { | |
112 return (obj->*method)(p.a, p.b); | |
113 } | |
114 | |
115 // 2 - 1 | |
116 template <typename R, typename T, typename Method, typename P1, typename P2, | |
117 typename C1> | |
118 inline R DispatchToMethod(T* obj, Method method, | |
119 const Tuple2<P1, P2>& p, | |
120 const Tuple1<C1>& c) { | |
121 return (obj->*method)(p.a, p.b, c.a); | |
122 } | |
123 | |
124 // 2 - 2 | |
125 template <typename R, typename T, typename Method, typename P1, typename P2, | |
126 typename C1, typename C2> | |
127 inline R DispatchToMethod(T* obj, Method method, | |
128 const Tuple2<P1, P2>& p, | |
129 const Tuple2<C1, C2>& c) { | |
130 return (obj->*method)(p.a, p.b, c.a, c.b); | |
131 } | |
132 | |
133 // 2 - 3 | |
134 template <typename R, typename T, typename Method, typename P1, typename P2, | |
135 typename C1, typename C2, typename C3> | |
136 inline R DispatchToMethod(T* obj, Method method, | |
137 const Tuple2<P1, P2>& p, | |
138 const Tuple3<C1, C2, C3>& c) { | |
139 return (obj->*method)(p.a, p.b, c.a, c.b, c.c); | |
140 } | |
141 | |
142 // 2 - 4 | |
143 template <typename R, typename T, typename Method, typename P1, typename P2, | |
144 typename C1, typename C2, typename C3, typename C4> | |
145 inline R DispatchToMethod(T* obj, Method method, | |
146 const Tuple2<P1, P2>& p, | |
147 const Tuple4<C1, C2, C3, C4>& c) { | |
148 return (obj->*method)(p.a, p.b, c.a, c.b, c.c, c.d); | |
149 } | |
150 | |
151 // 3 - 0 | |
152 template <typename R, typename T, typename Method, typename P1, typename P2, | |
153 typename P3> | |
154 inline R DispatchToMethod(T* obj, Method method, | |
155 const Tuple3<P1, P2, P3>& p, | |
156 const Tuple0& c) { | |
157 return (obj->*method)(p.a, p.b, p.c); | |
158 } | |
159 | |
160 // 3 - 1 | |
161 template <typename R, typename T, typename Method, typename P1, typename P2, | |
162 typename P3, typename C1> | |
163 inline R DispatchToMethod(T* obj, Method method, | |
164 const Tuple3<P1, P2, P3>& p, | |
165 const Tuple1<C1>& c) { | |
166 return (obj->*method)(p.a, p.b, p.c, c.a); | |
167 } | |
168 | |
169 // 3 - 2 | |
170 template <typename R, typename T, typename Method, typename P1, typename P2, | |
171 typename P3, typename C1, typename C2> | |
172 inline R DispatchToMethod(T* obj, Method method, | |
173 const Tuple3<P1, P2, P3>& p, | |
174 const Tuple2<C1, C2>& c) { | |
175 return (obj->*method)(p.a, p.b, p.c, c.a, c.b); | |
176 } | |
177 | |
178 // 3 - 3 | |
179 template <typename R, typename T, typename Method, typename P1, typename P2, | |
180 typename P3, typename C1, typename C2, typename C3> | |
181 inline R DispatchToMethod(T* obj, Method method, | |
182 const Tuple3<P1, P2, P3>& p, | |
183 const Tuple3<C1, C2, C3>& c) { | |
184 return (obj->*method)(p.a, p.b, p.c, c.a, c.b, c.c); | |
185 } | |
186 | |
187 // 3 - 4 | |
188 template <typename R, typename T, typename Method, typename P1, typename P2, | |
189 typename P3, typename C1, typename C2, typename C3, typename C4> | |
190 inline R DispatchToMethod(T* obj, Method method, | |
191 const Tuple3<P1, P2, P3>& p, | |
192 const Tuple4<C1, C2, C3, C4>& c) { | |
193 return (obj->*method)(p.a, p.b, p.c, c.a, c.b, c.c, c.d); | |
194 } | |
195 | |
196 // 4 - 0 | |
197 template <typename R, typename T, typename Method, typename P1, typename P2, | |
198 typename P3, typename P4> | |
199 inline R DispatchToMethod(T* obj, Method method, | |
200 const Tuple4<P1, P2, P3, P4>& p, | |
201 const Tuple0& c) { | |
202 return (obj->*method)(p.a, p.b, p.c, p.d); | |
203 } | |
204 | |
205 // 4 - 1 | |
206 template <typename R, typename T, typename Method, typename P1, typename P2, | |
207 typename P3, typename P4, typename C1> | |
208 inline R DispatchToMethod(T* obj, Method method, | |
209 const Tuple4<P1, P2, P3, P4>& p, | |
210 const Tuple1<C1>& c) { | |
211 return (obj->*method)(p.a, p.b, p.c, p.d, c.a); | |
212 } | |
213 | |
214 // 4 - 2 | |
215 template <typename R, typename T, typename Method, typename P1, typename P2, | |
216 typename P3, typename P4, typename C1, typename C2> | |
217 inline R DispatchToMethod(T* obj, Method method, | |
218 const Tuple4<P1, P2, P3, P4>& p, | |
219 const Tuple2<C1, C2>& c) { | |
220 return (obj->*method)(p.a, p.b, p.c, p.d, c.a, c.b); | |
221 } | |
222 | |
223 // 4 - 3 | |
224 template <typename R, typename T, typename Method, typename P1, typename P2, | |
225 typename P3, typename P4, typename C1, typename C2, typename C3> | |
226 inline R DispatchToMethod(T* obj, Method method, | |
227 const Tuple4<P1, P2, P3, P4>& p, | |
228 const Tuple3<C1, C2, C3>& c) { | |
229 return (obj->*method)(p.a, p.b, p.c, p.d, c.a, c.b, c.c); | |
230 } | |
231 | |
232 // 4 - 4 | |
233 template <typename R, typename T, typename Method, typename P1, typename P2, | |
234 typename P3, typename P4, typename C1, typename C2, typename C3, | |
235 typename C4> | |
236 inline R DispatchToMethod(T* obj, Method method, | |
237 const Tuple4<P1, P2, P3, P4>& p, | |
238 const Tuple4<C1, C2, C3, C4>& c) { | |
239 return (obj->*method)(p.a, p.b, p.c, p.d, c.a, c.b, c.c, c.d); | |
240 } | |
241 | |
242 // Interface that is exposed to the consumer, that does the actual calling | |
243 // of the method. | |
244 template <typename R, typename Params> | |
245 class MutantRunner { | |
246 public: | |
247 virtual R RunWithParams(const Params& params) = 0; | |
248 virtual ~MutantRunner() {} | |
249 }; | |
250 | |
251 // MutantImpl holds pre-bound arguments (like Task) and like Callback | |
252 // allows call-time arguments. | |
253 template <typename R, typename T, typename Method, | |
254 typename PreBound, typename Params> | |
255 class MutantImpl : public CallbackStorage<T, Method>, | |
256 public MutantRunner<R, Params> { | |
257 public: | |
258 MutantImpl(T* obj, Method meth, const PreBound& pb) | |
259 : CallbackStorage<T, Method>(obj, meth), | |
260 pb_(pb) { | |
261 } | |
262 | |
263 // MutantRunner implementation | |
264 virtual R RunWithParams(const Params& params) { | |
265 return DispatchToMethod<R>(this->obj_, this->meth_, pb_, params); | |
266 } | |
267 | |
268 PreBound pb_; | |
269 }; | |
270 | |
271 // Simple MutantRunner<> wrapper acting as a functor. | |
272 // Redirects operator() to MutantRunner<Params>::Run() | |
273 template <typename R, typename Params> | |
274 struct MutantFunctor { | |
275 explicit MutantFunctor(MutantRunner<R, Params>* cb) : impl_(cb) { | |
276 } | |
277 | |
278 ~MutantFunctor() { | |
279 } | |
280 | |
281 inline R operator()() { | |
282 return impl_->RunWithParams(Tuple0()); | |
283 } | |
284 | |
285 template <typename Arg1> | |
286 inline R operator()(const Arg1& a) { | |
287 return impl_->RunWithParams(Params(a)); | |
288 } | |
289 | |
290 template <typename Arg1, typename Arg2> | |
291 inline R operator()(const Arg1& a, const Arg2& b) { | |
292 return impl_->RunWithParams(Params(a, b)); | |
293 } | |
294 | |
295 template <typename Arg1, typename Arg2, typename Arg3> | |
296 inline R operator()(const Arg1& a, const Arg2& b, const Arg3& c) { | |
297 return impl_->RunWithParams(Params(a, b, c)); | |
298 } | |
299 | |
300 template <typename Arg1, typename Arg2, typename Arg3, typename Arg4> | |
301 inline R operator()(const Arg1& a, const Arg2& b, const Arg3& c, | |
302 const Arg4& d) { | |
303 return impl_->RunWithParams(Params(a, b, c, d)); | |
304 } | |
305 | |
306 private: | |
307 // We need copy constructor since MutantFunctor is copied few times | |
308 // inside GMock machinery, hence no DISALLOW_EVIL_CONTRUCTORS | |
309 MutantFunctor(); | |
310 linked_ptr<MutantRunner<R, Params> > impl_; | |
311 }; | |
312 | |
313 | |
314 | |
315 // 0 - 0 | |
316 template <typename R, typename T> | |
317 inline MutantFunctor<R, Tuple0> | |
318 CreateFunctor(T* obj, R (T::*method)()) { | |
319 MutantRunner<R, Tuple0> *t = new MutantImpl<R, T, | |
320 R (T::*)(), | |
321 Tuple0, Tuple0> | |
322 (obj, method, MakeTuple()); | |
323 return MutantFunctor<R, Tuple0>(t); | |
324 } | |
325 | |
326 // 0 - 1 | |
327 template <typename R, typename T, typename A1> | |
328 inline MutantFunctor<R, Tuple1<A1> > | |
329 CreateFunctor(T* obj, R (T::*method)(A1)) { | |
330 MutantRunner<R, Tuple1<A1> > *t = new MutantImpl<R, T, | |
331 R (T::*)(A1), | |
332 Tuple0, Tuple1<A1> > | |
333 (obj, method, MakeTuple()); | |
334 return MutantFunctor<R, Tuple1<A1> >(t); | |
335 } | |
336 | |
337 // 0 - 2 | |
338 template <typename R, typename T, typename A1, typename A2> | |
339 inline MutantFunctor<R, Tuple2<A1, A2> > | |
340 CreateFunctor(T* obj, R (T::*method)(A1, A2)) { | |
341 MutantRunner<R, Tuple2<A1, A2> > *t = new MutantImpl<R, T, | |
342 R (T::*)(A1, A2), | |
343 Tuple0, Tuple2<A1, A2> > | |
344 (obj, method, MakeTuple()); | |
345 return MutantFunctor<R, Tuple2<A1, A2> >(t); | |
346 } | |
347 | |
348 // 0 - 3 | |
349 template <typename R, typename T, typename A1, typename A2, typename A3> | |
350 inline MutantFunctor<R, Tuple3<A1, A2, A3> > | |
351 CreateFunctor(T* obj, R (T::*method)(A1, A2, A3)) { | |
352 MutantRunner<R, Tuple3<A1, A2, A3> > *t = new MutantImpl<R, T, | |
353 R (T::*)(A1, A2, A3), | |
354 Tuple0, Tuple3<A1, A2, A3> > | |
355 (obj, method, MakeTuple()); | |
356 return MutantFunctor<R, Tuple3<A1, A2, A3> >(t); | |
357 } | |
358 | |
359 // 0 - 4 | |
360 template <typename R, typename T, typename A1, typename A2, typename A3, | |
361 typename A4> | |
362 inline MutantFunctor<R, Tuple4<A1, A2, A3, A4> > | |
363 CreateFunctor(T* obj, R (T::*method)(A1, A2, A3, A4)) { | |
364 MutantRunner<R, Tuple4<A1, A2, A3, A4> > *t = new MutantImpl<R, T, | |
365 R (T::*)(A1, A2, A3, A4), | |
366 Tuple0, Tuple4<A1, A2, A3, A4> > | |
367 (obj, method, MakeTuple()); | |
368 return MutantFunctor<R, Tuple4<A1, A2, A3, A4> >(t); | |
369 } | |
370 | |
371 // 1 - 0 | |
372 template <typename R, typename T, typename P1, typename X1> | |
373 inline MutantFunctor<R, Tuple0> | |
374 CreateFunctor(T* obj, R (T::*method)(X1), const P1& p1) { | |
375 MutantRunner<R, Tuple0> *t = new MutantImpl<R, T, | |
376 R (T::*)(X1), | |
377 Tuple1<P1>, Tuple0> | |
378 (obj, method, MakeTuple(p1)); | |
379 return MutantFunctor<R, Tuple0>(t); | |
380 } | |
381 | |
382 // 1 - 1 | |
383 template <typename R, typename T, typename P1, typename A1, typename X1> | |
384 inline MutantFunctor<R, Tuple1<A1> > | |
385 CreateFunctor(T* obj, R (T::*method)(X1, A1), const P1& p1) { | |
386 MutantRunner<R, Tuple1<A1> > *t = new MutantImpl<R, T, | |
387 R (T::*)(X1, A1), | |
388 Tuple1<P1>, Tuple1<A1> > | |
389 (obj, method, MakeTuple(p1)); | |
390 return MutantFunctor<R, Tuple1<A1> >(t); | |
391 } | |
392 | |
393 // 1 - 2 | |
394 template <typename R, typename T, typename P1, typename A1, typename A2, | |
395 typename X1> | |
396 inline MutantFunctor<R, Tuple2<A1, A2> > | |
397 CreateFunctor(T* obj, R (T::*method)(X1, A1, A2), const P1& p1) { | |
398 MutantRunner<R, Tuple2<A1, A2> > *t = new MutantImpl<R, T, | |
399 R (T::*)(X1, A1, A2), | |
400 Tuple1<P1>, Tuple2<A1, A2> > | |
401 (obj, method, MakeTuple(p1)); | |
402 return MutantFunctor<R, Tuple2<A1, A2> >(t); | |
403 } | |
404 | |
405 // 1 - 3 | |
406 template <typename R, typename T, typename P1, typename A1, typename A2, | |
407 typename A3, typename X1> | |
408 inline MutantFunctor<R, Tuple3<A1, A2, A3> > | |
409 CreateFunctor(T* obj, R (T::*method)(X1, A1, A2, A3), const P1& p1) { | |
410 MutantRunner<R, Tuple3<A1, A2, A3> > *t = new MutantImpl<R, T, | |
411 R (T::*)(X1, A1, A2, A3), | |
412 Tuple1<P1>, Tuple3<A1, A2, A3> > | |
413 (obj, method, MakeTuple(p1)); | |
414 return MutantFunctor<R, Tuple3<A1, A2, A3> >(t); | |
415 } | |
416 | |
417 // 1 - 4 | |
418 template <typename R, typename T, typename P1, typename A1, typename A2, | |
419 typename A3, typename A4, typename X1> | |
420 inline MutantFunctor<R, Tuple4<A1, A2, A3, A4> > | |
421 CreateFunctor(T* obj, R (T::*method)(X1, A1, A2, A3, A4), const P1& p1) { | |
422 MutantRunner<R, Tuple4<A1, A2, A3, A4> > *t = new MutantImpl<R, T, | |
423 R (T::*)(X1, A1, A2, A3, A4), | |
424 Tuple1<P1>, Tuple4<A1, A2, A3, A4> > | |
425 (obj, method, MakeTuple(p1)); | |
426 return MutantFunctor<R, Tuple4<A1, A2, A3, A4> >(t); | |
427 } | |
428 | |
429 // 2 - 0 | |
430 template <typename R, typename T, typename P1, typename P2, typename X1, | |
431 typename X2> | |
432 inline MutantFunctor<R, Tuple0> | |
433 CreateFunctor(T* obj, R (T::*method)(X1, X2), const P1& p1, const P2& p2) { | |
434 MutantRunner<R, Tuple0> *t = new MutantImpl<R, T, | |
435 R (T::*)(X1, X2), | |
436 Tuple2<P1, P2>, Tuple0> | |
437 (obj, method, MakeTuple(p1, p2)); | |
438 return MutantFunctor<R, Tuple0>(t); | |
439 } | |
440 | |
441 // 2 - 1 | |
442 template <typename R, typename T, typename P1, typename P2, typename A1, | |
443 typename X1, typename X2> | |
444 inline MutantFunctor<R, Tuple1<A1> > | |
445 CreateFunctor(T* obj, R (T::*method)(X1, X2, A1), const P1& p1, const P2& p2) { | |
446 MutantRunner<R, Tuple1<A1> > *t = new MutantImpl<R, T, | |
447 R (T::*)(X1, X2, A1), | |
448 Tuple2<P1, P2>, Tuple1<A1> > | |
449 (obj, method, MakeTuple(p1, p2)); | |
450 return MutantFunctor<R, Tuple1<A1> >(t); | |
451 } | |
452 | |
453 // 2 - 2 | |
454 template <typename R, typename T, typename P1, typename P2, typename A1, | |
455 typename A2, typename X1, typename X2> | |
456 inline MutantFunctor<R, Tuple2<A1, A2> > | |
457 CreateFunctor(T* obj, R (T::*method)(X1, X2, A1, A2), const P1& p1, | |
458 const P2& p2) { | |
459 MutantRunner<R, Tuple2<A1, A2> > *t = new MutantImpl<R, T, | |
460 R (T::*)(X1, X2, A1, A2), | |
461 Tuple2<P1, P2>, Tuple2<A1, A2> > | |
462 (obj, method, MakeTuple(p1, p2)); | |
463 return MutantFunctor<R, Tuple2<A1, A2> >(t); | |
464 } | |
465 | |
466 // 2 - 3 | |
467 template <typename R, typename T, typename P1, typename P2, typename A1, | |
468 typename A2, typename A3, typename X1, typename X2> | |
469 inline MutantFunctor<R, Tuple3<A1, A2, A3> > | |
470 CreateFunctor(T* obj, R (T::*method)(X1, X2, A1, A2, A3), const P1& p1, | |
471 const P2& p2) { | |
472 MutantRunner<R, Tuple3<A1, A2, A3> > *t = new MutantImpl<R, T, | |
473 R (T::*)(X1, X2, A1, A2, A3), | |
474 Tuple2<P1, P2>, Tuple3<A1, A2, A3> > | |
475 (obj, method, MakeTuple(p1, p2)); | |
476 return MutantFunctor<R, Tuple3<A1, A2, A3> >(t); | |
477 } | |
478 | |
479 // 2 - 4 | |
480 template <typename R, typename T, typename P1, typename P2, typename A1, | |
481 typename A2, typename A3, typename A4, typename X1, typename X2> | |
482 inline MutantFunctor<R, Tuple4<A1, A2, A3, A4> > | |
483 CreateFunctor(T* obj, R (T::*method)(X1, X2, A1, A2, A3, A4), const P1& p1, | |
484 const P2& p2) { | |
485 MutantRunner<R, Tuple4<A1, A2, A3, A4> > *t = new MutantImpl<R, T, | |
486 R (T::*)(X1, X2, A1, A2, A3, A4), | |
487 Tuple2<P1, P2>, Tuple4<A1, A2, A3, A4> > | |
488 (obj, method, MakeTuple(p1, p2)); | |
489 return MutantFunctor<R, Tuple4<A1, A2, A3, A4> >(t); | |
490 } | |
491 | |
492 // 3 - 0 | |
493 template <typename R, typename T, typename P1, typename P2, typename P3, | |
494 typename X1, typename X2, typename X3> | |
495 inline MutantFunctor<R, Tuple0> | |
496 CreateFunctor(T* obj, R (T::*method)(X1, X2, X3), const P1& p1, const P2& p2, | |
497 const P3& p3) { | |
498 MutantRunner<R, Tuple0> *t = new MutantImpl<R, T, | |
499 R (T::*)(X1, X2, X3), | |
500 Tuple3<P1, P2, P3>, Tuple0> | |
501 (obj, method, MakeTuple(p1, p2, p3)); | |
502 return MutantFunctor<R, Tuple0>(t); | |
503 } | |
504 | |
505 // 3 - 1 | |
506 template <typename R, typename T, typename P1, typename P2, typename P3, | |
507 typename A1, typename X1, typename X2, typename X3> | |
508 inline MutantFunctor<R, Tuple1<A1> > | |
509 CreateFunctor(T* obj, R (T::*method)(X1, X2, X3, A1), const P1& p1, | |
510 const P2& p2, const P3& p3) { | |
511 MutantRunner<R, Tuple1<A1> > *t = new MutantImpl<R, T, | |
512 R (T::*)(X1, X2, X3, A1), | |
513 Tuple3<P1, P2, P3>, Tuple1<A1> > | |
514 (obj, method, MakeTuple(p1, p2, p3)); | |
515 return MutantFunctor<R, Tuple1<A1> >(t); | |
516 } | |
517 | |
518 // 3 - 2 | |
519 template <typename R, typename T, typename P1, typename P2, typename P3, | |
520 typename A1, typename A2, typename X1, typename X2, typename X3> | |
521 inline MutantFunctor<R, Tuple2<A1, A2> > | |
522 CreateFunctor(T* obj, R (T::*method)(X1, X2, X3, A1, A2), const P1& p1, | |
523 const P2& p2, const P3& p3) { | |
524 MutantRunner<R, Tuple2<A1, A2> > *t = new MutantImpl<R, T, | |
525 R (T::*)(X1, X2, X3, A1, A2), | |
526 Tuple3<P1, P2, P3>, Tuple2<A1, A2> > | |
527 (obj, method, MakeTuple(p1, p2, p3)); | |
528 return MutantFunctor<R, Tuple2<A1, A2> >(t); | |
529 } | |
530 | |
531 // 3 - 3 | |
532 template <typename R, typename T, typename P1, typename P2, typename P3, | |
533 typename A1, typename A2, typename A3, typename X1, typename X2, | |
534 typename X3> | |
535 inline MutantFunctor<R, Tuple3<A1, A2, A3> > | |
536 CreateFunctor(T* obj, R (T::*method)(X1, X2, X3, A1, A2, A3), const P1& p1, | |
537 const P2& p2, const P3& p3) { | |
538 MutantRunner<R, Tuple3<A1, A2, A3> > *t = new MutantImpl<R, T, | |
539 R (T::*)(X1, X2, X3, A1, A2, A3), | |
540 Tuple3<P1, P2, P3>, Tuple3<A1, A2, A3> > | |
541 (obj, method, MakeTuple(p1, p2, p3)); | |
542 return MutantFunctor<R, Tuple3<A1, A2, A3> >(t); | |
543 } | |
544 | |
545 // 3 - 4 | |
546 template <typename R, typename T, typename P1, typename P2, typename P3, | |
547 typename A1, typename A2, typename A3, typename A4, typename X1, | |
548 typename X2, typename X3> | |
549 inline MutantFunctor<R, Tuple4<A1, A2, A3, A4> > | |
550 CreateFunctor(T* obj, R (T::*method)(X1, X2, X3, A1, A2, A3, A4), const P1& p1, | |
551 const P2& p2, const P3& p3) { | |
552 MutantRunner<R, Tuple4<A1, A2, A3, A4> > *t = new MutantImpl<R, T, | |
553 R (T::*)(X1, X2, X3, A1, A2, A3, A4), | |
554 Tuple3<P1, P2, P3>, Tuple4<A1, A2, A3, A4> > | |
555 (obj, method, MakeTuple(p1, p2, p3)); | |
556 return MutantFunctor<R, Tuple4<A1, A2, A3, A4> >(t); | |
557 } | |
558 | |
559 // 4 - 0 | |
560 template <typename R, typename T, typename P1, typename P2, typename P3, | |
561 typename P4, typename X1, typename X2, typename X3, typename X4> | |
562 inline MutantFunctor<R, Tuple0> | |
563 CreateFunctor(T* obj, R (T::*method)(X1, X2, X3, X4), const P1& p1, | |
564 const P2& p2, const P3& p3, const P4& p4) { | |
565 MutantRunner<R, Tuple0> *t = new MutantImpl<R, T, | |
566 R (T::*)(X1, X2, X3, X4), | |
567 Tuple4<P1, P2, P3, P4>, Tuple0> | |
568 (obj, method, MakeTuple(p1, p2, p3, p4)); | |
569 return MutantFunctor<R, Tuple0>(t); | |
570 } | |
571 | |
572 // 4 - 1 | |
573 template <typename R, typename T, typename P1, typename P2, typename P3, | |
574 typename P4, typename A1, typename X1, typename X2, typename X3, | |
575 typename X4> | |
576 inline MutantFunctor<R, Tuple1<A1> > | |
577 CreateFunctor(T* obj, R (T::*method)(X1, X2, X3, X4, A1), const P1& p1, | |
578 const P2& p2, const P3& p3, const P4& p4) { | |
579 MutantRunner<R, Tuple1<A1> > *t = new MutantImpl<R, T, | |
580 R (T::*)(X1, X2, X3, X4, A1), | |
581 Tuple4<P1, P2, P3, P4>, Tuple1<A1> > | |
582 (obj, method, MakeTuple(p1, p2, p3, p4)); | |
583 return MutantFunctor<R, Tuple1<A1> >(t); | |
584 } | |
585 | |
586 // 4 - 2 | |
587 template <typename R, typename T, typename P1, typename P2, typename P3, | |
588 typename P4, typename A1, typename A2, typename X1, typename X2, | |
589 typename X3, typename X4> | |
590 inline MutantFunctor<R, Tuple2<A1, A2> > | |
591 CreateFunctor(T* obj, R (T::*method)(X1, X2, X3, X4, A1, A2), const P1& p1, | |
592 const P2& p2, const P3& p3, const P4& p4) { | |
593 MutantRunner<R, Tuple2<A1, A2> > *t = new MutantImpl<R, T, | |
594 R (T::*)(X1, X2, X3, X4, A1, A2), | |
595 Tuple4<P1, P2, P3, P4>, Tuple2<A1, A2> > | |
596 (obj, method, MakeTuple(p1, p2, p3, p4)); | |
597 return MutantFunctor<R, Tuple2<A1, A2> >(t); | |
598 } | |
599 | |
600 // 4 - 3 | |
601 template <typename R, typename T, typename P1, typename P2, typename P3, | |
602 typename P4, typename A1, typename A2, typename A3, typename X1, | |
603 typename X2, typename X3, typename X4> | |
604 inline MutantFunctor<R, Tuple3<A1, A2, A3> > | |
605 CreateFunctor(T* obj, R (T::*method)(X1, X2, X3, X4, A1, A2, A3), const P1& p1, | |
606 const P2& p2, const P3& p3, const P4& p4) { | |
607 MutantRunner<R, Tuple3<A1, A2, A3> > *t = new MutantImpl<R, T, | |
608 R (T::*)(X1, X2, X3, X4, A1, A2, A3), | |
609 Tuple4<P1, P2, P3, P4>, Tuple3<A1, A2, A3> > | |
610 (obj, method, MakeTuple(p1, p2, p3, p4)); | |
611 return MutantFunctor<R, Tuple3<A1, A2, A3> >(t); | |
612 } | |
613 | |
614 // 4 - 4 | |
615 template <typename R, typename T, typename P1, typename P2, typename P3, | |
616 typename P4, typename A1, typename A2, typename A3, typename A4, | |
617 typename X1, typename X2, typename X3, typename X4> | |
618 inline MutantFunctor<R, Tuple4<A1, A2, A3, A4> > | |
619 CreateFunctor(T* obj, R (T::*method)(X1, X2, X3, X4, A1, A2, A3, A4), | |
620 const P1& p1, const P2& p2, const P3& p3, const P4& p4) { | |
621 MutantRunner<R, Tuple4<A1, A2, A3, A4> > *t = new MutantImpl<R, T, | |
622 R (T::*)(X1, X2, X3, X4, A1, A2, A3, A4), | |
623 Tuple4<P1, P2, P3, P4>, Tuple4<A1, A2, A3, A4> > | |
624 (obj, method, MakeTuple(p1, p2, p3, p4)); | |
625 return MutantFunctor<R, Tuple4<A1, A2, A3, A4> >(t); | |
626 } | |
627 #endif // CHROME_FRAME_TEST_HELPER_GMOCK_H_ | |
OLD | NEW |