blob: 7884ea24dff697011cdafda548e6865110e9583f (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
|
// Copyright (c) 2011 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 "chrome/browser/sync/js_test_util.h"
#include "base/basictypes.h"
#include "base/memory/scoped_ptr.h"
#include "chrome/browser/sync/js_arg_list.h"
#include "chrome/browser/sync/js_event_details.h"
namespace browser_sync {
void PrintTo(const JsArgList& args, ::std::ostream* os) {
*os << args.ToString();
}
void PrintTo(const JsEventDetails& details, ::std::ostream* os) {
*os << details.ToString();
}
namespace {
// Matcher implementation for HasArgs().
class HasArgsMatcher
: public ::testing::MatcherInterface<const JsArgList&> {
public:
explicit HasArgsMatcher(const JsArgList& expected_args)
: expected_args_(expected_args) {}
virtual ~HasArgsMatcher() {}
virtual bool MatchAndExplain(
const JsArgList& args,
::testing::MatchResultListener* listener) const {
// No need to annotate listener since we already define PrintTo().
return args.Get().Equals(&expected_args_.Get());
}
virtual void DescribeTo(::std::ostream* os) const {
*os << "has args " << expected_args_.ToString();
}
virtual void DescribeNegationTo(::std::ostream* os) const {
*os << "doesn't have args " << expected_args_.ToString();
}
private:
const JsArgList expected_args_;
DISALLOW_COPY_AND_ASSIGN(HasArgsMatcher);
};
// Matcher implementation for HasDetails().
class HasDetailsMatcher
: public ::testing::MatcherInterface<const JsEventDetails&> {
public:
explicit HasDetailsMatcher(const JsEventDetails& expected_details)
: expected_details_(expected_details) {}
virtual ~HasDetailsMatcher() {}
virtual bool MatchAndExplain(
const JsEventDetails& details,
::testing::MatchResultListener* listener) const {
// No need to annotate listener since we already define PrintTo().
return details.Get().Equals(&expected_details_.Get());
}
virtual void DescribeTo(::std::ostream* os) const {
*os << "has details " << expected_details_.ToString();
}
virtual void DescribeNegationTo(::std::ostream* os) const {
*os << "doesn't have details " << expected_details_.ToString();
}
private:
const JsEventDetails expected_details_;
DISALLOW_COPY_AND_ASSIGN(HasDetailsMatcher);
};
} // namespace
::testing::Matcher<const JsArgList&> HasArgs(const JsArgList& expected_args) {
return ::testing::MakeMatcher(new HasArgsMatcher(expected_args));
}
::testing::Matcher<const JsArgList&> HasArgsAsList(
const ListValue& expected_args) {
scoped_ptr<ListValue> expected_args_copy(expected_args.DeepCopy());
return HasArgs(JsArgList(expected_args_copy.get()));
}
::testing::Matcher<const JsEventDetails&> HasDetails(
const JsEventDetails& expected_details) {
return ::testing::MakeMatcher(new HasDetailsMatcher(expected_details));
}
::testing::Matcher<const JsEventDetails&> HasDetailsAsDictionary(
const DictionaryValue& expected_details) {
scoped_ptr<DictionaryValue> expected_details_copy(
expected_details.DeepCopy());
return HasDetails(JsEventDetails(expected_details_copy.get()));
}
MockJsBackend::MockJsBackend() {}
MockJsBackend::~MockJsBackend() {}
MockJsFrontend::MockJsFrontend() {}
MockJsFrontend::~MockJsFrontend() {}
MockJsEventHandler::MockJsEventHandler() {}
MockJsEventHandler::~MockJsEventHandler() {}
MockJsEventRouter::MockJsEventRouter() {}
MockJsEventRouter::~MockJsEventRouter() {}
} // namespace browser_sync
|