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

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

Issue 11415049: Implement features needed for local ack handling in InvalidationStateTracker. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: ...... Created 8 years 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_test_util.cc
diff --git a/sync/internal_api/public/base/invalidation_test_util.cc b/sync/internal_api/public/base/invalidation_test_util.cc
index a95b65795df827439e3050e015170c983ce17127..3f3910be72f1f857c614a703da4e3ca10fb92a7e 100644
--- a/sync/internal_api/public/base/invalidation_test_util.cc
+++ b/sync/internal_api/public/base/invalidation_test_util.cc
@@ -5,6 +5,9 @@
#include "sync/internal_api/public/base/invalidation_test_util.h"
#include "base/basictypes.h"
+#include "base/json/json_writer.h"
+#include "base/json/string_escape.h"
+#include "base/values.h"
#include "sync/internal_api/public/base/invalidation.h"
namespace syncer {
@@ -17,6 +20,39 @@ using ::testing::PrintToString;
namespace {
+class AckHandleEqMatcher
+ : public MatcherInterface<const AckHandle&> {
+ public:
+ explicit AckHandleEqMatcher(const AckHandle& expected);
+
+ virtual bool MatchAndExplain(const AckHandle& actual,
+ MatchResultListener* listener) const;
+ virtual void DescribeTo(::std::ostream* os) const;
+ virtual void DescribeNegationTo(::std::ostream* os) const;
+
+ private:
+ const AckHandle expected_;
+
+ DISALLOW_COPY_AND_ASSIGN(AckHandleEqMatcher);
+};
+
+AckHandleEqMatcher::AckHandleEqMatcher(const AckHandle& expected)
+ : expected_(expected) {
+}
+
+bool AckHandleEqMatcher::MatchAndExplain(const AckHandle& actual,
+ MatchResultListener* listener) const {
+ return expected_.Equals(actual);
+}
+
+void AckHandleEqMatcher::DescribeTo(::std::ostream* os) const {
+ *os << " is equal to " << PrintToString(expected_);
+}
+
+void AckHandleEqMatcher::DescribeNegationTo(::std::ostream* os) const {
+ *os << " isn't equal to " << PrintToString(expected_);
+}
+
class InvalidationEqMatcher
: public MatcherInterface<const Invalidation&> {
public:
@@ -52,8 +88,23 @@ void InvalidationEqMatcher::DescribeNegationTo(::std::ostream* os) const {
} // namespace
-void PrintTo(const Invalidation& invalidation, ::std::ostream* os) {
- *os << "{ payload: " << invalidation.payload << " }";
+void PrintTo(const AckHandle& ack_handle, ::std::ostream* os ) {
+ scoped_ptr<base::Value> value(ack_handle.ToValue());
+ std::string printable_ack_handle;
+ base::JSONWriter::Write(value.get(), &printable_ack_handle);
+ *os << "{ ack_handle: " << printable_ack_handle << " }";
+}
+
+Matcher<const AckHandle&> Eq(const AckHandle& expected) {
+ return MakeMatcher(new AckHandleEqMatcher(expected));
+}
+
+void PrintTo(const Invalidation& state, ::std::ostream* os) {
+ std::string printable_payload;
+ base::JsonDoubleQuote(state.payload,
+ true /* put_in_quotes */,
+ &printable_payload);
+ *os << "{ payload: " << printable_payload << " }";
}
Matcher<const Invalidation&> Eq(const Invalidation& expected) {
« no previous file with comments | « sync/internal_api/public/base/invalidation_test_util.h ('k') | sync/notifier/fake_invalidation_state_tracker.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698