OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "sync/internal_api/public/base/invalidation_state_test_util.h" |
| 6 |
| 7 #include "base/basictypes.h" |
| 8 #include "sync/internal_api/public/base/invalidation_state.h" |
| 9 |
| 10 namespace syncer { |
| 11 |
| 12 using ::testing::MakeMatcher; |
| 13 using ::testing::MatchResultListener; |
| 14 using ::testing::Matcher; |
| 15 using ::testing::MatcherInterface; |
| 16 using ::testing::PrintToString; |
| 17 |
| 18 namespace { |
| 19 |
| 20 class InvalidationStateEqMatcher |
| 21 : public MatcherInterface<const InvalidationState&> { |
| 22 public: |
| 23 explicit InvalidationStateEqMatcher(const InvalidationState& expected); |
| 24 |
| 25 virtual bool MatchAndExplain(const InvalidationState& actual, |
| 26 MatchResultListener* listener) const; |
| 27 virtual void DescribeTo(::std::ostream* os) const; |
| 28 virtual void DescribeNegationTo(::std::ostream* os) const; |
| 29 |
| 30 private: |
| 31 const InvalidationState expected_; |
| 32 |
| 33 DISALLOW_COPY_AND_ASSIGN(InvalidationStateEqMatcher); |
| 34 }; |
| 35 |
| 36 InvalidationStateEqMatcher::InvalidationStateEqMatcher( |
| 37 const InvalidationState& expected) : expected_(expected) { |
| 38 } |
| 39 |
| 40 bool InvalidationStateEqMatcher::MatchAndExplain( |
| 41 const InvalidationState& actual, MatchResultListener* listener) const { |
| 42 return expected_.payload == actual.payload; |
| 43 } |
| 44 |
| 45 void InvalidationStateEqMatcher::DescribeTo(::std::ostream* os) const { |
| 46 *os << " is equal to " << PrintToString(expected_); |
| 47 } |
| 48 |
| 49 void InvalidationStateEqMatcher::DescribeNegationTo(::std::ostream* os) const { |
| 50 *os << " isn't equal to " << PrintToString(expected_); |
| 51 } |
| 52 |
| 53 } // namespace |
| 54 |
| 55 void PrintTo(const InvalidationState& state, ::std::ostream* os) { |
| 56 *os << "{ payload: " << state.payload << " }"; |
| 57 } |
| 58 |
| 59 Matcher<const InvalidationState&> Eq(const InvalidationState& expected) { |
| 60 return MakeMatcher(new InvalidationStateEqMatcher(expected)); |
| 61 } |
| 62 |
| 63 } // namespace syncer |
OLD | NEW |