Chromium Code Reviews| Index: sync/internal_api/public/base/invalidation_state_test_util.cc |
| diff --git a/sync/internal_api/public/base/invalidation_state_test_util.cc b/sync/internal_api/public/base/invalidation_state_test_util.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..41546c1e5d6221e4c2d7ef1dd1634bd6c9dee198 |
| --- /dev/null |
| +++ b/sync/internal_api/public/base/invalidation_state_test_util.cc |
| @@ -0,0 +1,62 @@ |
| +// Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#include "sync/internal_api/public/base/invalidation_state_test_util.h" |
| + |
| +#include "base/basictypes.h" |
| + |
| +namespace syncer { |
| + |
| +using ::testing::MakeMatcher; |
| +using ::testing::MatchResultListener; |
| +using ::testing::Matcher; |
| +using ::testing::MatcherInterface; |
| +using ::testing::PrintToString; |
| + |
| +namespace { |
| + |
| +class InvalidationStateEqMatcher |
| + : public MatcherInterface<const InvalidationState&> { |
| + public: |
| + explicit InvalidationStateEqMatcher(const InvalidationState& expected); |
| + |
| + virtual bool MatchAndExplain(const InvalidationState& actual, |
| + MatchResultListener* listener) const; |
| + virtual void DescribeTo(::std::ostream* os) const; |
| + virtual void DescribeNegationTo(::std::ostream* os) const; |
| + |
| + private: |
| + InvalidationState expected_; |
|
akalin
2012/08/22 23:24:27
const
dcheng
2012/08/22 23:47:11
Done.
|
| + |
| + DISALLOW_COPY_AND_ASSIGN(InvalidationStateEqMatcher); |
| +}; |
| + |
| +InvalidationStateEqMatcher::InvalidationStateEqMatcher( |
| + const InvalidationState& expected) : expected_(expected) { |
| +} |
| + |
| +bool InvalidationStateEqMatcher::MatchAndExplain( |
| + const InvalidationState& actual, MatchResultListener* listener) const { |
| + return expected_.payload == actual.payload; |
| +} |
| + |
| +void InvalidationStateEqMatcher::DescribeTo(::std::ostream* os) const { |
| + *os << " is equal to " << PrintToString(expected_); |
| +} |
| + |
| +void InvalidationStateEqMatcher::DescribeNegationTo(::std::ostream* os) const { |
| + *os << " isn't equal to " << PrintToString(expected_); |
| +} |
| + |
| +} // namespace |
| + |
| +void PrintTo(const InvalidationState& state, ::std::ostream* os) { |
| + *os << "{ payload: " << state.payload << " }"; |
| +} |
| + |
| +Matcher<const InvalidationState&> Eq(const InvalidationState& expected) { |
| + return MakeMatcher(new InvalidationStateEqMatcher(expected)); |
| +} |
| + |
| +} // namespace syncer |