| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef CHROME_BROWSER_SYNC_JS_TEST_UTIL_H_ | 5 #ifndef CHROME_BROWSER_SYNC_JS_TEST_UTIL_H_ |
| 6 #define CHROME_BROWSER_SYNC_JS_TEST_UTIL_H_ | 6 #define CHROME_BROWSER_SYNC_JS_TEST_UTIL_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <ostream> | 9 #include <ostream> |
| 10 #include <string> | 10 #include <string> |
| 11 | 11 |
| 12 #include "chrome/browser/sync/js_backend.h" | 12 #include "chrome/browser/sync/js_backend.h" |
| 13 #include "chrome/browser/sync/js_frontend.h" | 13 #include "chrome/browser/sync/js_frontend.h" |
| 14 #include "chrome/browser/sync/js_event_handler.h" | 14 #include "chrome/browser/sync/js_event_handler.h" |
| 15 #include "chrome/browser/sync/js_event_router.h" | 15 #include "chrome/browser/sync/js_event_router.h" |
| 16 #include "testing/gmock/include/gmock/gmock.h" | 16 #include "testing/gmock/include/gmock/gmock.h" |
| 17 | 17 |
| 18 namespace base { |
| 18 class DictionaryValue; | 19 class DictionaryValue; |
| 19 class ListValue; | 20 class ListValue; |
| 21 } |
| 20 | 22 |
| 21 namespace browser_sync { | 23 namespace browser_sync { |
| 22 | 24 |
| 23 class JsArgList; | 25 class JsArgList; |
| 24 class JsEventDetails; | 26 class JsEventDetails; |
| 25 | 27 |
| 26 // Defined for googletest. Equivalent to "*os << args.ToString()". | 28 // Defined for googletest. Equivalent to "*os << args.ToString()". |
| 27 void PrintTo(const JsArgList& args, ::std::ostream* os); | 29 void PrintTo(const JsArgList& args, ::std::ostream* os); |
| 28 void PrintTo(const JsEventDetails& details, ::std::ostream* os); | 30 void PrintTo(const JsEventDetails& details, ::std::ostream* os); |
| 29 | 31 |
| 30 // A gmock matcher for JsArgList. Use like: | 32 // A gmock matcher for JsArgList. Use like: |
| 31 // | 33 // |
| 32 // EXPECT_CALL(mock, HandleJsMessageReply("foo", HasArgs(expected_args))); | 34 // EXPECT_CALL(mock, HandleJsMessageReply("foo", HasArgs(expected_args))); |
| 33 ::testing::Matcher<const JsArgList&> HasArgs(const JsArgList& expected_args); | 35 ::testing::Matcher<const JsArgList&> HasArgs(const JsArgList& expected_args); |
| 34 | 36 |
| 35 // Like HasArgs() but takes a ListValue instead. | 37 // Like HasArgs() but takes a ListValue instead. |
| 36 ::testing::Matcher<const JsArgList&> HasArgsAsList( | 38 ::testing::Matcher<const JsArgList&> HasArgsAsList( |
| 37 const ListValue& expected_args); | 39 const base::ListValue& expected_args); |
| 38 | 40 |
| 39 // A gmock matcher for JsEventDetails. Use like: | 41 // A gmock matcher for JsEventDetails. Use like: |
| 40 // | 42 // |
| 41 // EXPECT_CALL(mock, HandleJsEvent("foo", HasArgs(expected_details))); | 43 // EXPECT_CALL(mock, HandleJsEvent("foo", HasArgs(expected_details))); |
| 42 ::testing::Matcher<const JsEventDetails&> HasDetails( | 44 ::testing::Matcher<const JsEventDetails&> HasDetails( |
| 43 const JsEventDetails& expected_details); | 45 const JsEventDetails& expected_details); |
| 44 | 46 |
| 45 // Like HasDetails() but takes a DictionaryValue instead. | 47 // Like HasDetails() but takes a DictionaryValue instead. |
| 46 ::testing::Matcher<const JsEventDetails&> HasDetailsAsDictionary( | 48 ::testing::Matcher<const JsEventDetails&> HasDetailsAsDictionary( |
| 47 const DictionaryValue& expected_details); | 49 const base::DictionaryValue& expected_details); |
| 48 | 50 |
| 49 // Mocks. | 51 // Mocks. |
| 50 | 52 |
| 51 class MockJsBackend : public JsBackend { | 53 class MockJsBackend : public JsBackend { |
| 52 public: | 54 public: |
| 53 MockJsBackend(); | 55 MockJsBackend(); |
| 54 ~MockJsBackend(); | 56 ~MockJsBackend(); |
| 55 | 57 |
| 56 MOCK_METHOD1(SetParentJsEventRouter, void(JsEventRouter*)); | 58 MOCK_METHOD1(SetParentJsEventRouter, void(JsEventRouter*)); |
| 57 MOCK_METHOD0(RemoveParentJsEventRouter, void()); | 59 MOCK_METHOD0(RemoveParentJsEventRouter, void()); |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 91 MOCK_METHOD2(RouteJsEvent, | 93 MOCK_METHOD2(RouteJsEvent, |
| 92 void(const ::std::string&, const JsEventDetails&)); | 94 void(const ::std::string&, const JsEventDetails&)); |
| 93 MOCK_METHOD3(RouteJsMessageReply, | 95 MOCK_METHOD3(RouteJsMessageReply, |
| 94 void(const ::std::string&, const JsArgList&, | 96 void(const ::std::string&, const JsArgList&, |
| 95 const JsEventHandler*)); | 97 const JsEventHandler*)); |
| 96 }; | 98 }; |
| 97 | 99 |
| 98 } // namespace browser_sync | 100 } // namespace browser_sync |
| 99 | 101 |
| 100 #endif // CHROME_BROWSER_SYNC_JS_TEST_UTIL_H_ | 102 #endif // CHROME_BROWSER_SYNC_JS_TEST_UTIL_H_ |
| OLD | NEW |