Upstreaming browser/ui/uikit_ui_util from iOS.
[chromium-blink-merge.git] / sync / js / js_test_util.cc
blobf596136a76c00e0e964382f2743a3fe826fada14
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.
5 #include "sync/js/js_test_util.h"
7 #include "base/basictypes.h"
8 #include "base/memory/scoped_ptr.h"
9 #include "sync/js/js_event_details.h"
11 namespace syncer {
13 void PrintTo(const JsEventDetails& details, ::std::ostream* os) {
14 *os << details.ToString();
17 namespace {
19 // Matcher implementation for HasDetails().
20 class HasDetailsMatcher
21 : public ::testing::MatcherInterface<const JsEventDetails&> {
22 public:
23 explicit HasDetailsMatcher(const JsEventDetails& expected_details)
24 : expected_details_(expected_details) {}
26 virtual ~HasDetailsMatcher() {}
28 virtual bool MatchAndExplain(
29 const JsEventDetails& details,
30 ::testing::MatchResultListener* listener) const {
31 // No need to annotate listener since we already define PrintTo().
32 return details.Get().Equals(&expected_details_.Get());
35 virtual void DescribeTo(::std::ostream* os) const {
36 *os << "has details " << expected_details_.ToString();
39 virtual void DescribeNegationTo(::std::ostream* os) const {
40 *os << "doesn't have details " << expected_details_.ToString();
43 private:
44 const JsEventDetails expected_details_;
46 DISALLOW_COPY_AND_ASSIGN(HasDetailsMatcher);
49 } // namespace
51 ::testing::Matcher<const JsEventDetails&> HasDetails(
52 const JsEventDetails& expected_details) {
53 return ::testing::MakeMatcher(new HasDetailsMatcher(expected_details));
56 ::testing::Matcher<const JsEventDetails&> HasDetailsAsDictionary(
57 const base::DictionaryValue& expected_details) {
58 scoped_ptr<base::DictionaryValue> expected_details_copy(
59 expected_details.DeepCopy());
60 return HasDetails(JsEventDetails(expected_details_copy.get()));
63 MockJsBackend::MockJsBackend() {}
65 MockJsBackend::~MockJsBackend() {}
67 WeakHandle<JsBackend> MockJsBackend::AsWeakHandle() {
68 return MakeWeakHandle(AsWeakPtr());
71 MockJsController::MockJsController() {}
73 MockJsController::~MockJsController() {}
75 MockJsEventHandler::MockJsEventHandler() {}
77 WeakHandle<JsEventHandler> MockJsEventHandler::AsWeakHandle() {
78 return MakeWeakHandle(AsWeakPtr());
81 MockJsEventHandler::~MockJsEventHandler() {}
83 } // namespace syncer