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 |
| 9 using ::testing::MakeMatcher; |
| 10 using ::testing::MatchResultListener; |
| 11 using ::testing::Matcher; |
| 12 using ::testing::MatcherInterface; |
| 13 using ::testing::PrintToString; |
| 14 |
| 15 namespace syncer { |
| 16 |
| 17 namespace { |
| 18 |
| 19 class InvalidationStateEqMatcher |
| 20 : public MatcherInterface<const InvalidationState&> { |
| 21 public: |
| 22 explicit InvalidationStateEqMatcher(const InvalidationState& expected); |
| 23 |
| 24 virtual bool MatchAndExplain(const InvalidationState& actual, |
| 25 MatchResultListener* listener) const; |
| 26 virtual void DescribeTo(::std::ostream* os) const; |
| 27 virtual void DescribeNegationTo(::std::ostream* os) const; |
| 28 |
| 29 private: |
| 30 InvalidationState expected_; |
| 31 |
| 32 DISALLOW_COPY_AND_ASSIGN(InvalidationStateEqMatcher); |
| 33 }; |
| 34 |
| 35 InvalidationStateEqMatcher::InvalidationStateEqMatcher( |
| 36 const InvalidationState& expected) : expected_(expected) { |
| 37 } |
| 38 |
| 39 bool InvalidationStateEqMatcher::MatchAndExplain( |
| 40 const InvalidationState& actual, MatchResultListener* listener) const { |
| 41 return expected_.payload == actual.payload; |
| 42 } |
| 43 |
| 44 void InvalidationStateEqMatcher::DescribeTo(::std::ostream* os) const { |
| 45 *os << " is equal to " << PrintToString(expected_); |
| 46 } |
| 47 |
| 48 void InvalidationStateEqMatcher::DescribeNegationTo(::std::ostream* os) const { |
| 49 *os << " isn't equal to " << PrintToString(expected_); |
| 50 } |
| 51 |
| 52 } // namespace |
| 53 |
| 54 void PrintTo(const InvalidationState& state, ::std::ostream* os) { |
| 55 *os << "{ payload: " << state.payload << "}"; |
| 56 } |
| 57 |
| 58 Matcher<const InvalidationState&> Eq(const InvalidationState& expected) { |
| 59 return MakeMatcher(new InvalidationStateEqMatcher(expected)); |
| 60 } |
| 61 |
| 62 } // namespace syncer |
OLD | NEW |