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