36 #ifndef GMOCK_INCLUDE_GMOCK_GMOCK_ACTIONS_H_ 37 #define GMOCK_INCLUDE_GMOCK_GMOCK_ACTIONS_H_ 62 template <
typename F1,
typename F2>
74 static bool Exists() {
return false; }
76 Assert(
false, __FILE__, __LINE__,
77 "Default action undefined for the function return type.");
78 return internal::Invalid<T>();
98 static bool Exists() {
return true; }
99 static T*
Get() {
return NULL; }
104 #define GMOCK_DEFINE_DEFAULT_ACTION_FOR_RETURN_TYPE_(type, value) \ 106 class BuiltInDefaultValue<type> { \ 108 static bool Exists() { return true; } \ 109 static type Get() { return value; } \ 113 #if GTEST_HAS_GLOBAL_STRING 115 #endif // GTEST_HAS_GLOBAL_STRING 128 #if GMOCK_WCHAR_T_IS_NATIVE_ 143 #undef GMOCK_DEFINE_DEFAULT_ACTION_FOR_RETURN_TYPE_ 160 template <
typename T>
177 static bool IsSet() {
return value_ != NULL; }
189 return value_ == NULL ?
198 template <
typename T>
212 static bool IsSet() {
return address_ != NULL; }
224 return address_ == NULL ?
241 template <
typename T>
245 template <
typename T>
249 template <
typename F>
262 virtual Result Perform(
const ArgumentTuple& args) = 0;
277 template <
typename F>
298 template <
typename Func>
310 Result
Perform(
const ArgumentTuple& args)
const {
312 !IsDoDefault(), __FILE__, __LINE__,
313 "You are using DoDefault() inside a composite action like " 314 "DoAll() or WithArgs(). This is not supported for technical " 315 "reasons. Please instead spell out the default action, or " 316 "assign the default action to an Action variable and use " 317 "the variable in various places.");
318 return impl_->Perform(args);
322 template <
typename F1,
typename F2>
349 template <
typename Impl>
354 template <
typename F>
360 template <
typename F>
368 virtual Result
Perform(
const ArgumentTuple& args) {
369 return impl_.template Perform<Result>(args);
385 template <
typename F>
397 template <
typename Impl>
406 template <
typename F1,
typename F2>
414 virtual Result
Perform(
const ArgumentTuple& args) {
415 return impl_->Perform(args);
448 template <
typename R>
458 template <
typename F>
471 use_ReturnRef_instead_of_Return_to_return_a_reference);
477 template <
typename F>
493 virtual Result
Perform(
const ArgumentTuple&) {
return value_; }
497 Result_cannot_be_a_reference_type);
512 template <
typename Result,
typename ArgumentTuple>
515 ReturnNull_can_be_used_to_return_a_pointer_only);
524 template <
typename Result,
typename ArgumentTuple>
533 template <
typename T>
541 template <
typename F>
548 use_Return_instead_of_ReturnRef_to_return_a_value);
554 template <
typename F>
560 explicit Impl(
T& ref) : ref_(ref) {}
562 virtual Result
Perform(
const ArgumentTuple&) {
580 template <
typename T>
589 template <
typename F>
597 use_Return_instead_of_ReturnRefOfCopy_to_return_a_value);
603 template <
typename F>
609 explicit Impl(
const T& value) : value_(value) {}
611 virtual Result
Perform(
const ArgumentTuple&) {
631 template <
typename F>
637 template <
typename T1,
typename T2>
642 template <
typename Result,
typename ArgumentTuple>
654 #if !GTEST_OS_WINDOWS_MOBILE 658 template <
typename T>
662 : errno_(errno_value),
664 template <
typename Result,
typename ArgumentTuple>
677 #endif // !GTEST_OS_WINDOWS_MOBILE 683 template <
size_t N,
typename A,
bool kIsProto>
690 template <
typename Result,
typename ArgumentTuple>
691 void Perform(
const ArgumentTuple& args)
const {
693 *::std::tr1::get<N>(args) = value_;
702 template <
size_t N,
typename Proto>
710 proto_->CopyFrom(proto);
713 template <
typename Result,
typename ArgumentTuple>
714 void Perform(
const ArgumentTuple& args)
const {
716 ::std::tr1::get<N>(args)->CopyFrom(*proto_);
730 template <
typename FunctionImpl>
736 : function_impl_(function_impl) {}
740 template <
typename Result,
typename ArgumentTuple>
741 Result
Perform(
const ArgumentTuple&) {
return function_impl_(); }
750 template <
class Class,
typename MethodPtr>
754 : obj_ptr_(obj_ptr), method_ptr_(method_ptr) {}
756 template <
typename Result,
typename ArgumentTuple>
758 return (obj_ptr_->*method_ptr_)();
769 template <
typename A>
774 template <
typename F>
793 template <
typename F>
799 explicit Impl(
const A& action) : action_(action) {}
801 virtual void Perform(
const ArgumentTuple& args) {
803 action_.Perform(args);
829 template <
typename T>
837 operator T&()
const {
return *pointer_; }
843 template <
typename T>
851 template <
typename Action1,
typename Action2>
855 : action1_(action1), action2_(action2) {}
859 template <
typename F>
866 template <
typename F>
874 : action1_(action1), action2_(action2) {}
876 virtual Result
Perform(
const ArgumentTuple& args) {
877 action1_.Perform(args);
878 return action2_.Perform(args);
932 template <
typename To>
933 template <
typename From>
935 : impl_(new internal::ActionAdaptor<To, From>(from)) {}
940 template <
typename R>
956 template <
typename R>
964 template <
typename R>
976 template <
size_t N,
typename T>
985 #if !((GTEST_GCC_VER_ && GTEST_GCC_VER_ < 40000) || GTEST_OS_SYMBIAN) 994 N,
const char*,
false>(p));
1002 N,
const wchar_t*,
false>(p));
1007 template <
size_t N,
typename T>
1017 template <
typename T1,
typename T2>
1022 #if !GTEST_OS_WINDOWS_MOBILE 1025 template <
typename T>
1032 #endif // !GTEST_OS_WINDOWS_MOBILE 1037 template <
typename FunctionImpl>
1046 template <
class Class,
typename MethodPtr>
1051 obj_ptr, method_ptr));
1057 template <
typename A>
1069 template <
typename T>
1076 #endif // GMOCK_INCLUDE_GMOCK_GMOCK_ACTIONS_H_ virtual Result Perform(const ArgumentTuple &)
Definition: gmock-actions.h:611
Definition: gmock-actions.h:770
virtual Result Perform(const ArgumentTuple &args)
Definition: gmock-actions.h:876
Impl impl_
Definition: gmock-actions.h:378
Definition: gmock-actions.h:867
virtual Result Perform(const ArgumentTuple &)
Definition: gmock-actions.h:493
To ImplicitCast_(To x)
Definition: gtest-port.h:982
static bool Exists()
Definition: gmock-actions.h:181
Class *const obj_ptr_
Definition: gmock-actions.h:762
internal::Function< F >::Result Result
Definition: gmock-actions.h:363
PolymorphicAction< internal::ReturnNullAction > ReturnNull()
Definition: gmock-actions.h:946
Definition: gmock-actions.h:49
virtual Result Perform(const ArgumentTuple &)
Definition: gmock-actions.h:562
internal::IgnoredValue Unused
Definition: gmock-actions.h:926
static void Get()
Definition: gmock-actions.h:237
const T2 value_
Definition: gmock-actions.h:649
Definition: gtest-internal.h:770
ActionAdaptor(const Action< F2 > &from)
Definition: gmock-actions.h:412
static T * address_
Definition: gmock-actions.h:228
Definition: gmock-actions.h:627
Function< F >::Result Result
Definition: gmock-actions.h:869
Function< F >::MakeResultVoid VoidResult
Definition: gmock-actions.h:871
static bool IsSet()
Definition: gmock-actions.h:212
Result Perform(const ArgumentTuple &) const
Definition: gmock-actions.h:757
PolymorphicAction< internal::AssignAction< T1, T2 > > Assign(T1 *ptr, T2 val)
Definition: gmock-actions.h:1018
T1 *const ptr_
Definition: gmock-actions.h:648
Definition: gmock-actions.h:161
Definition: gmock-actions.h:509
Action(ActionInterface< F > *impl)
Definition: gmock-actions.h:289
Definition: gmock-actions.h:278
::std::string string
Definition: gtest-port.h:756
Definition: gmock-actions.h:604
Definition: gmock-actions.h:534
const Action< F > action2_
Definition: gmock-actions.h:883
internal::Function< F >::Result Result
Definition: gmock-actions.h:280
const T value_
Definition: gmock-actions.h:621
Action
ActionpointController is a state machine with states: 1) NONE 2) FLY: fly towards a point 3) FIGHT: f...
Definition: ActionpointController.h:63
Definition: gtest-port.h:1473
Definition: InputPrereqs.h:107
Definition: gmock-actions.h:638
internal::Function< F >::ArgumentTuple ArgumentTuple
Definition: gmock-actions.h:253
DoBothAction(Action1 action1, Action2 action2)
Definition: gmock-actions.h:854
SetErrnoAndReturnAction(int errno_value, T result)
Definition: gmock-actions.h:661
PolymorphicAction< internal::InvokeWithoutArgsAction< FunctionImpl > > InvokeWithoutArgs(FunctionImpl function_impl)
Definition: gmock-actions.h:1039
static const T * value_
Definition: gmock-actions.h:193
SetArgumentPointeeAction(const Proto &proto)
Definition: gmock-actions.h:709
static void Perform(const ArgumentTuple &)
Definition: gmock-actions.h:525
Impl(T &ref)
Definition: gmock-actions.h:560
void Perform(const ArgumentTuple &args) const
Definition: gmock-actions.h:691
static void Set(T &x)
Definition: gmock-actions.h:202
Function< F >::ArgumentTuple ArgumentTuple
Definition: gmock-actions.h:870
static T * Get()
Definition: gmock-actions.h:99
Definition: gmock-actions.h:852
virtual Result Perform(const ArgumentTuple &args)
Definition: gmock-actions.h:368
internal::Function< F >::Result Result
Definition: gmock-actions.h:796
Result value_
Definition: gmock-actions.h:498
static T Get()
Definition: gmock-actions.h:90
internal::Function< F1 >::ArgumentTuple ArgumentTuple
Definition: gmock-actions.h:410
Function< F >::ArgumentTuple ArgumentTuple
Definition: gmock-actions.h:607
internal::Function< F >::ArgumentTuple ArgumentTuple
Definition: gmock-actions.h:281
PolymorphicAction< Impl > MakePolymorphicAction(const Impl &impl)
Definition: gmock-actions.h:398
#define GTEST_DISALLOW_ASSIGN_(type)
Definition: gtest-port.h:615
IgnoreResultAction(const A &action)
Definition: gmock-actions.h:772
PolymorphicAction< internal::SetErrnoAndReturnAction< T > > SetErrnoAndReturn(int errval, T result)
Definition: gmock-actions.h:1027
T value_
Definition: gmock-actions.h:616
static bool Exists()
Definition: gmock-actions.h:236
typedef void(ENET_CALLBACK *ENetPacketFreeCallback)(struct _ENetPacket *)
Action1 action1_
Definition: gmock-actions.h:888
internal::ReturnRefAction< R > ReturnRef(R &x)
Definition: gmock-actions.h:957
T & ref_
Definition: gmock-actions.h:572
const Action< VoidResult > action1_
Definition: gmock-actions.h:882
Definition: gmock-actions.h:659
Definition: gmock-actions.h:794
static void Set(T x)
Definition: gmock-actions.h:165
PolymorphicAction< internal::SetArgumentPointeeAction< N, T, internal::IsAProtocolMessage< T >::value > > SetArgumentPointee(const T &x)
Definition: gmock-actions.h:1011
const int errno_
Definition: gmock-actions.h:671
static void Print(const T &value,::std::ostream *os)
Definition: gtest-printers.h:591
Action()
Definition: gmock-actions.h:285
Function< F >::ArgumentTuple ArgumentTuple
Definition: gmock-actions.h:481
#define GTEST_COMPILE_ASSERT_(expr, msg)
Definition: gtest-port.h:699
internal::Function< F >::ArgumentTuple ArgumentTuple
Definition: gmock-actions.h:364
static T & Get()
Definition: gmock-actions.h:223
static bool IsSet()
Definition: gmock-actions.h:177
Definition: gtest-linked_ptr.h:136
InvokeWithoutArgsAction(FunctionImpl function_impl)
Definition: gmock-actions.h:735
virtual Result Perform(const ArgumentTuple &args)
Definition: gmock-actions.h:414
static bool Exists()
Definition: gmock-actions.h:89
Definition: gmock-actions.h:71
Definition: gmock-actions.h:63
static void Clear()
Definition: gmock-actions.h:207
R value_
Definition: gmock-actions.h:503
internal::Function< F1 >::Result Result
Definition: gmock-actions.h:409
PolymorphicAction(const Impl &impl)
Definition: gmock-actions.h:352
Definition: InputPrereqs.h:77
Action(const Action &action)
Definition: gmock-actions.h:292
const internal::linked_ptr< Proto > proto_
Definition: gmock-actions.h:720
internal::Function< F >::MakeResultIgnoredValue OriginalFunction
Definition: gmock-actions.h:810
internal::ReturnRefOfCopyAction< R > ReturnRefOfCopy(const R &x)
Definition: gmock-actions.h:965
Impl impl_
Definition: gmock-actions.h:373
internal::ReferenceWrapper< T > ByRef(T &l_value)
Definition: gmock-actions.h:1070
static void Clear()
Definition: gmock-actions.h:171
Definition: gmock-actions.h:731
Result Perform(const ArgumentTuple &args) const
Definition: gmock-actions.h:310
void Perform(const ArgumentTuple &) const
Definition: gmock-actions.h:643
Result Perform(const ArgumentTuple &)
Definition: gmock-actions.h:741
const T result_
Definition: gmock-actions.h:672
static bool Exists()
Definition: gmock-actions.h:216
Definition: gmock-actions.h:581
Definition: InputPrereqs.h:96
virtual ~ActionInterface()
Definition: gmock-actions.h:256
Function< F >::Result Result
Definition: gmock-actions.h:557
Definition: gmock-internal-utils.h:338
Function< F >::Result Result
Definition: gmock-actions.h:480
Impl(const A &action)
Definition: gmock-actions.h:799
Definition: InputPrereqs.h:78
SetArgumentPointeeAction(const A &value)
Definition: gmock-actions.h:688
internal::Function< F >::ArgumentTuple ArgumentTuple
Definition: gmock-actions.h:797
GMOCK_DEFINE_DEFAULT_ACTION_FOR_RETURN_TYPE_(void,)
Definition: gmock-actions.h:684
internal::Function< F >::Result Result
Definition: gmock-actions.h:252
AssignAction(T1 *ptr, T2 value)
Definition: gmock-actions.h:640
static T Get()
Definition: gmock-actions.h:75
const internal::linked_ptr< ActionInterface< F2 > > impl_
Definition: gmock-actions.h:419
FunctionImpl function_impl_
Definition: gmock-actions.h:744
Definition: gmock-generated-internal-utils.h:53
MonomorphicImpl(const Impl &impl)
Definition: gmock-actions.h:366
Definition: gtest-internal.h:900
Definition: gmock-actions.h:350
Definition: gmock-actions.h:751
internal::linked_ptr< ActionInterface< F > > impl_
Definition: gmock-actions.h:325
bool IsDoDefault() const
Definition: gmock-actions.h:302
ActionInterface()
Definition: gmock-actions.h:255
internal::DoDefaultAction DoDefault()
Definition: gmock-actions.h:970
internal::ReturnAction< R > Return(R value)
Definition: gmock-actions.h:941
Definition: gmock-generated-internal-utils.h:152
void Assert(bool condition, const char *file, int line)
Definition: gmock-internal-utils.h:288
Definition: gmock-actions.h:449
const A value_
Definition: gmock-actions.h:697
Matcher< T > A()
Definition: gmock-matchers.h:2574
Definition: gmock-actions.h:250
PolymorphicAction< internal::SetArgumentPointeeAction< N, T, internal::IsAProtocolMessage< T >::value > > SetArgPointee(const T &x)
Definition: gmock-actions.h:980
static bool Exists()
Definition: gmock-actions.h:74
static bool Exists()
Definition: gmock-actions.h:98
Definition: gmock-actions.h:555
InvokeMethodWithoutArgsAction(Class *obj_ptr, MethodPtr method_ptr)
Definition: gmock-actions.h:753
ReferenceWrapper(T &l_value)
Definition: gmock-actions.h:833
Definition: gmock-actions.h:478
T & ref_
Definition: gmock-actions.h:567
#define GTEST_DISALLOW_COPY_AND_ASSIGN_(type)
Definition: gtest-port.h:620
Impl(const Action< VoidResult > &action1, const Action< F > &action2)
Definition: gmock-actions.h:873
TypeWithSize< 8 >::UInt UInt64
Definition: gtest-port.h:1735
Definition: gmock-actions.h:830
const A action_
Definition: gmock-actions.h:817
static T Get()
Definition: gmock-actions.h:188
void Perform(const ArgumentTuple &args) const
Definition: gmock-actions.h:714
virtual void Perform(const ArgumentTuple &args)
Definition: gmock-actions.h:801
static Result Perform(const ArgumentTuple &)
Definition: gmock-actions.h:513
Impl(R value)
Definition: gmock-actions.h:490
Impl(const T &value)
Definition: gmock-actions.h:609
Function< F >::ArgumentTuple ArgumentTuple
Definition: gmock-actions.h:558
internal::IgnoreResultAction< A > IgnoreResult(const A &an_action)
Definition: gmock-actions.h:1058
TypeWithSize< 8 >::Int Int64
Definition: gtest-port.h:1734
const Action< OriginalFunction > action_
Definition: gmock-actions.h:812
Result Perform(const ArgumentTuple &) const
Definition: gmock-actions.h:665
T * pointer_
Definition: gmock-actions.h:839
const MethodPtr method_ptr_
Definition: gmock-actions.h:763
Definition: InputPrereqs.h:80
ReturnRefAction(T &ref)
Definition: gmock-actions.h:537
Definition: gmock-actions.h:521
void PrintTo(const ReferenceWrapper< T > &ref,::std::ostream *os)
Definition: gmock-actions.h:844
ReturnAction(R value)
Definition: gmock-actions.h:454
Function< F >::Result Result
Definition: gmock-actions.h:606
Action< F > MakeAction(ActionInterface< F > *impl)
Definition: gmock-actions.h:386
Action2 action2_
Definition: gmock-actions.h:889
#define Class(ClassName)
Returns the Identifier of the given class.
Definition: CoreIncludes.h:147
ReturnRefOfCopyAction(const T &value)
Definition: gmock-actions.h:585
Definition: gmock-actions.h:361