OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
116 sync_internals_ui_->HandleJsEvent("testMessage", JsEventDetails()); | 116 sync_internals_ui_->HandleJsEvent("testMessage", JsEventDetails()); |
117 } | 117 } |
118 | 118 |
119 TEST_F(SyncInternalsUITestWithService, HandleJsReply) { | 119 TEST_F(SyncInternalsUITestWithService, HandleJsReply) { |
120 EXPECT_CALL( | 120 EXPECT_CALL( |
121 *web_ui_, | 121 *web_ui_, |
122 ExecuteJavascript( | 122 ExecuteJavascript( |
123 ASCIIToUTF16("chrome.sync.testMessage.handleReply(5,true);"))); | 123 ASCIIToUTF16("chrome.sync.testMessage.handleReply(5,true);"))); |
124 | 124 |
125 base::ListValue args; | 125 base::ListValue args; |
126 args.Append(new base::FundamentalValue(5)); | 126 args.Append(new base::Value(5)); |
127 args.Append(new base::FundamentalValue(true)); | 127 args.Append(new base::Value(true)); |
128 sync_internals_ui_->HandleJsReply("testMessage", JsArgList(&args)); | 128 sync_internals_ui_->HandleJsReply("testMessage", JsArgList(&args)); |
129 } | 129 } |
130 | 130 |
131 TEST_F(SyncInternalsUITestWithService, OnWebUISendBasic) { | 131 TEST_F(SyncInternalsUITestWithService, OnWebUISendBasic) { |
132 const std::string& name = "testName"; | 132 const std::string& name = "testName"; |
133 base::ListValue args; | 133 base::ListValue args; |
134 args.Append(new base::FundamentalValue(10)); | 134 args.Append(new base::Value(10)); |
135 | 135 |
136 EXPECT_CALL(mock_js_controller_, | 136 EXPECT_CALL(mock_js_controller_, |
137 ProcessJsMessage(name, HasArgsAsList(args), _)); | 137 ProcessJsMessage(name, HasArgsAsList(args), _)); |
138 | 138 |
139 sync_internals_ui_->OverrideHandleWebUIMessage(GURL(), name, args); | 139 sync_internals_ui_->OverrideHandleWebUIMessage(GURL(), name, args); |
140 } | 140 } |
141 | 141 |
142 // Tests with NULL ProfileSyncService. | 142 // Tests with NULL ProfileSyncService. |
143 class SyncInternalsUITestWithoutService | 143 class SyncInternalsUITestWithoutService |
144 : public ChromeRenderViewHostTestHarness { | 144 : public ChromeRenderViewHostTestHarness { |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
182 sync_internals_ui_->HandleJsEvent("testMessage", JsEventDetails()); | 182 sync_internals_ui_->HandleJsEvent("testMessage", JsEventDetails()); |
183 } | 183 } |
184 | 184 |
185 TEST_F(SyncInternalsUITestWithoutService, HandleJsReply) { | 185 TEST_F(SyncInternalsUITestWithoutService, HandleJsReply) { |
186 EXPECT_CALL( | 186 EXPECT_CALL( |
187 *web_ui_, | 187 *web_ui_, |
188 ExecuteJavascript( | 188 ExecuteJavascript( |
189 ASCIIToUTF16("chrome.sync.testMessage.handleReply(5,true);"))); | 189 ASCIIToUTF16("chrome.sync.testMessage.handleReply(5,true);"))); |
190 | 190 |
191 base::ListValue args; | 191 base::ListValue args; |
192 args.Append(new base::FundamentalValue(5)); | 192 args.Append(new base::Value(5)); |
193 args.Append(new base::FundamentalValue(true)); | 193 args.Append(new base::Value(true)); |
194 sync_internals_ui_->HandleJsReply( | 194 sync_internals_ui_->HandleJsReply( |
195 "testMessage", JsArgList(&args)); | 195 "testMessage", JsArgList(&args)); |
196 } | 196 } |
197 | 197 |
198 TEST_F(SyncInternalsUITestWithoutService, OnWebUISendBasic) { | 198 TEST_F(SyncInternalsUITestWithoutService, OnWebUISendBasic) { |
199 const std::string& name = "testName"; | 199 const std::string& name = "testName"; |
200 base::ListValue args; | 200 base::ListValue args; |
201 args.Append(new base::FundamentalValue(5)); | 201 args.Append(new base::Value(5)); |
202 | 202 |
203 // Should drop the message. | 203 // Should drop the message. |
204 sync_internals_ui_->OverrideHandleWebUIMessage(GURL(), name, args); | 204 sync_internals_ui_->OverrideHandleWebUIMessage(GURL(), name, args); |
205 } | 205 } |
206 | 206 |
207 // TODO(lipalani) - add a test case to test about:sync with a non null | 207 // TODO(lipalani) - add a test case to test about:sync with a non null |
208 // service. | 208 // service. |
209 TEST_F(SyncInternalsUITestWithoutService, OnWebUISendGetAboutInfo) { | 209 TEST_F(SyncInternalsUITestWithoutService, OnWebUISendGetAboutInfo) { |
210 const char kAboutInfoCall[] = | 210 const char kAboutInfoCall[] = |
211 "chrome.sync.getAboutInfo.handleReply({\"summary\":\"SYNC DISABLED\"});"; | 211 "chrome.sync.getAboutInfo.handleReply({\"summary\":\"SYNC DISABLED\"});"; |
212 EXPECT_CALL(*web_ui_, | 212 EXPECT_CALL(*web_ui_, |
213 ExecuteJavascript(ASCIIToUTF16(kAboutInfoCall))); | 213 ExecuteJavascript(ASCIIToUTF16(kAboutInfoCall))); |
214 | 214 |
215 base::ListValue args; | 215 base::ListValue args; |
216 sync_internals_ui_->OverrideHandleWebUIMessage( | 216 sync_internals_ui_->OverrideHandleWebUIMessage( |
217 GURL(), "getAboutInfo", args); | 217 GURL(), "getAboutInfo", args); |
218 } | 218 } |
219 | 219 |
220 } // namespace | 220 } // namespace |
221 | 221 |
222 */ | 222 */ |
OLD | NEW |