• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright (c) 2011 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 "chrome/browser/sync/js_test_util.h"
6 
7 #include "base/basictypes.h"
8 #include "chrome/browser/sync/js_arg_list.h"
9 
10 namespace browser_sync {
11 
PrintTo(const JsArgList & args,::std::ostream * os)12 void PrintTo(const JsArgList& args, ::std::ostream* os) {
13   *os << args.ToString();
14 }
15 
16 namespace {
17 
18 // Matcher implementation for HasArgs().
19 class HasArgsMatcher
20     : public ::testing::MatcherInterface<const JsArgList&> {
21  public:
HasArgsMatcher(const JsArgList & expected_args)22   explicit HasArgsMatcher(const JsArgList& expected_args)
23       : expected_args_(expected_args) {}
24 
~HasArgsMatcher()25   virtual ~HasArgsMatcher() {}
26 
MatchAndExplain(const JsArgList & args,::testing::MatchResultListener * listener) const27   virtual bool MatchAndExplain(
28       const JsArgList& args,
29       ::testing::MatchResultListener* listener) const {
30     // No need to annotate listener since we already define PrintTo().
31     return args.Get().Equals(&expected_args_.Get());
32   }
33 
DescribeTo(::std::ostream * os) const34   virtual void DescribeTo(::std::ostream* os) const {
35     *os << "has args " << expected_args_.ToString();
36   }
37 
DescribeNegationTo(::std::ostream * os) const38   virtual void DescribeNegationTo(::std::ostream* os) const {
39     *os << "doesn't have args " << expected_args_.ToString();
40   }
41 
42  private:
43   const JsArgList expected_args_;
44 
45   DISALLOW_COPY_AND_ASSIGN(HasArgsMatcher);
46 };
47 
48 }  // namespace
49 
HasArgs(const JsArgList & expected_args)50 ::testing::Matcher<const JsArgList&> HasArgs(const JsArgList& expected_args) {
51   return ::testing::MakeMatcher(new HasArgsMatcher(expected_args));
52 }
53 
HasArgsAsList(const ListValue & expected_args)54 ::testing::Matcher<const JsArgList&> HasArgsAsList(
55     const ListValue& expected_args) {
56   return HasArgs(JsArgList(expected_args));
57 }
58 
MockJsBackend()59 MockJsBackend::MockJsBackend() {}
60 
~MockJsBackend()61 MockJsBackend::~MockJsBackend() {}
62 
MockJsFrontend()63 MockJsFrontend::MockJsFrontend() {}
64 
~MockJsFrontend()65 MockJsFrontend::~MockJsFrontend() {}
66 
MockJsEventHandler()67 MockJsEventHandler::MockJsEventHandler() {}
68 
~MockJsEventHandler()69 MockJsEventHandler::~MockJsEventHandler() {}
70 
MockJsEventRouter()71 MockJsEventRouter::MockJsEventRouter() {}
72 
~MockJsEventRouter()73 MockJsEventRouter::~MockJsEventRouter() {}
74 
75 }  // namespace browser_sync
76 
77