Home | History | Annotate | Download | only in sync
      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 
     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:
     22   explicit HasArgsMatcher(const JsArgList& expected_args)
     23       : expected_args_(expected_args) {}
     24 
     25   virtual ~HasArgsMatcher() {}
     26 
     27   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 
     34   virtual void DescribeTo(::std::ostream* os) const {
     35     *os << "has args " << expected_args_.ToString();
     36   }
     37 
     38   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 
     50 ::testing::Matcher<const JsArgList&> HasArgs(const JsArgList& expected_args) {
     51   return ::testing::MakeMatcher(new HasArgsMatcher(expected_args));
     52 }
     53 
     54 ::testing::Matcher<const JsArgList&> HasArgsAsList(
     55     const ListValue& expected_args) {
     56   return HasArgs(JsArgList(expected_args));
     57 }
     58 
     59 MockJsBackend::MockJsBackend() {}
     60 
     61 MockJsBackend::~MockJsBackend() {}
     62 
     63 MockJsFrontend::MockJsFrontend() {}
     64 
     65 MockJsFrontend::~MockJsFrontend() {}
     66 
     67 MockJsEventHandler::MockJsEventHandler() {}
     68 
     69 MockJsEventHandler::~MockJsEventHandler() {}
     70 
     71 MockJsEventRouter::MockJsEventRouter() {}
     72 
     73 MockJsEventRouter::~MockJsEventRouter() {}
     74 
     75 }  // namespace browser_sync
     76 
     77