OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 <map> | 5 #include <map> |
6 #include <string> | 6 #include <string> |
7 | 7 |
8 #include "apps/app_window_registry.h" | 8 #include "apps/app_window_registry.h" |
9 #include "apps/ui/native_app_window.h" | 9 #include "apps/ui/native_app_window.h" |
10 #include "ash/shell.h" | 10 #include "ash/shell.h" |
(...skipping 464 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
475 | 475 |
476 void WaitForPolicy() { | 476 void WaitForPolicy() { |
477 // This observes the display name becoming available as this indicates | 477 // This observes the display name becoming available as this indicates |
478 // device-local account policy is fully loaded, which is a prerequisite for | 478 // device-local account policy is fully loaded, which is a prerequisite for |
479 // successful login. | 479 // successful login. |
480 content::WindowedNotificationObserver( | 480 content::WindowedNotificationObserver( |
481 chrome::NOTIFICATION_USER_LIST_CHANGED, | 481 chrome::NOTIFICATION_USER_LIST_CHANGED, |
482 base::Bind(&DisplayNameMatches, user_id_1_, kDisplayName)).Wait(); | 482 base::Bind(&DisplayNameMatches, user_id_1_, kDisplayName)).Wait(); |
483 } | 483 } |
484 | 484 |
| 485 void GetWebContents(content::WebContents** contents) { |
| 486 chromeos::LoginDisplayHostImpl* host = |
| 487 reinterpret_cast<chromeos::LoginDisplayHostImpl*>( |
| 488 chromeos::LoginDisplayHostImpl::default_host()); |
| 489 ASSERT_TRUE(host); |
| 490 chromeos::WebUILoginView* web_ui_login_view = host->GetWebUILoginView(); |
| 491 ASSERT_TRUE(web_ui_login_view); |
| 492 content::WebUI* web_ui = web_ui_login_view->GetWebUI(); |
| 493 ASSERT_TRUE(web_ui); |
| 494 *contents = web_ui->GetWebContents(); |
| 495 ASSERT_TRUE(*contents); |
| 496 } |
| 497 |
485 void WaitForLoginUI() { | 498 void WaitForLoginUI() { |
486 // Wait for the login UI to be ready. | 499 // Wait for the login UI to be ready. |
487 chromeos::LoginDisplayHostImpl* host = | 500 chromeos::LoginDisplayHostImpl* host = |
488 reinterpret_cast<chromeos::LoginDisplayHostImpl*>( | 501 reinterpret_cast<chromeos::LoginDisplayHostImpl*>( |
489 chromeos::LoginDisplayHostImpl::default_host()); | 502 chromeos::LoginDisplayHostImpl::default_host()); |
490 ASSERT_TRUE(host); | 503 ASSERT_TRUE(host); |
491 chromeos::OobeUI* oobe_ui = host->GetOobeUI(); | 504 chromeos::OobeUI* oobe_ui = host->GetOobeUI(); |
492 ASSERT_TRUE(oobe_ui); | 505 ASSERT_TRUE(oobe_ui); |
493 base::RunLoop run_loop; | 506 base::RunLoop run_loop; |
494 const bool oobe_ui_ready = oobe_ui->IsJSReady(run_loop.QuitClosure()); | 507 const bool oobe_ui_ready = oobe_ui->IsJSReady(run_loop.QuitClosure()); |
495 if (!oobe_ui_ready) | 508 if (!oobe_ui_ready) |
496 run_loop.Run(); | 509 run_loop.Run(); |
| 510 |
| 511 // The network selection screen changes the application locale on load and |
| 512 // once again on blur. Wait for the screen to load and blur it so that any |
| 513 // locale changes caused by this screen happen now and do not affect any |
| 514 // subsequent parts of the test. |
| 515 content::WebContents* contents = NULL; |
| 516 ASSERT_NO_FATAL_FAILURE(GetWebContents(&contents)); |
| 517 bool done = false; |
| 518 ASSERT_TRUE(content::ExecuteScriptAndExtractBool( |
| 519 contents, |
| 520 "var languageSelect = document.getElementById('language-select');" |
| 521 "var blurAndReportSuccess = function() {" |
| 522 " languageSelect.blur();" |
| 523 " domAutomationController.send(true);" |
| 524 "};" |
| 525 "if (document.activeElement == languageSelect)" |
| 526 " blurAndReportSuccess();" |
| 527 "else" |
| 528 " languageSelect.addEventListener('focus', blurAndReportSuccess);", |
| 529 &done)); |
497 } | 530 } |
498 | 531 |
499 void StartLogin(const std::string& locale, | 532 void StartLogin(const std::string& locale, |
500 const std::string& input_method) { | 533 const std::string& input_method) { |
501 // Start login into the device-local account. | 534 // Start login into the device-local account. |
502 chromeos::LoginDisplayHostImpl* host = | 535 chromeos::LoginDisplayHostImpl* host = |
503 reinterpret_cast<chromeos::LoginDisplayHostImpl*>( | 536 reinterpret_cast<chromeos::LoginDisplayHostImpl*>( |
504 chromeos::LoginDisplayHostImpl::default_host()); | 537 chromeos::LoginDisplayHostImpl::default_host()); |
505 ASSERT_TRUE(host); | 538 ASSERT_TRUE(host); |
506 host->StartSignInScreen(LoginScreenContext()); | 539 host->StartSignInScreen(LoginScreenContext()); |
(...skipping 730 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1237 | 1270 |
1238 // Verify that the Terms of Service screen is being shown. | 1271 // Verify that the Terms of Service screen is being shown. |
1239 chromeos::WizardController* wizard_controller = | 1272 chromeos::WizardController* wizard_controller = |
1240 chromeos::WizardController::default_controller(); | 1273 chromeos::WizardController::default_controller(); |
1241 ASSERT_TRUE(wizard_controller); | 1274 ASSERT_TRUE(wizard_controller); |
1242 ASSERT_TRUE(wizard_controller->current_screen()); | 1275 ASSERT_TRUE(wizard_controller->current_screen()); |
1243 EXPECT_EQ(chromeos::WizardController::kTermsOfServiceScreenName, | 1276 EXPECT_EQ(chromeos::WizardController::kTermsOfServiceScreenName, |
1244 wizard_controller->current_screen()->GetName()); | 1277 wizard_controller->current_screen()->GetName()); |
1245 | 1278 |
1246 // Wait for the Terms of Service to finish downloading. | 1279 // Wait for the Terms of Service to finish downloading. |
1247 chromeos::LoginDisplayHostImpl* host = | 1280 content::WebContents* contents = NULL; |
1248 reinterpret_cast<chromeos::LoginDisplayHostImpl*>( | 1281 ASSERT_NO_FATAL_FAILURE(GetWebContents(&contents)); |
1249 chromeos::LoginDisplayHostImpl::default_host()); | |
1250 ASSERT_TRUE(host); | |
1251 chromeos::WebUILoginView* web_ui_login_view = host->GetWebUILoginView(); | |
1252 ASSERT_TRUE(web_ui_login_view); | |
1253 content::WebUI* web_ui = web_ui_login_view->GetWebUI(); | |
1254 ASSERT_TRUE(web_ui); | |
1255 content::WebContents* contents = web_ui->GetWebContents(); | |
1256 ASSERT_TRUE(contents); | |
1257 bool done = false; | 1282 bool done = false; |
1258 ASSERT_TRUE(content::ExecuteScriptAndExtractBool(contents, | 1283 ASSERT_TRUE(content::ExecuteScriptAndExtractBool(contents, |
1259 "var screenElement = document.getElementById('terms-of-service');" | 1284 "var screenElement = document.getElementById('terms-of-service');" |
1260 "function SendReplyIfDownloadDone() {" | 1285 "function SendReplyIfDownloadDone() {" |
1261 " if (screenElement.classList.contains('tos-loading'))" | 1286 " if (screenElement.classList.contains('tos-loading'))" |
1262 " return false;" | 1287 " return false;" |
1263 " domAutomationController.send(true);" | 1288 " domAutomationController.send(true);" |
1264 " observer.disconnect();" | 1289 " observer.disconnect();" |
1265 " return true;" | 1290 " return true;" |
1266 "}" | 1291 "}" |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1327 // Verify that the Terms of Service screen is being shown. | 1352 // Verify that the Terms of Service screen is being shown. |
1328 chromeos::WizardController* wizard_controller = | 1353 chromeos::WizardController* wizard_controller = |
1329 chromeos::WizardController::default_controller(); | 1354 chromeos::WizardController::default_controller(); |
1330 ASSERT_TRUE(wizard_controller); | 1355 ASSERT_TRUE(wizard_controller); |
1331 ASSERT_TRUE(wizard_controller->current_screen()); | 1356 ASSERT_TRUE(wizard_controller->current_screen()); |
1332 EXPECT_EQ(chromeos::WizardController::kTermsOfServiceScreenName, | 1357 EXPECT_EQ(chromeos::WizardController::kTermsOfServiceScreenName, |
1333 wizard_controller->current_screen()->GetName()); | 1358 wizard_controller->current_screen()->GetName()); |
1334 | 1359 |
1335 // Wait for the Terms of Service to finish downloading, then get the status of | 1360 // Wait for the Terms of Service to finish downloading, then get the status of |
1336 // the screen's UI elements. | 1361 // the screen's UI elements. |
1337 chromeos::LoginDisplayHostImpl* host = | 1362 content::WebContents* contents = NULL; |
1338 reinterpret_cast<chromeos::LoginDisplayHostImpl*>( | 1363 ASSERT_NO_FATAL_FAILURE(GetWebContents(&contents)); |
1339 chromeos::LoginDisplayHostImpl::default_host()); | |
1340 ASSERT_TRUE(host); | |
1341 chromeos::WebUILoginView* web_ui_login_view = host->GetWebUILoginView(); | |
1342 ASSERT_TRUE(web_ui_login_view); | |
1343 content::WebUI* web_ui = web_ui_login_view->GetWebUI(); | |
1344 ASSERT_TRUE(web_ui); | |
1345 content::WebContents* contents = web_ui->GetWebContents(); | |
1346 ASSERT_TRUE(contents); | |
1347 std::string json; | 1364 std::string json; |
1348 ASSERT_TRUE(content::ExecuteScriptAndExtractString(contents, | 1365 ASSERT_TRUE(content::ExecuteScriptAndExtractString(contents, |
1349 "var screenElement = document.getElementById('terms-of-service');" | 1366 "var screenElement = document.getElementById('terms-of-service');" |
1350 "function SendReplyIfDownloadDone() {" | 1367 "function SendReplyIfDownloadDone() {" |
1351 " if (screenElement.classList.contains('tos-loading'))" | 1368 " if (screenElement.classList.contains('tos-loading'))" |
1352 " return false;" | 1369 " return false;" |
1353 " var status = {};" | 1370 " var status = {};" |
1354 " status.heading = document.getElementById('tos-heading').textContent;" | 1371 " status.heading = document.getElementById('tos-heading').textContent;" |
1355 " status.subheading =" | 1372 " status.subheading =" |
1356 " document.getElementById('tos-subheading').textContent;" | 1373 " document.getElementById('tos-subheading').textContent;" |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1425 ASSERT_TRUE(content::ExecuteScript(contents, | 1442 ASSERT_TRUE(content::ExecuteScript(contents, |
1426 "$('tos-accept-button').click();")); | 1443 "$('tos-accept-button').click();")); |
1427 | 1444 |
1428 WaitForSessionStart(); | 1445 WaitForSessionStart(); |
1429 } | 1446 } |
1430 | 1447 |
1431 INSTANTIATE_TEST_CASE_P(TermsOfServiceDownloadTestInstance, | 1448 INSTANTIATE_TEST_CASE_P(TermsOfServiceDownloadTestInstance, |
1432 TermsOfServiceDownloadTest, testing::Bool()); | 1449 TermsOfServiceDownloadTest, testing::Bool()); |
1433 | 1450 |
1434 } // namespace policy | 1451 } // namespace policy |
OLD | NEW |