Chromium Code Reviews| 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 | |
| 463 content::WindowedNotificationObserver( | 465 content::WindowedNotificationObserver( |
| 464 chrome::NOTIFICATION_LOGIN_OR_LOCK_WEBUI_VISIBLE, | 466 chrome::NOTIFICATION_LOGIN_OR_LOCK_WEBUI_VISIBLE, |
| 465 content::NotificationService::AllSources()).Wait(); | 467 content::NotificationService::AllSources()).Wait(); |
| 466 | 468 |
| 467 chromeos::LoginDisplayHostImpl* host = | 469 chromeos::LoginDisplayHostImpl* host = |
| 468 reinterpret_cast<chromeos::LoginDisplayHostImpl*>( | 470 reinterpret_cast<chromeos::LoginDisplayHostImpl*>( |
| 469 chromeos::LoginDisplayHostImpl::default_host()); | 471 chromeos::LoginDisplayHostImpl::default_host()); |
| 470 ASSERT_TRUE(host); | 472 ASSERT_TRUE(host); |
| 471 chromeos::WebUILoginView* web_ui_login_view = host->GetWebUILoginView(); | 473 chromeos::WebUILoginView* web_ui_login_view = host->GetWebUILoginView(); |
| 472 ASSERT_TRUE(web_ui_login_view); | 474 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(), | 696 EXPECT_EQ(layouts_from_locale.front(), |
| 695 input_method_manager->GetActiveIMEState() | 697 input_method_manager->GetActiveIMEState() |
| 696 ->GetCurrentInputMethod() | 698 ->GetCurrentInputMethod() |
| 697 .id()); | 699 .id()); |
| 698 } | 700 } |
| 699 | 701 |
| 700 const std::string user_id_1_; | 702 const std::string user_id_1_; |
| 701 const std::string user_id_2_; | 703 const std::string user_id_2_; |
| 702 const std::string public_session_input_method_id_; | 704 const std::string public_session_input_method_id_; |
| 703 | 705 |
| 706 std::string initial_locale_; | |
| 707 | |
| 704 scoped_ptr<base::RunLoop> run_loop_; | 708 scoped_ptr<base::RunLoop> run_loop_; |
| 705 | 709 |
| 706 UserPolicyBuilder device_local_account_policy_; | 710 UserPolicyBuilder device_local_account_policy_; |
| 707 LocalPolicyTestServer test_server_; | 711 LocalPolicyTestServer test_server_; |
| 708 | 712 |
| 709 content::WebContents* contents_; | 713 content::WebContents* contents_; |
| 710 | 714 |
| 711 private: | 715 private: |
| 712 DISALLOW_COPY_AND_ASSIGN(DeviceLocalAccountTest); | 716 DISALLOW_COPY_AND_ASSIGN(DeviceLocalAccountTest); |
| 713 }; | 717 }; |
| (...skipping 676 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1390 | 1394 |
| 1391 // Deny the logout. | 1395 // Deny the logout. |
| 1392 dialog->GetWidget()->Close(); | 1396 dialog->GetWidget()->Close(); |
| 1393 dialog = NULL; | 1397 dialog = NULL; |
| 1394 base::RunLoop().RunUntilIdle(); | 1398 base::RunLoop().RunUntilIdle(); |
| 1395 | 1399 |
| 1396 app_window_registry->RemoveObserver(this); | 1400 app_window_registry->RemoveObserver(this); |
| 1397 }; | 1401 }; |
| 1398 | 1402 |
| 1399 IN_PROC_BROWSER_TEST_F(DeviceLocalAccountTest, NoRecommendedLocaleNoSwitch) { | 1403 IN_PROC_BROWSER_TEST_F(DeviceLocalAccountTest, NoRecommendedLocaleNoSwitch) { |
| 1400 const std::string initial_locale = g_browser_process->GetApplicationLocale(); | |
| 1401 | |
| 1402 UploadAndInstallDeviceLocalAccountPolicy(); | 1404 UploadAndInstallDeviceLocalAccountPolicy(); |
| 1403 AddPublicSessionToDevicePolicy(kAccountId1); | 1405 AddPublicSessionToDevicePolicy(kAccountId1); |
| 1404 | 1406 |
| 1405 WaitForPolicy(); | 1407 WaitForPolicy(); |
| 1406 | 1408 |
| 1407 // Click on the pod to expand it. Verify that the pod expands to its basic | 1409 // Click on the pod to expand it. Verify that the pod expands to its basic |
| 1408 // form as there are no recommended locales. | 1410 // form as there are no recommended locales. |
| 1409 bool advanced = false; | 1411 bool advanced = false; |
| 1410 ASSERT_TRUE(content::ExecuteScriptAndExtractBool( | 1412 ASSERT_TRUE(content::ExecuteScriptAndExtractBool( |
| 1411 contents_, | 1413 contents_, |
| 1412 base::StringPrintf( | 1414 base::StringPrintf( |
| 1413 "var pod =" | 1415 "var pod =" |
| 1414 " document.getElementById('pod-row').getPodWithUsername_('%s');" | 1416 " document.getElementById('pod-row').getPodWithUsername_('%s');" |
| 1415 "pod.click();" | 1417 "pod.click();" |
| 1416 "domAutomationController.send(pod.classList.contains('advanced'));", | 1418 "domAutomationController.send(pod.classList.contains('advanced'));", |
| 1417 user_id_1_.c_str()), | 1419 user_id_1_.c_str()), |
| 1418 &advanced)); | 1420 &advanced)); |
| 1419 EXPECT_FALSE(advanced); | 1421 EXPECT_FALSE(advanced); |
| 1422 EXPECT_EQ(l10n_util::GetLanguage(initial_locale_), | |
|
pneubeck (no reviews)
2014/08/19 15:09:30
from reading this file and the function declaratio
bartfab (slow)
2014/08/19 17:03:01
I added comments and made this code a bit more con
pneubeck (no reviews)
2014/08/20 09:03:40
FROM_HERE ? :-)
I suggested that to keep the redun
bartfab (slow)
2014/08/20 17:52:28
OK, you got me convinced. I moved the locale check
| |
| 1423 icu::Locale::getDefault().getLanguage()); | |
| 1420 | 1424 |
| 1421 // Click the enter button to start the session. | 1425 // Click the enter button to start the session. |
| 1422 ASSERT_TRUE(content::ExecuteScript( | 1426 ASSERT_TRUE(content::ExecuteScript( |
| 1423 contents_, | 1427 contents_, |
| 1424 base::StringPrintf( | 1428 base::StringPrintf( |
| 1425 "document.getElementById('pod-row').getPodWithUsername_('%s')" | 1429 "document.getElementById('pod-row').getPodWithUsername_('%s')" |
| 1426 " .querySelector('.enter-button').click();", | 1430 " .querySelector('.enter-button').click();", |
| 1427 user_id_1_.c_str()))); | 1431 user_id_1_.c_str()))); |
| 1428 | 1432 |
| 1429 WaitForSessionStart(); | 1433 WaitForSessionStart(); |
| 1430 | 1434 |
| 1431 // Verify that the locale has not changed and the first keyboard layout | 1435 // Verify that the locale has not changed and the first keyboard layout |
| 1432 // applicable to the locale was chosen. | 1436 // applicable to the locale was chosen. |
| 1433 EXPECT_EQ(initial_locale, g_browser_process->GetApplicationLocale()); | 1437 EXPECT_EQ(initial_locale_, g_browser_process->GetApplicationLocale()); |
| 1438 EXPECT_EQ(l10n_util::GetLanguage(initial_locale_), | |
| 1439 icu::Locale::getDefault().getLanguage()); | |
| 1434 VerifyKeyboardLayoutMatchesLocale(); | 1440 VerifyKeyboardLayoutMatchesLocale(); |
| 1435 } | 1441 } |
| 1436 | 1442 |
| 1437 IN_PROC_BROWSER_TEST_F(DeviceLocalAccountTest, NoRecommendedLocaleSwitch) { | 1443 IN_PROC_BROWSER_TEST_F(DeviceLocalAccountTest, NoRecommendedLocaleSwitch) { |
| 1438 UploadAndInstallDeviceLocalAccountPolicy(); | 1444 UploadAndInstallDeviceLocalAccountPolicy(); |
| 1439 AddPublicSessionToDevicePolicy(kAccountId1); | 1445 AddPublicSessionToDevicePolicy(kAccountId1); |
| 1440 | 1446 |
| 1441 WaitForPolicy(); | 1447 WaitForPolicy(); |
| 1442 | 1448 |
| 1443 // Click on the pod to expand it. Verify that the pod expands to its basic | 1449 // Click on the pod to expand it. Verify that the pod expands to its basic |
| 1444 // form as there are no recommended locales. | 1450 // form as there are no recommended locales. |
| 1445 bool advanced = false; | 1451 bool advanced = false; |
| 1446 ASSERT_TRUE(content::ExecuteScriptAndExtractBool( | 1452 ASSERT_TRUE(content::ExecuteScriptAndExtractBool( |
| 1447 contents_, | 1453 contents_, |
| 1448 base::StringPrintf( | 1454 base::StringPrintf( |
| 1449 "var pod =" | 1455 "var pod =" |
| 1450 " document.getElementById('pod-row').getPodWithUsername_('%s');" | 1456 " document.getElementById('pod-row').getPodWithUsername_('%s');" |
| 1451 "pod.click();" | 1457 "pod.click();" |
| 1452 "domAutomationController.send(pod.classList.contains('advanced'));", | 1458 "domAutomationController.send(pod.classList.contains('advanced'));", |
| 1453 user_id_1_.c_str()), | 1459 user_id_1_.c_str()), |
| 1454 &advanced)); | 1460 &advanced)); |
| 1455 EXPECT_FALSE(advanced); | 1461 EXPECT_FALSE(advanced); |
| 1462 EXPECT_EQ(l10n_util::GetLanguage(initial_locale_), | |
| 1463 icu::Locale::getDefault().getLanguage()); | |
| 1456 | 1464 |
| 1457 // Click the link that switches the pod to its advanced form. Verify that the | 1465 // Click the link that switches the pod to its advanced form. Verify that the |
| 1458 // pod switches from basic to advanced. | 1466 // pod switches from basic to advanced. |
| 1459 ASSERT_TRUE(content::ExecuteScriptAndExtractBool( | 1467 ASSERT_TRUE(content::ExecuteScriptAndExtractBool( |
| 1460 contents_, | 1468 contents_, |
| 1461 base::StringPrintf( | 1469 base::StringPrintf( |
| 1462 "var pod =" | 1470 "var pod =" |
| 1463 " document.getElementById('pod-row').getPodWithUsername_('%s');" | 1471 " document.getElementById('pod-row').getPodWithUsername_('%s');" |
| 1464 "pod.querySelector('.language-and-input').click();" | 1472 "pod.querySelector('.language-and-input').click();" |
| 1465 "domAutomationController.send(pod.classList.contains('advanced'));", | 1473 "domAutomationController.send(pod.classList.contains('advanced'));", |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 1476 "languageSelect.value = '%s';" | 1484 "languageSelect.value = '%s';" |
| 1477 "var event = document.createEvent('HTMLEvents');" | 1485 "var event = document.createEvent('HTMLEvents');" |
| 1478 "event.initEvent('change', false, true);" | 1486 "event.initEvent('change', false, true);" |
| 1479 "languageSelect.dispatchEvent(event);", | 1487 "languageSelect.dispatchEvent(event);", |
| 1480 user_id_1_.c_str(), | 1488 user_id_1_.c_str(), |
| 1481 kPublicSessionLocale))); | 1489 kPublicSessionLocale))); |
| 1482 | 1490 |
| 1483 // The UI will have requested an updated list of keyboard layouts at this | 1491 // The UI will have requested an updated list of keyboard layouts at this |
| 1484 // point. Wait for the constructions of this list to finish. | 1492 // point. Wait for the constructions of this list to finish. |
| 1485 WaitForGetKeyboardLayoutsForLocaleToFinish(); | 1493 WaitForGetKeyboardLayoutsForLocaleToFinish(); |
| 1494 EXPECT_EQ(l10n_util::GetLanguage(initial_locale_), | |
| 1495 icu::Locale::getDefault().getLanguage()); | |
| 1486 | 1496 |
| 1487 // Manually select a different keyboard layout and click the enter button to | 1497 // Manually select a different keyboard layout and click the enter button to |
| 1488 // start the session. | 1498 // start the session. |
| 1489 ASSERT_TRUE(content::ExecuteScript( | 1499 ASSERT_TRUE(content::ExecuteScript( |
| 1490 contents_, | 1500 contents_, |
| 1491 base::StringPrintf( | 1501 base::StringPrintf( |
| 1492 "var pod =" | 1502 "var pod =" |
| 1493 " document.getElementById('pod-row').getPodWithUsername_('%s');" | 1503 " document.getElementById('pod-row').getPodWithUsername_('%s');" |
| 1494 "pod.querySelector('.keyboard-select').value = '%s';" | 1504 "pod.querySelector('.keyboard-select').value = '%s';" |
| 1495 "pod.querySelector('.enter-button').click();", | 1505 "pod.querySelector('.enter-button').click();", |
| 1496 user_id_1_.c_str(), | 1506 user_id_1_.c_str(), |
| 1497 public_session_input_method_id_.c_str()))); | 1507 public_session_input_method_id_.c_str()))); |
| 1498 | 1508 |
| 1499 WaitForSessionStart(); | 1509 WaitForSessionStart(); |
| 1500 | 1510 |
| 1501 // Verify that the locale and keyboard layout have been applied. | 1511 // Verify that the locale and keyboard layout have been applied. |
| 1502 EXPECT_EQ(kPublicSessionLocale, g_browser_process->GetApplicationLocale()); | 1512 EXPECT_EQ(kPublicSessionLocale, g_browser_process->GetApplicationLocale()); |
| 1513 EXPECT_EQ(l10n_util::GetLanguage(kPublicSessionLocale), | |
| 1514 icu::Locale::getDefault().getLanguage()); | |
| 1503 EXPECT_EQ(public_session_input_method_id_, | 1515 EXPECT_EQ(public_session_input_method_id_, |
| 1504 chromeos::input_method::InputMethodManager::Get() | 1516 chromeos::input_method::InputMethodManager::Get() |
| 1505 ->GetActiveIMEState() | 1517 ->GetActiveIMEState() |
| 1506 ->GetCurrentInputMethod() | 1518 ->GetCurrentInputMethod() |
| 1507 .id()); | 1519 .id()); |
| 1508 } | 1520 } |
| 1509 | 1521 |
| 1510 IN_PROC_BROWSER_TEST_F(DeviceLocalAccountTest, OneRecommendedLocale) { | 1522 IN_PROC_BROWSER_TEST_F(DeviceLocalAccountTest, OneRecommendedLocale) { |
| 1511 // Specify a recommended locale. | 1523 // Specify a recommended locale. |
| 1512 SetRecommendedLocales(kSingleRecommendedLocale, | 1524 SetRecommendedLocales(kSingleRecommendedLocale, |
| 1513 arraysize(kSingleRecommendedLocale)); | 1525 arraysize(kSingleRecommendedLocale)); |
| 1514 UploadAndInstallDeviceLocalAccountPolicy(); | 1526 UploadAndInstallDeviceLocalAccountPolicy(); |
| 1515 AddPublicSessionToDevicePolicy(kAccountId1); | 1527 AddPublicSessionToDevicePolicy(kAccountId1); |
| 1516 | 1528 |
| 1517 WaitForPolicy(); | 1529 WaitForPolicy(); |
| 1518 | 1530 |
| 1519 // Click on the pod to expand it. Verify that the pod expands to its basic | 1531 // Click on the pod to expand it. Verify that the pod expands to its basic |
| 1520 // form as there is only one recommended locale. | 1532 // form as there is only one recommended locale. |
| 1521 bool advanced = false; | 1533 bool advanced = false; |
| 1522 ASSERT_TRUE(content::ExecuteScriptAndExtractBool( | 1534 ASSERT_TRUE(content::ExecuteScriptAndExtractBool( |
| 1523 contents_, | 1535 contents_, |
| 1524 base::StringPrintf( | 1536 base::StringPrintf( |
| 1525 "var pod =" | 1537 "var pod =" |
| 1526 " document.getElementById('pod-row').getPodWithUsername_('%s');" | 1538 " document.getElementById('pod-row').getPodWithUsername_('%s');" |
| 1527 "pod.click();" | 1539 "pod.click();" |
| 1528 "domAutomationController.send(pod.classList.contains('advanced'));", | 1540 "domAutomationController.send(pod.classList.contains('advanced'));", |
| 1529 user_id_1_.c_str()), | 1541 user_id_1_.c_str()), |
| 1530 &advanced)); | 1542 &advanced)); |
| 1531 EXPECT_FALSE(advanced); | 1543 EXPECT_FALSE(advanced); |
| 1544 EXPECT_EQ(l10n_util::GetLanguage(initial_locale_), | |
| 1545 icu::Locale::getDefault().getLanguage()); | |
| 1532 | 1546 |
| 1533 // Click the enter button to start the session. | 1547 // Click the enter button to start the session. |
| 1534 ASSERT_TRUE(content::ExecuteScript( | 1548 ASSERT_TRUE(content::ExecuteScript( |
| 1535 contents_, | 1549 contents_, |
| 1536 base::StringPrintf( | 1550 base::StringPrintf( |
| 1537 "document.getElementById('pod-row').getPodWithUsername_('%s')" | 1551 "document.getElementById('pod-row').getPodWithUsername_('%s')" |
| 1538 " .querySelector('.enter-button').click();", | 1552 " .querySelector('.enter-button').click();", |
| 1539 user_id_1_.c_str()))); | 1553 user_id_1_.c_str()))); |
| 1540 | 1554 |
| 1541 WaitForSessionStart(); | 1555 WaitForSessionStart(); |
| 1542 | 1556 |
| 1543 // Verify that the recommended locale has been applied and the first keyboard | 1557 // Verify that the recommended locale has been applied and the first keyboard |
| 1544 // layout applicable to the locale was chosen. | 1558 // layout applicable to the locale was chosen. |
| 1545 EXPECT_EQ(kSingleRecommendedLocale[0], | 1559 EXPECT_EQ(kSingleRecommendedLocale[0], |
| 1546 g_browser_process->GetApplicationLocale()); | 1560 g_browser_process->GetApplicationLocale()); |
| 1561 EXPECT_EQ(l10n_util::GetLanguage(kSingleRecommendedLocale[0]), | |
| 1562 icu::Locale::getDefault().getLanguage()); | |
| 1547 VerifyKeyboardLayoutMatchesLocale(); | 1563 VerifyKeyboardLayoutMatchesLocale(); |
| 1548 } | 1564 } |
| 1549 | 1565 |
| 1550 IN_PROC_BROWSER_TEST_F(DeviceLocalAccountTest, MultipleRecommendedLocales) { | 1566 IN_PROC_BROWSER_TEST_F(DeviceLocalAccountTest, MultipleRecommendedLocales) { |
| 1551 // Specify recommended locales. | 1567 // Specify recommended locales. |
| 1552 SetRecommendedLocales(kRecommendedLocales1, arraysize(kRecommendedLocales1)); | 1568 SetRecommendedLocales(kRecommendedLocales1, arraysize(kRecommendedLocales1)); |
| 1553 UploadAndInstallDeviceLocalAccountPolicy(); | 1569 UploadAndInstallDeviceLocalAccountPolicy(); |
| 1554 AddPublicSessionToDevicePolicy(kAccountId1); | 1570 AddPublicSessionToDevicePolicy(kAccountId1); |
| 1555 AddPublicSessionToDevicePolicy(kAccountId2); | 1571 AddPublicSessionToDevicePolicy(kAccountId2); |
| 1556 | 1572 |
| 1557 WaitForPolicy(); | 1573 WaitForPolicy(); |
| 1558 | 1574 |
| 1559 // Click on the pod to expand it. Verify that the pod expands to its advanced | 1575 // 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. | 1576 // form directly as there are two or more recommended locales. |
| 1561 bool advanced = false; | 1577 bool advanced = false; |
| 1562 ASSERT_TRUE(content::ExecuteScriptAndExtractBool( | 1578 ASSERT_TRUE(content::ExecuteScriptAndExtractBool( |
| 1563 contents_, | 1579 contents_, |
| 1564 base::StringPrintf( | 1580 base::StringPrintf( |
| 1565 "var pod =" | 1581 "var pod =" |
| 1566 " document.getElementById('pod-row').getPodWithUsername_('%s');" | 1582 " document.getElementById('pod-row').getPodWithUsername_('%s');" |
| 1567 "pod.click();" | 1583 "pod.click();" |
| 1568 "domAutomationController.send(pod.classList.contains('advanced'));", | 1584 "domAutomationController.send(pod.classList.contains('advanced'));", |
| 1569 user_id_1_.c_str()), | 1585 user_id_1_.c_str()), |
| 1570 &advanced)); | 1586 &advanced)); |
| 1571 EXPECT_TRUE(advanced); | 1587 EXPECT_TRUE(advanced); |
| 1588 EXPECT_EQ(l10n_util::GetLanguage(initial_locale_), | |
| 1589 icu::Locale::getDefault().getLanguage()); | |
| 1572 | 1590 |
| 1573 // Verify that the pod shows a list of locales beginning with the recommended | 1591 // Verify that the pod shows a list of locales beginning with the recommended |
| 1574 // ones, followed by others. | 1592 // ones, followed by others. |
| 1575 const std::string get_locale_list = base::StringPrintf( | 1593 const std::string get_locale_list = base::StringPrintf( |
| 1576 "var languageSelect = document.getElementById('pod-row')" | 1594 "var languageSelect = document.getElementById('pod-row')" |
| 1577 " .getPodWithUsername_('%s').querySelector('.language-select');" | 1595 " .getPodWithUsername_('%s').querySelector('.language-select');" |
| 1578 "var locales = [];" | 1596 "var locales = [];" |
| 1579 "for (var i = 0; i < languageSelect.length; ++i)" | 1597 "for (var i = 0; i < languageSelect.length; ++i)" |
| 1580 " locales.push(languageSelect.options[i].value);" | 1598 " locales.push(languageSelect.options[i].value);" |
| 1581 "domAutomationController.send(JSON.stringify(locales));", | 1599 "domAutomationController.send(JSON.stringify(locales));", |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1683 | 1701 |
| 1684 // Verify that the manually selected locale is still selected. | 1702 // Verify that the manually selected locale is still selected. |
| 1685 ASSERT_TRUE(content::ExecuteScriptAndExtractString(contents_, | 1703 ASSERT_TRUE(content::ExecuteScriptAndExtractString(contents_, |
| 1686 get_selected_locale, | 1704 get_selected_locale, |
| 1687 &selected_locale)); | 1705 &selected_locale)); |
| 1688 EXPECT_EQ(kPublicSessionLocale, selected_locale); | 1706 EXPECT_EQ(kPublicSessionLocale, selected_locale); |
| 1689 | 1707 |
| 1690 // The UI will request an updated list of keyboard layouts at this point. Wait | 1708 // The UI will request an updated list of keyboard layouts at this point. Wait |
| 1691 // for the constructions of this list to finish. | 1709 // for the constructions of this list to finish. |
| 1692 WaitForGetKeyboardLayoutsForLocaleToFinish(); | 1710 WaitForGetKeyboardLayoutsForLocaleToFinish(); |
| 1711 EXPECT_EQ(initial_locale_, | |
| 1712 g_browser_process->GetApplicationLocale()); | |
| 1693 | 1713 |
| 1694 // Manually select a different keyboard layout. | 1714 // Manually select a different keyboard layout. |
| 1695 ASSERT_TRUE(content::ExecuteScript( | 1715 ASSERT_TRUE(content::ExecuteScript( |
| 1696 contents_, | 1716 contents_, |
| 1697 base::StringPrintf( | 1717 base::StringPrintf( |
| 1698 "document.getElementById('pod-row').getPodWithUsername_('%s')" | 1718 "document.getElementById('pod-row').getPodWithUsername_('%s')" |
| 1699 " .querySelector('.keyboard-select').value = '%s';", | 1719 " .querySelector('.keyboard-select').value = '%s';", |
| 1700 user_id_1_.c_str(), | 1720 user_id_1_.c_str(), |
| 1701 public_session_input_method_id_.c_str()))); | 1721 public_session_input_method_id_.c_str()))); |
| 1702 | 1722 |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1744 contents_, | 1764 contents_, |
| 1745 base::StringPrintf( | 1765 base::StringPrintf( |
| 1746 "document.getElementById('pod-row').getPodWithUsername_('%s')" | 1766 "document.getElementById('pod-row').getPodWithUsername_('%s')" |
| 1747 " .querySelector('.enter-button').click();", | 1767 " .querySelector('.enter-button').click();", |
| 1748 user_id_1_.c_str()))); | 1768 user_id_1_.c_str()))); |
| 1749 | 1769 |
| 1750 WaitForSessionStart(); | 1770 WaitForSessionStart(); |
| 1751 | 1771 |
| 1752 // Verify that the locale and keyboard layout have been applied. | 1772 // Verify that the locale and keyboard layout have been applied. |
| 1753 EXPECT_EQ(kPublicSessionLocale, g_browser_process->GetApplicationLocale()); | 1773 EXPECT_EQ(kPublicSessionLocale, g_browser_process->GetApplicationLocale()); |
| 1774 EXPECT_EQ(l10n_util::GetLanguage(kPublicSessionLocale), | |
| 1775 icu::Locale::getDefault().getLanguage()); | |
| 1754 EXPECT_EQ(public_session_input_method_id_, | 1776 EXPECT_EQ(public_session_input_method_id_, |
| 1755 chromeos::input_method::InputMethodManager::Get() | 1777 chromeos::input_method::InputMethodManager::Get() |
| 1756 ->GetActiveIMEState() | 1778 ->GetActiveIMEState() |
| 1757 ->GetCurrentInputMethod() | 1779 ->GetCurrentInputMethod() |
| 1758 .id()); | 1780 .id()); |
| 1759 } | 1781 } |
| 1760 | 1782 |
| 1761 IN_PROC_BROWSER_TEST_F(DeviceLocalAccountTest, | 1783 IN_PROC_BROWSER_TEST_F(DeviceLocalAccountTest, |
| 1762 AutoLoginWithoutRecommendedLocales) { | 1784 AutoLoginWithoutRecommendedLocales) { |
| 1763 const std::string initial_locale = g_browser_process->GetApplicationLocale(); | |
| 1764 | |
| 1765 UploadAndInstallDeviceLocalAccountPolicy(); | 1785 UploadAndInstallDeviceLocalAccountPolicy(); |
| 1766 AddPublicSessionToDevicePolicy(kAccountId1); | 1786 AddPublicSessionToDevicePolicy(kAccountId1); |
| 1767 EnableAutoLogin(); | 1787 EnableAutoLogin(); |
| 1768 | 1788 |
| 1769 WaitForPolicy(); | 1789 WaitForPolicy(); |
| 1770 | 1790 |
| 1771 WaitForSessionStart(); | 1791 WaitForSessionStart(); |
| 1772 | 1792 |
| 1773 // Verify that the locale has not changed and the first keyboard layout | 1793 // Verify that the locale has not changed and the first keyboard layout |
| 1774 // applicable to the locale was chosen. | 1794 // applicable to the locale was chosen. |
| 1775 EXPECT_EQ(initial_locale, g_browser_process->GetApplicationLocale()); | 1795 EXPECT_EQ(initial_locale_, g_browser_process->GetApplicationLocale()); |
| 1796 EXPECT_EQ(l10n_util::GetLanguage(initial_locale_), | |
| 1797 icu::Locale::getDefault().getLanguage()); | |
| 1776 VerifyKeyboardLayoutMatchesLocale(); | 1798 VerifyKeyboardLayoutMatchesLocale(); |
| 1777 } | 1799 } |
| 1778 | 1800 |
| 1779 IN_PROC_BROWSER_TEST_F(DeviceLocalAccountTest, | 1801 IN_PROC_BROWSER_TEST_F(DeviceLocalAccountTest, |
| 1780 AutoLoginWithRecommendedLocales) { | 1802 AutoLoginWithRecommendedLocales) { |
| 1781 // Specify recommended locales. | 1803 // Specify recommended locales. |
| 1782 SetRecommendedLocales(kRecommendedLocales1, arraysize(kRecommendedLocales1)); | 1804 SetRecommendedLocales(kRecommendedLocales1, arraysize(kRecommendedLocales1)); |
| 1783 UploadAndInstallDeviceLocalAccountPolicy(); | 1805 UploadAndInstallDeviceLocalAccountPolicy(); |
| 1784 AddPublicSessionToDevicePolicy(kAccountId1); | 1806 AddPublicSessionToDevicePolicy(kAccountId1); |
| 1785 EnableAutoLogin(); | 1807 EnableAutoLogin(); |
| 1786 | 1808 |
| 1787 WaitForPolicy(); | 1809 WaitForPolicy(); |
| 1788 | 1810 |
| 1789 WaitForSessionStart(); | 1811 WaitForSessionStart(); |
| 1790 | 1812 |
| 1791 // Verify that the first recommended locale has been applied and the first | 1813 // Verify that the first recommended locale has been applied and the first |
| 1792 // keyboard layout applicable to the locale was chosen. | 1814 // keyboard layout applicable to the locale was chosen. |
| 1793 EXPECT_EQ(kRecommendedLocales1[0], g_browser_process->GetApplicationLocale()); | 1815 EXPECT_EQ(kRecommendedLocales1[0], g_browser_process->GetApplicationLocale()); |
| 1816 EXPECT_EQ(l10n_util::GetLanguage(kRecommendedLocales1[0]), | |
| 1817 icu::Locale::getDefault().getLanguage()); | |
| 1794 VerifyKeyboardLayoutMatchesLocale(); | 1818 VerifyKeyboardLayoutMatchesLocale(); |
| 1795 } | 1819 } |
| 1796 | 1820 |
| 1797 IN_PROC_BROWSER_TEST_F(DeviceLocalAccountTest, TermsOfServiceWithLocaleSwitch) { | 1821 IN_PROC_BROWSER_TEST_F(DeviceLocalAccountTest, TermsOfServiceWithLocaleSwitch) { |
| 1798 // Specify Terms of Service URL. | 1822 // Specify Terms of Service URL. |
| 1799 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady()); | 1823 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady()); |
| 1800 device_local_account_policy_.payload().mutable_termsofserviceurl()->set_value( | 1824 device_local_account_policy_.payload().mutable_termsofserviceurl()->set_value( |
| 1801 embedded_test_server()->GetURL( | 1825 embedded_test_server()->GetURL( |
| 1802 std::string("/") + kExistentTermsOfServicePath).spec()); | 1826 std::string("/") + kExistentTermsOfServicePath).spec()); |
| 1803 UploadAndInstallDeviceLocalAccountPolicy(); | 1827 UploadAndInstallDeviceLocalAccountPolicy(); |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 1814 "languageSelect.value = '%s';" | 1838 "languageSelect.value = '%s';" |
| 1815 "var event = document.createEvent('HTMLEvents');" | 1839 "var event = document.createEvent('HTMLEvents');" |
| 1816 "event.initEvent('change', false, true);" | 1840 "event.initEvent('change', false, true);" |
| 1817 "languageSelect.dispatchEvent(event);", | 1841 "languageSelect.dispatchEvent(event);", |
| 1818 user_id_1_.c_str(), | 1842 user_id_1_.c_str(), |
| 1819 kPublicSessionLocale))); | 1843 kPublicSessionLocale))); |
| 1820 | 1844 |
| 1821 // The UI will have requested an updated list of keyboard layouts at this | 1845 // The UI will have requested an updated list of keyboard layouts at this |
| 1822 // point. Wait for the constructions of this list to finish. | 1846 // point. Wait for the constructions of this list to finish. |
| 1823 WaitForGetKeyboardLayoutsForLocaleToFinish(); | 1847 WaitForGetKeyboardLayoutsForLocaleToFinish(); |
| 1848 EXPECT_EQ(l10n_util::GetLanguage(initial_locale_), | |
| 1849 icu::Locale::getDefault().getLanguage()); | |
| 1824 | 1850 |
| 1825 // Set up an observer that will quit the message loop when login has succeeded | 1851 // 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. | 1852 // and the first wizard screen, if any, is being shown. |
| 1827 base::RunLoop login_wait_run_loop; | 1853 base::RunLoop login_wait_run_loop; |
| 1828 chromeos::MockAuthStatusConsumer login_status_consumer; | 1854 chromeos::MockAuthStatusConsumer login_status_consumer; |
| 1829 EXPECT_CALL(login_status_consumer, OnAuthSuccess(_)).Times(1).WillOnce( | 1855 EXPECT_CALL(login_status_consumer, OnAuthSuccess(_)).Times(1).WillOnce( |
| 1830 InvokeWithoutArgs(&login_wait_run_loop, &base::RunLoop::Quit)); | 1856 InvokeWithoutArgs(&login_wait_run_loop, &base::RunLoop::Quit)); |
| 1831 chromeos::ExistingUserController* controller = | 1857 chromeos::ExistingUserController* controller = |
| 1832 chromeos::ExistingUserController::current_controller(); | 1858 chromeos::ExistingUserController::current_controller(); |
| 1833 ASSERT_TRUE(controller); | 1859 ASSERT_TRUE(controller); |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1871 "}" | 1897 "}" |
| 1872 "var observer = new MutationObserver(SendReplyIfDownloadDone);" | 1898 "var observer = new MutationObserver(SendReplyIfDownloadDone);" |
| 1873 "if (!SendReplyIfDownloadDone()) {" | 1899 "if (!SendReplyIfDownloadDone()) {" |
| 1874 " var options = { attributes: true, attributeFilter: [ 'class' ] };" | 1900 " var options = { attributes: true, attributeFilter: [ 'class' ] };" |
| 1875 " observer.observe(screenElement, options);" | 1901 " observer.observe(screenElement, options);" |
| 1876 "}", | 1902 "}", |
| 1877 &done)); | 1903 &done)); |
| 1878 | 1904 |
| 1879 // Verify that the locale and keyboard layout have been applied. | 1905 // Verify that the locale and keyboard layout have been applied. |
| 1880 EXPECT_EQ(kPublicSessionLocale, g_browser_process->GetApplicationLocale()); | 1906 EXPECT_EQ(kPublicSessionLocale, g_browser_process->GetApplicationLocale()); |
| 1907 EXPECT_EQ(l10n_util::GetLanguage(kPublicSessionLocale), | |
| 1908 icu::Locale::getDefault().getLanguage()); | |
| 1881 EXPECT_EQ(public_session_input_method_id_, | 1909 EXPECT_EQ(public_session_input_method_id_, |
| 1882 chromeos::input_method::InputMethodManager::Get() | 1910 chromeos::input_method::InputMethodManager::Get() |
| 1883 ->GetActiveIMEState() | 1911 ->GetActiveIMEState() |
| 1884 ->GetCurrentInputMethod() | 1912 ->GetCurrentInputMethod() |
| 1885 .id()); | 1913 .id()); |
| 1886 | 1914 |
| 1887 // Click the accept button. | 1915 // Click the accept button. |
| 1888 ASSERT_TRUE(content::ExecuteScript(contents_, | 1916 ASSERT_TRUE(content::ExecuteScript(contents_, |
| 1889 "$('tos-accept-button').click();")); | 1917 "$('tos-accept-button').click();")); |
| 1890 | 1918 |
| 1891 WaitForSessionStart(); | 1919 WaitForSessionStart(); |
| 1892 | 1920 |
| 1893 // Verify that the locale and keyboard layout are still in force. | 1921 // Verify that the locale and keyboard layout are still in force. |
| 1894 EXPECT_EQ(kPublicSessionLocale, g_browser_process->GetApplicationLocale()); | 1922 EXPECT_EQ(kPublicSessionLocale, g_browser_process->GetApplicationLocale()); |
| 1923 EXPECT_EQ(l10n_util::GetLanguage(kPublicSessionLocale), | |
| 1924 icu::Locale::getDefault().getLanguage()); | |
| 1895 EXPECT_EQ(public_session_input_method_id_, | 1925 EXPECT_EQ(public_session_input_method_id_, |
| 1896 chromeos::input_method::InputMethodManager::Get() | 1926 chromeos::input_method::InputMethodManager::Get() |
| 1897 ->GetActiveIMEState() | 1927 ->GetActiveIMEState() |
| 1898 ->GetCurrentInputMethod() | 1928 ->GetCurrentInputMethod() |
| 1899 .id()); | 1929 .id()); |
| 1900 } | 1930 } |
| 1901 | 1931 |
| 1902 class TermsOfServiceDownloadTest : public DeviceLocalAccountTest, | 1932 class TermsOfServiceDownloadTest : public DeviceLocalAccountTest, |
| 1903 public testing::WithParamInterface<bool> { | 1933 public testing::WithParamInterface<bool> { |
| 1904 }; | 1934 }; |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2024 ASSERT_TRUE(content::ExecuteScript(contents_, | 2054 ASSERT_TRUE(content::ExecuteScript(contents_, |
| 2025 "$('tos-accept-button').click();")); | 2055 "$('tos-accept-button').click();")); |
| 2026 | 2056 |
| 2027 WaitForSessionStart(); | 2057 WaitForSessionStart(); |
| 2028 } | 2058 } |
| 2029 | 2059 |
| 2030 INSTANTIATE_TEST_CASE_P(TermsOfServiceDownloadTestInstance, | 2060 INSTANTIATE_TEST_CASE_P(TermsOfServiceDownloadTestInstance, |
| 2031 TermsOfServiceDownloadTest, testing::Bool()); | 2061 TermsOfServiceDownloadTest, testing::Bool()); |
| 2032 | 2062 |
| 2033 } // namespace policy | 2063 } // namespace policy |
| OLD | NEW |