00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060 #ifndef GMOCK_INCLUDE_GMOCK_GMOCK_SPEC_BUILDERS_H_
00061 #define GMOCK_INCLUDE_GMOCK_GMOCK_SPEC_BUILDERS_H_
00062
00063 #include <map>
00064 #include <set>
00065 #include <sstream>
00066 #include <string>
00067 #include <vector>
00068
00069 #if GTEST_HAS_EXCEPTIONS
00070 # include <stdexcept>
00071 #endif
00072
00073 #include "gmock/gmock-actions.h"
00074 #include "gmock/gmock-cardinalities.h"
00075 #include "gmock/gmock-matchers.h"
00076 #include "gmock/internal/gmock-internal-utils.h"
00077 #include "gmock/internal/gmock-port.h"
00078 #include "gtest/gtest.h"
00079
00080 namespace testing {
00081
00082
00083 class Expectation;
00084
00085
00086 class ExpectationSet;
00087
00088
00089
00090 namespace internal {
00091
00092
00093 template <typename F> class FunctionMocker;
00094
00095
00096 class ExpectationBase;
00097
00098
00099 template <typename F> class TypedExpectation;
00100
00101
00102 class ExpectationTester;
00103
00104
00105 template <typename F> class FunctionMockerBase;
00106
00107
00108
00109
00110
00111
00112
00113
00114
00115
00116
00117
00118 GTEST_API_ GTEST_DECLARE_STATIC_MUTEX_(g_gmock_mutex);
00119
00120
00121 class UntypedActionResultHolderBase;
00122
00123
00124
00125
00126 class GTEST_API_ UntypedFunctionMockerBase {
00127 public:
00128 UntypedFunctionMockerBase();
00129 virtual ~UntypedFunctionMockerBase();
00130
00131
00132
00133
00134 bool VerifyAndClearExpectationsLocked()
00135 GTEST_EXCLUSIVE_LOCK_REQUIRED_(g_gmock_mutex);
00136
00137
00138 virtual void ClearDefaultActionsLocked()
00139 GTEST_EXCLUSIVE_LOCK_REQUIRED_(g_gmock_mutex) = 0;
00140
00141
00142
00143
00144
00145
00146
00147
00148
00149
00150 virtual UntypedActionResultHolderBase* UntypedPerformDefaultAction(
00151 const void* untyped_args,
00152 const string& call_description) const = 0;
00153
00154
00155
00156
00157 virtual UntypedActionResultHolderBase* UntypedPerformAction(
00158 const void* untyped_action,
00159 const void* untyped_args) const = 0;
00160
00161
00162
00163
00164 virtual void UntypedDescribeUninterestingCall(
00165 const void* untyped_args,
00166 ::std::ostream* os) const
00167 GTEST_LOCK_EXCLUDED_(g_gmock_mutex) = 0;
00168
00169
00170
00171
00172
00173
00174
00175 virtual const ExpectationBase* UntypedFindMatchingExpectation(
00176 const void* untyped_args,
00177 const void** untyped_action, bool* is_excessive,
00178 ::std::ostream* what, ::std::ostream* why)
00179 GTEST_LOCK_EXCLUDED_(g_gmock_mutex) = 0;
00180
00181
00182 virtual void UntypedPrintArgs(const void* untyped_args,
00183 ::std::ostream* os) const = 0;
00184
00185
00186
00187
00188
00189
00190 void RegisterOwner(const void* mock_obj)
00191 GTEST_LOCK_EXCLUDED_(g_gmock_mutex);
00192
00193
00194
00195
00196 void SetOwnerAndName(const void* mock_obj, const char* name)
00197 GTEST_LOCK_EXCLUDED_(g_gmock_mutex);
00198
00199
00200
00201
00202 const void* MockObject() const
00203 GTEST_LOCK_EXCLUDED_(g_gmock_mutex);
00204
00205
00206
00207 const char* Name() const
00208 GTEST_LOCK_EXCLUDED_(g_gmock_mutex);
00209
00210
00211
00212
00213
00214 const UntypedActionResultHolderBase* UntypedInvokeWith(
00215 const void* untyped_args)
00216 GTEST_LOCK_EXCLUDED_(g_gmock_mutex);
00217
00218 protected:
00219 typedef std::vector<const void*> UntypedOnCallSpecs;
00220
00221 typedef std::vector<internal::linked_ptr<ExpectationBase> >
00222 UntypedExpectations;
00223
00224
00225
00226 Expectation GetHandleOf(ExpectationBase* exp);
00227
00228
00229
00230
00231 const void* mock_obj_;
00232
00233
00234
00235 const char* name_;
00236
00237
00238 UntypedOnCallSpecs untyped_on_call_specs_;
00239
00240
00241 UntypedExpectations untyped_expectations_;
00242 };
00243
00244
00245 class UntypedOnCallSpecBase {
00246 public:
00247
00248 UntypedOnCallSpecBase(const char* a_file, int a_line)
00249 : file_(a_file), line_(a_line), last_clause_(kNone) {}
00250
00251
00252 const char* file() const { return file_; }
00253 int line() const { return line_; }
00254
00255 protected:
00256
00257 enum Clause {
00258
00259
00260 kNone,
00261 kWith,
00262 kWillByDefault
00263 };
00264
00265
00266 void AssertSpecProperty(bool property, const string& failure_message) const {
00267 Assert(property, file_, line_, failure_message);
00268 }
00269
00270
00271 void ExpectSpecProperty(bool property, const string& failure_message) const {
00272 Expect(property, file_, line_, failure_message);
00273 }
00274
00275 const char* file_;
00276 int line_;
00277
00278
00279
00280 Clause last_clause_;
00281 };
00282
00283
00284 template <typename F>
00285 class OnCallSpec : public UntypedOnCallSpecBase {
00286 public:
00287 typedef typename Function<F>::ArgumentTuple ArgumentTuple;
00288 typedef typename Function<F>::ArgumentMatcherTuple ArgumentMatcherTuple;
00289
00290
00291
00292 OnCallSpec(const char* a_file, int a_line,
00293 const ArgumentMatcherTuple& matchers)
00294 : UntypedOnCallSpecBase(a_file, a_line),
00295 matchers_(matchers),
00296
00297
00298
00299
00300 extra_matcher_(A<const ArgumentTuple&>()) {
00301 }
00302
00303
00304 OnCallSpec& With(const Matcher<const ArgumentTuple&>& m) {
00305
00306 ExpectSpecProperty(last_clause_ < kWith,
00307 ".With() cannot appear "
00308 "more than once in an ON_CALL().");
00309 last_clause_ = kWith;
00310
00311 extra_matcher_ = m;
00312 return *this;
00313 }
00314
00315
00316 OnCallSpec& WillByDefault(const Action<F>& action) {
00317 ExpectSpecProperty(last_clause_ < kWillByDefault,
00318 ".WillByDefault() must appear "
00319 "exactly once in an ON_CALL().");
00320 last_clause_ = kWillByDefault;
00321
00322 ExpectSpecProperty(!action.IsDoDefault(),
00323 "DoDefault() cannot be used in ON_CALL().");
00324 action_ = action;
00325 return *this;
00326 }
00327
00328
00329 bool Matches(const ArgumentTuple& args) const {
00330 return TupleMatches(matchers_, args) && extra_matcher_.Matches(args);
00331 }
00332
00333
00334 const Action<F>& GetAction() const {
00335 AssertSpecProperty(last_clause_ == kWillByDefault,
00336 ".WillByDefault() must appear exactly "
00337 "once in an ON_CALL().");
00338 return action_;
00339 }
00340
00341 private:
00342
00343
00344
00345
00346
00347
00348
00349
00350
00351
00352
00353
00354
00355 ArgumentMatcherTuple matchers_;
00356 Matcher<const ArgumentTuple&> extra_matcher_;
00357 Action<F> action_;
00358 };
00359
00360
00361 enum CallReaction {
00362 kAllow,
00363 kWarn,
00364 kFail,
00365 kDefault = kWarn
00366 };
00367
00368 }
00369
00370
00371 class GTEST_API_ Mock {
00372 public:
00373
00374
00375
00376
00377 static void AllowLeak(const void* mock_obj)
00378 GTEST_LOCK_EXCLUDED_(internal::g_gmock_mutex);
00379
00380
00381
00382
00383 static bool VerifyAndClearExpectations(void* mock_obj)
00384 GTEST_LOCK_EXCLUDED_(internal::g_gmock_mutex);
00385
00386
00387
00388
00389 static bool VerifyAndClear(void* mock_obj)
00390 GTEST_LOCK_EXCLUDED_(internal::g_gmock_mutex);
00391
00392 private:
00393 friend class internal::UntypedFunctionMockerBase;
00394
00395
00396
00397 template <typename F>
00398 friend class internal::FunctionMockerBase;
00399
00400 template <typename M>
00401 friend class NiceMock;
00402
00403 template <typename M>
00404 friend class NaggyMock;
00405
00406 template <typename M>
00407 friend class StrictMock;
00408
00409
00410
00411 static void AllowUninterestingCalls(const void* mock_obj)
00412 GTEST_LOCK_EXCLUDED_(internal::g_gmock_mutex);
00413
00414
00415
00416 static void WarnUninterestingCalls(const void* mock_obj)
00417 GTEST_LOCK_EXCLUDED_(internal::g_gmock_mutex);
00418
00419
00420
00421 static void FailUninterestingCalls(const void* mock_obj)
00422 GTEST_LOCK_EXCLUDED_(internal::g_gmock_mutex);
00423
00424
00425
00426 static void UnregisterCallReaction(const void* mock_obj)
00427 GTEST_LOCK_EXCLUDED_(internal::g_gmock_mutex);
00428
00429
00430
00431 static internal::CallReaction GetReactionOnUninterestingCalls(
00432 const void* mock_obj)
00433 GTEST_LOCK_EXCLUDED_(internal::g_gmock_mutex);
00434
00435
00436
00437
00438 static bool VerifyAndClearExpectationsLocked(void* mock_obj)
00439 GTEST_EXCLUSIVE_LOCK_REQUIRED_(internal::g_gmock_mutex);
00440
00441
00442 static void ClearDefaultActionsLocked(void* mock_obj)
00443 GTEST_EXCLUSIVE_LOCK_REQUIRED_(internal::g_gmock_mutex);
00444
00445
00446 static void Register(
00447 const void* mock_obj,
00448 internal::UntypedFunctionMockerBase* mocker)
00449 GTEST_LOCK_EXCLUDED_(internal::g_gmock_mutex);
00450
00451
00452
00453
00454 static void RegisterUseByOnCallOrExpectCall(
00455 const void* mock_obj, const char* file, int line)
00456 GTEST_LOCK_EXCLUDED_(internal::g_gmock_mutex);
00457
00458
00459
00460
00461
00462 static void UnregisterLocked(internal::UntypedFunctionMockerBase* mocker)
00463 GTEST_EXCLUSIVE_LOCK_REQUIRED_(internal::g_gmock_mutex);
00464 };
00465
00466
00467
00468
00469
00470
00471
00472
00473
00474
00475
00476
00477
00478
00479
00480
00481
00482
00483
00484
00485
00486
00487 class GTEST_API_ Expectation {
00488 public:
00489
00490 Expectation();
00491
00492 ~Expectation();
00493
00494
00495
00496
00497
00498
00499
00500
00501
00502
00503 Expectation(internal::ExpectationBase& exp);
00504
00505
00506
00507
00508
00509 bool operator==(const Expectation& rhs) const {
00510 return expectation_base_ == rhs.expectation_base_;
00511 }
00512
00513 bool operator!=(const Expectation& rhs) const { return !(*this == rhs); }
00514
00515 private:
00516 friend class ExpectationSet;
00517 friend class Sequence;
00518 friend class ::testing::internal::ExpectationBase;
00519 friend class ::testing::internal::UntypedFunctionMockerBase;
00520
00521 template <typename F>
00522 friend class ::testing::internal::FunctionMockerBase;
00523
00524 template <typename F>
00525 friend class ::testing::internal::TypedExpectation;
00526
00527
00528 class Less {
00529 public:
00530 bool operator()(const Expectation& lhs, const Expectation& rhs) const {
00531 return lhs.expectation_base_.get() < rhs.expectation_base_.get();
00532 }
00533 };
00534
00535 typedef ::std::set<Expectation, Less> Set;
00536
00537 Expectation(
00538 const internal::linked_ptr<internal::ExpectationBase>& expectation_base);
00539
00540
00541 const internal::linked_ptr<internal::ExpectationBase>&
00542 expectation_base() const {
00543 return expectation_base_;
00544 }
00545
00546
00547 internal::linked_ptr<internal::ExpectationBase> expectation_base_;
00548 };
00549
00550
00551
00552
00553
00554
00555
00556
00557
00558
00559
00560
00561
00562
00563 class ExpectationSet {
00564 public:
00565
00566 typedef Expectation::Set::const_iterator const_iterator;
00567
00568
00569 typedef Expectation::Set::value_type value_type;
00570
00571
00572 ExpectationSet() {}
00573
00574
00575
00576
00577 ExpectationSet(internal::ExpectationBase& exp) {
00578 *this += Expectation(exp);
00579 }
00580
00581
00582
00583
00584 ExpectationSet(const Expectation& e) {
00585 *this += e;
00586 }
00587
00588
00589
00590
00591
00592
00593 bool operator==(const ExpectationSet& rhs) const {
00594 return expectations_ == rhs.expectations_;
00595 }
00596
00597 bool operator!=(const ExpectationSet& rhs) const { return !(*this == rhs); }
00598
00599
00600
00601 ExpectationSet& operator+=(const Expectation& e) {
00602 expectations_.insert(e);
00603 return *this;
00604 }
00605
00606 int size() const { return static_cast<int>(expectations_.size()); }
00607
00608 const_iterator begin() const { return expectations_.begin(); }
00609 const_iterator end() const { return expectations_.end(); }
00610
00611 private:
00612 Expectation::Set expectations_;
00613 };
00614
00615
00616
00617
00618
00619 class GTEST_API_ Sequence {
00620 public:
00621
00622 Sequence() : last_expectation_(new Expectation) {}
00623
00624
00625
00626 void AddExpectation(const Expectation& expectation) const;
00627
00628 private:
00629
00630
00631
00632
00633 internal::linked_ptr<Expectation> last_expectation_;
00634 };
00635
00636
00637
00638
00639
00640
00641
00642
00643
00644
00645
00646
00647
00648
00649
00650
00651
00652
00653
00654
00655
00656
00657
00658
00659
00660 class GTEST_API_ InSequence {
00661 public:
00662 InSequence();
00663 ~InSequence();
00664 private:
00665 bool sequence_created_;
00666
00667 GTEST_DISALLOW_COPY_AND_ASSIGN_(InSequence);
00668 } GTEST_ATTRIBUTE_UNUSED_;
00669
00670 namespace internal {
00671
00672
00673
00674 GTEST_API_ extern ThreadLocal<Sequence*> g_gmock_implicit_sequence;
00675
00676
00677
00678
00679
00680
00681
00682
00683
00684
00685
00686
00687
00688
00689
00690 class GTEST_API_ ExpectationBase {
00691 public:
00692
00693 ExpectationBase(const char* file, int line, const string& source_text);
00694
00695 virtual ~ExpectationBase();
00696
00697
00698 const char* file() const { return file_; }
00699 int line() const { return line_; }
00700 const char* source_text() const { return source_text_.c_str(); }
00701
00702 const Cardinality& cardinality() const { return cardinality_; }
00703
00704
00705 void DescribeLocationTo(::std::ostream* os) const {
00706 *os << FormatFileLocation(file(), line()) << " ";
00707 }
00708
00709
00710
00711 void DescribeCallCountTo(::std::ostream* os) const
00712 GTEST_EXCLUSIVE_LOCK_REQUIRED_(g_gmock_mutex);
00713
00714
00715
00716 virtual void MaybeDescribeExtraMatcherTo(::std::ostream* os) = 0;
00717
00718 protected:
00719 friend class ::testing::Expectation;
00720 friend class UntypedFunctionMockerBase;
00721
00722 enum Clause {
00723
00724 kNone,
00725 kWith,
00726 kTimes,
00727 kInSequence,
00728 kAfter,
00729 kWillOnce,
00730 kWillRepeatedly,
00731 kRetiresOnSaturation
00732 };
00733
00734 typedef std::vector<const void*> UntypedActions;
00735
00736
00737
00738 virtual Expectation GetHandle() = 0;
00739
00740
00741 void AssertSpecProperty(bool property, const string& failure_message) const {
00742 Assert(property, file_, line_, failure_message);
00743 }
00744
00745
00746 void ExpectSpecProperty(bool property, const string& failure_message) const {
00747 Expect(property, file_, line_, failure_message);
00748 }
00749
00750
00751
00752 void SpecifyCardinality(const Cardinality& cardinality);
00753
00754
00755
00756 bool cardinality_specified() const { return cardinality_specified_; }
00757
00758
00759 void set_cardinality(const Cardinality& a_cardinality) {
00760 cardinality_ = a_cardinality;
00761 }
00762
00763
00764
00765
00766
00767
00768 void RetireAllPreRequisites()
00769 GTEST_EXCLUSIVE_LOCK_REQUIRED_(g_gmock_mutex);
00770
00771
00772 bool is_retired() const
00773 GTEST_EXCLUSIVE_LOCK_REQUIRED_(g_gmock_mutex) {
00774 g_gmock_mutex.AssertHeld();
00775 return retired_;
00776 }
00777
00778
00779 void Retire()
00780 GTEST_EXCLUSIVE_LOCK_REQUIRED_(g_gmock_mutex) {
00781 g_gmock_mutex.AssertHeld();
00782 retired_ = true;
00783 }
00784
00785
00786 bool IsSatisfied() const
00787 GTEST_EXCLUSIVE_LOCK_REQUIRED_(g_gmock_mutex) {
00788 g_gmock_mutex.AssertHeld();
00789 return cardinality().IsSatisfiedByCallCount(call_count_);
00790 }
00791
00792
00793 bool IsSaturated() const
00794 GTEST_EXCLUSIVE_LOCK_REQUIRED_(g_gmock_mutex) {
00795 g_gmock_mutex.AssertHeld();
00796 return cardinality().IsSaturatedByCallCount(call_count_);
00797 }
00798
00799
00800 bool IsOverSaturated() const
00801 GTEST_EXCLUSIVE_LOCK_REQUIRED_(g_gmock_mutex) {
00802 g_gmock_mutex.AssertHeld();
00803 return cardinality().IsOverSaturatedByCallCount(call_count_);
00804 }
00805
00806
00807 bool AllPrerequisitesAreSatisfied() const
00808 GTEST_EXCLUSIVE_LOCK_REQUIRED_(g_gmock_mutex);
00809
00810
00811 void FindUnsatisfiedPrerequisites(ExpectationSet* result) const
00812 GTEST_EXCLUSIVE_LOCK_REQUIRED_(g_gmock_mutex);
00813
00814
00815 int call_count() const
00816 GTEST_EXCLUSIVE_LOCK_REQUIRED_(g_gmock_mutex) {
00817 g_gmock_mutex.AssertHeld();
00818 return call_count_;
00819 }
00820
00821
00822 void IncrementCallCount()
00823 GTEST_EXCLUSIVE_LOCK_REQUIRED_(g_gmock_mutex) {
00824 g_gmock_mutex.AssertHeld();
00825 call_count_++;
00826 }
00827
00828
00829
00830
00831
00832 void CheckActionCountIfNotDone() const
00833 GTEST_LOCK_EXCLUDED_(mutex_);
00834
00835 friend class ::testing::Sequence;
00836 friend class ::testing::internal::ExpectationTester;
00837
00838 template <typename Function>
00839 friend class TypedExpectation;
00840
00841
00842 void UntypedTimes(const Cardinality& a_cardinality);
00843
00844
00845
00846 const char* file_;
00847 int line_;
00848 const string source_text_;
00849
00850 bool cardinality_specified_;
00851 Cardinality cardinality_;
00852
00853
00854
00855
00856
00857
00858 ExpectationSet immediate_prerequisites_;
00859
00860
00861
00862 int call_count_;
00863 bool retired_;
00864 UntypedActions untyped_actions_;
00865 bool extra_matcher_specified_;
00866 bool repeated_action_specified_;
00867 bool retires_on_saturation_;
00868 Clause last_clause_;
00869 mutable bool action_count_checked_;
00870 mutable Mutex mutex_;
00871
00872 GTEST_DISALLOW_ASSIGN_(ExpectationBase);
00873 };
00874
00875
00876 template <typename F>
00877 class TypedExpectation : public ExpectationBase {
00878 public:
00879 typedef typename Function<F>::ArgumentTuple ArgumentTuple;
00880 typedef typename Function<F>::ArgumentMatcherTuple ArgumentMatcherTuple;
00881 typedef typename Function<F>::Result Result;
00882
00883 TypedExpectation(FunctionMockerBase<F>* owner,
00884 const char* a_file, int a_line, const string& a_source_text,
00885 const ArgumentMatcherTuple& m)
00886 : ExpectationBase(a_file, a_line, a_source_text),
00887 owner_(owner),
00888 matchers_(m),
00889
00890
00891
00892
00893 extra_matcher_(A<const ArgumentTuple&>()),
00894 repeated_action_(DoDefault()) {}
00895
00896 virtual ~TypedExpectation() {
00897
00898
00899 CheckActionCountIfNotDone();
00900 for (UntypedActions::const_iterator it = untyped_actions_.begin();
00901 it != untyped_actions_.end(); ++it) {
00902 delete static_cast<const Action<F>*>(*it);
00903 }
00904 }
00905
00906
00907 TypedExpectation& With(const Matcher<const ArgumentTuple&>& m) {
00908 if (last_clause_ == kWith) {
00909 ExpectSpecProperty(false,
00910 ".With() cannot appear "
00911 "more than once in an EXPECT_CALL().");
00912 } else {
00913 ExpectSpecProperty(last_clause_ < kWith,
00914 ".With() must be the first "
00915 "clause in an EXPECT_CALL().");
00916 }
00917 last_clause_ = kWith;
00918
00919 extra_matcher_ = m;
00920 extra_matcher_specified_ = true;
00921 return *this;
00922 }
00923
00924
00925 TypedExpectation& Times(const Cardinality& a_cardinality) {
00926 ExpectationBase::UntypedTimes(a_cardinality);
00927 return *this;
00928 }
00929
00930
00931 TypedExpectation& Times(int n) {
00932 return Times(Exactly(n));
00933 }
00934
00935
00936 TypedExpectation& InSequence(const Sequence& s) {
00937 ExpectSpecProperty(last_clause_ <= kInSequence,
00938 ".InSequence() cannot appear after .After(),"
00939 " .WillOnce(), .WillRepeatedly(), or "
00940 ".RetiresOnSaturation().");
00941 last_clause_ = kInSequence;
00942
00943 s.AddExpectation(GetHandle());
00944 return *this;
00945 }
00946 TypedExpectation& InSequence(const Sequence& s1, const Sequence& s2) {
00947 return InSequence(s1).InSequence(s2);
00948 }
00949 TypedExpectation& InSequence(const Sequence& s1, const Sequence& s2,
00950 const Sequence& s3) {
00951 return InSequence(s1, s2).InSequence(s3);
00952 }
00953 TypedExpectation& InSequence(const Sequence& s1, const Sequence& s2,
00954 const Sequence& s3, const Sequence& s4) {
00955 return InSequence(s1, s2, s3).InSequence(s4);
00956 }
00957 TypedExpectation& InSequence(const Sequence& s1, const Sequence& s2,
00958 const Sequence& s3, const Sequence& s4,
00959 const Sequence& s5) {
00960 return InSequence(s1, s2, s3, s4).InSequence(s5);
00961 }
00962
00963
00964 TypedExpectation& After(const ExpectationSet& s) {
00965 ExpectSpecProperty(last_clause_ <= kAfter,
00966 ".After() cannot appear after .WillOnce(),"
00967 " .WillRepeatedly(), or "
00968 ".RetiresOnSaturation().");
00969 last_clause_ = kAfter;
00970
00971 for (ExpectationSet::const_iterator it = s.begin(); it != s.end(); ++it) {
00972 immediate_prerequisites_ += *it;
00973 }
00974 return *this;
00975 }
00976 TypedExpectation& After(const ExpectationSet& s1, const ExpectationSet& s2) {
00977 return After(s1).After(s2);
00978 }
00979 TypedExpectation& After(const ExpectationSet& s1, const ExpectationSet& s2,
00980 const ExpectationSet& s3) {
00981 return After(s1, s2).After(s3);
00982 }
00983 TypedExpectation& After(const ExpectationSet& s1, const ExpectationSet& s2,
00984 const ExpectationSet& s3, const ExpectationSet& s4) {
00985 return After(s1, s2, s3).After(s4);
00986 }
00987 TypedExpectation& After(const ExpectationSet& s1, const ExpectationSet& s2,
00988 const ExpectationSet& s3, const ExpectationSet& s4,
00989 const ExpectationSet& s5) {
00990 return After(s1, s2, s3, s4).After(s5);
00991 }
00992
00993
00994 TypedExpectation& WillOnce(const Action<F>& action) {
00995 ExpectSpecProperty(last_clause_ <= kWillOnce,
00996 ".WillOnce() cannot appear after "
00997 ".WillRepeatedly() or .RetiresOnSaturation().");
00998 last_clause_ = kWillOnce;
00999
01000 untyped_actions_.push_back(new Action<F>(action));
01001 if (!cardinality_specified()) {
01002 set_cardinality(Exactly(static_cast<int>(untyped_actions_.size())));
01003 }
01004 return *this;
01005 }
01006
01007
01008 TypedExpectation& WillRepeatedly(const Action<F>& action) {
01009 if (last_clause_ == kWillRepeatedly) {
01010 ExpectSpecProperty(false,
01011 ".WillRepeatedly() cannot appear "
01012 "more than once in an EXPECT_CALL().");
01013 } else {
01014 ExpectSpecProperty(last_clause_ < kWillRepeatedly,
01015 ".WillRepeatedly() cannot appear "
01016 "after .RetiresOnSaturation().");
01017 }
01018 last_clause_ = kWillRepeatedly;
01019 repeated_action_specified_ = true;
01020
01021 repeated_action_ = action;
01022 if (!cardinality_specified()) {
01023 set_cardinality(AtLeast(static_cast<int>(untyped_actions_.size())));
01024 }
01025
01026
01027
01028 CheckActionCountIfNotDone();
01029 return *this;
01030 }
01031
01032
01033 TypedExpectation& RetiresOnSaturation() {
01034 ExpectSpecProperty(last_clause_ < kRetiresOnSaturation,
01035 ".RetiresOnSaturation() cannot appear "
01036 "more than once.");
01037 last_clause_ = kRetiresOnSaturation;
01038 retires_on_saturation_ = true;
01039
01040
01041
01042 CheckActionCountIfNotDone();
01043 return *this;
01044 }
01045
01046
01047
01048 const ArgumentMatcherTuple& matchers() const {
01049 return matchers_;
01050 }
01051
01052
01053 const Matcher<const ArgumentTuple&>& extra_matcher() const {
01054 return extra_matcher_;
01055 }
01056
01057
01058 const Action<F>& repeated_action() const { return repeated_action_; }
01059
01060
01061
01062 virtual void MaybeDescribeExtraMatcherTo(::std::ostream* os) {
01063 if (extra_matcher_specified_) {
01064 *os << " Expected args: ";
01065 extra_matcher_.DescribeTo(os);
01066 *os << "\n";
01067 }
01068 }
01069
01070 private:
01071 template <typename Function>
01072 friend class FunctionMockerBase;
01073
01074
01075
01076 virtual Expectation GetHandle() {
01077 return owner_->GetHandleOf(this);
01078 }
01079
01080
01081
01082
01083
01084
01085 bool Matches(const ArgumentTuple& args) const
01086 GTEST_EXCLUSIVE_LOCK_REQUIRED_(g_gmock_mutex) {
01087 g_gmock_mutex.AssertHeld();
01088 return TupleMatches(matchers_, args) && extra_matcher_.Matches(args);
01089 }
01090
01091
01092 bool ShouldHandleArguments(const ArgumentTuple& args) const
01093 GTEST_EXCLUSIVE_LOCK_REQUIRED_(g_gmock_mutex) {
01094 g_gmock_mutex.AssertHeld();
01095
01096
01097
01098
01099
01100 CheckActionCountIfNotDone();
01101 return !is_retired() && AllPrerequisitesAreSatisfied() && Matches(args);
01102 }
01103
01104
01105
01106 void ExplainMatchResultTo(
01107 const ArgumentTuple& args,
01108 ::std::ostream* os) const
01109 GTEST_EXCLUSIVE_LOCK_REQUIRED_(g_gmock_mutex) {
01110 g_gmock_mutex.AssertHeld();
01111
01112 if (is_retired()) {
01113 *os << " Expected: the expectation is active\n"
01114 << " Actual: it is retired\n";
01115 } else if (!Matches(args)) {
01116 if (!TupleMatches(matchers_, args)) {
01117 ExplainMatchFailureTupleTo(matchers_, args, os);
01118 }
01119 StringMatchResultListener listener;
01120 if (!extra_matcher_.MatchAndExplain(args, &listener)) {
01121 *os << " Expected args: ";
01122 extra_matcher_.DescribeTo(os);
01123 *os << "\n Actual: don't match";
01124
01125 internal::PrintIfNotEmpty(listener.str(), os);
01126 *os << "\n";
01127 }
01128 } else if (!AllPrerequisitesAreSatisfied()) {
01129 *os << " Expected: all pre-requisites are satisfied\n"
01130 << " Actual: the following immediate pre-requisites "
01131 << "are not satisfied:\n";
01132 ExpectationSet unsatisfied_prereqs;
01133 FindUnsatisfiedPrerequisites(&unsatisfied_prereqs);
01134 int i = 0;
01135 for (ExpectationSet::const_iterator it = unsatisfied_prereqs.begin();
01136 it != unsatisfied_prereqs.end(); ++it) {
01137 it->expectation_base()->DescribeLocationTo(os);
01138 *os << "pre-requisite #" << i++ << "\n";
01139 }
01140 *os << " (end of pre-requisites)\n";
01141 } else {
01142
01143
01144
01145
01146 *os << "The call matches the expectation.\n";
01147 }
01148 }
01149
01150
01151 const Action<F>& GetCurrentAction(
01152 const FunctionMockerBase<F>* mocker,
01153 const ArgumentTuple& args) const
01154 GTEST_EXCLUSIVE_LOCK_REQUIRED_(g_gmock_mutex) {
01155 g_gmock_mutex.AssertHeld();
01156 const int count = call_count();
01157 Assert(count >= 1, __FILE__, __LINE__,
01158 "call_count() is <= 0 when GetCurrentAction() is "
01159 "called - this should never happen.");
01160
01161 const int action_count = static_cast<int>(untyped_actions_.size());
01162 if (action_count > 0 && !repeated_action_specified_ &&
01163 count > action_count) {
01164
01165
01166 ::std::stringstream ss;
01167 DescribeLocationTo(&ss);
01168 ss << "Actions ran out in " << source_text() << "...\n"
01169 << "Called " << count << " times, but only "
01170 << action_count << " WillOnce()"
01171 << (action_count == 1 ? " is" : "s are") << " specified - ";
01172 mocker->DescribeDefaultActionTo(args, &ss);
01173 Log(kWarning, ss.str(), 1);
01174 }
01175
01176 return count <= action_count ?
01177 *static_cast<const Action<F>*>(untyped_actions_[count - 1]) :
01178 repeated_action();
01179 }
01180
01181
01182
01183
01184
01185
01186
01187
01188 const Action<F>* GetActionForArguments(
01189 const FunctionMockerBase<F>* mocker,
01190 const ArgumentTuple& args,
01191 ::std::ostream* what,
01192 ::std::ostream* why)
01193 GTEST_EXCLUSIVE_LOCK_REQUIRED_(g_gmock_mutex) {
01194 g_gmock_mutex.AssertHeld();
01195 if (IsSaturated()) {
01196
01197 IncrementCallCount();
01198 *what << "Mock function called more times than expected - ";
01199 mocker->DescribeDefaultActionTo(args, what);
01200 DescribeCallCountTo(why);
01201
01202
01203
01204
01205 return NULL;
01206 }
01207
01208 IncrementCallCount();
01209 RetireAllPreRequisites();
01210
01211 if (retires_on_saturation_ && IsSaturated()) {
01212 Retire();
01213 }
01214
01215
01216 *what << "Mock function call matches " << source_text() <<"...\n";
01217 return &(GetCurrentAction(mocker, args));
01218 }
01219
01220
01221
01222 FunctionMockerBase<F>* const owner_;
01223 ArgumentMatcherTuple matchers_;
01224 Matcher<const ArgumentTuple&> extra_matcher_;
01225 Action<F> repeated_action_;
01226
01227 GTEST_DISALLOW_COPY_AND_ASSIGN_(TypedExpectation);
01228 };
01229
01230
01231
01232
01233
01234
01235
01236
01237
01238
01239
01240
01241 GTEST_API_ void LogWithLocation(testing::internal::LogSeverity severity,
01242 const char* file, int line,
01243 const string& message);
01244
01245 template <typename F>
01246 class MockSpec {
01247 public:
01248 typedef typename internal::Function<F>::ArgumentTuple ArgumentTuple;
01249 typedef typename internal::Function<F>::ArgumentMatcherTuple
01250 ArgumentMatcherTuple;
01251
01252
01253
01254 explicit MockSpec(internal::FunctionMockerBase<F>* function_mocker)
01255 : function_mocker_(function_mocker) {}
01256
01257
01258
01259 internal::OnCallSpec<F>& InternalDefaultActionSetAt(
01260 const char* file, int line, const char* obj, const char* call) {
01261 LogWithLocation(internal::kInfo, file, line,
01262 string("ON_CALL(") + obj + ", " + call + ") invoked");
01263 return function_mocker_->AddNewOnCallSpec(file, line, matchers_);
01264 }
01265
01266
01267
01268 internal::TypedExpectation<F>& InternalExpectedAt(
01269 const char* file, int line, const char* obj, const char* call) {
01270 const string source_text(string("EXPECT_CALL(") + obj + ", " + call + ")");
01271 LogWithLocation(internal::kInfo, file, line, source_text + " invoked");
01272 return function_mocker_->AddNewExpectation(
01273 file, line, source_text, matchers_);
01274 }
01275
01276 private:
01277 template <typename Function>
01278 friend class internal::FunctionMocker;
01279
01280 void SetMatchers(const ArgumentMatcherTuple& matchers) {
01281 matchers_ = matchers;
01282 }
01283
01284
01285 internal::FunctionMockerBase<F>* const function_mocker_;
01286
01287 ArgumentMatcherTuple matchers_;
01288
01289 GTEST_DISALLOW_ASSIGN_(MockSpec);
01290 };
01291
01292
01293
01294
01295
01296
01297 #ifdef _MSC_VER
01298 # pragma warning(push) // Saves the current warning state.
01299 # pragma warning(disable:4355) // Temporarily disables warning 4355.
01300 #endif // _MSV_VER
01301
01302
01303
01304
01305
01306
01307
01308
01309
01310
01311 class UntypedActionResultHolderBase {
01312 public:
01313 virtual ~UntypedActionResultHolderBase() {}
01314
01315
01316 virtual void PrintAsActionResult(::std::ostream* os) const = 0;
01317 };
01318
01319
01320 template <typename T>
01321 class ActionResultHolder : public UntypedActionResultHolderBase {
01322 public:
01323 explicit ActionResultHolder(T a_value) : value_(a_value) {}
01324
01325
01326
01327
01328
01329 T GetValueAndDelete() const {
01330 T retval(value_);
01331 delete this;
01332 return retval;
01333 }
01334
01335
01336 virtual void PrintAsActionResult(::std::ostream* os) const {
01337 *os << "\n Returns: ";
01338
01339 UniversalPrinter<T>::Print(value_, os);
01340 }
01341
01342
01343
01344 template <typename F>
01345 static ActionResultHolder* PerformDefaultAction(
01346 const FunctionMockerBase<F>* func_mocker,
01347 const typename Function<F>::ArgumentTuple& args,
01348 const string& call_description) {
01349 return new ActionResultHolder(
01350 func_mocker->PerformDefaultAction(args, call_description));
01351 }
01352
01353
01354
01355 template <typename F>
01356 static ActionResultHolder*
01357 PerformAction(const Action<F>& action,
01358 const typename Function<F>::ArgumentTuple& args) {
01359 return new ActionResultHolder(action.Perform(args));
01360 }
01361
01362 private:
01363 T value_;
01364
01365
01366 GTEST_DISALLOW_ASSIGN_(ActionResultHolder);
01367 };
01368
01369
01370 template <>
01371 class ActionResultHolder<void> : public UntypedActionResultHolderBase {
01372 public:
01373 void GetValueAndDelete() const { delete this; }
01374
01375 virtual void PrintAsActionResult(::std::ostream* ) const {}
01376
01377
01378 template <typename F>
01379 static ActionResultHolder* PerformDefaultAction(
01380 const FunctionMockerBase<F>* func_mocker,
01381 const typename Function<F>::ArgumentTuple& args,
01382 const string& call_description) {
01383 func_mocker->PerformDefaultAction(args, call_description);
01384 return NULL;
01385 }
01386
01387
01388 template <typename F>
01389 static ActionResultHolder* PerformAction(
01390 const Action<F>& action,
01391 const typename Function<F>::ArgumentTuple& args) {
01392 action.Perform(args);
01393 return NULL;
01394 }
01395 };
01396
01397
01398
01399
01400 template <typename F>
01401 class FunctionMockerBase : public UntypedFunctionMockerBase {
01402 public:
01403 typedef typename Function<F>::Result Result;
01404 typedef typename Function<F>::ArgumentTuple ArgumentTuple;
01405 typedef typename Function<F>::ArgumentMatcherTuple ArgumentMatcherTuple;
01406
01407 FunctionMockerBase() : current_spec_(this) {}
01408
01409
01410
01411
01412 virtual ~FunctionMockerBase()
01413 GTEST_LOCK_EXCLUDED_(g_gmock_mutex) {
01414 MutexLock l(&g_gmock_mutex);
01415 VerifyAndClearExpectationsLocked();
01416 Mock::UnregisterLocked(this);
01417 ClearDefaultActionsLocked();
01418 }
01419
01420
01421
01422
01423 const OnCallSpec<F>* FindOnCallSpec(
01424 const ArgumentTuple& args) const {
01425 for (UntypedOnCallSpecs::const_reverse_iterator it
01426 = untyped_on_call_specs_.rbegin();
01427 it != untyped_on_call_specs_.rend(); ++it) {
01428 const OnCallSpec<F>* spec = static_cast<const OnCallSpec<F>*>(*it);
01429 if (spec->Matches(args))
01430 return spec;
01431 }
01432
01433 return NULL;
01434 }
01435
01436
01437
01438
01439
01440
01441
01442
01443 Result PerformDefaultAction(const ArgumentTuple& args,
01444 const string& call_description) const {
01445 const OnCallSpec<F>* const spec =
01446 this->FindOnCallSpec(args);
01447 if (spec != NULL) {
01448 return spec->GetAction().Perform(args);
01449 }
01450 const string message = call_description +
01451 "\n The mock function has no default action "
01452 "set, and its return type has no default value set.";
01453 #if GTEST_HAS_EXCEPTIONS
01454 if (!DefaultValue<Result>::Exists()) {
01455 throw std::runtime_error(message);
01456 }
01457 #else
01458 Assert(DefaultValue<Result>::Exists(), "", -1, message);
01459 #endif
01460 return DefaultValue<Result>::Get();
01461 }
01462
01463
01464
01465
01466
01467
01468 virtual UntypedActionResultHolderBase* UntypedPerformDefaultAction(
01469 const void* untyped_args,
01470 const string& call_description) const {
01471 const ArgumentTuple& args =
01472 *static_cast<const ArgumentTuple*>(untyped_args);
01473 return ResultHolder::PerformDefaultAction(this, args, call_description);
01474 }
01475
01476
01477
01478
01479
01480 virtual UntypedActionResultHolderBase* UntypedPerformAction(
01481 const void* untyped_action, const void* untyped_args) const {
01482
01483
01484 const Action<F> action = *static_cast<const Action<F>*>(untyped_action);
01485 const ArgumentTuple& args =
01486 *static_cast<const ArgumentTuple*>(untyped_args);
01487 return ResultHolder::PerformAction(action, args);
01488 }
01489
01490
01491
01492 virtual void ClearDefaultActionsLocked()
01493 GTEST_EXCLUSIVE_LOCK_REQUIRED_(g_gmock_mutex) {
01494 g_gmock_mutex.AssertHeld();
01495
01496
01497
01498
01499
01500
01501
01502
01503 UntypedOnCallSpecs specs_to_delete;
01504 untyped_on_call_specs_.swap(specs_to_delete);
01505
01506 g_gmock_mutex.Unlock();
01507 for (UntypedOnCallSpecs::const_iterator it =
01508 specs_to_delete.begin();
01509 it != specs_to_delete.end(); ++it) {
01510 delete static_cast<const OnCallSpec<F>*>(*it);
01511 }
01512
01513
01514
01515 g_gmock_mutex.Lock();
01516 }
01517
01518 protected:
01519 template <typename Function>
01520 friend class MockSpec;
01521
01522 typedef ActionResultHolder<Result> ResultHolder;
01523
01524
01525
01526
01527 Result InvokeWith(const ArgumentTuple& args)
01528 GTEST_LOCK_EXCLUDED_(g_gmock_mutex) {
01529 return static_cast<const ResultHolder*>(
01530 this->UntypedInvokeWith(&args))->GetValueAndDelete();
01531 }
01532
01533
01534 OnCallSpec<F>& AddNewOnCallSpec(
01535 const char* file, int line,
01536 const ArgumentMatcherTuple& m)
01537 GTEST_LOCK_EXCLUDED_(g_gmock_mutex) {
01538 Mock::RegisterUseByOnCallOrExpectCall(MockObject(), file, line);
01539 OnCallSpec<F>* const on_call_spec = new OnCallSpec<F>(file, line, m);
01540 untyped_on_call_specs_.push_back(on_call_spec);
01541 return *on_call_spec;
01542 }
01543
01544
01545 TypedExpectation<F>& AddNewExpectation(
01546 const char* file,
01547 int line,
01548 const string& source_text,
01549 const ArgumentMatcherTuple& m)
01550 GTEST_LOCK_EXCLUDED_(g_gmock_mutex) {
01551 Mock::RegisterUseByOnCallOrExpectCall(MockObject(), file, line);
01552 TypedExpectation<F>* const expectation =
01553 new TypedExpectation<F>(this, file, line, source_text, m);
01554 const linked_ptr<ExpectationBase> untyped_expectation(expectation);
01555 untyped_expectations_.push_back(untyped_expectation);
01556
01557
01558 Sequence* const implicit_sequence = g_gmock_implicit_sequence.get();
01559 if (implicit_sequence != NULL) {
01560 implicit_sequence->AddExpectation(Expectation(untyped_expectation));
01561 }
01562
01563 return *expectation;
01564 }
01565
01566
01567
01568 MockSpec<F>& current_spec() { return current_spec_; }
01569
01570 private:
01571 template <typename Func> friend class TypedExpectation;
01572
01573
01574
01575
01576
01577
01578 void DescribeDefaultActionTo(const ArgumentTuple& args,
01579 ::std::ostream* os) const {
01580 const OnCallSpec<F>* const spec = FindOnCallSpec(args);
01581
01582 if (spec == NULL) {
01583 *os << (internal::type_equals<Result, void>::value ?
01584 "returning directly.\n" :
01585 "returning default value.\n");
01586 } else {
01587 *os << "taking default action specified at:\n"
01588 << FormatFileLocation(spec->file(), spec->line()) << "\n";
01589 }
01590 }
01591
01592
01593
01594
01595 virtual void UntypedDescribeUninterestingCall(
01596 const void* untyped_args,
01597 ::std::ostream* os) const
01598 GTEST_LOCK_EXCLUDED_(g_gmock_mutex) {
01599 const ArgumentTuple& args =
01600 *static_cast<const ArgumentTuple*>(untyped_args);
01601 *os << "Uninteresting mock function call - ";
01602 DescribeDefaultActionTo(args, os);
01603 *os << " Function call: " << Name();
01604 UniversalPrint(args, os);
01605 }
01606
01607
01608
01609
01610
01611
01612
01613
01614
01615
01616
01617
01618
01619
01620
01621
01622
01623 virtual const ExpectationBase* UntypedFindMatchingExpectation(
01624 const void* untyped_args,
01625 const void** untyped_action, bool* is_excessive,
01626 ::std::ostream* what, ::std::ostream* why)
01627 GTEST_LOCK_EXCLUDED_(g_gmock_mutex) {
01628 const ArgumentTuple& args =
01629 *static_cast<const ArgumentTuple*>(untyped_args);
01630 MutexLock l(&g_gmock_mutex);
01631 TypedExpectation<F>* exp = this->FindMatchingExpectationLocked(args);
01632 if (exp == NULL) {
01633 this->FormatUnexpectedCallMessageLocked(args, what, why);
01634 return NULL;
01635 }
01636
01637
01638
01639
01640 *is_excessive = exp->IsSaturated();
01641 const Action<F>* action = exp->GetActionForArguments(this, args, what, why);
01642 if (action != NULL && action->IsDoDefault())
01643 action = NULL;
01644 *untyped_action = action;
01645 return exp;
01646 }
01647
01648
01649 virtual void UntypedPrintArgs(const void* untyped_args,
01650 ::std::ostream* os) const {
01651 const ArgumentTuple& args =
01652 *static_cast<const ArgumentTuple*>(untyped_args);
01653 UniversalPrint(args, os);
01654 }
01655
01656
01657
01658 TypedExpectation<F>* FindMatchingExpectationLocked(
01659 const ArgumentTuple& args) const
01660 GTEST_EXCLUSIVE_LOCK_REQUIRED_(g_gmock_mutex) {
01661 g_gmock_mutex.AssertHeld();
01662 for (typename UntypedExpectations::const_reverse_iterator it =
01663 untyped_expectations_.rbegin();
01664 it != untyped_expectations_.rend(); ++it) {
01665 TypedExpectation<F>* const exp =
01666 static_cast<TypedExpectation<F>*>(it->get());
01667 if (exp->ShouldHandleArguments(args)) {
01668 return exp;
01669 }
01670 }
01671 return NULL;
01672 }
01673
01674
01675 void FormatUnexpectedCallMessageLocked(
01676 const ArgumentTuple& args,
01677 ::std::ostream* os,
01678 ::std::ostream* why) const
01679 GTEST_EXCLUSIVE_LOCK_REQUIRED_(g_gmock_mutex) {
01680 g_gmock_mutex.AssertHeld();
01681 *os << "\nUnexpected mock function call - ";
01682 DescribeDefaultActionTo(args, os);
01683 PrintTriedExpectationsLocked(args, why);
01684 }
01685
01686
01687
01688 void PrintTriedExpectationsLocked(
01689 const ArgumentTuple& args,
01690 ::std::ostream* why) const
01691 GTEST_EXCLUSIVE_LOCK_REQUIRED_(g_gmock_mutex) {
01692 g_gmock_mutex.AssertHeld();
01693 const int count = static_cast<int>(untyped_expectations_.size());
01694 *why << "Google Mock tried the following " << count << " "
01695 << (count == 1 ? "expectation, but it didn't match" :
01696 "expectations, but none matched")
01697 << ":\n";
01698 for (int i = 0; i < count; i++) {
01699 TypedExpectation<F>* const expectation =
01700 static_cast<TypedExpectation<F>*>(untyped_expectations_[i].get());
01701 *why << "\n";
01702 expectation->DescribeLocationTo(why);
01703 if (count > 1) {
01704 *why << "tried expectation #" << i << ": ";
01705 }
01706 *why << expectation->source_text() << "...\n";
01707 expectation->ExplainMatchResultTo(args, why);
01708 expectation->DescribeCallCountTo(why);
01709 }
01710 }
01711
01712
01713
01714 MockSpec<F> current_spec_;
01715
01716
01717
01718
01719
01720
01721
01722
01723
01724
01725
01726
01727
01728 GTEST_DISALLOW_COPY_AND_ASSIGN_(FunctionMockerBase);
01729 };
01730
01731 #ifdef _MSC_VER
01732 # pragma warning(pop) // Restores the warning state.
01733 #endif // _MSV_VER
01734
01735
01736
01737
01738
01739
01740
01741
01742
01743 void ReportUninterestingCall(CallReaction reaction, const string& msg);
01744
01745 }
01746
01747
01748
01749
01750
01751
01752 using internal::MockSpec;
01753
01754
01755
01756
01757
01758
01759
01760
01761
01762
01763
01764
01765
01766
01767
01768
01769 template <typename T>
01770 inline const T& Const(const T& x) { return x; }
01771
01772
01773 inline Expectation::Expectation(internal::ExpectationBase& exp)
01774 : expectation_base_(exp.GetHandle().expectation_base()) {}
01775
01776 }
01777
01778
01779
01780
01781
01782 #define GMOCK_ON_CALL_IMPL_(obj, call) \
01783 ((obj).gmock_##call).InternalDefaultActionSetAt(__FILE__, __LINE__, \
01784 #obj, #call)
01785 #define ON_CALL(obj, call) GMOCK_ON_CALL_IMPL_(obj, call)
01786
01787 #define GMOCK_EXPECT_CALL_IMPL_(obj, call) \
01788 ((obj).gmock_##call).InternalExpectedAt(__FILE__, __LINE__, #obj, #call)
01789 #define EXPECT_CALL(obj, call) GMOCK_EXPECT_CALL_IMPL_(obj, call)
01790
01791 #endif // GMOCK_INCLUDE_GMOCK_GMOCK_SPEC_BUILDERS_H_