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 #include "chrome/browser/ui/webui/sync_internals_ui.h" | 5 #include "chrome/browser/ui/webui/sync_internals_ui.h" |
6 | 6 |
7 #include <cstddef> | 7 #include <cstddef> |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/message_loop.h" | 10 #include "base/message_loop.h" |
11 #include "base/utf_string_conversions.h" | 11 #include "base/utf_string_conversions.h" |
12 #include "base/values.h" | 12 #include "base/values.h" |
13 #include "chrome/browser/sync/js/js_arg_list.h" | 13 #include "chrome/browser/sync/js/js_arg_list.h" |
14 #include "chrome/browser/sync/js/js_event_details.h" | 14 #include "chrome/browser/sync/js/js_event_details.h" |
15 #include "chrome/browser/sync/js/js_test_util.h" | 15 #include "chrome/browser/sync/js/js_test_util.h" |
16 #include "chrome/browser/sync/profile_sync_service_mock.h" | 16 #include "chrome/browser/sync/profile_sync_service_mock.h" |
17 #include "chrome/test/base/chrome_render_view_host_test_harness.h" | 17 #include "chrome/test/base/chrome_render_view_host_test_harness.h" |
18 #include "chrome/test/base/profile_mock.h" | 18 #include "chrome/test/base/profile_mock.h" |
19 #include "content/browser/tab_contents/test_tab_contents.h" | 19 #include "content/browser/tab_contents/test_tab_contents.h" |
| 20 #include "content/public/browser/web_ui_controller.h" |
20 #include "content/test/test_browser_thread.h" | 21 #include "content/test/test_browser_thread.h" |
21 #include "testing/gmock/include/gmock/gmock.h" | 22 #include "testing/gmock/include/gmock/gmock.h" |
22 #include "testing/gtest/include/gtest/gtest.h" | 23 #include "testing/gtest/include/gtest/gtest.h" |
23 | 24 |
24 namespace { | 25 namespace { |
25 | 26 |
26 using browser_sync::HasArgsAsList; | 27 using browser_sync::HasArgsAsList; |
27 using browser_sync::JsArgList; | 28 using browser_sync::JsArgList; |
28 using browser_sync::JsEventDetails; | 29 using browser_sync::JsEventDetails; |
29 using content::BrowserThread; | 30 using content::BrowserThread; |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
114 } | 115 } |
115 | 116 |
116 TEST_F(SyncInternalsUITestWithService, OnWebUISendBasic) { | 117 TEST_F(SyncInternalsUITestWithService, OnWebUISendBasic) { |
117 const std::string& name = "testName"; | 118 const std::string& name = "testName"; |
118 ListValue args; | 119 ListValue args; |
119 args.Append(Value::CreateIntegerValue(10)); | 120 args.Append(Value::CreateIntegerValue(10)); |
120 | 121 |
121 EXPECT_CALL(mock_js_controller_, | 122 EXPECT_CALL(mock_js_controller_, |
122 ProcessJsMessage(name, HasArgsAsList(args), _)); | 123 ProcessJsMessage(name, HasArgsAsList(args), _)); |
123 | 124 |
124 test_sync_internals_ui_->OnWebUISend(GURL(), name, args); | 125 test_sync_internals_ui_->controller()->OverrideHandleWebUIMessage( |
| 126 GURL(), name, args); |
125 } | 127 } |
126 | 128 |
127 // Tests with NULL ProfileSyncService. | 129 // Tests with NULL ProfileSyncService. |
128 class SyncInternalsUITestWithoutService | 130 class SyncInternalsUITestWithoutService |
129 : public ChromeRenderViewHostTestHarness { | 131 : public ChromeRenderViewHostTestHarness { |
130 protected: | 132 protected: |
131 SyncInternalsUITestWithoutService() {} | 133 SyncInternalsUITestWithoutService() {} |
132 | 134 |
133 virtual ~SyncInternalsUITestWithoutService() {} | 135 virtual ~SyncInternalsUITestWithoutService() {} |
134 | 136 |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
176 test_sync_internals_ui_->HandleJsReply( | 178 test_sync_internals_ui_->HandleJsReply( |
177 "testMessage", JsArgList(&args)); | 179 "testMessage", JsArgList(&args)); |
178 } | 180 } |
179 | 181 |
180 TEST_F(SyncInternalsUITestWithoutService, OnWebUISendBasic) { | 182 TEST_F(SyncInternalsUITestWithoutService, OnWebUISendBasic) { |
181 const std::string& name = "testName"; | 183 const std::string& name = "testName"; |
182 ListValue args; | 184 ListValue args; |
183 args.Append(Value::CreateIntegerValue(5)); | 185 args.Append(Value::CreateIntegerValue(5)); |
184 | 186 |
185 // Should drop the message. | 187 // Should drop the message. |
186 test_sync_internals_ui_->OnWebUISend(GURL(), name, args); | 188 test_sync_internals_ui_->controller()->OverrideHandleWebUIMessage( |
| 189 GURL(), name, args); |
187 } | 190 } |
188 | 191 |
189 // TODO(lipalani) - add a test case to test about:sync with a non null | 192 // TODO(lipalani) - add a test case to test about:sync with a non null |
190 // service. | 193 // service. |
191 TEST_F(SyncInternalsUITestWithoutService, OnWebUISendGetAboutInfo) { | 194 TEST_F(SyncInternalsUITestWithoutService, OnWebUISendGetAboutInfo) { |
192 const char kAboutInfoCall[] = | 195 const char kAboutInfoCall[] = |
193 "chrome.sync.getAboutInfo.handleReply({\"summary\":\"SYNC DISABLED\"});"; | 196 "chrome.sync.getAboutInfo.handleReply({\"summary\":\"SYNC DISABLED\"});"; |
194 EXPECT_CALL(*test_sync_internals_ui_, | 197 EXPECT_CALL(*test_sync_internals_ui_, |
195 ExecuteJavascript(ASCIIToUTF16(kAboutInfoCall))); | 198 ExecuteJavascript(ASCIIToUTF16(kAboutInfoCall))); |
196 | 199 |
197 ListValue args; | 200 ListValue args; |
198 test_sync_internals_ui_->OnWebUISend(GURL(), "getAboutInfo", args); | 201 test_sync_internals_ui_->controller()->OverrideHandleWebUIMessage( |
| 202 GURL(), "getAboutInfo", args); |
199 } | 203 } |
200 | 204 |
201 } // namespace | 205 } // namespace |
OLD | NEW |