HELLO·Android
系统源代码
IT资讯
技术文章
我的收藏
注册
登录
-
我收藏的文章
创建代码块
我的代码块
我的账号
Ice Cream Sandwich
|
4.0.2_r1
下载
查看原文件
收藏
根目录
external
chromium
testing
gmock_mutant.h
// Copyright (c) 2011 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. // This file automatically generated by testing/generate_gmock_mutant.py. // DO NOT EDIT. #ifndef TESTING_GMOCK_MUTANT_H_ #define TESTING_GMOCK_MUTANT_H_ // The intention of this file is to make possible using GMock actions in // all of its syntactic beauty. Classes and helper functions can be used as // more generic variants of Task and Callback classes (see base/task.h) // Mutant supports both pre-bound arguments (like Task) and call-time // arguments (like Callback) - hence the name. :-) // // DispatchToMethod/Function supports two sets of arguments: pre-bound (P) and // call-time (C). The arguments as well as the return type are templatized. // DispatchToMethod/Function will also try to call the selected method or // function even if provided pre-bound arguments does not match exactly with // the function signature hence the X1, X2 ... XN parameters in CreateFunctor. // DispatchToMethod will try to invoke method that may not belong to the // object's class itself but to the object's class base class. // // Additionally you can bind the object at calltime by binding a pointer to // pointer to the object at creation time - before including this file you // have to #define GMOCK_MUTANT_INCLUDE_LATE_OBJECT_BINDING. // // TODO(stoyan): It's yet not clear to me should we use T& and T&* instead // of T* and T** when we invoke CreateFunctor to match the EXPECT_CALL style. // // // Sample usage with gMock: // // struct Mock : public ObjectDelegate { // MOCK_METHOD2(string, OnRequest(int n, const string& request)); // MOCK_METHOD1(void, OnQuit(int exit_code)); // MOCK_METHOD2(void, LogMessage(int level, const string& message)); // // string HandleFlowers(const string& reply, int n, const string& request) { // string result = SStringPrintf("In request of %d %s ", n, request); // for (int i = 0; i < n; ++i) result.append(reply) // return result; // } // // void DoLogMessage(int level, const string& message) { // } // // void QuitMessageLoop(int seconds) { // MessageLoop* loop = MessageLoop::current(); // loop->PostDelayedTask(FROM_HERE, new MessageLoop::QuitTask, // 1000 * seconds); // } // }; // // Mock mock; // // Will invoke mock.HandleFlowers("orchids", n, request) // // "orchids" is a pre-bound argument, and
and
are call-time // // arguments - they are not known until the OnRequest mock is invoked. // EXPECT_CALL(mock, OnRequest(Ge(5), StartsWith("flower")) // .Times(1) // .WillOnce(Invoke(CreateFunctor(&mock, &Mock::HandleFlowers, // string("orchids")))); // // // // No pre-bound arguments, two call-time arguments passed // // directly to DoLogMessage // EXPECT_CALL(mock, OnLogMessage(_, _)) // .Times(AnyNumber()) // .WillAlways(Invoke(CreateFunctor, &mock, &Mock::DoLogMessage)); // // // // In this case we have a single pre-bound argument - 3. We ignore // // all of the arguments of OnQuit. // EXCEPT_CALL(mock, OnQuit(_)) // .Times(1) // .WillOnce(InvokeWithoutArgs(CreateFunctor( // &mock, &Mock::QuitMessageLoop, 3))); // // MessageLoop loop; // loop.Run(); // // // // Here is another example of how we can set an action that invokes // // method of an object that is not yet created. // struct Mock : public ObjectDelegate { // MOCK_METHOD1(void, DemiurgeCreated(Demiurge*)); // MOCK_METHOD2(void, OnRequest(int count, const string&)); // // void StoreDemiurge(Demiurge* w) { // demiurge_ = w; // } // // Demiurge* demiurge; // } // // EXPECT_CALL(mock, DemiurgeCreated(_)).Times(1) // .WillOnce(Invoke(CreateFunctor(&mock, &Mock::StoreDemiurge))); // // EXPECT_CALL(mock, OnRequest(_, StrEq("Moby Dick"))) // .Times(AnyNumber()) // .WillAlways(WithArgs<0>(Invoke( // CreateFunctor(&mock->demiurge_, &Demiurge::DecreaseMonsters)))); // #include "base/memory/linked_ptr.h" #include "base/tuple.h" // for Tuple namespace testing { // 0 - 0 template
inline R DispatchToMethod(T* obj, Method method, const Tuple0& p, const Tuple0& c) { return (obj->*method)(); } template
inline R DispatchToFunction(Function function, const Tuple0& p, const Tuple0& c) { return (*function)(); } // 0 - 1 template
inline R DispatchToMethod(T* obj, Method method, const Tuple0& p, const Tuple1
& c) { return (obj->*method)(c.a); } template
inline R DispatchToFunction(Function function, const Tuple0& p, const Tuple1
& c) { return (*function)(c.a); } // 0 - 2 template
inline R DispatchToMethod(T* obj, Method method, const Tuple0& p, const Tuple2
& c) { return (obj->*method)(c.a, c.b); } template
inline R DispatchToFunction(Function function, const Tuple0& p, const Tuple2
& c) { return (*function)(c.a, c.b); } // 0 - 3 template
inline R DispatchToMethod(T* obj, Method method, const Tuple0& p, const Tuple3
& c) { return (obj->*method)(c.a, c.b, c.c); } template
inline R DispatchToFunction(Function function, const Tuple0& p, const Tuple3
& c) { return (*function)(c.a, c.b, c.c); } // 0 - 4 template
inline R DispatchToMethod(T* obj, Method method, const Tuple0& p, const Tuple4
& c) { return (obj->*method)(c.a, c.b, c.c, c.d); } template
inline R DispatchToFunction(Function function, const Tuple0& p, const Tuple4
& c) { return (*function)(c.a, c.b, c.c, c.d); } // 0 - 5 template
inline R DispatchToMethod(T* obj, Method method, const Tuple0& p, const Tuple5
& c) { return (obj->*method)(c.a, c.b, c.c, c.d, c.e); } template
inline R DispatchToFunction(Function function, const Tuple0& p, const Tuple5
& c) { return (*function)(c.a, c.b, c.c, c.d, c.e); } // 0 - 6 template
inline R DispatchToMethod(T* obj, Method method, const Tuple0& p, const Tuple6
& c) { return (obj->*method)(c.a, c.b, c.c, c.d, c.e, c.f); } template
inline R DispatchToFunction(Function function, const Tuple0& p, const Tuple6
& c) { return (*function)(c.a, c.b, c.c, c.d, c.e, c.f); } // 1 - 0 template
inline R DispatchToMethod(T* obj, Method method, const Tuple1
& p, const Tuple0& c) { return (obj->*method)(p.a); } template
inline R DispatchToFunction(Function function, const Tuple1
& p, const Tuple0& c) { return (*function)(p.a); } // 1 - 1 template
inline R DispatchToMethod(T* obj, Method method, const Tuple1
& p, const Tuple1
& c) { return (obj->*method)(p.a, c.a); } template
inline R DispatchToFunction(Function function, const Tuple1
& p, const Tuple1
& c) { return (*function)(p.a, c.a); } // 1 - 2 template
inline R DispatchToMethod(T* obj, Method method, const Tuple1
& p, const Tuple2
& c) { return (obj->*method)(p.a, c.a, c.b); } template
inline R DispatchToFunction(Function function, const Tuple1
& p, const Tuple2
& c) { return (*function)(p.a, c.a, c.b); } // 1 - 3 template
inline R DispatchToMethod(T* obj, Method method, const Tuple1
& p, const Tuple3
& c) { return (obj->*method)(p.a, c.a, c.b, c.c); } template
inline R DispatchToFunction(Function function, const Tuple1
& p, const Tuple3
& c) { return (*function)(p.a, c.a, c.b, c.c); } // 1 - 4 template
inline R DispatchToMethod(T* obj, Method method, const Tuple1
& p, const Tuple4
& c) { return (obj->*method)(p.a, c.a, c.b, c.c, c.d); } template
inline R DispatchToFunction(Function function, const Tuple1
& p, const Tuple4
& c) { return (*function)(p.a, c.a, c.b, c.c, c.d); } // 1 - 5 template
inline R DispatchToMethod(T* obj, Method method, const Tuple1
& p, const Tuple5
& c) { return (obj->*method)(p.a, c.a, c.b, c.c, c.d, c.e); } template
inline R DispatchToFunction(Function function, const Tuple1
& p, const Tuple5
& c) { return (*function)(p.a, c.a, c.b, c.c, c.d, c.e); } // 1 - 6 template
inline R DispatchToMethod(T* obj, Method method, const Tuple1
& p, const Tuple6
& c) { return (obj->*method)(p.a, c.a, c.b, c.c, c.d, c.e, c.f); } template
inline R DispatchToFunction(Function function, const Tuple1
& p, const Tuple6
& c) { return (*function)(p.a, c.a, c.b, c.c, c.d, c.e, c.f); } // 2 - 0 template
inline R DispatchToMethod(T* obj, Method method, const Tuple2
& p, const Tuple0& c) { return (obj->*method)(p.a, p.b); } template
inline R DispatchToFunction(Function function, const Tuple2
& p, const Tuple0& c) { return (*function)(p.a, p.b); } // 2 - 1 template
inline R DispatchToMethod(T* obj, Method method, const Tuple2
& p, const Tuple1
& c) { return (obj->*method)(p.a, p.b, c.a); } template
inline R DispatchToFunction(Function function, const Tuple2
& p, const Tuple1
& c) { return (*function)(p.a, p.b, c.a); } // 2 - 2 template
inline R DispatchToMethod(T* obj, Method method, const Tuple2
& p, const Tuple2
& c) { return (obj->*method)(p.a, p.b, c.a, c.b); } template
inline R DispatchToFunction(Function function, const Tuple2
& p, const Tuple2
& c) { return (*function)(p.a, p.b, c.a, c.b); } // 2 - 3 template
inline R DispatchToMethod(T* obj, Method method, const Tuple2
& p, const Tuple3
& c) { return (obj->*method)(p.a, p.b, c.a, c.b, c.c); } template
inline R DispatchToFunction(Function function, const Tuple2
& p, const Tuple3
& c) { return (*function)(p.a, p.b, c.a, c.b, c.c); } // 2 - 4 template
inline R DispatchToMethod(T* obj, Method method, const Tuple2
& p, const Tuple4
& c) { return (obj->*method)(p.a, p.b, c.a, c.b, c.c, c.d); } template
inline R DispatchToFunction(Function function, const Tuple2
& p, const Tuple4
& c) { return (*function)(p.a, p.b, c.a, c.b, c.c, c.d); } // 2 - 5 template
inline R DispatchToMethod(T* obj, Method method, const Tuple2
& p, const Tuple5
& c) { return (obj->*method)(p.a, p.b, c.a, c.b, c.c, c.d, c.e); } template
inline R DispatchToFunction(Function function, const Tuple2
& p, const Tuple5
& c) { return (*function)(p.a, p.b, c.a, c.b, c.c, c.d, c.e); } // 2 - 6 template
inline R DispatchToMethod(T* obj, Method method, const Tuple2
& p, const Tuple6
& c) { return (obj->*method)(p.a, p.b, c.a, c.b, c.c, c.d, c.e, c.f); } template
inline R DispatchToFunction(Function function, const Tuple2
& p, const Tuple6
& c) { return (*function)(p.a, p.b, c.a, c.b, c.c, c.d, c.e, c.f); } // 3 - 0 template
inline R DispatchToMethod(T* obj, Method method, const Tuple3
& p, const Tuple0& c) { return (obj->*method)(p.a, p.b, p.c); } template
inline R DispatchToFunction(Function function, const Tuple3
& p, const Tuple0& c) { return (*function)(p.a, p.b, p.c); } // 3 - 1 template
inline R DispatchToMethod(T* obj, Method method, const Tuple3
& p, const Tuple1
& c) { return (obj->*method)(p.a, p.b, p.c, c.a); } template
inline R DispatchToFunction(Function function, const Tuple3
& p, const Tuple1
& c) { return (*function)(p.a, p.b, p.c, c.a); } // 3 - 2 template
inline R DispatchToMethod(T* obj, Method method, const Tuple3
& p, const Tuple2
& c) { return (obj->*method)(p.a, p.b, p.c, c.a, c.b); } template
inline R DispatchToFunction(Function function, const Tuple3
& p, const Tuple2
& c) { return (*function)(p.a, p.b, p.c, c.a, c.b); } // 3 - 3 template
inline R DispatchToMethod(T* obj, Method method, const Tuple3
& p, const Tuple3
& c) { return (obj->*method)(p.a, p.b, p.c, c.a, c.b, c.c); } template
inline R DispatchToFunction(Function function, const Tuple3
& p, const Tuple3
& c) { return (*function)(p.a, p.b, p.c, c.a, c.b, c.c); } // 3 - 4 template
inline R DispatchToMethod(T* obj, Method method, const Tuple3
& p, const Tuple4
& c) { return (obj->*method)(p.a, p.b, p.c, c.a, c.b, c.c, c.d); } template
inline R DispatchToFunction(Function function, const Tuple3
& p, const Tuple4
& c) { return (*function)(p.a, p.b, p.c, c.a, c.b, c.c, c.d); } // 3 - 5 template
inline R DispatchToMethod(T* obj, Method method, const Tuple3
& p, const Tuple5
& c) { return (obj->*method)(p.a, p.b, p.c, c.a, c.b, c.c, c.d, c.e); } template
inline R DispatchToFunction(Function function, const Tuple3
& p, const Tuple5
& c) { return (*function)(p.a, p.b, p.c, c.a, c.b, c.c, c.d, c.e); } // 3 - 6 template
inline R DispatchToMethod(T* obj, Method method, const Tuple3
& p, const Tuple6
& c) { return (obj->*method)(p.a, p.b, p.c, c.a, c.b, c.c, c.d, c.e, c.f); } template
inline R DispatchToFunction(Function function, const Tuple3
& p, const Tuple6
& c) { return (*function)(p.a, p.b, p.c, c.a, c.b, c.c, c.d, c.e, c.f); } // 4 - 0 template
inline R DispatchToMethod(T* obj, Method method, const Tuple4
& p, const Tuple0& c) { return (obj->*method)(p.a, p.b, p.c, p.d); } template
inline R DispatchToFunction(Function function, const Tuple4
& p, const Tuple0& c) { return (*function)(p.a, p.b, p.c, p.d); } // 4 - 1 template
inline R DispatchToMethod(T* obj, Method method, const Tuple4
& p, const Tuple1
& c) { return (obj->*method)(p.a, p.b, p.c, p.d, c.a); } template
inline R DispatchToFunction(Function function, const Tuple4
& p, const Tuple1
& c) { return (*function)(p.a, p.b, p.c, p.d, c.a); } // 4 - 2 template
inline R DispatchToMethod(T* obj, Method method, const Tuple4
& p, const Tuple2
& c) { return (obj->*method)(p.a, p.b, p.c, p.d, c.a, c.b); } template
inline R DispatchToFunction(Function function, const Tuple4
& p, const Tuple2
& c) { return (*function)(p.a, p.b, p.c, p.d, c.a, c.b); } // 4 - 3 template
inline R DispatchToMethod(T* obj, Method method, const Tuple4
& p, const Tuple3
& c) { return (obj->*method)(p.a, p.b, p.c, p.d, c.a, c.b, c.c); } template
inline R DispatchToFunction(Function function, const Tuple4
& p, const Tuple3
& c) { return (*function)(p.a, p.b, p.c, p.d, c.a, c.b, c.c); } // 4 - 4 template
inline R DispatchToMethod(T* obj, Method method, const Tuple4
& p, const Tuple4
& c) { return (obj->*method)(p.a, p.b, p.c, p.d, c.a, c.b, c.c, c.d); } template
inline R DispatchToFunction(Function function, const Tuple4
& p, const Tuple4
& c) { return (*function)(p.a, p.b, p.c, p.d, c.a, c.b, c.c, c.d); } // 4 - 5 template
inline R DispatchToMethod(T* obj, Method method, const Tuple4
& p, const Tuple5
& c) { return (obj->*method)(p.a, p.b, p.c, p.d, c.a, c.b, c.c, c.d, c.e); } template
inline R DispatchToFunction(Function function, const Tuple4
& p, const Tuple5
& c) { return (*function)(p.a, p.b, p.c, p.d, c.a, c.b, c.c, c.d, c.e); } // 4 - 6 template
inline R DispatchToMethod(T* obj, Method method, const Tuple4
& p, const Tuple6
& c) { return (obj->*method)(p.a, p.b, p.c, p.d, c.a, c.b, c.c, c.d, c.e, c.f); } template
inline R DispatchToFunction(Function function, const Tuple4
& p, const Tuple6
& c) { return (*function)(p.a, p.b, p.c, p.d, c.a, c.b, c.c, c.d, c.e, c.f); } // 5 - 0 template
inline R DispatchToMethod(T* obj, Method method, const Tuple5
& p, const Tuple0& c) { return (obj->*method)(p.a, p.b, p.c, p.d, p.e); } template
inline R DispatchToFunction(Function function, const Tuple5
& p, const Tuple0& c) { return (*function)(p.a, p.b, p.c, p.d, p.e); } // 5 - 1 template
inline R DispatchToMethod(T* obj, Method method, const Tuple5
& p, const Tuple1
& c) { return (obj->*method)(p.a, p.b, p.c, p.d, p.e, c.a); } template
inline R DispatchToFunction(Function function, const Tuple5
& p, const Tuple1
& c) { return (*function)(p.a, p.b, p.c, p.d, p.e, c.a); } // 5 - 2 template
inline R DispatchToMethod(T* obj, Method method, const Tuple5
& p, const Tuple2
& c) { return (obj->*method)(p.a, p.b, p.c, p.d, p.e, c.a, c.b); } template
inline R DispatchToFunction(Function function, const Tuple5
& p, const Tuple2
& c) { return (*function)(p.a, p.b, p.c, p.d, p.e, c.a, c.b); } // 5 - 3 template
inline R DispatchToMethod(T* obj, Method method, const Tuple5
& p, const Tuple3
& c) { return (obj->*method)(p.a, p.b, p.c, p.d, p.e, c.a, c.b, c.c); } template
inline R DispatchToFunction(Function function, const Tuple5
& p, const Tuple3
& c) { return (*function)(p.a, p.b, p.c, p.d, p.e, c.a, c.b, c.c); } // 5 - 4 template
inline R DispatchToMethod(T* obj, Method method, const Tuple5
& p, const Tuple4
& c) { return (obj->*method)(p.a, p.b, p.c, p.d, p.e, c.a, c.b, c.c, c.d); } template
inline R DispatchToFunction(Function function, const Tuple5
& p, const Tuple4
& c) { return (*function)(p.a, p.b, p.c, p.d, p.e, c.a, c.b, c.c, c.d); } // 5 - 5 template
inline R DispatchToMethod(T* obj, Method method, const Tuple5
& p, const Tuple5
& c) { return (obj->*method)(p.a, p.b, p.c, p.d, p.e, c.a, c.b, c.c, c.d, c.e); } template
inline R DispatchToFunction(Function function, const Tuple5
& p, const Tuple5
& c) { return (*function)(p.a, p.b, p.c, p.d, p.e, c.a, c.b, c.c, c.d, c.e); } // 5 - 6 template
inline R DispatchToMethod(T* obj, Method method, const Tuple5
& p, const Tuple6
& c) { return (obj->*method)(p.a, p.b, p.c, p.d, p.e, c.a, c.b, c.c, c.d, c.e, c.f); } template
inline R DispatchToFunction(Function function, const Tuple5
& p, const Tuple6
& c) { return (*function)(p.a, p.b, p.c, p.d, p.e, c.a, c.b, c.c, c.d, c.e, c.f); } // 6 - 0 template
inline R DispatchToMethod(T* obj, Method method, const Tuple6
& p, const Tuple0& c) { return (obj->*method)(p.a, p.b, p.c, p.d, p.e, p.f); } template
inline R DispatchToFunction(Function function, const Tuple6
& p, const Tuple0& c) { return (*function)(p.a, p.b, p.c, p.d, p.e, p.f); } // 6 - 1 template
inline R DispatchToMethod(T* obj, Method method, const Tuple6
& p, const Tuple1
& c) { return (obj->*method)(p.a, p.b, p.c, p.d, p.e, p.f, c.a); } template
inline R DispatchToFunction(Function function, const Tuple6
& p, const Tuple1
& c) { return (*function)(p.a, p.b, p.c, p.d, p.e, p.f, c.a); } // 6 - 2 template
inline R DispatchToMethod(T* obj, Method method, const Tuple6
& p, const Tuple2
& c) { return (obj->*method)(p.a, p.b, p.c, p.d, p.e, p.f, c.a, c.b); } template
inline R DispatchToFunction(Function function, const Tuple6
& p, const Tuple2
& c) { return (*function)(p.a, p.b, p.c, p.d, p.e, p.f, c.a, c.b); } // 6 - 3 template
inline R DispatchToMethod(T* obj, Method method, const Tuple6
& p, const Tuple3
& c) { return (obj->*method)(p.a, p.b, p.c, p.d, p.e, p.f, c.a, c.b, c.c); } template
inline R DispatchToFunction(Function function, const Tuple6
& p, const Tuple3
& c) { return (*function)(p.a, p.b, p.c, p.d, p.e, p.f, c.a, c.b, c.c); } // 6 - 4 template
inline R DispatchToMethod(T* obj, Method method, const Tuple6
& p, const Tuple4
& c) { return (obj->*method)(p.a, p.b, p.c, p.d, p.e, p.f, c.a, c.b, c.c, c.d); } template