| 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_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 "base/json/json_writer.h" | 8 #include "base/json/json_writer.h" |
| 9 #include "base/json/string_escape.h" | 9 #include "base/json/string_escape.h" |
| 10 #include "base/values.h" | 10 #include "base/values.h" |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 68 | 68 |
| 69 DISALLOW_COPY_AND_ASSIGN(InvalidationEqMatcher); | 69 DISALLOW_COPY_AND_ASSIGN(InvalidationEqMatcher); |
| 70 }; | 70 }; |
| 71 | 71 |
| 72 InvalidationEqMatcher::InvalidationEqMatcher( | 72 InvalidationEqMatcher::InvalidationEqMatcher( |
| 73 const Invalidation& expected) : expected_(expected) { | 73 const Invalidation& expected) : expected_(expected) { |
| 74 } | 74 } |
| 75 | 75 |
| 76 bool InvalidationEqMatcher::MatchAndExplain( | 76 bool InvalidationEqMatcher::MatchAndExplain( |
| 77 const Invalidation& actual, MatchResultListener* listener) const { | 77 const Invalidation& actual, MatchResultListener* listener) const { |
| 78 return expected_.payload == actual.payload; | 78 return expected_.GetPayload() == actual.GetPayload(); |
| 79 } | 79 } |
| 80 | 80 |
| 81 void InvalidationEqMatcher::DescribeTo(::std::ostream* os) const { | 81 void InvalidationEqMatcher::DescribeTo(::std::ostream* os) const { |
| 82 *os << " is equal to " << PrintToString(expected_); | 82 *os << " is equal to " << PrintToString(expected_); |
| 83 } | 83 } |
| 84 | 84 |
| 85 void InvalidationEqMatcher::DescribeNegationTo(::std::ostream* os) const { | 85 void InvalidationEqMatcher::DescribeNegationTo(::std::ostream* os) const { |
| 86 *os << " isn't equal to " << PrintToString(expected_); | 86 *os << " isn't equal to " << PrintToString(expected_); |
| 87 } | 87 } |
| 88 | 88 |
| 89 } // namespace | 89 } // namespace |
| 90 | 90 |
| 91 void PrintTo(const AckHandle& ack_handle, ::std::ostream* os ) { | 91 void PrintTo(const AckHandle& ack_handle, ::std::ostream* os ) { |
| 92 scoped_ptr<base::Value> value(ack_handle.ToValue()); | 92 scoped_ptr<base::Value> value(ack_handle.ToValue()); |
| 93 std::string printable_ack_handle; | 93 std::string printable_ack_handle; |
| 94 base::JSONWriter::Write(value.get(), &printable_ack_handle); | 94 base::JSONWriter::Write(value.get(), &printable_ack_handle); |
| 95 *os << "{ ack_handle: " << printable_ack_handle << " }"; | 95 *os << "{ ack_handle: " << printable_ack_handle << " }"; |
| 96 } | 96 } |
| 97 | 97 |
| 98 Matcher<const AckHandle&> Eq(const AckHandle& expected) { | 98 Matcher<const AckHandle&> Eq(const AckHandle& expected) { |
| 99 return MakeMatcher(new AckHandleEqMatcher(expected)); | 99 return MakeMatcher(new AckHandleEqMatcher(expected)); |
| 100 } | 100 } |
| 101 | 101 |
| 102 void PrintTo(const Invalidation& state, ::std::ostream* os) { | 102 void PrintTo(const Invalidation& state, ::std::ostream* os) { |
| 103 std::string printable_payload; | 103 std::string printable_payload; |
| 104 base::JsonDoubleQuote(state.payload, | 104 base::JsonDoubleQuote(state.GetPayload(), |
| 105 true /* put_in_quotes */, | 105 true /* put_in_quotes */, |
| 106 &printable_payload); | 106 &printable_payload); |
| 107 *os << "{ payload: " << printable_payload << " }"; | 107 *os << "{ payload: " << printable_payload << " }"; |
| 108 } | 108 } |
| 109 | 109 |
| 110 Matcher<const Invalidation&> Eq(const Invalidation& expected) { | 110 Matcher<const Invalidation&> Eq(const Invalidation& expected) { |
| 111 return MakeMatcher(new InvalidationEqMatcher(expected)); | 111 return MakeMatcher(new InvalidationEqMatcher(expected)); |
| 112 } | 112 } |
| 113 | 113 |
| 114 } // namespace syncer | 114 } // namespace syncer |
| OLD | NEW |