OLD | NEW |
---|---|
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/chromeos/login/test/oobe_base_test.h" | 5 #include "chrome/browser/chromeos/login/test/oobe_base_test.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/json/json_file_value_serializer.h" | 8 #include "base/json/json_file_value_serializer.h" |
9 #include "base/message_loop/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
10 #include "base/path_service.h" | 10 #include "base/path_service.h" |
11 #include "chrome/browser/chrome_notification_types.h" | 11 #include "chrome/browser/chrome_notification_types.h" |
12 #include "chrome/browser/chromeos/login/existing_user_controller.h" | 12 #include "chrome/browser/chromeos/login/existing_user_controller.h" |
13 #include "chrome/browser/chromeos/login/test/https_forwarder.h" | 13 #include "chrome/browser/chromeos/login/test/https_forwarder.h" |
14 #include "chrome/browser/chromeos/login/ui/webui_login_view.h" | |
14 #include "chrome/browser/chromeos/net/network_portal_detector_test_impl.h" | 15 #include "chrome/browser/chromeos/net/network_portal_detector_test_impl.h" |
15 #include "chrome/browser/lifetime/application_lifetime.h" | 16 #include "chrome/browser/lifetime/application_lifetime.h" |
16 #include "chrome/browser/ui/webui/signin/inline_login_ui.h" | 17 #include "chrome/browser/ui/webui/signin/inline_login_ui.h" |
17 #include "chrome/common/chrome_constants.h" | 18 #include "chrome/common/chrome_constants.h" |
18 #include "chrome/common/chrome_paths.h" | 19 #include "chrome/common/chrome_paths.h" |
19 #include "chrome/common/chrome_switches.h" | 20 #include "chrome/common/chrome_switches.h" |
20 #include "chrome/common/pref_names.h" | 21 #include "chrome/common/pref_names.h" |
21 #include "chromeos/chromeos_switches.h" | 22 #include "chromeos/chromeos_switches.h" |
22 #include "chromeos/dbus/fake_shill_manager_client.h" | 23 #include "chromeos/dbus/fake_shill_manager_client.h" |
23 #include "components/policy/core/common/policy_switches.h" | 24 #include "components/policy/core/common/policy_switches.h" |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
119 kFakeLSIDCookie); | 120 kFakeLSIDCookie); |
120 } | 121 } |
121 | 122 |
122 // Restart the thread as the sandbox host process has already been spawned. | 123 // Restart the thread as the sandbox host process has already been spawned. |
123 embedded_test_server()->RestartThreadAndListen(); | 124 embedded_test_server()->RestartThreadAndListen(); |
124 | 125 |
125 login_screen_load_observer_.reset(new content::WindowedNotificationObserver( | 126 login_screen_load_observer_.reset(new content::WindowedNotificationObserver( |
126 chrome::NOTIFICATION_LOGIN_OR_LOCK_WEBUI_VISIBLE, | 127 chrome::NOTIFICATION_LOGIN_OR_LOCK_WEBUI_VISIBLE, |
127 content::NotificationService::AllSources())); | 128 content::NotificationService::AllSources())); |
128 | 129 |
130 js_checker_.set_web_contents(LoginDisplayHostImpl::default_host() | |
131 ->GetWebUILoginView() | |
132 ->GetWebContents()); | |
129 ExtensionApiTest::SetUpOnMainThread(); | 133 ExtensionApiTest::SetUpOnMainThread(); |
130 } | 134 } |
131 | 135 |
132 void OobeBaseTest::TearDownOnMainThread() { | 136 void OobeBaseTest::TearDownOnMainThread() { |
133 // If the login display is still showing, exit gracefully. | 137 // If the login display is still showing, exit gracefully. |
134 if (LoginDisplayHostImpl::default_host()) { | 138 if (LoginDisplayHostImpl::default_host()) { |
135 base::MessageLoop::current()->PostTask(FROM_HERE, | 139 base::MessageLoop::current()->PostTask(FROM_HERE, |
136 base::Bind(&chrome::AttemptExit)); | 140 base::Bind(&chrome::AttemptExit)); |
137 content::RunMessageLoop(); | 141 content::RunMessageLoop(); |
138 } | 142 } |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
205 portal_state); | 209 portal_state); |
206 network_portal_detector_->NotifyObserversForTesting(); | 210 network_portal_detector_->NotifyObserversForTesting(); |
207 } | 211 } |
208 | 212 |
209 base::Closure OobeBaseTest::SimulateNetworkPortalClosure() { | 213 base::Closure OobeBaseTest::SimulateNetworkPortalClosure() { |
210 return base::Bind(&OobeBaseTest::SimulateNetworkPortal, | 214 return base::Bind(&OobeBaseTest::SimulateNetworkPortal, |
211 base::Unretained(this)); | 215 base::Unretained(this)); |
212 } | 216 } |
213 | 217 |
214 void OobeBaseTest::JsExpect(const std::string& expression) { | 218 void OobeBaseTest::JsExpect(const std::string& expression) { |
215 bool result; | 219 JS().ExpectTrue(expression); |
216 ASSERT_TRUE(content::ExecuteScriptAndExtractBool( | |
217 GetLoginUI()->GetWebContents(), | |
218 "window.domAutomationController.send(!!(" + expression + "));", | |
219 &result)); | |
220 ASSERT_TRUE(result) << expression; | |
221 } | 220 } |
222 | 221 |
223 content::WebUI* OobeBaseTest::GetLoginUI() { | 222 content::WebUI* OobeBaseTest::GetLoginUI() { |
224 return static_cast<chromeos::LoginDisplayHostImpl*>( | 223 return static_cast<chromeos::LoginDisplayHostImpl*>( |
225 chromeos::LoginDisplayHostImpl::default_host())->GetOobeUI()->web_ui(); | 224 chromeos::LoginDisplayHostImpl::default_host())->GetOobeUI()->web_ui(); |
226 } | 225 } |
227 | 226 |
228 WebUILoginDisplay* OobeBaseTest::GetLoginDisplay() { | 227 WebUILoginDisplay* OobeBaseTest::GetLoginDisplay() { |
229 ExistingUserController* controller = | 228 ExistingUserController* controller = |
230 ExistingUserController::current_controller(); | 229 ExistingUserController::current_controller(); |
231 CHECK(controller); | 230 CHECK(controller); |
232 return static_cast<WebUILoginDisplay*>( | 231 return static_cast<WebUILoginDisplay*>( |
233 controller->login_display()); | 232 controller->login_display()); |
234 } | 233 } |
235 | 234 |
236 void OobeBaseTest::WaitForGaiaPageLoad() { | 235 void OobeBaseTest::WaitForGaiaPageLoad() { |
237 WaitForSigninScreen(); | 236 WaitForSigninScreen(); |
238 | 237 |
239 if (!use_webview()) | 238 if (!use_webview()) |
240 return; | 239 return; |
241 | 240 |
242 ASSERT_TRUE(content::ExecuteScript( | 241 ASSERT_TRUE(content::ExecuteScript( |
achuithb
2015/05/26 06:28:21
Shouldn't you update this code as well?
dzhioev (left Google)
2015/05/26 21:18:15
Done.
| |
243 GetLoginUI()->GetWebContents(), | 242 GetLoginUI()->GetWebContents(), |
244 "$('gaia-signin').gaiaAuthHost_.addEventListener('ready'," | 243 "$('gaia-signin').gaiaAuthHost_.addEventListener('ready'," |
245 "function() {" | 244 "function() {" |
246 "window.domAutomationController.setAutomationId(0);" | 245 "window.domAutomationController.setAutomationId(0);" |
247 "window.domAutomationController.send('GaiaReady');" | 246 "window.domAutomationController.send('GaiaReady');" |
248 "});")); | 247 "});")); |
249 | 248 |
250 content::DOMMessageQueue message_queue; | 249 content::DOMMessageQueue message_queue; |
251 std::string message; | 250 std::string message; |
252 do { | 251 do { |
(...skipping 24 matching lines...) Expand all Loading... | |
277 "document.getElementById('$FieldId').value = '$FieldValue';" | 276 "document.getElementById('$FieldId').value = '$FieldValue';" |
278 "var e = new Event('input');" | 277 "var e = new Event('input');" |
279 "document.getElementById('$FieldId').dispatchEvent(e);" | 278 "document.getElementById('$FieldId').dispatchEvent(e);" |
280 "})();"; | 279 "})();"; |
281 ReplaceSubstringsAfterOffset(&js, 0, "$FieldId", field_id); | 280 ReplaceSubstringsAfterOffset(&js, 0, "$FieldId", field_id); |
282 ReplaceSubstringsAfterOffset(&js, 0, "$FieldValue", field_value); | 281 ReplaceSubstringsAfterOffset(&js, 0, "$FieldValue", field_value); |
283 ExecuteJsInSigninFrame(js); | 282 ExecuteJsInSigninFrame(js); |
284 } | 283 } |
285 | 284 |
286 } // namespace chromeos | 285 } // namespace chromeos |
OLD | NEW |