Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(586)

Unified Diff: sync/internal_api/public/base/invalidation_state_test_util.cc

Issue 10837214: Refactor ModelTypePayloadMap and ObjectIdPayloadMap to StateMaps. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix unit test Created 8 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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..a27d0456a86de8fe2924fce6dbfedecd65e0e3cd
--- /dev/null
+++ b/sync/internal_api/public/base/invalidation_state_test_util.cc
@@ -0,0 +1,63 @@
+// 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"
+#include "sync/internal_api/public/base/invalidation_state.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:
+ const InvalidationState expected_;
+
+ 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
« no previous file with comments | « sync/internal_api/public/base/invalidation_state_test_util.h ('k') | sync/internal_api/public/base/model_type_payload_map.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698