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.h" | 10 #include "apps/app_window.h" |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
122 #include "net/base/url_util.h" | 122 #include "net/base/url_util.h" |
123 #include "net/http/http_status_code.h" | 123 #include "net/http/http_status_code.h" |
124 #include "net/test/embedded_test_server/embedded_test_server.h" | 124 #include "net/test/embedded_test_server/embedded_test_server.h" |
125 #include "net/test/embedded_test_server/http_request.h" | 125 #include "net/test/embedded_test_server/http_request.h" |
126 #include "net/test/embedded_test_server/http_response.h" | 126 #include "net/test/embedded_test_server/http_response.h" |
127 #include "net/url_request/test_url_fetcher_factory.h" | 127 #include "net/url_request/test_url_fetcher_factory.h" |
128 #include "net/url_request/url_fetcher_delegate.h" | 128 #include "net/url_request/url_fetcher_delegate.h" |
129 #include "net/url_request/url_request_status.h" | 129 #include "net/url_request/url_request_status.h" |
130 #include "policy/policy_constants.h" | 130 #include "policy/policy_constants.h" |
131 #include "testing/gmock/include/gmock/gmock.h" | 131 #include "testing/gmock/include/gmock/gmock.h" |
| 132 #include "third_party/icu/source/common/unicode/locid.h" |
132 #include "ui/base/l10n/l10n_util.h" | 133 #include "ui/base/l10n/l10n_util.h" |
133 #include "ui/base/window_open_disposition.h" | 134 #include "ui/base/window_open_disposition.h" |
134 #include "ui/gfx/image/image_skia.h" | 135 #include "ui/gfx/image/image_skia.h" |
135 #include "ui/views/widget/widget.h" | 136 #include "ui/views/widget/widget.h" |
136 #include "url/gurl.h" | 137 #include "url/gurl.h" |
137 //#include "third_party/cros_system_api/dbus/service_constants.h" | |
138 | 138 |
139 namespace em = enterprise_management; | 139 namespace em = enterprise_management; |
140 | 140 |
141 using chromeos::LoginScreenContext; | 141 using chromeos::LoginScreenContext; |
142 using testing::InvokeWithoutArgs; | 142 using testing::InvokeWithoutArgs; |
143 using testing::Return; | 143 using testing::Return; |
144 using testing::_; | 144 using testing::_; |
145 | 145 |
146 namespace policy { | 146 namespace policy { |
147 | 147 |
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
371 net::URLRequestStatus::Status status) { | 371 net::URLRequestStatus::Status status) { |
372 task_runner->PostTask(FROM_HERE, callback); | 372 task_runner->PostTask(FROM_HERE, callback); |
373 return make_scoped_ptr(new net::FakeURLFetcher( | 373 return make_scoped_ptr(new net::FakeURLFetcher( |
374 url, delegate, response_data, response_code, status)); | 374 url, delegate, response_data, response_code, status)); |
375 } | 375 } |
376 | 376 |
377 bool IsSessionStarted() { | 377 bool IsSessionStarted() { |
378 return user_manager::UserManager::Get()->IsSessionStarted(); | 378 return user_manager::UserManager::Get()->IsSessionStarted(); |
379 } | 379 } |
380 | 380 |
381 // GetKeyboardLayoutsForLocale() posts a task to a background task runner. This | |
382 // method flushes that task runner and the current thread's message loop to | |
383 // ensure that GetKeyboardLayoutsForLocale() is finished. | |
384 void WaitForGetKeyboardLayoutsForLocaleToFinish() { | |
385 base::SequencedWorkerPool* worker_pool = | |
386 content::BrowserThread::GetBlockingPool(); | |
387 scoped_refptr<base::SequencedTaskRunner> background_task_runner = | |
388 worker_pool->GetSequencedTaskRunner( | |
389 worker_pool->GetNamedSequenceToken(kSequenceToken)); | |
390 base::RunLoop run_loop; | |
391 background_task_runner->PostTaskAndReply(FROM_HERE, | |
392 base::Bind(&base::DoNothing), | |
393 run_loop.QuitClosure()); | |
394 run_loop.Run(); | |
395 base::RunLoop().RunUntilIdle(); | |
396 } | |
397 | |
398 } // namespace | 381 } // namespace |
399 | 382 |
400 class DeviceLocalAccountTest : public DevicePolicyCrosBrowserTest, | 383 class DeviceLocalAccountTest : public DevicePolicyCrosBrowserTest, |
401 public user_manager::UserManager::Observer, | 384 public user_manager::UserManager::Observer, |
402 public chrome::BrowserListObserver, | 385 public chrome::BrowserListObserver, |
403 public apps::AppWindowRegistry::Observer { | 386 public apps::AppWindowRegistry::Observer { |
404 protected: | 387 protected: |
405 DeviceLocalAccountTest() | 388 DeviceLocalAccountTest() |
406 : user_id_1_(GenerateDeviceLocalAccountUserId( | 389 : user_id_1_(GenerateDeviceLocalAccountUserId( |
407 kAccountId1, DeviceLocalAccount::TYPE_PUBLIC_SESSION)), | 390 kAccountId1, DeviceLocalAccount::TYPE_PUBLIC_SESSION)), |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
454 | 437 |
455 InstallOwnerKey(); | 438 InstallOwnerKey(); |
456 MarkAsEnterpriseOwned(); | 439 MarkAsEnterpriseOwned(); |
457 | 440 |
458 InitializePolicy(); | 441 InitializePolicy(); |
459 } | 442 } |
460 | 443 |
461 virtual void SetUpOnMainThread() OVERRIDE { | 444 virtual void SetUpOnMainThread() OVERRIDE { |
462 DevicePolicyCrosBrowserTest::SetUpOnMainThread(); | 445 DevicePolicyCrosBrowserTest::SetUpOnMainThread(); |
463 | 446 |
| 447 initial_locale_ = g_browser_process->GetApplicationLocale(); |
| 448 initial_language_ = l10n_util::GetLanguage(initial_locale_); |
| 449 |
464 content::WindowedNotificationObserver( | 450 content::WindowedNotificationObserver( |
465 chrome::NOTIFICATION_LOGIN_OR_LOCK_WEBUI_VISIBLE, | 451 chrome::NOTIFICATION_LOGIN_OR_LOCK_WEBUI_VISIBLE, |
466 content::NotificationService::AllSources()).Wait(); | 452 content::NotificationService::AllSources()).Wait(); |
467 | 453 |
468 chromeos::LoginDisplayHostImpl* host = | 454 chromeos::LoginDisplayHostImpl* host = |
469 reinterpret_cast<chromeos::LoginDisplayHostImpl*>( | 455 reinterpret_cast<chromeos::LoginDisplayHostImpl*>( |
470 chromeos::LoginDisplayHostImpl::default_host()); | 456 chromeos::LoginDisplayHostImpl::default_host()); |
471 ASSERT_TRUE(host); | 457 ASSERT_TRUE(host); |
472 chromeos::WebUILoginView* web_ui_login_view = host->GetWebUILoginView(); | 458 chromeos::WebUILoginView* web_ui_login_view = host->GetWebUILoginView(); |
473 ASSERT_TRUE(web_ui_login_view); | 459 ASSERT_TRUE(web_ui_login_view); |
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
649 expected_display_name).Wait(); | 635 expected_display_name).Wait(); |
650 } | 636 } |
651 | 637 |
652 void WaitForPolicy() { | 638 void WaitForPolicy() { |
653 // Wait for the display name becoming available as that indicates | 639 // Wait for the display name becoming available as that indicates |
654 // device-local account policy is fully loaded, which is a prerequisite for | 640 // device-local account policy is fully loaded, which is a prerequisite for |
655 // successful login. | 641 // successful login. |
656 WaitForDisplayName(user_id_1_, kDisplayName1); | 642 WaitForDisplayName(user_id_1_, kDisplayName1); |
657 } | 643 } |
658 | 644 |
| 645 void ExpandPublicSessionPod(bool expect_advanced) { |
| 646 bool advanced = false; |
| 647 // Click on the pod to expand it. |
| 648 ASSERT_TRUE(content::ExecuteScriptAndExtractBool( |
| 649 contents_, |
| 650 base::StringPrintf( |
| 651 "var pod =" |
| 652 " document.getElementById('pod-row').getPodWithUsername_('%s');" |
| 653 "pod.click();" |
| 654 "domAutomationController.send(pod.classList.contains('advanced'));", |
| 655 user_id_1_.c_str()), |
| 656 &advanced)); |
| 657 // Verify that the pod expanded to its basic/advanced form, as expected. |
| 658 EXPECT_EQ(expect_advanced, advanced); |
| 659 |
| 660 // Verify that the construction of the pod's language list did not affect |
| 661 // the current ICU locale. |
| 662 EXPECT_EQ(initial_language_, icu::Locale::getDefault().getLanguage()); |
| 663 } |
| 664 |
| 665 // GetKeyboardLayoutsForLocale() posts a task to a background task runner. |
| 666 // This method flushes that task runner and the current thread's message loop |
| 667 // to ensure that GetKeyboardLayoutsForLocale() is finished. |
| 668 void WaitForGetKeyboardLayoutsForLocaleToFinish() { |
| 669 base::SequencedWorkerPool* worker_pool = |
| 670 content::BrowserThread::GetBlockingPool(); |
| 671 scoped_refptr<base::SequencedTaskRunner> background_task_runner = |
| 672 worker_pool->GetSequencedTaskRunner( |
| 673 worker_pool->GetNamedSequenceToken(kSequenceToken)); |
| 674 base::RunLoop run_loop; |
| 675 background_task_runner->PostTaskAndReply(FROM_HERE, |
| 676 base::Bind(&base::DoNothing), |
| 677 run_loop.QuitClosure()); |
| 678 run_loop.Run(); |
| 679 base::RunLoop().RunUntilIdle(); |
| 680 |
| 681 // Verify that the construction of the keyboard layout list did not affect |
| 682 // the current ICU locale. |
| 683 EXPECT_EQ(initial_language_, icu::Locale::getDefault().getLanguage()); |
| 684 } |
| 685 |
659 void StartLogin(const std::string& locale, | 686 void StartLogin(const std::string& locale, |
660 const std::string& input_method) { | 687 const std::string& input_method) { |
661 // Start login into the device-local account. | 688 // Start login into the device-local account. |
662 chromeos::LoginDisplayHostImpl* host = | 689 chromeos::LoginDisplayHostImpl* host = |
663 reinterpret_cast<chromeos::LoginDisplayHostImpl*>( | 690 reinterpret_cast<chromeos::LoginDisplayHostImpl*>( |
664 chromeos::LoginDisplayHostImpl::default_host()); | 691 chromeos::LoginDisplayHostImpl::default_host()); |
665 ASSERT_TRUE(host); | 692 ASSERT_TRUE(host); |
666 host->StartSignInScreen(LoginScreenContext()); | 693 host->StartSignInScreen(LoginScreenContext()); |
667 chromeos::ExistingUserController* controller = | 694 chromeos::ExistingUserController* controller = |
668 chromeos::ExistingUserController::current_controller(); | 695 chromeos::ExistingUserController::current_controller(); |
(...skipping 26 matching lines...) Expand all Loading... |
695 EXPECT_EQ(layouts_from_locale.front(), | 722 EXPECT_EQ(layouts_from_locale.front(), |
696 input_method_manager->GetActiveIMEState() | 723 input_method_manager->GetActiveIMEState() |
697 ->GetCurrentInputMethod() | 724 ->GetCurrentInputMethod() |
698 .id()); | 725 .id()); |
699 } | 726 } |
700 | 727 |
701 const std::string user_id_1_; | 728 const std::string user_id_1_; |
702 const std::string user_id_2_; | 729 const std::string user_id_2_; |
703 const std::string public_session_input_method_id_; | 730 const std::string public_session_input_method_id_; |
704 | 731 |
| 732 std::string initial_locale_; |
| 733 std::string initial_language_; |
| 734 |
705 scoped_ptr<base::RunLoop> run_loop_; | 735 scoped_ptr<base::RunLoop> run_loop_; |
706 | 736 |
707 UserPolicyBuilder device_local_account_policy_; | 737 UserPolicyBuilder device_local_account_policy_; |
708 LocalPolicyTestServer test_server_; | 738 LocalPolicyTestServer test_server_; |
709 | 739 |
710 content::WebContents* contents_; | 740 content::WebContents* contents_; |
711 | 741 |
712 private: | 742 private: |
713 DISALLOW_COPY_AND_ASSIGN(DeviceLocalAccountTest); | 743 DISALLOW_COPY_AND_ASSIGN(DeviceLocalAccountTest); |
714 }; | 744 }; |
(...skipping 676 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1391 | 1421 |
1392 // Deny the logout. | 1422 // Deny the logout. |
1393 dialog->GetWidget()->Close(); | 1423 dialog->GetWidget()->Close(); |
1394 dialog = NULL; | 1424 dialog = NULL; |
1395 base::RunLoop().RunUntilIdle(); | 1425 base::RunLoop().RunUntilIdle(); |
1396 | 1426 |
1397 app_window_registry->RemoveObserver(this); | 1427 app_window_registry->RemoveObserver(this); |
1398 }; | 1428 }; |
1399 | 1429 |
1400 IN_PROC_BROWSER_TEST_F(DeviceLocalAccountTest, NoRecommendedLocaleNoSwitch) { | 1430 IN_PROC_BROWSER_TEST_F(DeviceLocalAccountTest, NoRecommendedLocaleNoSwitch) { |
1401 const std::string initial_locale = g_browser_process->GetApplicationLocale(); | |
1402 | |
1403 UploadAndInstallDeviceLocalAccountPolicy(); | 1431 UploadAndInstallDeviceLocalAccountPolicy(); |
1404 AddPublicSessionToDevicePolicy(kAccountId1); | 1432 AddPublicSessionToDevicePolicy(kAccountId1); |
1405 | 1433 |
1406 WaitForPolicy(); | 1434 WaitForPolicy(); |
1407 | 1435 |
1408 // Click on the pod to expand it. Verify that the pod expands to its basic | 1436 ExpandPublicSessionPod(false); |
1409 // form as there are no recommended locales. | |
1410 bool advanced = false; | |
1411 ASSERT_TRUE(content::ExecuteScriptAndExtractBool( | |
1412 contents_, | |
1413 base::StringPrintf( | |
1414 "var pod =" | |
1415 " document.getElementById('pod-row').getPodWithUsername_('%s');" | |
1416 "pod.click();" | |
1417 "domAutomationController.send(pod.classList.contains('advanced'));", | |
1418 user_id_1_.c_str()), | |
1419 &advanced)); | |
1420 EXPECT_FALSE(advanced); | |
1421 | 1437 |
1422 // Click the enter button to start the session. | 1438 // Click the enter button to start the session. |
1423 ASSERT_TRUE(content::ExecuteScript( | 1439 ASSERT_TRUE(content::ExecuteScript( |
1424 contents_, | 1440 contents_, |
1425 base::StringPrintf( | 1441 base::StringPrintf( |
1426 "document.getElementById('pod-row').getPodWithUsername_('%s')" | 1442 "document.getElementById('pod-row').getPodWithUsername_('%s')" |
1427 " .querySelector('.enter-button').click();", | 1443 " .querySelector('.enter-button').click();", |
1428 user_id_1_.c_str()))); | 1444 user_id_1_.c_str()))); |
1429 | 1445 |
1430 WaitForSessionStart(); | 1446 WaitForSessionStart(); |
1431 | 1447 |
1432 // Verify that the locale has not changed and the first keyboard layout | 1448 // Verify that the locale has not changed and the first keyboard layout |
1433 // applicable to the locale was chosen. | 1449 // applicable to the locale was chosen. |
1434 EXPECT_EQ(initial_locale, g_browser_process->GetApplicationLocale()); | 1450 EXPECT_EQ(initial_locale_, g_browser_process->GetApplicationLocale()); |
| 1451 EXPECT_EQ(initial_language_, icu::Locale::getDefault().getLanguage()); |
1435 VerifyKeyboardLayoutMatchesLocale(); | 1452 VerifyKeyboardLayoutMatchesLocale(); |
1436 } | 1453 } |
1437 | 1454 |
1438 IN_PROC_BROWSER_TEST_F(DeviceLocalAccountTest, NoRecommendedLocaleSwitch) { | 1455 IN_PROC_BROWSER_TEST_F(DeviceLocalAccountTest, NoRecommendedLocaleSwitch) { |
1439 UploadAndInstallDeviceLocalAccountPolicy(); | 1456 UploadAndInstallDeviceLocalAccountPolicy(); |
1440 AddPublicSessionToDevicePolicy(kAccountId1); | 1457 AddPublicSessionToDevicePolicy(kAccountId1); |
1441 | 1458 |
1442 WaitForPolicy(); | 1459 WaitForPolicy(); |
1443 | 1460 |
1444 // Click on the pod to expand it. Verify that the pod expands to its basic | 1461 ExpandPublicSessionPod(false); |
1445 // form as there are no recommended locales. | 1462 |
| 1463 // Click the link that switches the pod to its advanced form. Verify that the |
| 1464 // pod switches from basic to advanced. |
1446 bool advanced = false; | 1465 bool advanced = false; |
1447 ASSERT_TRUE(content::ExecuteScriptAndExtractBool( | 1466 ASSERT_TRUE(content::ExecuteScriptAndExtractBool( |
1448 contents_, | 1467 contents_, |
1449 base::StringPrintf( | 1468 base::StringPrintf( |
1450 "var pod =" | |
1451 " document.getElementById('pod-row').getPodWithUsername_('%s');" | |
1452 "pod.click();" | |
1453 "domAutomationController.send(pod.classList.contains('advanced'));", | |
1454 user_id_1_.c_str()), | |
1455 &advanced)); | |
1456 EXPECT_FALSE(advanced); | |
1457 | |
1458 // Click the link that switches the pod to its advanced form. Verify that the | |
1459 // pod switches from basic to advanced. | |
1460 ASSERT_TRUE(content::ExecuteScriptAndExtractBool( | |
1461 contents_, | |
1462 base::StringPrintf( | |
1463 "var pod =" | 1469 "var pod =" |
1464 " document.getElementById('pod-row').getPodWithUsername_('%s');" | 1470 " document.getElementById('pod-row').getPodWithUsername_('%s');" |
1465 "pod.querySelector('.language-and-input').click();" | 1471 "pod.querySelector('.language-and-input').click();" |
1466 "domAutomationController.send(pod.classList.contains('advanced'));", | 1472 "domAutomationController.send(pod.classList.contains('advanced'));", |
1467 user_id_1_.c_str()), | 1473 user_id_1_.c_str()), |
1468 &advanced)); | 1474 &advanced)); |
1469 EXPECT_FALSE(advanced); | 1475 EXPECT_FALSE(advanced); |
1470 | 1476 |
1471 // Manually select a different locale. | 1477 // Manually select a different locale. |
1472 ASSERT_TRUE(content::ExecuteScript( | 1478 ASSERT_TRUE(content::ExecuteScript( |
(...skipping 21 matching lines...) Expand all Loading... |
1494 " document.getElementById('pod-row').getPodWithUsername_('%s');" | 1500 " document.getElementById('pod-row').getPodWithUsername_('%s');" |
1495 "pod.querySelector('.keyboard-select').value = '%s';" | 1501 "pod.querySelector('.keyboard-select').value = '%s';" |
1496 "pod.querySelector('.enter-button').click();", | 1502 "pod.querySelector('.enter-button').click();", |
1497 user_id_1_.c_str(), | 1503 user_id_1_.c_str(), |
1498 public_session_input_method_id_.c_str()))); | 1504 public_session_input_method_id_.c_str()))); |
1499 | 1505 |
1500 WaitForSessionStart(); | 1506 WaitForSessionStart(); |
1501 | 1507 |
1502 // Verify that the locale and keyboard layout have been applied. | 1508 // Verify that the locale and keyboard layout have been applied. |
1503 EXPECT_EQ(kPublicSessionLocale, g_browser_process->GetApplicationLocale()); | 1509 EXPECT_EQ(kPublicSessionLocale, g_browser_process->GetApplicationLocale()); |
| 1510 EXPECT_EQ(l10n_util::GetLanguage(kPublicSessionLocale), |
| 1511 icu::Locale::getDefault().getLanguage()); |
1504 EXPECT_EQ(public_session_input_method_id_, | 1512 EXPECT_EQ(public_session_input_method_id_, |
1505 chromeos::input_method::InputMethodManager::Get() | 1513 chromeos::input_method::InputMethodManager::Get() |
1506 ->GetActiveIMEState() | 1514 ->GetActiveIMEState() |
1507 ->GetCurrentInputMethod() | 1515 ->GetCurrentInputMethod() |
1508 .id()); | 1516 .id()); |
1509 } | 1517 } |
1510 | 1518 |
1511 IN_PROC_BROWSER_TEST_F(DeviceLocalAccountTest, OneRecommendedLocale) { | 1519 IN_PROC_BROWSER_TEST_F(DeviceLocalAccountTest, OneRecommendedLocale) { |
1512 // Specify a recommended locale. | 1520 // Specify a recommended locale. |
1513 SetRecommendedLocales(kSingleRecommendedLocale, | 1521 SetRecommendedLocales(kSingleRecommendedLocale, |
1514 arraysize(kSingleRecommendedLocale)); | 1522 arraysize(kSingleRecommendedLocale)); |
1515 UploadAndInstallDeviceLocalAccountPolicy(); | 1523 UploadAndInstallDeviceLocalAccountPolicy(); |
1516 AddPublicSessionToDevicePolicy(kAccountId1); | 1524 AddPublicSessionToDevicePolicy(kAccountId1); |
1517 | 1525 |
1518 WaitForPolicy(); | 1526 WaitForPolicy(); |
1519 | 1527 |
1520 // Click on the pod to expand it. Verify that the pod expands to its basic | 1528 ExpandPublicSessionPod(false); |
1521 // form as there is only one recommended locale. | |
1522 bool advanced = false; | |
1523 ASSERT_TRUE(content::ExecuteScriptAndExtractBool( | |
1524 contents_, | |
1525 base::StringPrintf( | |
1526 "var pod =" | |
1527 " document.getElementById('pod-row').getPodWithUsername_('%s');" | |
1528 "pod.click();" | |
1529 "domAutomationController.send(pod.classList.contains('advanced'));", | |
1530 user_id_1_.c_str()), | |
1531 &advanced)); | |
1532 EXPECT_FALSE(advanced); | |
1533 | 1529 |
1534 // Click the enter button to start the session. | 1530 // Click the enter button to start the session. |
1535 ASSERT_TRUE(content::ExecuteScript( | 1531 ASSERT_TRUE(content::ExecuteScript( |
1536 contents_, | 1532 contents_, |
1537 base::StringPrintf( | 1533 base::StringPrintf( |
1538 "document.getElementById('pod-row').getPodWithUsername_('%s')" | 1534 "document.getElementById('pod-row').getPodWithUsername_('%s')" |
1539 " .querySelector('.enter-button').click();", | 1535 " .querySelector('.enter-button').click();", |
1540 user_id_1_.c_str()))); | 1536 user_id_1_.c_str()))); |
1541 | 1537 |
1542 WaitForSessionStart(); | 1538 WaitForSessionStart(); |
1543 | 1539 |
1544 // Verify that the recommended locale has been applied and the first keyboard | 1540 // Verify that the recommended locale has been applied and the first keyboard |
1545 // layout applicable to the locale was chosen. | 1541 // layout applicable to the locale was chosen. |
1546 EXPECT_EQ(kSingleRecommendedLocale[0], | 1542 EXPECT_EQ(kSingleRecommendedLocale[0], |
1547 g_browser_process->GetApplicationLocale()); | 1543 g_browser_process->GetApplicationLocale()); |
| 1544 EXPECT_EQ(l10n_util::GetLanguage(kSingleRecommendedLocale[0]), |
| 1545 icu::Locale::getDefault().getLanguage()); |
1548 VerifyKeyboardLayoutMatchesLocale(); | 1546 VerifyKeyboardLayoutMatchesLocale(); |
1549 } | 1547 } |
1550 | 1548 |
1551 IN_PROC_BROWSER_TEST_F(DeviceLocalAccountTest, MultipleRecommendedLocales) { | 1549 IN_PROC_BROWSER_TEST_F(DeviceLocalAccountTest, MultipleRecommendedLocales) { |
1552 // Specify recommended locales. | 1550 // Specify recommended locales. |
1553 SetRecommendedLocales(kRecommendedLocales1, arraysize(kRecommendedLocales1)); | 1551 SetRecommendedLocales(kRecommendedLocales1, arraysize(kRecommendedLocales1)); |
1554 UploadAndInstallDeviceLocalAccountPolicy(); | 1552 UploadAndInstallDeviceLocalAccountPolicy(); |
1555 AddPublicSessionToDevicePolicy(kAccountId1); | 1553 AddPublicSessionToDevicePolicy(kAccountId1); |
1556 AddPublicSessionToDevicePolicy(kAccountId2); | 1554 AddPublicSessionToDevicePolicy(kAccountId2); |
1557 | 1555 |
1558 WaitForPolicy(); | 1556 WaitForPolicy(); |
1559 | 1557 |
1560 // Click on the pod to expand it. Verify that the pod expands to its advanced | 1558 ExpandPublicSessionPod(true); |
1561 // form directly as there are two or more recommended locales. | |
1562 bool advanced = false; | |
1563 ASSERT_TRUE(content::ExecuteScriptAndExtractBool( | |
1564 contents_, | |
1565 base::StringPrintf( | |
1566 "var pod =" | |
1567 " document.getElementById('pod-row').getPodWithUsername_('%s');" | |
1568 "pod.click();" | |
1569 "domAutomationController.send(pod.classList.contains('advanced'));", | |
1570 user_id_1_.c_str()), | |
1571 &advanced)); | |
1572 EXPECT_TRUE(advanced); | |
1573 | 1559 |
1574 // Verify that the pod shows a list of locales beginning with the recommended | 1560 // Verify that the pod shows a list of locales beginning with the recommended |
1575 // ones, followed by others. | 1561 // ones, followed by others. |
1576 const std::string get_locale_list = base::StringPrintf( | 1562 const std::string get_locale_list = base::StringPrintf( |
1577 "var languageSelect = document.getElementById('pod-row')" | 1563 "var languageSelect = document.getElementById('pod-row')" |
1578 " .getPodWithUsername_('%s').querySelector('.language-select');" | 1564 " .getPodWithUsername_('%s').querySelector('.language-select');" |
1579 "var locales = [];" | 1565 "var locales = [];" |
1580 "for (var i = 0; i < languageSelect.length; ++i)" | 1566 "for (var i = 0; i < languageSelect.length; ++i)" |
1581 " locales.push(languageSelect.options[i].value);" | 1567 " locales.push(languageSelect.options[i].value);" |
1582 "domAutomationController.send(JSON.stringify(locales));", | 1568 "domAutomationController.send(JSON.stringify(locales));", |
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1725 "state.keyboardLayout = pod.querySelector('.keyboard-select').value;" | 1711 "state.keyboardLayout = pod.querySelector('.keyboard-select').value;" |
1726 "console.log(JSON.stringify(state));" | 1712 "console.log(JSON.stringify(state));" |
1727 "domAutomationController.send(JSON.stringify(state));", | 1713 "domAutomationController.send(JSON.stringify(state));", |
1728 user_id_1_.c_str()), | 1714 user_id_1_.c_str()), |
1729 &json)); | 1715 &json)); |
1730 LOG(ERROR) << json; | 1716 LOG(ERROR) << json; |
1731 value_ptr.reset(base::JSONReader::Read(json)); | 1717 value_ptr.reset(base::JSONReader::Read(json)); |
1732 const base::DictionaryValue* state = NULL; | 1718 const base::DictionaryValue* state = NULL; |
1733 ASSERT_TRUE(value_ptr); | 1719 ASSERT_TRUE(value_ptr); |
1734 ASSERT_TRUE(value_ptr->GetAsDictionary(&state)); | 1720 ASSERT_TRUE(value_ptr->GetAsDictionary(&state)); |
| 1721 bool advanced = false; |
1735 EXPECT_TRUE(state->GetBoolean("advanced", &advanced)); | 1722 EXPECT_TRUE(state->GetBoolean("advanced", &advanced)); |
1736 EXPECT_TRUE(advanced); | 1723 EXPECT_TRUE(advanced); |
1737 EXPECT_TRUE(state->GetString("locale", &selected_locale)); | 1724 EXPECT_TRUE(state->GetString("locale", &selected_locale)); |
1738 EXPECT_EQ(kPublicSessionLocale, selected_locale); | 1725 EXPECT_EQ(kPublicSessionLocale, selected_locale); |
1739 std::string selected_keyboard_layout; | 1726 std::string selected_keyboard_layout; |
1740 EXPECT_TRUE(state->GetString("keyboardLayout", &selected_keyboard_layout)); | 1727 EXPECT_TRUE(state->GetString("keyboardLayout", &selected_keyboard_layout)); |
1741 EXPECT_EQ(public_session_input_method_id_, selected_keyboard_layout); | 1728 EXPECT_EQ(public_session_input_method_id_, selected_keyboard_layout); |
1742 | 1729 |
1743 // Click the enter button to start the session. | 1730 // Click the enter button to start the session. |
1744 ASSERT_TRUE(content::ExecuteScript( | 1731 ASSERT_TRUE(content::ExecuteScript( |
1745 contents_, | 1732 contents_, |
1746 base::StringPrintf( | 1733 base::StringPrintf( |
1747 "document.getElementById('pod-row').getPodWithUsername_('%s')" | 1734 "document.getElementById('pod-row').getPodWithUsername_('%s')" |
1748 " .querySelector('.enter-button').click();", | 1735 " .querySelector('.enter-button').click();", |
1749 user_id_1_.c_str()))); | 1736 user_id_1_.c_str()))); |
1750 | 1737 |
1751 WaitForSessionStart(); | 1738 WaitForSessionStart(); |
1752 | 1739 |
1753 // Verify that the locale and keyboard layout have been applied. | 1740 // Verify that the locale and keyboard layout have been applied. |
1754 EXPECT_EQ(kPublicSessionLocale, g_browser_process->GetApplicationLocale()); | 1741 EXPECT_EQ(kPublicSessionLocale, g_browser_process->GetApplicationLocale()); |
| 1742 EXPECT_EQ(l10n_util::GetLanguage(kPublicSessionLocale), |
| 1743 icu::Locale::getDefault().getLanguage()); |
1755 EXPECT_EQ(public_session_input_method_id_, | 1744 EXPECT_EQ(public_session_input_method_id_, |
1756 chromeos::input_method::InputMethodManager::Get() | 1745 chromeos::input_method::InputMethodManager::Get() |
1757 ->GetActiveIMEState() | 1746 ->GetActiveIMEState() |
1758 ->GetCurrentInputMethod() | 1747 ->GetCurrentInputMethod() |
1759 .id()); | 1748 .id()); |
1760 } | 1749 } |
1761 | 1750 |
1762 IN_PROC_BROWSER_TEST_F(DeviceLocalAccountTest, | 1751 IN_PROC_BROWSER_TEST_F(DeviceLocalAccountTest, |
1763 AutoLoginWithoutRecommendedLocales) { | 1752 AutoLoginWithoutRecommendedLocales) { |
1764 const std::string initial_locale = g_browser_process->GetApplicationLocale(); | |
1765 | |
1766 UploadAndInstallDeviceLocalAccountPolicy(); | 1753 UploadAndInstallDeviceLocalAccountPolicy(); |
1767 AddPublicSessionToDevicePolicy(kAccountId1); | 1754 AddPublicSessionToDevicePolicy(kAccountId1); |
1768 EnableAutoLogin(); | 1755 EnableAutoLogin(); |
1769 | 1756 |
1770 WaitForPolicy(); | 1757 WaitForPolicy(); |
1771 | 1758 |
1772 WaitForSessionStart(); | 1759 WaitForSessionStart(); |
1773 | 1760 |
1774 // Verify that the locale has not changed and the first keyboard layout | 1761 // Verify that the locale has not changed and the first keyboard layout |
1775 // applicable to the locale was chosen. | 1762 // applicable to the locale was chosen. |
1776 EXPECT_EQ(initial_locale, g_browser_process->GetApplicationLocale()); | 1763 EXPECT_EQ(initial_locale_, g_browser_process->GetApplicationLocale()); |
| 1764 EXPECT_EQ(initial_language_, icu::Locale::getDefault().getLanguage()); |
1777 VerifyKeyboardLayoutMatchesLocale(); | 1765 VerifyKeyboardLayoutMatchesLocale(); |
1778 } | 1766 } |
1779 | 1767 |
1780 IN_PROC_BROWSER_TEST_F(DeviceLocalAccountTest, | 1768 IN_PROC_BROWSER_TEST_F(DeviceLocalAccountTest, |
1781 AutoLoginWithRecommendedLocales) { | 1769 AutoLoginWithRecommendedLocales) { |
1782 // Specify recommended locales. | 1770 // Specify recommended locales. |
1783 SetRecommendedLocales(kRecommendedLocales1, arraysize(kRecommendedLocales1)); | 1771 SetRecommendedLocales(kRecommendedLocales1, arraysize(kRecommendedLocales1)); |
1784 UploadAndInstallDeviceLocalAccountPolicy(); | 1772 UploadAndInstallDeviceLocalAccountPolicy(); |
1785 AddPublicSessionToDevicePolicy(kAccountId1); | 1773 AddPublicSessionToDevicePolicy(kAccountId1); |
1786 EnableAutoLogin(); | 1774 EnableAutoLogin(); |
1787 | 1775 |
1788 WaitForPolicy(); | 1776 WaitForPolicy(); |
1789 | 1777 |
1790 WaitForSessionStart(); | 1778 WaitForSessionStart(); |
1791 | 1779 |
1792 // Verify that the first recommended locale has been applied and the first | 1780 // Verify that the first recommended locale has been applied and the first |
1793 // keyboard layout applicable to the locale was chosen. | 1781 // keyboard layout applicable to the locale was chosen. |
1794 EXPECT_EQ(kRecommendedLocales1[0], g_browser_process->GetApplicationLocale()); | 1782 EXPECT_EQ(kRecommendedLocales1[0], g_browser_process->GetApplicationLocale()); |
| 1783 EXPECT_EQ(l10n_util::GetLanguage(kRecommendedLocales1[0]), |
| 1784 icu::Locale::getDefault().getLanguage()); |
1795 VerifyKeyboardLayoutMatchesLocale(); | 1785 VerifyKeyboardLayoutMatchesLocale(); |
1796 } | 1786 } |
1797 | 1787 |
1798 IN_PROC_BROWSER_TEST_F(DeviceLocalAccountTest, TermsOfServiceWithLocaleSwitch) { | 1788 IN_PROC_BROWSER_TEST_F(DeviceLocalAccountTest, TermsOfServiceWithLocaleSwitch) { |
1799 // Specify Terms of Service URL. | 1789 // Specify Terms of Service URL. |
1800 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady()); | 1790 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady()); |
1801 device_local_account_policy_.payload().mutable_termsofserviceurl()->set_value( | 1791 device_local_account_policy_.payload().mutable_termsofserviceurl()->set_value( |
1802 embedded_test_server()->GetURL( | 1792 embedded_test_server()->GetURL( |
1803 std::string("/") + kExistentTermsOfServicePath).spec()); | 1793 std::string("/") + kExistentTermsOfServicePath).spec()); |
1804 UploadAndInstallDeviceLocalAccountPolicy(); | 1794 UploadAndInstallDeviceLocalAccountPolicy(); |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1872 "}" | 1862 "}" |
1873 "var observer = new MutationObserver(SendReplyIfDownloadDone);" | 1863 "var observer = new MutationObserver(SendReplyIfDownloadDone);" |
1874 "if (!SendReplyIfDownloadDone()) {" | 1864 "if (!SendReplyIfDownloadDone()) {" |
1875 " var options = { attributes: true, attributeFilter: [ 'class' ] };" | 1865 " var options = { attributes: true, attributeFilter: [ 'class' ] };" |
1876 " observer.observe(screenElement, options);" | 1866 " observer.observe(screenElement, options);" |
1877 "}", | 1867 "}", |
1878 &done)); | 1868 &done)); |
1879 | 1869 |
1880 // Verify that the locale and keyboard layout have been applied. | 1870 // Verify that the locale and keyboard layout have been applied. |
1881 EXPECT_EQ(kPublicSessionLocale, g_browser_process->GetApplicationLocale()); | 1871 EXPECT_EQ(kPublicSessionLocale, g_browser_process->GetApplicationLocale()); |
| 1872 EXPECT_EQ(l10n_util::GetLanguage(kPublicSessionLocale), |
| 1873 icu::Locale::getDefault().getLanguage()); |
1882 EXPECT_EQ(public_session_input_method_id_, | 1874 EXPECT_EQ(public_session_input_method_id_, |
1883 chromeos::input_method::InputMethodManager::Get() | 1875 chromeos::input_method::InputMethodManager::Get() |
1884 ->GetActiveIMEState() | 1876 ->GetActiveIMEState() |
1885 ->GetCurrentInputMethod() | 1877 ->GetCurrentInputMethod() |
1886 .id()); | 1878 .id()); |
1887 | 1879 |
1888 // Click the accept button. | 1880 // Click the accept button. |
1889 ASSERT_TRUE(content::ExecuteScript(contents_, | 1881 ASSERT_TRUE(content::ExecuteScript(contents_, |
1890 "$('tos-accept-button').click();")); | 1882 "$('tos-accept-button').click();")); |
1891 | 1883 |
1892 WaitForSessionStart(); | 1884 WaitForSessionStart(); |
1893 | 1885 |
1894 // Verify that the locale and keyboard layout are still in force. | 1886 // Verify that the locale and keyboard layout are still in force. |
1895 EXPECT_EQ(kPublicSessionLocale, g_browser_process->GetApplicationLocale()); | 1887 EXPECT_EQ(kPublicSessionLocale, g_browser_process->GetApplicationLocale()); |
| 1888 EXPECT_EQ(l10n_util::GetLanguage(kPublicSessionLocale), |
| 1889 icu::Locale::getDefault().getLanguage()); |
1896 EXPECT_EQ(public_session_input_method_id_, | 1890 EXPECT_EQ(public_session_input_method_id_, |
1897 chromeos::input_method::InputMethodManager::Get() | 1891 chromeos::input_method::InputMethodManager::Get() |
1898 ->GetActiveIMEState() | 1892 ->GetActiveIMEState() |
1899 ->GetCurrentInputMethod() | 1893 ->GetCurrentInputMethod() |
1900 .id()); | 1894 .id()); |
1901 } | 1895 } |
1902 | 1896 |
1903 class TermsOfServiceDownloadTest : public DeviceLocalAccountTest, | 1897 class TermsOfServiceDownloadTest : public DeviceLocalAccountTest, |
1904 public testing::WithParamInterface<bool> { | 1898 public testing::WithParamInterface<bool> { |
1905 }; | 1899 }; |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2025 ASSERT_TRUE(content::ExecuteScript(contents_, | 2019 ASSERT_TRUE(content::ExecuteScript(contents_, |
2026 "$('tos-accept-button').click();")); | 2020 "$('tos-accept-button').click();")); |
2027 | 2021 |
2028 WaitForSessionStart(); | 2022 WaitForSessionStart(); |
2029 } | 2023 } |
2030 | 2024 |
2031 INSTANTIATE_TEST_CASE_P(TermsOfServiceDownloadTestInstance, | 2025 INSTANTIATE_TEST_CASE_P(TermsOfServiceDownloadTestInstance, |
2032 TermsOfServiceDownloadTest, testing::Bool()); | 2026 TermsOfServiceDownloadTest, testing::Bool()); |
2033 | 2027 |
2034 } // namespace policy | 2028 } // namespace policy |
OLD | NEW |