blob: f596136a76c00e0e964382f2743a3fe826fada14 (
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
|
// 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/js/js_test_util.h"
#include "base/basictypes.h"
#include "base/memory/scoped_ptr.h"
#include "sync/js/js_event_details.h"
namespace syncer {
void PrintTo(const JsEventDetails& details, ::std::ostream* os) {
*os << details.ToString();
}
namespace {
// 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 JsEventDetails&> HasDetails(
const JsEventDetails& expected_details) {
return ::testing::MakeMatcher(new HasDetailsMatcher(expected_details));
}
::testing::Matcher<const JsEventDetails&> HasDetailsAsDictionary(
const base::DictionaryValue& expected_details) {
scoped_ptr<base::DictionaryValue> expected_details_copy(
expected_details.DeepCopy());
return HasDetails(JsEventDetails(expected_details_copy.get()));
}
MockJsBackend::MockJsBackend() {}
MockJsBackend::~MockJsBackend() {}
WeakHandle<JsBackend> MockJsBackend::AsWeakHandle() {
return MakeWeakHandle(AsWeakPtr());
}
MockJsController::MockJsController() {}
MockJsController::~MockJsController() {}
MockJsEventHandler::MockJsEventHandler() {}
WeakHandle<JsEventHandler> MockJsEventHandler::AsWeakHandle() {
return MakeWeakHandle(AsWeakPtr());
}
MockJsEventHandler::~MockJsEventHandler() {}
} // namespace syncer
|