| 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 <set> | 6 #include <set> |
| 7 #include <string> | 7 #include <string> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "apps/app_window_registry.h" | 10 #include "apps/app_window_registry.h" |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 121 #include "net/base/url_util.h" | 121 #include "net/base/url_util.h" |
| 122 #include "net/http/http_status_code.h" | 122 #include "net/http/http_status_code.h" |
| 123 #include "net/test/embedded_test_server/embedded_test_server.h" | 123 #include "net/test/embedded_test_server/embedded_test_server.h" |
| 124 #include "net/test/embedded_test_server/http_request.h" | 124 #include "net/test/embedded_test_server/http_request.h" |
| 125 #include "net/test/embedded_test_server/http_response.h" | 125 #include "net/test/embedded_test_server/http_response.h" |
| 126 #include "net/url_request/test_url_fetcher_factory.h" | 126 #include "net/url_request/test_url_fetcher_factory.h" |
| 127 #include "net/url_request/url_fetcher_delegate.h" | 127 #include "net/url_request/url_fetcher_delegate.h" |
| 128 #include "net/url_request/url_request_status.h" | 128 #include "net/url_request/url_request_status.h" |
| 129 #include "policy/policy_constants.h" | 129 #include "policy/policy_constants.h" |
| 130 #include "testing/gmock/include/gmock/gmock.h" | 130 #include "testing/gmock/include/gmock/gmock.h" |
| 131 #include "third_party/icu/source/common/unicode/locid.h" |
| 131 #include "ui/base/l10n/l10n_util.h" | 132 #include "ui/base/l10n/l10n_util.h" |
| 132 #include "ui/base/window_open_disposition.h" | 133 #include "ui/base/window_open_disposition.h" |
| 133 #include "ui/gfx/image/image_skia.h" | 134 #include "ui/gfx/image/image_skia.h" |
| 134 #include "ui/views/widget/widget.h" | 135 #include "ui/views/widget/widget.h" |
| 135 #include "url/gurl.h" | 136 #include "url/gurl.h" |
| 136 //#include "third_party/cros_system_api/dbus/service_constants.h" | |
| 137 | 137 |
| 138 namespace em = enterprise_management; | 138 namespace em = enterprise_management; |
| 139 | 139 |
| 140 using chromeos::LoginScreenContext; | 140 using chromeos::LoginScreenContext; |
| 141 using testing::InvokeWithoutArgs; | 141 using testing::InvokeWithoutArgs; |
| 142 using testing::Return; | 142 using testing::Return; |
| 143 using testing::_; | 143 using testing::_; |
| 144 | 144 |
| 145 namespace policy { | 145 namespace policy { |
| 146 | 146 |
| (...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 453 | 453 |
| 454 InstallOwnerKey(); | 454 InstallOwnerKey(); |
| 455 MarkAsEnterpriseOwned(); | 455 MarkAsEnterpriseOwned(); |
| 456 | 456 |
| 457 InitializePolicy(); | 457 InitializePolicy(); |
| 458 } | 458 } |
| 459 | 459 |
| 460 virtual void SetUpOnMainThread() OVERRIDE { | 460 virtual void SetUpOnMainThread() OVERRIDE { |
| 461 DevicePolicyCrosBrowserTest::SetUpOnMainThread(); | 461 DevicePolicyCrosBrowserTest::SetUpOnMainThread(); |
| 462 | 462 |
| 463 initial_locale_ = g_browser_process->GetApplicationLocale(); |
| 464 initial_language_ = l10n_util::GetLanguage(initial_locale_); |
| 465 |
| 463 content::WindowedNotificationObserver( | 466 content::WindowedNotificationObserver( |
| 464 chrome::NOTIFICATION_LOGIN_OR_LOCK_WEBUI_VISIBLE, | 467 chrome::NOTIFICATION_LOGIN_OR_LOCK_WEBUI_VISIBLE, |
| 465 content::NotificationService::AllSources()).Wait(); | 468 content::NotificationService::AllSources()).Wait(); |
| 466 | 469 |
| 467 chromeos::LoginDisplayHostImpl* host = | 470 chromeos::LoginDisplayHostImpl* host = |
| 468 reinterpret_cast<chromeos::LoginDisplayHostImpl*>( | 471 reinterpret_cast<chromeos::LoginDisplayHostImpl*>( |
| 469 chromeos::LoginDisplayHostImpl::default_host()); | 472 chromeos::LoginDisplayHostImpl::default_host()); |
| 470 ASSERT_TRUE(host); | 473 ASSERT_TRUE(host); |
| 471 chromeos::WebUILoginView* web_ui_login_view = host->GetWebUILoginView(); | 474 chromeos::WebUILoginView* web_ui_login_view = host->GetWebUILoginView(); |
| 472 ASSERT_TRUE(web_ui_login_view); | 475 ASSERT_TRUE(web_ui_login_view); |
| (...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 694 EXPECT_EQ(layouts_from_locale.front(), | 697 EXPECT_EQ(layouts_from_locale.front(), |
| 695 input_method_manager->GetActiveIMEState() | 698 input_method_manager->GetActiveIMEState() |
| 696 ->GetCurrentInputMethod() | 699 ->GetCurrentInputMethod() |
| 697 .id()); | 700 .id()); |
| 698 } | 701 } |
| 699 | 702 |
| 700 const std::string user_id_1_; | 703 const std::string user_id_1_; |
| 701 const std::string user_id_2_; | 704 const std::string user_id_2_; |
| 702 const std::string public_session_input_method_id_; | 705 const std::string public_session_input_method_id_; |
| 703 | 706 |
| 707 std::string initial_locale_; |
| 708 std::string initial_language_; |
| 709 |
| 704 scoped_ptr<base::RunLoop> run_loop_; | 710 scoped_ptr<base::RunLoop> run_loop_; |
| 705 | 711 |
| 706 UserPolicyBuilder device_local_account_policy_; | 712 UserPolicyBuilder device_local_account_policy_; |
| 707 LocalPolicyTestServer test_server_; | 713 LocalPolicyTestServer test_server_; |
| 708 | 714 |
| 709 content::WebContents* contents_; | 715 content::WebContents* contents_; |
| 710 | 716 |
| 711 private: | 717 private: |
| 712 DISALLOW_COPY_AND_ASSIGN(DeviceLocalAccountTest); | 718 DISALLOW_COPY_AND_ASSIGN(DeviceLocalAccountTest); |
| 713 }; | 719 }; |
| (...skipping 676 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1390 | 1396 |
| 1391 // Deny the logout. | 1397 // Deny the logout. |
| 1392 dialog->GetWidget()->Close(); | 1398 dialog->GetWidget()->Close(); |
| 1393 dialog = NULL; | 1399 dialog = NULL; |
| 1394 base::RunLoop().RunUntilIdle(); | 1400 base::RunLoop().RunUntilIdle(); |
| 1395 | 1401 |
| 1396 app_window_registry->RemoveObserver(this); | 1402 app_window_registry->RemoveObserver(this); |
| 1397 }; | 1403 }; |
| 1398 | 1404 |
| 1399 IN_PROC_BROWSER_TEST_F(DeviceLocalAccountTest, NoRecommendedLocaleNoSwitch) { | 1405 IN_PROC_BROWSER_TEST_F(DeviceLocalAccountTest, NoRecommendedLocaleNoSwitch) { |
| 1400 const std::string initial_locale = g_browser_process->GetApplicationLocale(); | |
| 1401 | |
| 1402 UploadAndInstallDeviceLocalAccountPolicy(); | 1406 UploadAndInstallDeviceLocalAccountPolicy(); |
| 1403 AddPublicSessionToDevicePolicy(kAccountId1); | 1407 AddPublicSessionToDevicePolicy(kAccountId1); |
| 1404 | 1408 |
| 1405 WaitForPolicy(); | 1409 WaitForPolicy(); |
| 1406 | 1410 |
| 1407 // Click on the pod to expand it. Verify that the pod expands to its basic | 1411 // Click on the pod to expand it. Verify that the pod expands to its basic |
| 1408 // form as there are no recommended locales. | 1412 // form as there are no recommended locales. |
| 1409 bool advanced = false; | 1413 bool advanced = false; |
| 1410 ASSERT_TRUE(content::ExecuteScriptAndExtractBool( | 1414 ASSERT_TRUE(content::ExecuteScriptAndExtractBool( |
| 1411 contents_, | 1415 contents_, |
| 1412 base::StringPrintf( | 1416 base::StringPrintf( |
| 1413 "var pod =" | 1417 "var pod =" |
| 1414 " document.getElementById('pod-row').getPodWithUsername_('%s');" | 1418 " document.getElementById('pod-row').getPodWithUsername_('%s');" |
| 1415 "pod.click();" | 1419 "pod.click();" |
| 1416 "domAutomationController.send(pod.classList.contains('advanced'));", | 1420 "domAutomationController.send(pod.classList.contains('advanced'));", |
| 1417 user_id_1_.c_str()), | 1421 user_id_1_.c_str()), |
| 1418 &advanced)); | 1422 &advanced)); |
| 1419 EXPECT_FALSE(advanced); | 1423 EXPECT_FALSE(advanced); |
| 1420 | 1424 |
| 1425 // Verify that the construction of the pod's language list did not affect the |
| 1426 // current ICU locale. |
| 1427 EXPECT_EQ(initial_language_, icu::Locale::getDefault().getLanguage()); |
| 1428 |
| 1421 // Click the enter button to start the session. | 1429 // Click the enter button to start the session. |
| 1422 ASSERT_TRUE(content::ExecuteScript( | 1430 ASSERT_TRUE(content::ExecuteScript( |
| 1423 contents_, | 1431 contents_, |
| 1424 base::StringPrintf( | 1432 base::StringPrintf( |
| 1425 "document.getElementById('pod-row').getPodWithUsername_('%s')" | 1433 "document.getElementById('pod-row').getPodWithUsername_('%s')" |
| 1426 " .querySelector('.enter-button').click();", | 1434 " .querySelector('.enter-button').click();", |
| 1427 user_id_1_.c_str()))); | 1435 user_id_1_.c_str()))); |
| 1428 | 1436 |
| 1429 WaitForSessionStart(); | 1437 WaitForSessionStart(); |
| 1430 | 1438 |
| 1431 // Verify that the locale has not changed and the first keyboard layout | 1439 // Verify that the locale has not changed and the first keyboard layout |
| 1432 // applicable to the locale was chosen. | 1440 // applicable to the locale was chosen. |
| 1433 EXPECT_EQ(initial_locale, g_browser_process->GetApplicationLocale()); | 1441 EXPECT_EQ(initial_locale_, g_browser_process->GetApplicationLocale()); |
| 1442 EXPECT_EQ(initial_language_, icu::Locale::getDefault().getLanguage()); |
| 1434 VerifyKeyboardLayoutMatchesLocale(); | 1443 VerifyKeyboardLayoutMatchesLocale(); |
| 1435 } | 1444 } |
| 1436 | 1445 |
| 1437 IN_PROC_BROWSER_TEST_F(DeviceLocalAccountTest, NoRecommendedLocaleSwitch) { | 1446 IN_PROC_BROWSER_TEST_F(DeviceLocalAccountTest, NoRecommendedLocaleSwitch) { |
| 1438 UploadAndInstallDeviceLocalAccountPolicy(); | 1447 UploadAndInstallDeviceLocalAccountPolicy(); |
| 1439 AddPublicSessionToDevicePolicy(kAccountId1); | 1448 AddPublicSessionToDevicePolicy(kAccountId1); |
| 1440 | 1449 |
| 1441 WaitForPolicy(); | 1450 WaitForPolicy(); |
| 1442 | 1451 |
| 1443 // Click on the pod to expand it. Verify that the pod expands to its basic | 1452 // Click on the pod to expand it. Verify that the pod expands to its basic |
| 1444 // form as there are no recommended locales. | 1453 // form as there are no recommended locales. |
| 1445 bool advanced = false; | 1454 bool advanced = false; |
| 1446 ASSERT_TRUE(content::ExecuteScriptAndExtractBool( | 1455 ASSERT_TRUE(content::ExecuteScriptAndExtractBool( |
| 1447 contents_, | 1456 contents_, |
| 1448 base::StringPrintf( | 1457 base::StringPrintf( |
| 1449 "var pod =" | 1458 "var pod =" |
| 1450 " document.getElementById('pod-row').getPodWithUsername_('%s');" | 1459 " document.getElementById('pod-row').getPodWithUsername_('%s');" |
| 1451 "pod.click();" | 1460 "pod.click();" |
| 1452 "domAutomationController.send(pod.classList.contains('advanced'));", | 1461 "domAutomationController.send(pod.classList.contains('advanced'));", |
| 1453 user_id_1_.c_str()), | 1462 user_id_1_.c_str()), |
| 1454 &advanced)); | 1463 &advanced)); |
| 1455 EXPECT_FALSE(advanced); | 1464 EXPECT_FALSE(advanced); |
| 1456 | 1465 |
| 1466 // Verify that the construction of the pod's language list did not affect the |
| 1467 // current ICU locale. |
| 1468 EXPECT_EQ(initial_language_, icu::Locale::getDefault().getLanguage()); |
| 1469 |
| 1457 // Click the link that switches the pod to its advanced form. Verify that the | 1470 // Click the link that switches the pod to its advanced form. Verify that the |
| 1458 // pod switches from basic to advanced. | 1471 // pod switches from basic to advanced. |
| 1459 ASSERT_TRUE(content::ExecuteScriptAndExtractBool( | 1472 ASSERT_TRUE(content::ExecuteScriptAndExtractBool( |
| 1460 contents_, | 1473 contents_, |
| 1461 base::StringPrintf( | 1474 base::StringPrintf( |
| 1462 "var pod =" | 1475 "var pod =" |
| 1463 " document.getElementById('pod-row').getPodWithUsername_('%s');" | 1476 " document.getElementById('pod-row').getPodWithUsername_('%s');" |
| 1464 "pod.querySelector('.language-and-input').click();" | 1477 "pod.querySelector('.language-and-input').click();" |
| 1465 "domAutomationController.send(pod.classList.contains('advanced'));", | 1478 "domAutomationController.send(pod.classList.contains('advanced'));", |
| 1466 user_id_1_.c_str()), | 1479 user_id_1_.c_str()), |
| (...skipping 10 matching lines...) Expand all Loading... |
| 1477 "var event = document.createEvent('HTMLEvents');" | 1490 "var event = document.createEvent('HTMLEvents');" |
| 1478 "event.initEvent('change', false, true);" | 1491 "event.initEvent('change', false, true);" |
| 1479 "languageSelect.dispatchEvent(event);", | 1492 "languageSelect.dispatchEvent(event);", |
| 1480 user_id_1_.c_str(), | 1493 user_id_1_.c_str(), |
| 1481 kPublicSessionLocale))); | 1494 kPublicSessionLocale))); |
| 1482 | 1495 |
| 1483 // The UI will have requested an updated list of keyboard layouts at this | 1496 // The UI will have requested an updated list of keyboard layouts at this |
| 1484 // point. Wait for the constructions of this list to finish. | 1497 // point. Wait for the constructions of this list to finish. |
| 1485 WaitForGetKeyboardLayoutsForLocaleToFinish(); | 1498 WaitForGetKeyboardLayoutsForLocaleToFinish(); |
| 1486 | 1499 |
| 1500 // Verify that the construction of the updated keyboard layout list did not |
| 1501 // affect the current ICU locale. |
| 1502 EXPECT_EQ(initial_language_, icu::Locale::getDefault().getLanguage()); |
| 1503 |
| 1487 // Manually select a different keyboard layout and click the enter button to | 1504 // Manually select a different keyboard layout and click the enter button to |
| 1488 // start the session. | 1505 // start the session. |
| 1489 ASSERT_TRUE(content::ExecuteScript( | 1506 ASSERT_TRUE(content::ExecuteScript( |
| 1490 contents_, | 1507 contents_, |
| 1491 base::StringPrintf( | 1508 base::StringPrintf( |
| 1492 "var pod =" | 1509 "var pod =" |
| 1493 " document.getElementById('pod-row').getPodWithUsername_('%s');" | 1510 " document.getElementById('pod-row').getPodWithUsername_('%s');" |
| 1494 "pod.querySelector('.keyboard-select').value = '%s';" | 1511 "pod.querySelector('.keyboard-select').value = '%s';" |
| 1495 "pod.querySelector('.enter-button').click();", | 1512 "pod.querySelector('.enter-button').click();", |
| 1496 user_id_1_.c_str(), | 1513 user_id_1_.c_str(), |
| 1497 public_session_input_method_id_.c_str()))); | 1514 public_session_input_method_id_.c_str()))); |
| 1498 | 1515 |
| 1499 WaitForSessionStart(); | 1516 WaitForSessionStart(); |
| 1500 | 1517 |
| 1501 // Verify that the locale and keyboard layout have been applied. | 1518 // Verify that the locale and keyboard layout have been applied. |
| 1502 EXPECT_EQ(kPublicSessionLocale, g_browser_process->GetApplicationLocale()); | 1519 EXPECT_EQ(kPublicSessionLocale, g_browser_process->GetApplicationLocale()); |
| 1520 EXPECT_EQ(l10n_util::GetLanguage(kPublicSessionLocale), |
| 1521 icu::Locale::getDefault().getLanguage()); |
| 1503 EXPECT_EQ(public_session_input_method_id_, | 1522 EXPECT_EQ(public_session_input_method_id_, |
| 1504 chromeos::input_method::InputMethodManager::Get() | 1523 chromeos::input_method::InputMethodManager::Get() |
| 1505 ->GetActiveIMEState() | 1524 ->GetActiveIMEState() |
| 1506 ->GetCurrentInputMethod() | 1525 ->GetCurrentInputMethod() |
| 1507 .id()); | 1526 .id()); |
| 1508 } | 1527 } |
| 1509 | 1528 |
| 1510 IN_PROC_BROWSER_TEST_F(DeviceLocalAccountTest, OneRecommendedLocale) { | 1529 IN_PROC_BROWSER_TEST_F(DeviceLocalAccountTest, OneRecommendedLocale) { |
| 1511 // Specify a recommended locale. | 1530 // Specify a recommended locale. |
| 1512 SetRecommendedLocales(kSingleRecommendedLocale, | 1531 SetRecommendedLocales(kSingleRecommendedLocale, |
| (...skipping 10 matching lines...) Expand all Loading... |
| 1523 contents_, | 1542 contents_, |
| 1524 base::StringPrintf( | 1543 base::StringPrintf( |
| 1525 "var pod =" | 1544 "var pod =" |
| 1526 " document.getElementById('pod-row').getPodWithUsername_('%s');" | 1545 " document.getElementById('pod-row').getPodWithUsername_('%s');" |
| 1527 "pod.click();" | 1546 "pod.click();" |
| 1528 "domAutomationController.send(pod.classList.contains('advanced'));", | 1547 "domAutomationController.send(pod.classList.contains('advanced'));", |
| 1529 user_id_1_.c_str()), | 1548 user_id_1_.c_str()), |
| 1530 &advanced)); | 1549 &advanced)); |
| 1531 EXPECT_FALSE(advanced); | 1550 EXPECT_FALSE(advanced); |
| 1532 | 1551 |
| 1552 // Verify that the construction of the pod's language list did not affect the |
| 1553 // current ICU locale. |
| 1554 EXPECT_EQ(initial_language_, icu::Locale::getDefault().getLanguage()); |
| 1555 |
| 1533 // Click the enter button to start the session. | 1556 // Click the enter button to start the session. |
| 1534 ASSERT_TRUE(content::ExecuteScript( | 1557 ASSERT_TRUE(content::ExecuteScript( |
| 1535 contents_, | 1558 contents_, |
| 1536 base::StringPrintf( | 1559 base::StringPrintf( |
| 1537 "document.getElementById('pod-row').getPodWithUsername_('%s')" | 1560 "document.getElementById('pod-row').getPodWithUsername_('%s')" |
| 1538 " .querySelector('.enter-button').click();", | 1561 " .querySelector('.enter-button').click();", |
| 1539 user_id_1_.c_str()))); | 1562 user_id_1_.c_str()))); |
| 1540 | 1563 |
| 1541 WaitForSessionStart(); | 1564 WaitForSessionStart(); |
| 1542 | 1565 |
| 1543 // Verify that the recommended locale has been applied and the first keyboard | 1566 // Verify that the recommended locale has been applied and the first keyboard |
| 1544 // layout applicable to the locale was chosen. | 1567 // layout applicable to the locale was chosen. |
| 1545 EXPECT_EQ(kSingleRecommendedLocale[0], | 1568 EXPECT_EQ(kSingleRecommendedLocale[0], |
| 1546 g_browser_process->GetApplicationLocale()); | 1569 g_browser_process->GetApplicationLocale()); |
| 1570 EXPECT_EQ(l10n_util::GetLanguage(kSingleRecommendedLocale[0]), |
| 1571 icu::Locale::getDefault().getLanguage()); |
| 1547 VerifyKeyboardLayoutMatchesLocale(); | 1572 VerifyKeyboardLayoutMatchesLocale(); |
| 1548 } | 1573 } |
| 1549 | 1574 |
| 1550 IN_PROC_BROWSER_TEST_F(DeviceLocalAccountTest, MultipleRecommendedLocales) { | 1575 IN_PROC_BROWSER_TEST_F(DeviceLocalAccountTest, MultipleRecommendedLocales) { |
| 1551 // Specify recommended locales. | 1576 // Specify recommended locales. |
| 1552 SetRecommendedLocales(kRecommendedLocales1, arraysize(kRecommendedLocales1)); | 1577 SetRecommendedLocales(kRecommendedLocales1, arraysize(kRecommendedLocales1)); |
| 1553 UploadAndInstallDeviceLocalAccountPolicy(); | 1578 UploadAndInstallDeviceLocalAccountPolicy(); |
| 1554 AddPublicSessionToDevicePolicy(kAccountId1); | 1579 AddPublicSessionToDevicePolicy(kAccountId1); |
| 1555 AddPublicSessionToDevicePolicy(kAccountId2); | 1580 AddPublicSessionToDevicePolicy(kAccountId2); |
| 1556 | 1581 |
| 1557 WaitForPolicy(); | 1582 WaitForPolicy(); |
| 1558 | 1583 |
| 1559 // Click on the pod to expand it. Verify that the pod expands to its advanced | 1584 // Click on the pod to expand it. Verify that the pod expands to its advanced |
| 1560 // form directly as there are two or more recommended locales. | 1585 // form directly as there are two or more recommended locales. |
| 1561 bool advanced = false; | 1586 bool advanced = false; |
| 1562 ASSERT_TRUE(content::ExecuteScriptAndExtractBool( | 1587 ASSERT_TRUE(content::ExecuteScriptAndExtractBool( |
| 1563 contents_, | 1588 contents_, |
| 1564 base::StringPrintf( | 1589 base::StringPrintf( |
| 1565 "var pod =" | 1590 "var pod =" |
| 1566 " document.getElementById('pod-row').getPodWithUsername_('%s');" | 1591 " document.getElementById('pod-row').getPodWithUsername_('%s');" |
| 1567 "pod.click();" | 1592 "pod.click();" |
| 1568 "domAutomationController.send(pod.classList.contains('advanced'));", | 1593 "domAutomationController.send(pod.classList.contains('advanced'));", |
| 1569 user_id_1_.c_str()), | 1594 user_id_1_.c_str()), |
| 1570 &advanced)); | 1595 &advanced)); |
| 1571 EXPECT_TRUE(advanced); | 1596 EXPECT_TRUE(advanced); |
| 1572 | 1597 |
| 1598 // Verify that the construction of the pod's language list did not affect the |
| 1599 // current ICU locale. |
| 1600 EXPECT_EQ(initial_language_, icu::Locale::getDefault().getLanguage()); |
| 1601 |
| 1573 // Verify that the pod shows a list of locales beginning with the recommended | 1602 // Verify that the pod shows a list of locales beginning with the recommended |
| 1574 // ones, followed by others. | 1603 // ones, followed by others. |
| 1575 const std::string get_locale_list = base::StringPrintf( | 1604 const std::string get_locale_list = base::StringPrintf( |
| 1576 "var languageSelect = document.getElementById('pod-row')" | 1605 "var languageSelect = document.getElementById('pod-row')" |
| 1577 " .getPodWithUsername_('%s').querySelector('.language-select');" | 1606 " .getPodWithUsername_('%s').querySelector('.language-select');" |
| 1578 "var locales = [];" | 1607 "var locales = [];" |
| 1579 "for (var i = 0; i < languageSelect.length; ++i)" | 1608 "for (var i = 0; i < languageSelect.length; ++i)" |
| 1580 " locales.push(languageSelect.options[i].value);" | 1609 " locales.push(languageSelect.options[i].value);" |
| 1581 "domAutomationController.send(JSON.stringify(locales));", | 1610 "domAutomationController.send(JSON.stringify(locales));", |
| 1582 user_id_1_.c_str()); | 1611 user_id_1_.c_str()); |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1684 // Verify that the manually selected locale is still selected. | 1713 // Verify that the manually selected locale is still selected. |
| 1685 ASSERT_TRUE(content::ExecuteScriptAndExtractString(contents_, | 1714 ASSERT_TRUE(content::ExecuteScriptAndExtractString(contents_, |
| 1686 get_selected_locale, | 1715 get_selected_locale, |
| 1687 &selected_locale)); | 1716 &selected_locale)); |
| 1688 EXPECT_EQ(kPublicSessionLocale, selected_locale); | 1717 EXPECT_EQ(kPublicSessionLocale, selected_locale); |
| 1689 | 1718 |
| 1690 // The UI will request an updated list of keyboard layouts at this point. Wait | 1719 // The UI will request an updated list of keyboard layouts at this point. Wait |
| 1691 // for the constructions of this list to finish. | 1720 // for the constructions of this list to finish. |
| 1692 WaitForGetKeyboardLayoutsForLocaleToFinish(); | 1721 WaitForGetKeyboardLayoutsForLocaleToFinish(); |
| 1693 | 1722 |
| 1723 // Verify that the construction of the updated keyboard layout list did not |
| 1724 // affect the current ICU locale. |
| 1725 EXPECT_EQ(initial_locale_, icu::Locale::getDefault().getLanguage()); |
| 1726 |
| 1694 // Manually select a different keyboard layout. | 1727 // Manually select a different keyboard layout. |
| 1695 ASSERT_TRUE(content::ExecuteScript( | 1728 ASSERT_TRUE(content::ExecuteScript( |
| 1696 contents_, | 1729 contents_, |
| 1697 base::StringPrintf( | 1730 base::StringPrintf( |
| 1698 "document.getElementById('pod-row').getPodWithUsername_('%s')" | 1731 "document.getElementById('pod-row').getPodWithUsername_('%s')" |
| 1699 " .querySelector('.keyboard-select').value = '%s';", | 1732 " .querySelector('.keyboard-select').value = '%s';", |
| 1700 user_id_1_.c_str(), | 1733 user_id_1_.c_str(), |
| 1701 public_session_input_method_id_.c_str()))); | 1734 public_session_input_method_id_.c_str()))); |
| 1702 | 1735 |
| 1703 // Click on a different pod, causing focus to shift away and the pod to | 1736 // Click on a different pod, causing focus to shift away and the pod to |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1744 contents_, | 1777 contents_, |
| 1745 base::StringPrintf( | 1778 base::StringPrintf( |
| 1746 "document.getElementById('pod-row').getPodWithUsername_('%s')" | 1779 "document.getElementById('pod-row').getPodWithUsername_('%s')" |
| 1747 " .querySelector('.enter-button').click();", | 1780 " .querySelector('.enter-button').click();", |
| 1748 user_id_1_.c_str()))); | 1781 user_id_1_.c_str()))); |
| 1749 | 1782 |
| 1750 WaitForSessionStart(); | 1783 WaitForSessionStart(); |
| 1751 | 1784 |
| 1752 // Verify that the locale and keyboard layout have been applied. | 1785 // Verify that the locale and keyboard layout have been applied. |
| 1753 EXPECT_EQ(kPublicSessionLocale, g_browser_process->GetApplicationLocale()); | 1786 EXPECT_EQ(kPublicSessionLocale, g_browser_process->GetApplicationLocale()); |
| 1787 EXPECT_EQ(l10n_util::GetLanguage(kPublicSessionLocale), |
| 1788 icu::Locale::getDefault().getLanguage()); |
| 1754 EXPECT_EQ(public_session_input_method_id_, | 1789 EXPECT_EQ(public_session_input_method_id_, |
| 1755 chromeos::input_method::InputMethodManager::Get() | 1790 chromeos::input_method::InputMethodManager::Get() |
| 1756 ->GetActiveIMEState() | 1791 ->GetActiveIMEState() |
| 1757 ->GetCurrentInputMethod() | 1792 ->GetCurrentInputMethod() |
| 1758 .id()); | 1793 .id()); |
| 1759 } | 1794 } |
| 1760 | 1795 |
| 1761 IN_PROC_BROWSER_TEST_F(DeviceLocalAccountTest, | 1796 IN_PROC_BROWSER_TEST_F(DeviceLocalAccountTest, |
| 1762 AutoLoginWithoutRecommendedLocales) { | 1797 AutoLoginWithoutRecommendedLocales) { |
| 1763 const std::string initial_locale = g_browser_process->GetApplicationLocale(); | |
| 1764 | |
| 1765 UploadAndInstallDeviceLocalAccountPolicy(); | 1798 UploadAndInstallDeviceLocalAccountPolicy(); |
| 1766 AddPublicSessionToDevicePolicy(kAccountId1); | 1799 AddPublicSessionToDevicePolicy(kAccountId1); |
| 1767 EnableAutoLogin(); | 1800 EnableAutoLogin(); |
| 1768 | 1801 |
| 1769 WaitForPolicy(); | 1802 WaitForPolicy(); |
| 1770 | 1803 |
| 1771 WaitForSessionStart(); | 1804 WaitForSessionStart(); |
| 1772 | 1805 |
| 1773 // Verify that the locale has not changed and the first keyboard layout | 1806 // Verify that the locale has not changed and the first keyboard layout |
| 1774 // applicable to the locale was chosen. | 1807 // applicable to the locale was chosen. |
| 1775 EXPECT_EQ(initial_locale, g_browser_process->GetApplicationLocale()); | 1808 EXPECT_EQ(initial_locale_, g_browser_process->GetApplicationLocale()); |
| 1809 EXPECT_EQ(initial_language_, icu::Locale::getDefault().getLanguage()); |
| 1776 VerifyKeyboardLayoutMatchesLocale(); | 1810 VerifyKeyboardLayoutMatchesLocale(); |
| 1777 } | 1811 } |
| 1778 | 1812 |
| 1779 IN_PROC_BROWSER_TEST_F(DeviceLocalAccountTest, | 1813 IN_PROC_BROWSER_TEST_F(DeviceLocalAccountTest, |
| 1780 AutoLoginWithRecommendedLocales) { | 1814 AutoLoginWithRecommendedLocales) { |
| 1781 // Specify recommended locales. | 1815 // Specify recommended locales. |
| 1782 SetRecommendedLocales(kRecommendedLocales1, arraysize(kRecommendedLocales1)); | 1816 SetRecommendedLocales(kRecommendedLocales1, arraysize(kRecommendedLocales1)); |
| 1783 UploadAndInstallDeviceLocalAccountPolicy(); | 1817 UploadAndInstallDeviceLocalAccountPolicy(); |
| 1784 AddPublicSessionToDevicePolicy(kAccountId1); | 1818 AddPublicSessionToDevicePolicy(kAccountId1); |
| 1785 EnableAutoLogin(); | 1819 EnableAutoLogin(); |
| 1786 | 1820 |
| 1787 WaitForPolicy(); | 1821 WaitForPolicy(); |
| 1788 | 1822 |
| 1789 WaitForSessionStart(); | 1823 WaitForSessionStart(); |
| 1790 | 1824 |
| 1791 // Verify that the first recommended locale has been applied and the first | 1825 // Verify that the first recommended locale has been applied and the first |
| 1792 // keyboard layout applicable to the locale was chosen. | 1826 // keyboard layout applicable to the locale was chosen. |
| 1793 EXPECT_EQ(kRecommendedLocales1[0], g_browser_process->GetApplicationLocale()); | 1827 EXPECT_EQ(kRecommendedLocales1[0], g_browser_process->GetApplicationLocale()); |
| 1828 EXPECT_EQ(l10n_util::GetLanguage(kRecommendedLocales1[0]), |
| 1829 icu::Locale::getDefault().getLanguage()); |
| 1794 VerifyKeyboardLayoutMatchesLocale(); | 1830 VerifyKeyboardLayoutMatchesLocale(); |
| 1795 } | 1831 } |
| 1796 | 1832 |
| 1797 IN_PROC_BROWSER_TEST_F(DeviceLocalAccountTest, TermsOfServiceWithLocaleSwitch) { | 1833 IN_PROC_BROWSER_TEST_F(DeviceLocalAccountTest, TermsOfServiceWithLocaleSwitch) { |
| 1798 // Specify Terms of Service URL. | 1834 // Specify Terms of Service URL. |
| 1799 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady()); | 1835 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady()); |
| 1800 device_local_account_policy_.payload().mutable_termsofserviceurl()->set_value( | 1836 device_local_account_policy_.payload().mutable_termsofserviceurl()->set_value( |
| 1801 embedded_test_server()->GetURL( | 1837 embedded_test_server()->GetURL( |
| 1802 std::string("/") + kExistentTermsOfServicePath).spec()); | 1838 std::string("/") + kExistentTermsOfServicePath).spec()); |
| 1803 UploadAndInstallDeviceLocalAccountPolicy(); | 1839 UploadAndInstallDeviceLocalAccountPolicy(); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 1815 "var event = document.createEvent('HTMLEvents');" | 1851 "var event = document.createEvent('HTMLEvents');" |
| 1816 "event.initEvent('change', false, true);" | 1852 "event.initEvent('change', false, true);" |
| 1817 "languageSelect.dispatchEvent(event);", | 1853 "languageSelect.dispatchEvent(event);", |
| 1818 user_id_1_.c_str(), | 1854 user_id_1_.c_str(), |
| 1819 kPublicSessionLocale))); | 1855 kPublicSessionLocale))); |
| 1820 | 1856 |
| 1821 // The UI will have requested an updated list of keyboard layouts at this | 1857 // The UI will have requested an updated list of keyboard layouts at this |
| 1822 // point. Wait for the constructions of this list to finish. | 1858 // point. Wait for the constructions of this list to finish. |
| 1823 WaitForGetKeyboardLayoutsForLocaleToFinish(); | 1859 WaitForGetKeyboardLayoutsForLocaleToFinish(); |
| 1824 | 1860 |
| 1861 // Verify that the construction of the updated keyboard layout list did not |
| 1862 // affect the current ICU locale. |
| 1863 EXPECT_EQ(initial_language_, icu::Locale::getDefault().getLanguage()); |
| 1864 |
| 1825 // Set up an observer that will quit the message loop when login has succeeded | 1865 // Set up an observer that will quit the message loop when login has succeeded |
| 1826 // and the first wizard screen, if any, is being shown. | 1866 // and the first wizard screen, if any, is being shown. |
| 1827 base::RunLoop login_wait_run_loop; | 1867 base::RunLoop login_wait_run_loop; |
| 1828 chromeos::MockAuthStatusConsumer login_status_consumer; | 1868 chromeos::MockAuthStatusConsumer login_status_consumer; |
| 1829 EXPECT_CALL(login_status_consumer, OnAuthSuccess(_)).Times(1).WillOnce( | 1869 EXPECT_CALL(login_status_consumer, OnAuthSuccess(_)).Times(1).WillOnce( |
| 1830 InvokeWithoutArgs(&login_wait_run_loop, &base::RunLoop::Quit)); | 1870 InvokeWithoutArgs(&login_wait_run_loop, &base::RunLoop::Quit)); |
| 1831 chromeos::ExistingUserController* controller = | 1871 chromeos::ExistingUserController* controller = |
| 1832 chromeos::ExistingUserController::current_controller(); | 1872 chromeos::ExistingUserController::current_controller(); |
| 1833 ASSERT_TRUE(controller); | 1873 ASSERT_TRUE(controller); |
| 1834 controller->set_login_status_consumer(&login_status_consumer); | 1874 controller->set_login_status_consumer(&login_status_consumer); |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1871 "}" | 1911 "}" |
| 1872 "var observer = new MutationObserver(SendReplyIfDownloadDone);" | 1912 "var observer = new MutationObserver(SendReplyIfDownloadDone);" |
| 1873 "if (!SendReplyIfDownloadDone()) {" | 1913 "if (!SendReplyIfDownloadDone()) {" |
| 1874 " var options = { attributes: true, attributeFilter: [ 'class' ] };" | 1914 " var options = { attributes: true, attributeFilter: [ 'class' ] };" |
| 1875 " observer.observe(screenElement, options);" | 1915 " observer.observe(screenElement, options);" |
| 1876 "}", | 1916 "}", |
| 1877 &done)); | 1917 &done)); |
| 1878 | 1918 |
| 1879 // Verify that the locale and keyboard layout have been applied. | 1919 // Verify that the locale and keyboard layout have been applied. |
| 1880 EXPECT_EQ(kPublicSessionLocale, g_browser_process->GetApplicationLocale()); | 1920 EXPECT_EQ(kPublicSessionLocale, g_browser_process->GetApplicationLocale()); |
| 1921 EXPECT_EQ(l10n_util::GetLanguage(kPublicSessionLocale), |
| 1922 icu::Locale::getDefault().getLanguage()); |
| 1881 EXPECT_EQ(public_session_input_method_id_, | 1923 EXPECT_EQ(public_session_input_method_id_, |
| 1882 chromeos::input_method::InputMethodManager::Get() | 1924 chromeos::input_method::InputMethodManager::Get() |
| 1883 ->GetActiveIMEState() | 1925 ->GetActiveIMEState() |
| 1884 ->GetCurrentInputMethod() | 1926 ->GetCurrentInputMethod() |
| 1885 .id()); | 1927 .id()); |
| 1886 | 1928 |
| 1887 // Click the accept button. | 1929 // Click the accept button. |
| 1888 ASSERT_TRUE(content::ExecuteScript(contents_, | 1930 ASSERT_TRUE(content::ExecuteScript(contents_, |
| 1889 "$('tos-accept-button').click();")); | 1931 "$('tos-accept-button').click();")); |
| 1890 | 1932 |
| 1891 WaitForSessionStart(); | 1933 WaitForSessionStart(); |
| 1892 | 1934 |
| 1893 // Verify that the locale and keyboard layout are still in force. | 1935 // Verify that the locale and keyboard layout are still in force. |
| 1894 EXPECT_EQ(kPublicSessionLocale, g_browser_process->GetApplicationLocale()); | 1936 EXPECT_EQ(kPublicSessionLocale, g_browser_process->GetApplicationLocale()); |
| 1937 EXPECT_EQ(l10n_util::GetLanguage(kPublicSessionLocale), |
| 1938 icu::Locale::getDefault().getLanguage()); |
| 1895 EXPECT_EQ(public_session_input_method_id_, | 1939 EXPECT_EQ(public_session_input_method_id_, |
| 1896 chromeos::input_method::InputMethodManager::Get() | 1940 chromeos::input_method::InputMethodManager::Get() |
| 1897 ->GetActiveIMEState() | 1941 ->GetActiveIMEState() |
| 1898 ->GetCurrentInputMethod() | 1942 ->GetCurrentInputMethod() |
| 1899 .id()); | 1943 .id()); |
| 1900 } | 1944 } |
| 1901 | 1945 |
| 1902 class TermsOfServiceDownloadTest : public DeviceLocalAccountTest, | 1946 class TermsOfServiceDownloadTest : public DeviceLocalAccountTest, |
| 1903 public testing::WithParamInterface<bool> { | 1947 public testing::WithParamInterface<bool> { |
| 1904 }; | 1948 }; |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2024 ASSERT_TRUE(content::ExecuteScript(contents_, | 2068 ASSERT_TRUE(content::ExecuteScript(contents_, |
| 2025 "$('tos-accept-button').click();")); | 2069 "$('tos-accept-button').click();")); |
| 2026 | 2070 |
| 2027 WaitForSessionStart(); | 2071 WaitForSessionStart(); |
| 2028 } | 2072 } |
| 2029 | 2073 |
| 2030 INSTANTIATE_TEST_CASE_P(TermsOfServiceDownloadTestInstance, | 2074 INSTANTIATE_TEST_CASE_P(TermsOfServiceDownloadTestInstance, |
| 2031 TermsOfServiceDownloadTest, testing::Bool()); | 2075 TermsOfServiceDownloadTest, testing::Bool()); |
| 2032 | 2076 |
| 2033 } // namespace policy | 2077 } // namespace policy |
| OLD | NEW |