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

Side by Side Diff: sync/js/js_test_util.cc

Issue 2130453004: [Sync] Move //sync to //components/sync. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase. Created 4 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 unified diff | Download patch
« no previous file with comments | « sync/js/js_test_util.h ('k') | sync/js/sync_js_controller.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "sync/js/js_test_util.h"
6
7 #include <memory>
8
9 #include "base/macros.h"
10 #include "sync/js/js_event_details.h"
11
12 namespace syncer {
13
14 void PrintTo(const JsEventDetails& details, ::std::ostream* os) {
15 *os << details.ToString();
16 }
17
18 namespace {
19
20 // Matcher implementation for HasDetails().
21 class HasDetailsMatcher
22 : public ::testing::MatcherInterface<const JsEventDetails&> {
23 public:
24 explicit HasDetailsMatcher(const JsEventDetails& expected_details)
25 : expected_details_(expected_details) {}
26
27 virtual ~HasDetailsMatcher() {}
28
29 virtual bool MatchAndExplain(
30 const JsEventDetails& details,
31 ::testing::MatchResultListener* listener) const {
32 // No need to annotate listener since we already define PrintTo().
33 return details.Get().Equals(&expected_details_.Get());
34 }
35
36 virtual void DescribeTo(::std::ostream* os) const {
37 *os << "has details " << expected_details_.ToString();
38 }
39
40 virtual void DescribeNegationTo(::std::ostream* os) const {
41 *os << "doesn't have details " << expected_details_.ToString();
42 }
43
44 private:
45 const JsEventDetails expected_details_;
46
47 DISALLOW_COPY_AND_ASSIGN(HasDetailsMatcher);
48 };
49
50 } // namespace
51
52 ::testing::Matcher<const JsEventDetails&> HasDetails(
53 const JsEventDetails& expected_details) {
54 return ::testing::MakeMatcher(new HasDetailsMatcher(expected_details));
55 }
56
57 ::testing::Matcher<const JsEventDetails&> HasDetailsAsDictionary(
58 const base::DictionaryValue& expected_details) {
59 std::unique_ptr<base::DictionaryValue> expected_details_copy(
60 expected_details.DeepCopy());
61 return HasDetails(JsEventDetails(expected_details_copy.get()));
62 }
63
64 MockJsBackend::MockJsBackend() {}
65
66 MockJsBackend::~MockJsBackend() {}
67
68 WeakHandle<JsBackend> MockJsBackend::AsWeakHandle() {
69 return MakeWeakHandle(AsWeakPtr());
70 }
71
72 MockJsController::MockJsController() {}
73
74 MockJsController::~MockJsController() {}
75
76 MockJsEventHandler::MockJsEventHandler() {}
77
78 WeakHandle<JsEventHandler> MockJsEventHandler::AsWeakHandle() {
79 return MakeWeakHandle(AsWeakPtr());
80 }
81
82 MockJsEventHandler::~MockJsEventHandler() {}
83
84 } // namespace syncer
85
OLDNEW
« no previous file with comments | « sync/js/js_test_util.h ('k') | sync/js/sync_js_controller.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698