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