| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include <map> | 5 #include <map> |
| 6 #include <string> | 6 #include <string> |
| 7 | 7 |
| 8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
| 11 #include "base/callback.h" | 11 #include "base/callback.h" |
| 12 #include "base/command_line.h" | 12 #include "base/command_line.h" |
| 13 #include "base/file_util.h" | 13 #include "base/file_util.h" |
| 14 #include "base/files/file_path.h" | 14 #include "base/files/file_path.h" |
| 15 #include "base/files/scoped_temp_dir.h" | |
| 16 #include "base/json/json_reader.h" | 15 #include "base/json/json_reader.h" |
| 17 #include "base/memory/scoped_ptr.h" | 16 #include "base/memory/scoped_ptr.h" |
| 18 #include "base/message_loop/message_loop.h" | 17 #include "base/message_loop/message_loop.h" |
| 19 #include "base/path_service.h" | 18 #include "base/path_service.h" |
| 20 #include "base/run_loop.h" | 19 #include "base/run_loop.h" |
| 21 #include "base/strings/string_number_conversions.h" | |
| 22 #include "base/strings/string_util.h" | 20 #include "base/strings/string_util.h" |
| 23 #include "base/strings/stringprintf.h" | 21 #include "base/strings/stringprintf.h" |
| 24 #include "base/strings/utf_string_conversions.h" | 22 #include "base/strings/utf_string_conversions.h" |
| 25 #include "base/test/scoped_path_override.h" | |
| 26 #include "base/values.h" | 23 #include "base/values.h" |
| 27 #include "chrome/browser/browser_process.h" | 24 #include "chrome/browser/browser_process.h" |
| 28 #include "chrome/browser/chrome_notification_types.h" | 25 #include "chrome/browser/chrome_notification_types.h" |
| 29 #include "chrome/browser/chromeos/login/existing_user_controller.h" | 26 #include "chrome/browser/chromeos/login/existing_user_controller.h" |
| 30 #include "chrome/browser/chromeos/login/login_display_host.h" | 27 #include "chrome/browser/chromeos/login/login_display_host.h" |
| 31 #include "chrome/browser/chromeos/login/login_display_host_impl.h" | 28 #include "chrome/browser/chromeos/login/login_display_host_impl.h" |
| 32 #include "chrome/browser/chromeos/login/mock_login_status_consumer.h" | 29 #include "chrome/browser/chromeos/login/mock_login_status_consumer.h" |
| 33 #include "chrome/browser/chromeos/login/screens/wizard_screen.h" | 30 #include "chrome/browser/chromeos/login/screens/wizard_screen.h" |
| 34 #include "chrome/browser/chromeos/login/user.h" | 31 #include "chrome/browser/chromeos/login/user.h" |
| 35 #include "chrome/browser/chromeos/login/user_manager.h" | 32 #include "chrome/browser/chromeos/login/user_manager.h" |
| (...skipping 17 matching lines...) Expand all Loading... |
| 53 #include "chrome/browser/ui/browser_commands.h" | 50 #include "chrome/browser/ui/browser_commands.h" |
| 54 #include "chrome/browser/ui/browser_finder.h" | 51 #include "chrome/browser/ui/browser_finder.h" |
| 55 #include "chrome/browser/ui/browser_list.h" | 52 #include "chrome/browser/ui/browser_list.h" |
| 56 #include "chrome/browser/ui/browser_window.h" | 53 #include "chrome/browser/ui/browser_window.h" |
| 57 #include "chrome/browser/ui/host_desktop.h" | 54 #include "chrome/browser/ui/host_desktop.h" |
| 58 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 55 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
| 59 #include "chrome/browser/ui/webui/chromeos/login/oobe_ui.h" | 56 #include "chrome/browser/ui/webui/chromeos/login/oobe_ui.h" |
| 60 #include "chrome/common/chrome_paths.h" | 57 #include "chrome/common/chrome_paths.h" |
| 61 #include "chrome/common/chrome_switches.h" | 58 #include "chrome/common/chrome_switches.h" |
| 62 #include "chrome/common/extensions/extension.h" | 59 #include "chrome/common/extensions/extension.h" |
| 63 #include "chromeos/chromeos_paths.h" | |
| 64 #include "chromeos/chromeos_switches.h" | 60 #include "chromeos/chromeos_switches.h" |
| 65 #include "chromeos/dbus/cryptohome_client.h" | 61 #include "chromeos/dbus/cryptohome_client.h" |
| 66 #include "chromeos/dbus/dbus_method_call_status.h" | 62 #include "chromeos/dbus/dbus_method_call_status.h" |
| 67 #include "chromeos/dbus/fake_session_manager_client.h" | 63 #include "chromeos/dbus/fake_session_manager_client.h" |
| 68 #include "chromeos/dbus/session_manager_client.h" | 64 #include "chromeos/dbus/session_manager_client.h" |
| 69 #include "content/public/browser/notification_details.h" | 65 #include "content/public/browser/notification_details.h" |
| 70 #include "content/public/browser/notification_source.h" | 66 #include "content/public/browser/notification_source.h" |
| 71 #include "content/public/browser/web_contents.h" | 67 #include "content/public/browser/web_contents.h" |
| 72 #include "content/public/browser/web_ui.h" | 68 #include "content/public/browser/web_ui.h" |
| 73 #include "content/public/test/browser_test_utils.h" | 69 #include "content/public/test/browser_test_utils.h" |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 110 "<?xml version='1.0' encoding='UTF-8'?>\n" | 106 "<?xml version='1.0' encoding='UTF-8'?>\n" |
| 111 "<gupdate xmlns='http://www.google.com/update2/response' protocol='2.0'>\n"; | 107 "<gupdate xmlns='http://www.google.com/update2/response' protocol='2.0'>\n"; |
| 112 const char kUpdateManifestTemplate[] = | 108 const char kUpdateManifestTemplate[] = |
| 113 " <app appid='%s'>\n" | 109 " <app appid='%s'>\n" |
| 114 " <updatecheck codebase='%s' version='%s' />\n" | 110 " <updatecheck codebase='%s' version='%s' />\n" |
| 115 " </app>\n"; | 111 " </app>\n"; |
| 116 const char kUpdateManifestFooter[] = | 112 const char kUpdateManifestFooter[] = |
| 117 "</gupdate>\n"; | 113 "</gupdate>\n"; |
| 118 const char kHostedAppID[] = "kbmnembihfiondgfjekmnmcbddelicoi"; | 114 const char kHostedAppID[] = "kbmnembihfiondgfjekmnmcbddelicoi"; |
| 119 const char kHostedAppCRXPath[] = "extensions/hosted_app.crx"; | 115 const char kHostedAppCRXPath[] = "extensions/hosted_app.crx"; |
| 120 const char kHostedAppVersion[] = "1.0.0.0"; | 116 const char kHostedAppVersion[] = "0.1"; |
| 121 const char kGoodExtensionID[] = "ldnnhddmnhbkjipkidpdiheffobcpfmf"; | 117 const char kGoodExtensionID[] = "ldnnhddmnhbkjipkidpdiheffobcpfmf"; |
| 122 const char kGoodExtensionCRXPath[] = "extensions/good.crx"; | 118 const char kGoodExtensionPath[] = "extensions/good.crx"; |
| 123 const char kGoodExtensionVersion[] = "1.0"; | 119 const char kGoodExtensionVersion[] = "1.0"; |
| 124 | 120 |
| 125 // Helper that serves extension update manifests to Chrome. | 121 // Helper that serves extension update manifests to Chrome. |
| 126 class TestingUpdateManifestProvider { | 122 class TestingUpdateManifestProvider { |
| 127 public: | 123 public: |
| 128 | 124 |
| 129 // Update manifests will be served at |relative_update_url|. | 125 // Update manifests will be served at |relative_update_url|. |
| 130 explicit TestingUpdateManifestProvider( | 126 explicit TestingUpdateManifestProvider( |
| 131 const std::string& relative_update_url); | 127 const std::string& relative_update_url); |
| 132 ~TestingUpdateManifestProvider(); | 128 ~TestingUpdateManifestProvider(); |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 244 virtual void SetUp() OVERRIDE { | 240 virtual void SetUp() OVERRIDE { |
| 245 // Configure and start the test server. | 241 // Configure and start the test server. |
| 246 scoped_ptr<crypto::RSAPrivateKey> signing_key( | 242 scoped_ptr<crypto::RSAPrivateKey> signing_key( |
| 247 PolicyBuilder::CreateTestSigningKey()); | 243 PolicyBuilder::CreateTestSigningKey()); |
| 248 ASSERT_TRUE(test_server_.SetSigningKey(signing_key.get())); | 244 ASSERT_TRUE(test_server_.SetSigningKey(signing_key.get())); |
| 249 signing_key.reset(); | 245 signing_key.reset(); |
| 250 test_server_.RegisterClient(PolicyBuilder::kFakeToken, | 246 test_server_.RegisterClient(PolicyBuilder::kFakeToken, |
| 251 PolicyBuilder::kFakeDeviceId); | 247 PolicyBuilder::kFakeDeviceId); |
| 252 ASSERT_TRUE(test_server_.Start()); | 248 ASSERT_TRUE(test_server_.Start()); |
| 253 | 249 |
| 254 ASSERT_TRUE(extension_cache_root_dir_.CreateUniqueTempDir()); | |
| 255 extension_cache_root_dir_override_.reset(new base::ScopedPathOverride( | |
| 256 chromeos::DIR_DEVICE_LOCAL_ACCOUNT_CACHE, | |
| 257 extension_cache_root_dir_.path())); | |
| 258 | |
| 259 DevicePolicyCrosBrowserTest::SetUp(); | 250 DevicePolicyCrosBrowserTest::SetUp(); |
| 260 } | 251 } |
| 261 | 252 |
| 262 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { | 253 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { |
| 263 command_line->AppendSwitch(chromeos::switches::kLoginManager); | 254 command_line->AppendSwitch(chromeos::switches::kLoginManager); |
| 264 command_line->AppendSwitch(chromeos::switches::kForceLoginManagerInTests); | 255 command_line->AppendSwitch(chromeos::switches::kForceLoginManagerInTests); |
| 265 command_line->AppendSwitchASCII( | 256 command_line->AppendSwitchASCII( |
| 266 switches::kDeviceManagementUrl, test_server_.GetServiceURL().spec()); | 257 switches::kDeviceManagementUrl, test_server_.GetServiceURL().spec()); |
| 267 command_line->AppendSwitchASCII(chromeos::switches::kLoginProfile, "user"); | 258 command_line->AppendSwitchASCII(chromeos::switches::kLoginProfile, "user"); |
| 268 } | 259 } |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 338 std::string(), proto.SerializeAsString()); | 329 std::string(), proto.SerializeAsString()); |
| 339 } | 330 } |
| 340 | 331 |
| 341 void CheckPublicSessionPresent(const std::string& id) { | 332 void CheckPublicSessionPresent(const std::string& id) { |
| 342 const chromeos::User* user = chromeos::UserManager::Get()->FindUser(id); | 333 const chromeos::User* user = chromeos::UserManager::Get()->FindUser(id); |
| 343 ASSERT_TRUE(user); | 334 ASSERT_TRUE(user); |
| 344 EXPECT_EQ(id, user->email()); | 335 EXPECT_EQ(id, user->email()); |
| 345 EXPECT_EQ(chromeos::User::USER_TYPE_PUBLIC_ACCOUNT, user->GetType()); | 336 EXPECT_EQ(chromeos::User::USER_TYPE_PUBLIC_ACCOUNT, user->GetType()); |
| 346 } | 337 } |
| 347 | 338 |
| 348 base::FilePath GetCacheDirectoryForAccountID(const std::string& account_id) { | |
| 349 return extension_cache_root_dir_.path() | |
| 350 .Append(base::HexEncode(account_id.c_str(), account_id.size())); | |
| 351 } | |
| 352 | |
| 353 base::FilePath GetCacheCRXFile(const std::string& account_id, | |
| 354 const std::string& id, | |
| 355 const std::string& version) { | |
| 356 return GetCacheDirectoryForAccountID(account_id) | |
| 357 .Append(base::StringPrintf("%s-%s.crx", id.c_str(), version.c_str())); | |
| 358 } | |
| 359 | |
| 360 const std::string user_id_1_; | 339 const std::string user_id_1_; |
| 361 const std::string user_id_2_; | 340 const std::string user_id_2_; |
| 362 | 341 |
| 363 base::ScopedTempDir extension_cache_root_dir_; | |
| 364 scoped_ptr<base::ScopedPathOverride> extension_cache_root_dir_override_; | |
| 365 | |
| 366 UserPolicyBuilder device_local_account_policy_; | 342 UserPolicyBuilder device_local_account_policy_; |
| 367 LocalPolicyTestServer test_server_; | 343 LocalPolicyTestServer test_server_; |
| 368 }; | 344 }; |
| 369 | 345 |
| 370 static bool IsKnownUser(const std::string& account_id) { | 346 static bool IsKnownUser(const std::string& account_id) { |
| 371 return chromeos::UserManager::Get()->IsKnownUser(account_id); | 347 return chromeos::UserManager::Get()->IsKnownUser(account_id); |
| 372 } | 348 } |
| 373 | 349 |
| 374 IN_PROC_BROWSER_TEST_F(DeviceLocalAccountTest, LoginScreen) { | 350 IN_PROC_BROWSER_TEST_F(DeviceLocalAccountTest, LoginScreen) { |
| 375 AddPublicSessionToDevicePolicy(kAccountId1); | 351 AddPublicSessionToDevicePolicy(kAccountId1); |
| (...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 571 BrowserWindow* browser_window = browser->window(); | 547 BrowserWindow* browser_window = browser->window(); |
| 572 ASSERT_TRUE(browser_window); | 548 ASSERT_TRUE(browser_window); |
| 573 chrome::EndKeepAlive(); | 549 chrome::EndKeepAlive(); |
| 574 | 550 |
| 575 // Verify that an attempt to enter fullscreen mode is denied. | 551 // Verify that an attempt to enter fullscreen mode is denied. |
| 576 EXPECT_FALSE(browser_window->IsFullscreen()); | 552 EXPECT_FALSE(browser_window->IsFullscreen()); |
| 577 chrome::ToggleFullscreenMode(browser); | 553 chrome::ToggleFullscreenMode(browser); |
| 578 EXPECT_FALSE(browser_window->IsFullscreen()); | 554 EXPECT_FALSE(browser_window->IsFullscreen()); |
| 579 } | 555 } |
| 580 | 556 |
| 581 IN_PROC_BROWSER_TEST_F(DeviceLocalAccountTest, ExtensionsUncached) { | 557 IN_PROC_BROWSER_TEST_F(DeviceLocalAccountTest, ExtensionWhitelist) { |
| 582 // Make it possible to force-install a hosted app and an extension. | 558 // Make it possible to force-install a hosted app and an extension. |
| 583 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady()); | 559 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady()); |
| 584 TestingUpdateManifestProvider testing_update_manifest_provider( | 560 TestingUpdateManifestProvider testing_update_manifest_provider( |
| 585 kRelativeUpdateURL); | 561 kRelativeUpdateURL); |
| 586 testing_update_manifest_provider.AddUpdate( | 562 testing_update_manifest_provider.AddUpdate( |
| 587 kHostedAppID, | 563 kHostedAppID, |
| 588 kHostedAppVersion, | 564 kHostedAppVersion, |
| 589 embedded_test_server()->GetURL(std::string("/") + kHostedAppCRXPath)); | 565 embedded_test_server()->GetURL(std::string("/") + kHostedAppCRXPath)); |
| 590 testing_update_manifest_provider.AddUpdate( | 566 testing_update_manifest_provider.AddUpdate( |
| 591 kGoodExtensionID, | 567 kGoodExtensionID, |
| 592 kGoodExtensionVersion, | 568 kGoodExtensionVersion, |
| 593 embedded_test_server()->GetURL(std::string("/") + kGoodExtensionCRXPath)); | 569 embedded_test_server()->GetURL(std::string("/") + kGoodExtensionPath)); |
| 594 embedded_test_server()->RegisterRequestHandler( | 570 embedded_test_server()->RegisterRequestHandler( |
| 595 base::Bind(&TestingUpdateManifestProvider::HandleRequest, | 571 base::Bind(&TestingUpdateManifestProvider::HandleRequest, |
| 596 base::Unretained(&testing_update_manifest_provider))); | 572 base::Unretained(&testing_update_manifest_provider))); |
| 597 | 573 |
| 598 // Specify policy to force-install the hosted app and the extension. | 574 // Specify policy to force-install the hosted app and the extension. |
| 599 em::StringList* forcelist = device_local_account_policy_.payload() | 575 em::StringList* forcelist = device_local_account_policy_.payload() |
| 600 .mutable_extensioninstallforcelist()->mutable_value(); | 576 .mutable_extensioninstallforcelist()->mutable_value(); |
| 601 forcelist->add_entries(base::StringPrintf( | 577 forcelist->add_entries(base::StringPrintf( |
| 602 "%s;%s", | 578 "%s;%s", |
| 603 kHostedAppID, | 579 kHostedAppID, |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 642 base::Bind(DoesInstallFailureReferToId, kGoodExtensionID)); | 618 base::Bind(DoesInstallFailureReferToId, kGoodExtensionID)); |
| 643 | 619 |
| 644 // Start login into the device-local account. | 620 // Start login into the device-local account. |
| 645 host->StartSignInScreen(); | 621 host->StartSignInScreen(); |
| 646 chromeos::ExistingUserController* controller = | 622 chromeos::ExistingUserController* controller = |
| 647 chromeos::ExistingUserController::current_controller(); | 623 chromeos::ExistingUserController::current_controller(); |
| 648 ASSERT_TRUE(controller); | 624 ASSERT_TRUE(controller); |
| 649 controller->LoginAsPublicAccount(user_id_1_); | 625 controller->LoginAsPublicAccount(user_id_1_); |
| 650 | 626 |
| 651 // Wait for the hosted app installation to succeed and the extension | 627 // Wait for the hosted app installation to succeed and the extension |
| 652 // installation to fail (because hosted apps are whitelisted for use in | |
| 653 // device-local accounts and extensions are not). | |
| 654 hosted_app_observer.Wait(); | |
| 655 extension_observer.Wait(); | |
| 656 | |
| 657 // Verify that the hosted app was installed. | |
| 658 Profile* profile = ProfileManager::GetDefaultProfile(); | |
| 659 ASSERT_TRUE(profile); | |
| 660 ExtensionService* extension_service = | |
| 661 extensions::ExtensionSystem::Get(profile)->extension_service(); | |
| 662 EXPECT_TRUE(extension_service->GetExtensionById(kHostedAppID, true)); | |
| 663 | |
| 664 // Verify that the extension was not installed. | |
| 665 EXPECT_FALSE(extension_service->GetExtensionById(kGoodExtensionID, true)); | |
| 666 | |
| 667 // Verify that the app was copied to the account's extension cache. | |
| 668 base::FilePath test_dir; | |
| 669 ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &test_dir)); | |
| 670 EXPECT_TRUE(ContentsEqual( | |
| 671 GetCacheCRXFile(kAccountId1, kHostedAppID, kHostedAppVersion), | |
| 672 test_dir.Append(kHostedAppCRXPath))); | |
| 673 | |
| 674 // Verify that the extension was not copied to the account's extension cache. | |
| 675 EXPECT_FALSE(PathExists(GetCacheCRXFile( | |
| 676 kAccountId1, kGoodExtensionID, kGoodExtensionVersion))); | |
| 677 } | |
| 678 | |
| 679 IN_PROC_BROWSER_TEST_F(DeviceLocalAccountTest, ExtensionsCached) { | |
| 680 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady()); | |
| 681 | |
| 682 // Pre-populate the device local account's extension cache with a hosted app | |
| 683 // and an extension. | |
| 684 EXPECT_TRUE(file_util::CreateDirectory( | |
| 685 GetCacheDirectoryForAccountID(kAccountId1))); | |
| 686 base::FilePath test_dir; | |
| 687 ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &test_dir)); | |
| 688 const base::FilePath cached_hosted_app = | |
| 689 GetCacheCRXFile(kAccountId1, kHostedAppID, kHostedAppVersion); | |
| 690 EXPECT_TRUE(CopyFile(test_dir.Append(kHostedAppCRXPath), | |
| 691 cached_hosted_app)); | |
| 692 const base::FilePath cached_extension = | |
| 693 GetCacheCRXFile(kAccountId1, kGoodExtensionID, kGoodExtensionVersion); | |
| 694 EXPECT_TRUE(CopyFile(test_dir.Append(kGoodExtensionCRXPath), | |
| 695 cached_extension)); | |
| 696 | |
| 697 // Specify policy to force-install the hosted app. | |
| 698 em::StringList* forcelist = device_local_account_policy_.payload() | |
| 699 .mutable_extensioninstallforcelist()->mutable_value(); | |
| 700 forcelist->add_entries(base::StringPrintf( | |
| 701 "%s;%s", | |
| 702 kHostedAppID, | |
| 703 embedded_test_server()->GetURL(kRelativeUpdateURL).spec().c_str())); | |
| 704 forcelist->add_entries(base::StringPrintf( | |
| 705 "%s;%s", | |
| 706 kGoodExtensionID, | |
| 707 embedded_test_server()->GetURL(kRelativeUpdateURL).spec().c_str())); | |
| 708 | |
| 709 UploadAndInstallDeviceLocalAccountPolicy(); | |
| 710 AddPublicSessionToDevicePolicy(kAccountId1); | |
| 711 | |
| 712 // This observes the display name becoming available as this indicates | |
| 713 // device-local account policy is fully loaded, which is a prerequisite for | |
| 714 // successful login. | |
| 715 content::WindowedNotificationObserver( | |
| 716 chrome::NOTIFICATION_USER_LIST_CHANGED, | |
| 717 base::Bind(&DisplayNameMatches, user_id_1_, kDisplayName)).Wait(); | |
| 718 | |
| 719 // Wait for the login UI to be ready. | |
| 720 chromeos::LoginDisplayHostImpl* host = | |
| 721 reinterpret_cast<chromeos::LoginDisplayHostImpl*>( | |
| 722 chromeos::LoginDisplayHostImpl::default_host()); | |
| 723 ASSERT_TRUE(host); | |
| 724 chromeos::OobeUI* oobe_ui = host->GetOobeUI(); | |
| 725 ASSERT_TRUE(oobe_ui); | |
| 726 base::RunLoop run_loop; | |
| 727 const bool oobe_ui_ready = oobe_ui->IsJSReady(run_loop.QuitClosure()); | |
| 728 if (!oobe_ui_ready) | |
| 729 run_loop.Run(); | |
| 730 | |
| 731 // Ensure that the browser stays alive, even though no windows are opened | |
| 732 // during session start. | |
| 733 chrome::StartKeepAlive(); | |
| 734 | |
| 735 // Start listening for app/extension installation results. | |
| 736 content::WindowedNotificationObserver hosted_app_observer( | |
| 737 chrome::NOTIFICATION_EXTENSION_INSTALLED, | |
| 738 base::Bind(DoesInstallSuccessReferToId, kHostedAppID)); | |
| 739 content::WindowedNotificationObserver extension_observer( | |
| 740 chrome::NOTIFICATION_EXTENSION_INSTALL_ERROR, | |
| 741 base::Bind(DoesInstallFailureReferToId, kGoodExtensionID)); | |
| 742 | |
| 743 // Start login into the device-local account. | |
| 744 host->StartSignInScreen(); | |
| 745 chromeos::ExistingUserController* controller = | |
| 746 chromeos::ExistingUserController::current_controller(); | |
| 747 ASSERT_TRUE(controller); | |
| 748 controller->LoginAsPublicAccount(user_id_1_); | |
| 749 | |
| 750 // Wait for the hosted app installation to succeed and the extension | |
| 751 // installation to fail. | 628 // installation to fail. |
| 752 hosted_app_observer.Wait(); | 629 hosted_app_observer.Wait(); |
| 753 extension_observer.Wait(); | 630 extension_observer.Wait(); |
| 754 | 631 |
| 755 // Verify that the hosted app was installed. | 632 // Verify that the hosted app was installed. |
| 756 Profile* profile = ProfileManager::GetDefaultProfile(); | 633 Profile* profile = ProfileManager::GetDefaultProfile(); |
| 757 ASSERT_TRUE(profile); | 634 ASSERT_TRUE(profile); |
| 758 ExtensionService* extension_service = | 635 ExtensionService* extension_service = |
| 759 extensions::ExtensionSystem::Get(profile)->extension_service(); | 636 extensions::ExtensionSystem::Get(profile)->extension_service(); |
| 760 EXPECT_TRUE(extension_service->GetExtensionById(kHostedAppID, true)); | 637 EXPECT_TRUE(extension_service->GetExtensionById(kHostedAppID, true)); |
| 761 | 638 |
| 762 // Verify that the extension was not installed. | 639 // Verify that the extension was not installed. |
| 763 EXPECT_FALSE(extension_service->GetExtensionById(kGoodExtensionID, true)); | 640 EXPECT_FALSE(extension_service->GetExtensionById(kGoodExtensionID, true)); |
| 764 | |
| 765 // Verify that the app is still in the account's extension cache. | |
| 766 EXPECT_TRUE(PathExists(cached_hosted_app)); | |
| 767 | |
| 768 // Verify that the extension was removed from the account's extension cache. | |
| 769 EXPECT_FALSE(PathExists(cached_extension)); | |
| 770 } | 641 } |
| 771 | 642 |
| 772 class TermsOfServiceTest : public DeviceLocalAccountTest, | 643 class TermsOfServiceTest : public DeviceLocalAccountTest, |
| 773 public testing::WithParamInterface<bool> { | 644 public testing::WithParamInterface<bool> { |
| 774 }; | 645 }; |
| 775 | 646 |
| 776 IN_PROC_BROWSER_TEST_P(TermsOfServiceTest, TermsOfServiceScreen) { | 647 IN_PROC_BROWSER_TEST_P(TermsOfServiceTest, TermsOfServiceScreen) { |
| 777 // Specify Terms of Service URL. | 648 // Specify Terms of Service URL. |
| 778 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady()); | 649 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady()); |
| 779 device_local_account_policy_.payload().mutable_termsofserviceurl()->set_value( | 650 device_local_account_policy_.payload().mutable_termsofserviceurl()->set_value( |
| (...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 923 if (!IsSessionStarted()) { | 794 if (!IsSessionStarted()) { |
| 924 content::WindowedNotificationObserver(chrome::NOTIFICATION_SESSION_STARTED, | 795 content::WindowedNotificationObserver(chrome::NOTIFICATION_SESSION_STARTED, |
| 925 base::Bind(IsSessionStarted)).Wait(); | 796 base::Bind(IsSessionStarted)).Wait(); |
| 926 } | 797 } |
| 927 } | 798 } |
| 928 | 799 |
| 929 INSTANTIATE_TEST_CASE_P(TermsOfServiceTestInstance, | 800 INSTANTIATE_TEST_CASE_P(TermsOfServiceTestInstance, |
| 930 TermsOfServiceTest, testing::Bool()); | 801 TermsOfServiceTest, testing::Bool()); |
| 931 | 802 |
| 932 } // namespace policy | 803 } // namespace policy |
| OLD | NEW |