summaryrefslogtreecommitdiffstats
path: root/chrome/browser/sync/js_test_util.cc
blob: bd4f9c0b3ddecc2304ecfd559bfb005ac5cf9a73 (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
// 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 "chrome/browser/sync/js_arg_list.h"

namespace browser_sync {

void PrintTo(const JsArgList& args, ::std::ostream* os) {
  *os << args.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);
};

}  // 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) {
  return HasArgs(JsArgList(expected_args));
}

MockJsBackend::MockJsBackend() {}

MockJsBackend::~MockJsBackend() {}

MockJsFrontend::MockJsFrontend() {}

MockJsFrontend::~MockJsFrontend() {}

MockJsEventHandler::MockJsEventHandler() {}

MockJsEventHandler::~MockJsEventHandler() {}

MockJsEventRouter::MockJsEventRouter() {}

MockJsEventRouter::~MockJsEventRouter() {}

}  // namespace browser_sync