Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(702)

Side by Side Diff: chrome/browser/chromeos/login/kiosk_browsertest.cc

Issue 300843013: Install and launch kiosk app from cached crx file at start up. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Remove the useless offline_enabled_app_profile testing data. Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 "apps/app_window.h" 5 #include "apps/app_window.h"
6 #include "apps/app_window_registry.h" 6 #include "apps/app_window_registry.h"
7 #include "apps/ui/native_app_window.h" 7 #include "apps/ui/native_app_window.h"
8 #include "ash/desktop_background/desktop_background_controller.h" 8 #include "ash/desktop_background/desktop_background_controller.h"
9 #include "ash/desktop_background/desktop_background_controller_observer.h" 9 #include "ash/desktop_background/desktop_background_controller_observer.h"
10 #include "ash/shell.h" 10 #include "ash/shell.h"
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after
230 public: 230 public:
231 KioskTest() : fake_cws_(new FakeCWS) { 231 KioskTest() : fake_cws_(new FakeCWS) {
232 set_exit_when_last_browser_closes(false); 232 set_exit_when_last_browser_closes(false);
233 } 233 }
234 234
235 virtual ~KioskTest() {} 235 virtual ~KioskTest() {}
236 236
237 protected: 237 protected:
238 virtual void SetUp() OVERRIDE { 238 virtual void SetUp() OVERRIDE {
239 test_app_id_ = kTestKioskApp; 239 test_app_id_ = kTestKioskApp;
240 set_test_app_version("1.0.0");
241 set_test_crx_file(test_app_id() + ".crx");
242 needs_background_networking_ = true;
240 mock_user_manager_.reset(new MockUserManager); 243 mock_user_manager_.reset(new MockUserManager);
241 ProfileHelper::SetAlwaysReturnPrimaryUserForTesting(true); 244 ProfileHelper::SetAlwaysReturnPrimaryUserForTesting(true);
242 AppLaunchController::SkipSplashWaitForTesting(); 245 AppLaunchController::SkipSplashWaitForTesting();
243 AppLaunchController::SetNetworkWaitForTesting(kTestNetworkTimeoutSeconds); 246 AppLaunchController::SetNetworkWaitForTesting(kTestNetworkTimeoutSeconds);
244 247
245 OobeBaseTest::SetUp(); 248 OobeBaseTest::SetUp();
246 } 249 }
247 250
248 virtual void TearDown() OVERRIDE { 251 virtual void TearDown() OVERRIDE {
249 ProfileHelper::SetAlwaysReturnPrimaryUserForTesting(false); 252 ProfileHelper::SetAlwaysReturnPrimaryUserForTesting(false);
(...skipping 18 matching lines...) Expand all
268 271
269 void LaunchApp(const std::string& app_id, bool diagnostic_mode) { 272 void LaunchApp(const std::string& app_id, bool diagnostic_mode) {
270 bool new_kiosk_ui = KioskAppMenuHandler::EnableNewKioskUI(); 273 bool new_kiosk_ui = KioskAppMenuHandler::EnableNewKioskUI();
271 GetLoginUI()->CallJavascriptFunction(new_kiosk_ui ? 274 GetLoginUI()->CallJavascriptFunction(new_kiosk_ui ?
272 kLaunchAppForTestNewAPI : kLaunchAppForTestOldAPI, 275 kLaunchAppForTestNewAPI : kLaunchAppForTestOldAPI,
273 base::StringValue(app_id), 276 base::StringValue(app_id),
274 base::FundamentalValue(diagnostic_mode)); 277 base::FundamentalValue(diagnostic_mode));
275 } 278 }
276 279
277 void ReloadKioskApps() { 280 void ReloadKioskApps() {
281 SetupTestAppUpdateCheck();
282
278 // Remove then add to ensure NOTIFICATION_KIOSK_APPS_LOADED fires. 283 // Remove then add to ensure NOTIFICATION_KIOSK_APPS_LOADED fires.
279 KioskAppManager::Get()->RemoveApp(test_app_id_); 284 KioskAppManager::Get()->RemoveApp(test_app_id_);
280 KioskAppManager::Get()->AddApp(test_app_id_); 285 KioskAppManager::Get()->AddApp(test_app_id_);
281 } 286 }
282 287
288 void SetupTestAppUpdateCheck() {
289 if (!test_app_version().empty()) {
290 fake_cws_->SetUpdateCrx(
291 test_app_id(), test_crx_file(), test_app_version());
292 }
293 }
294
283 void ReloadAutolaunchKioskApps() { 295 void ReloadAutolaunchKioskApps() {
296 SetupTestAppUpdateCheck();
297
284 KioskAppManager::Get()->AddApp(test_app_id_); 298 KioskAppManager::Get()->AddApp(test_app_id_);
285 KioskAppManager::Get()->SetAutoLaunchApp(test_app_id_); 299 KioskAppManager::Get()->SetAutoLaunchApp(test_app_id_);
286 } 300 }
287 301
288 void PrepareAppLaunch() { 302 void StartUIForAppLaunch() {
289 EnableConsumerKioskMode(); 303 EnableConsumerKioskMode();
290 304
291 // Start UI 305 // Start UI
292 content::WindowedNotificationObserver login_signal( 306 content::WindowedNotificationObserver login_signal(
293 chrome::NOTIFICATION_LOGIN_OR_LOCK_WEBUI_VISIBLE, 307 chrome::NOTIFICATION_LOGIN_OR_LOCK_WEBUI_VISIBLE,
294 content::NotificationService::AllSources()); 308 content::NotificationService::AllSources());
295 chromeos::WizardController::SkipPostLoginScreensForTesting(); 309 chromeos::WizardController::SkipPostLoginScreensForTesting();
296 chromeos::WizardController* wizard_controller = 310 chromeos::WizardController* wizard_controller =
297 chromeos::WizardController::default_controller(); 311 chromeos::WizardController::default_controller();
298 if (wizard_controller) { 312 if (wizard_controller) {
299 wizard_controller->SkipToLoginForTesting(LoginScreenContext()); 313 wizard_controller->SkipToLoginForTesting(LoginScreenContext());
300 login_signal.Wait(); 314 login_signal.Wait();
301 } else { 315 } else {
302 // No wizard and running with an existing profile and it should land 316 // No wizard and running with an existing profile and it should land
303 // on account picker when new kiosk UI is enabled. Otherwise, just 317 // on account picker when new kiosk UI is enabled. Otherwise, just
304 // wait for the login signal from Gaia. 318 // wait for the login signal from Gaia.
305 if (KioskAppMenuHandler::EnableNewKioskUI()) 319 if (KioskAppMenuHandler::EnableNewKioskUI())
306 OobeScreenWaiter(OobeDisplay::SCREEN_ACCOUNT_PICKER).Wait(); 320 OobeScreenWaiter(OobeDisplay::SCREEN_ACCOUNT_PICKER).Wait();
307 else 321 else
308 login_signal.Wait(); 322 login_signal.Wait();
309 } 323 }
324 }
325
326 void PrepareAppLaunch() {
327 // Start UI
328 StartUIForAppLaunch();
310 329
311 // Wait for the Kiosk App configuration to reload. 330 // Wait for the Kiosk App configuration to reload.
312 content::WindowedNotificationObserver apps_loaded_signal( 331 content::WindowedNotificationObserver apps_loaded_signal(
313 chrome::NOTIFICATION_KIOSK_APPS_LOADED, 332 chrome::NOTIFICATION_KIOSK_APPS_LOADED,
314 content::NotificationService::AllSources()); 333 content::NotificationService::AllSources());
315 ReloadKioskApps(); 334 ReloadKioskApps();
316 apps_loaded_signal.Wait(); 335 apps_loaded_signal.Wait();
317 } 336 }
318 337
319 void StartAppLaunchFromLoginScreen(const base::Closure& network_setup_cb) { 338 void StartAppLaunchFromLoginScreen(const base::Closure& network_setup_cb) {
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
424 KioskAppManager::Get()->GetConsumerKioskAutoLaunchStatus( 443 KioskAppManager::Get()->GetConsumerKioskAutoLaunchStatus(
425 base::Bind(&ConsumerKioskAutoLaunchStatusCheck, 444 base::Bind(&ConsumerKioskAutoLaunchStatusCheck,
426 &status, 445 &status,
427 runner->QuitClosure())); 446 runner->QuitClosure()));
428 runner->Run(); 447 runner->Run();
429 CHECK_NE(status, 448 CHECK_NE(status,
430 static_cast<KioskAppManager::ConsumerKioskAutoLaunchStatus>(-1)); 449 static_cast<KioskAppManager::ConsumerKioskAutoLaunchStatus>(-1));
431 return status; 450 return status;
432 } 451 }
433 452
434 // Copies the app profile from |relative_app_profile_dir| from test directory
435 // to the app profile directory (assuming "user") under testing profile. This
436 // is for that needs to have a kiosk app already installed from a previous
437 // run. Note this must be called before app profile is loaded.
438 void SetupAppProfile(const std::string& relative_app_profile_dir) {
439 base::FilePath app_profile_dir;
440 KioskAppManager::App app_data;
441 CHECK(KioskAppManager::Get()->GetApp(test_app_id(), &app_data));
442 std::string app_user_id_hash =
443 CryptohomeClient::GetStubSanitizedUsername(app_data.user_id);
444 app_profile_dir =
445 ProfileHelper::GetProfilePathByUserIdHash(app_user_id_hash);
446 ASSERT_TRUE(base::CreateDirectory(app_profile_dir));
447
448 base::FilePath test_data_dir;
449 ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &test_data_dir));
450 test_data_dir = test_data_dir.AppendASCII(relative_app_profile_dir);
451 ASSERT_TRUE(
452 base::CopyFile(test_data_dir.Append(chrome::kPreferencesFilename),
453 app_profile_dir.Append(chrome::kPreferencesFilename)));
454 ASSERT_TRUE(
455 base::CopyDirectory(test_data_dir.AppendASCII("Extensions"),
456 app_profile_dir,
457 true));
458 }
459
460 void RunAppLaunchNetworkDownTest() { 453 void RunAppLaunchNetworkDownTest() {
461 mock_user_manager()->SetActiveUser(kTestOwnerEmail); 454 mock_user_manager()->SetActiveUser(kTestOwnerEmail);
462 AppLaunchSigninScreen::SetUserManagerForTesting(mock_user_manager()); 455 AppLaunchSigninScreen::SetUserManagerForTesting(mock_user_manager());
463 456
464 // Mock network could be configured with owner's password. 457 // Mock network could be configured with owner's password.
465 ScopedCanConfigureNetwork can_configure_network(true, true); 458 ScopedCanConfigureNetwork can_configure_network(true, true);
466 459
467 // Start app launch and wait for network connectivity timeout. 460 // Start app launch and wait for network connectivity timeout.
468 StartAppLaunchFromLoginScreen(SimulateNetworkOfflineClosure()); 461 StartAppLaunchFromLoginScreen(SimulateNetworkOfflineClosure());
469 OobeScreenWaiter splash_waiter(OobeDisplay::SCREEN_APP_LAUNCH_SPLASH); 462 OobeScreenWaiter splash_waiter(OobeDisplay::SCREEN_APP_LAUNCH_SPLASH);
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
502 return chromeos::LoginDisplayHostImpl::default_host() 495 return chromeos::LoginDisplayHostImpl::default_host()
503 ->GetAppLaunchController(); 496 ->GetAppLaunchController();
504 } 497 }
505 498
506 MockUserManager* mock_user_manager() { return mock_user_manager_.get(); } 499 MockUserManager* mock_user_manager() { return mock_user_manager_.get(); }
507 500
508 void set_test_app_id(const std::string& test_app_id) { 501 void set_test_app_id(const std::string& test_app_id) {
509 test_app_id_ = test_app_id; 502 test_app_id_ = test_app_id;
510 } 503 }
511 const std::string& test_app_id() const { return test_app_id_; } 504 const std::string& test_app_id() const { return test_app_id_; }
505 void set_test_app_version(const std::string& version) {
506 test_app_version_ = version;
507 }
508 const std::string& test_app_version() const { return test_app_version_; }
509 void set_test_crx_file(const std::string& filename) {
510 test_crx_file_ = filename;
511 }
512 const std::string& test_crx_file() const { return test_crx_file_; }
512 FakeCWS* fake_cws() { return fake_cws_.get(); } 513 FakeCWS* fake_cws() { return fake_cws_.get(); }
513 514
514 private: 515 private:
515 std::string test_app_id_; 516 std::string test_app_id_;
517 std::string test_app_version_;
518 std::string test_crx_file_;
516 scoped_ptr<FakeCWS> fake_cws_; 519 scoped_ptr<FakeCWS> fake_cws_;
517 scoped_ptr<MockUserManager> mock_user_manager_; 520 scoped_ptr<MockUserManager> mock_user_manager_;
518 521
519 DISALLOW_COPY_AND_ASSIGN(KioskTest); 522 DISALLOW_COPY_AND_ASSIGN(KioskTest);
520 }; 523 };
521 524
522 IN_PROC_BROWSER_TEST_F(KioskTest, InstallAndLaunchApp) { 525 IN_PROC_BROWSER_TEST_F(KioskTest, InstallAndLaunchApp) {
523 StartAppLaunchFromLoginScreen(SimulateNetworkOnlineClosure()); 526 StartAppLaunchFromLoginScreen(SimulateNetworkOnlineClosure());
524 WaitForAppLaunchSuccess(); 527 WaitForAppLaunchSuccess();
525 } 528 }
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
612 // Network error should show up automatically since this test does not 615 // Network error should show up automatically since this test does not
613 // require owner auth to configure network. 616 // require owner auth to configure network.
614 OobeScreenWaiter(OobeDisplay::SCREEN_ERROR_MESSAGE).Wait(); 617 OobeScreenWaiter(OobeDisplay::SCREEN_ERROR_MESSAGE).Wait();
615 618
616 ASSERT_TRUE(GetAppLaunchController()->showing_network_dialog()); 619 ASSERT_TRUE(GetAppLaunchController()->showing_network_dialog());
617 SimulateNetworkOnline(); 620 SimulateNetworkOnline();
618 WaitForAppLaunchSuccess(); 621 WaitForAppLaunchSuccess();
619 } 622 }
620 623
621 IN_PROC_BROWSER_TEST_F(KioskTest, LaunchAppUserCancel) { 624 IN_PROC_BROWSER_TEST_F(KioskTest, LaunchAppUserCancel) {
625 // Make fake_cws_ return empty update response.
626 set_test_app_version("");
622 StartAppLaunchFromLoginScreen(SimulateNetworkOfflineClosure()); 627 StartAppLaunchFromLoginScreen(SimulateNetworkOfflineClosure());
623 OobeScreenWaiter splash_waiter(OobeDisplay::SCREEN_APP_LAUNCH_SPLASH); 628 OobeScreenWaiter splash_waiter(OobeDisplay::SCREEN_APP_LAUNCH_SPLASH);
624 splash_waiter.Wait(); 629 splash_waiter.Wait();
625 630
626 CrosSettings::Get()->SetBoolean( 631 CrosSettings::Get()->SetBoolean(
627 kAccountsPrefDeviceLocalAccountAutoLoginBailoutEnabled, true); 632 kAccountsPrefDeviceLocalAccountAutoLoginBailoutEnabled, true);
628 content::WindowedNotificationObserver signal( 633 content::WindowedNotificationObserver signal(
629 chrome::NOTIFICATION_APP_TERMINATING, 634 chrome::NOTIFICATION_APP_TERMINATING,
630 content::NotificationService::AllSources()); 635 content::NotificationService::AllSources());
631 GetLoginUI()->CallJavascriptFunction("cr.ui.Oobe.handleAccelerator", 636 GetLoginUI()->CallJavascriptFunction("cr.ui.Oobe.handleAccelerator",
(...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after
875 chrome::NOTIFICATION_KIOSK_ENABLE_WARNING_VISIBLE, 880 chrome::NOTIFICATION_KIOSK_ENABLE_WARNING_VISIBLE,
876 content::NotificationService::AllSources()).Wait(); 881 content::NotificationService::AllSources()).Wait();
877 } 882 }
878 883
879 class KioskUpdateTest : public KioskTest { 884 class KioskUpdateTest : public KioskTest {
880 public: 885 public:
881 KioskUpdateTest() {} 886 KioskUpdateTest() {}
882 virtual ~KioskUpdateTest() {} 887 virtual ~KioskUpdateTest() {}
883 888
884 protected: 889 protected:
885 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE {
886 // Needs background networking so that ExtensionDownloader works.
887 needs_background_networking_ = true;
888 KioskTest::SetUpCommandLine(command_line);
889 }
890
891 virtual void SetUpOnMainThread() OVERRIDE { 890 virtual void SetUpOnMainThread() OVERRIDE {
892 KioskTest::SetUpOnMainThread(); 891 KioskTest::SetUpOnMainThread();
893 } 892 }
894 893
894 void PreCacheApp(const std::string& app_id,
895 const std::string& version,
896 const std::string& crx_file) {
897 set_test_app_id(app_id);
898 set_test_app_version(version);
899 set_test_crx_file(crx_file);
900
901 KioskAppManager* manager = KioskAppManager::Get();
902 AppDataLoadWaiter waiter(manager, app_id, version);
903 ReloadKioskApps();
904 waiter.Wait();
905 EXPECT_TRUE(waiter.loaded());
906 std::string cached_version;
907 base::FilePath file_path;
908 EXPECT_TRUE(manager->GetCachedCrx(app_id, &file_path, &cached_version));
909 EXPECT_EQ(version, cached_version);
910 }
911
912 void UpdateExternalCache(const std::string& version,
913 const std::string& crx_file) {
914 set_test_app_version(version);
915 set_test_crx_file(crx_file);
916 SetupTestAppUpdateCheck();
917
918 KioskAppManager* manager = KioskAppManager::Get();
919 AppDataLoadWaiter waiter(manager, test_app_id(), version);
920 KioskAppManager::Get()->UpdateExternalCache();
921 waiter.Wait();
922 EXPECT_TRUE(waiter.loaded());
923 std::string cached_version;
924 base::FilePath file_path;
925 EXPECT_TRUE(
926 manager->GetCachedCrx(test_app_id(), &file_path, &cached_version));
927 EXPECT_EQ(version, cached_version);
928 }
929
930 void PreCacheAndLaunchApp(const std::string& app_id,
931 const std::string& version,
932 const std::string& crx_file) {
933 set_test_app_id(app_id);
934 set_test_app_version(version);
935 set_test_crx_file(crx_file);
936 PrepareAppLaunch();
937 SimulateNetworkOnline();
938 LaunchApp(test_app_id(), false);
939 WaitForAppLaunchSuccess();
940 EXPECT_EQ(version, GetInstalledAppVersion().GetString());
941 }
942
895 private: 943 private:
944 class AppDataLoadWaiter : public KioskAppManagerObserver {
945 public:
946 AppDataLoadWaiter(KioskAppManager* manager,
947 const std::string& app_id,
948 const std::string& version)
949 : runner_(NULL),
950 manager_(manager),
951 loaded_(false),
952 quit_(false),
953 app_id_(app_id),
954 version_(version) {
955 manager_->AddObserver(this);
956 }
957
958 virtual ~AppDataLoadWaiter() { manager_->RemoveObserver(this); }
959
960 void Wait() {
961 if (quit_)
962 return;
963 runner_ = new content::MessageLoopRunner;
964 runner_->Run();
965 }
966
967 bool loaded() const { return loaded_; }
968
969 private:
970 // KioskAppManagerObserver overrides:
971 virtual void OnKioskExtensionLoadedInCache(
972 const std::string& app_id) OVERRIDE {
973 std::string cached_version;
974 base::FilePath file_path;
975 if (!manager_->GetCachedCrx(app_id_, &file_path, &cached_version))
976 return;
977 if (version_ != cached_version)
978 return;
979 loaded_ = true;
980 quit_ = true;
981 if (runner_)
982 runner_->Quit();
983 }
984
985 virtual void OnKioskExtensionDownloadFailed(
986 const std::string& app_id) OVERRIDE {
987 loaded_ = false;
988 quit_ = true;
989 if (runner_)
990 runner_->Quit();
991 }
992
993 scoped_refptr<content::MessageLoopRunner> runner_;
994 KioskAppManager* manager_;
995 bool loaded_;
996 bool quit_;
997 std::string app_id_;
998 std::string version_;
999
1000 DISALLOW_COPY_AND_ASSIGN(AppDataLoadWaiter);
1001 };
896 1002
897 DISALLOW_COPY_AND_ASSIGN(KioskUpdateTest); 1003 DISALLOW_COPY_AND_ASSIGN(KioskUpdateTest);
898 }; 1004 };
899 1005
1006 IN_PROC_BROWSER_TEST_F(KioskUpdateTest, PRE_LaunchOfflineEnabledAppNoNetwork) {
1007 PreCacheAndLaunchApp(kTestOfflineEnabledKioskApp,
1008 "1.0.0",
1009 std::string(kTestOfflineEnabledKioskApp) + "_v1.crx");
1010 }
1011
900 IN_PROC_BROWSER_TEST_F(KioskUpdateTest, LaunchOfflineEnabledAppNoNetwork) { 1012 IN_PROC_BROWSER_TEST_F(KioskUpdateTest, LaunchOfflineEnabledAppNoNetwork) {
901 set_test_app_id(kTestOfflineEnabledKioskApp); 1013 set_test_app_id(kTestOfflineEnabledKioskApp);
902 1014 StartUIForAppLaunch();
903 PrepareAppLaunch();
904 SimulateNetworkOffline(); 1015 SimulateNetworkOffline();
905 SetupAppProfile("chromeos/app_mode/offline_enabled_app_profile"); 1016 LaunchApp(test_app_id(), false);
906 1017 WaitForAppLaunchSuccess();
907 LaunchApp(test_app_id(), false); 1018
908 WaitForAppLaunchSuccess(); 1019 EXPECT_EQ("1.0.0", GetInstalledAppVersion().GetString());
1020 }
1021
1022 IN_PROC_BROWSER_TEST_F(KioskUpdateTest,
1023 PRE_LaunchCachedOfflineEnabledAppNoNetwork) {
1024 PreCacheApp(kTestOfflineEnabledKioskApp,
1025 "1.0.0",
1026 std::string(kTestOfflineEnabledKioskApp) + "_v1.crx");
1027 }
1028
1029 IN_PROC_BROWSER_TEST_F(KioskUpdateTest,
1030 LaunchCachedOfflineEnabledAppNoNetwork) {
1031 set_test_app_id(kTestOfflineEnabledKioskApp);
1032 EXPECT_TRUE(
1033 KioskAppManager::Get()->HasCachedCrx(kTestOfflineEnabledKioskApp));
1034 StartUIForAppLaunch();
1035 SimulateNetworkOffline();
1036 LaunchApp(test_app_id(), false);
1037 WaitForAppLaunchSuccess();
1038
1039 EXPECT_EQ("1.0.0", GetInstalledAppVersion().GetString());
1040 }
1041
1042 // Network offline, app v1.0 has run before, has cached v2.0 crx and v2.0 should
1043 // be installed and launched during next launch.
1044 IN_PROC_BROWSER_TEST_F(KioskUpdateTest,
1045 PRE_LaunchCachedNewVersionOfflineEnabledAppNoNetwork) {
1046 // Install and launch v1 app.
1047 PreCacheAndLaunchApp(kTestOfflineEnabledKioskApp,
1048 "1.0.0",
1049 std::string(kTestOfflineEnabledKioskApp) + "_v1.crx");
1050 // Update cache for v2 app.
1051 UpdateExternalCache("2.0.0",
1052 std::string(kTestOfflineEnabledKioskApp) + ".crx");
1053 // The installed app is still in v1.
1054 EXPECT_EQ("1.0.0", GetInstalledAppVersion().GetString());
1055 }
1056
1057 IN_PROC_BROWSER_TEST_F(KioskUpdateTest,
1058 LaunchCachedNewVersionOfflineEnabledAppNoNetwork) {
1059 set_test_app_id(kTestOfflineEnabledKioskApp);
1060 EXPECT_TRUE(KioskAppManager::Get()->HasCachedCrx(test_app_id()));
1061
1062 StartUIForAppLaunch();
1063 SimulateNetworkOffline();
1064 LaunchApp(test_app_id(), false);
1065 WaitForAppLaunchSuccess();
1066
1067 // v2 app should have been installed.
1068 EXPECT_EQ("2.0.0", GetInstalledAppVersion().GetString());
1069 }
1070
1071 IN_PROC_BROWSER_TEST_F(KioskUpdateTest, PRE_LaunchOfflineEnabledAppNoUpdate) {
1072 PreCacheAndLaunchApp(kTestOfflineEnabledKioskApp,
1073 "1.0.0",
1074 std::string(kTestOfflineEnabledKioskApp) + "_v1.crx");
909 } 1075 }
910 1076
911 IN_PROC_BROWSER_TEST_F(KioskUpdateTest, LaunchOfflineEnabledAppNoUpdate) { 1077 IN_PROC_BROWSER_TEST_F(KioskUpdateTest, LaunchOfflineEnabledAppNoUpdate) {
912 set_test_app_id(kTestOfflineEnabledKioskApp); 1078 set_test_app_id(kTestOfflineEnabledKioskApp);
913
914 fake_cws()->SetNoUpdate(test_app_id()); 1079 fake_cws()->SetNoUpdate(test_app_id());
915 1080
916 PrepareAppLaunch(); 1081 StartUIForAppLaunch();
917 SimulateNetworkOnline(); 1082 SimulateNetworkOnline();
918 SetupAppProfile("chromeos/app_mode/offline_enabled_app_profile"); 1083 LaunchApp(test_app_id(), false);
919 1084 WaitForAppLaunchSuccess();
920 LaunchApp(test_app_id(), false); 1085
921 WaitForAppLaunchSuccess(); 1086 EXPECT_EQ("1.0.0", GetInstalledAppVersion().GetString());
922 1087 }
923 EXPECT_EQ("1.0.0", GetInstalledAppVersion().GetString()); 1088
1089 IN_PROC_BROWSER_TEST_F(KioskUpdateTest, PRE_LaunchOfflineEnabledAppHasUpdate) {
1090 PreCacheAndLaunchApp(kTestOfflineEnabledKioskApp,
1091 "1.0.0",
1092 std::string(kTestOfflineEnabledKioskApp) + "_v1.crx");
924 } 1093 }
925 1094
926 IN_PROC_BROWSER_TEST_F(KioskUpdateTest, LaunchOfflineEnabledAppHasUpdate) { 1095 IN_PROC_BROWSER_TEST_F(KioskUpdateTest, LaunchOfflineEnabledAppHasUpdate) {
927 set_test_app_id(kTestOfflineEnabledKioskApp); 1096 set_test_app_id(kTestOfflineEnabledKioskApp);
928
929 fake_cws()->SetUpdateCrx( 1097 fake_cws()->SetUpdateCrx(
930 test_app_id(), "ajoggoflpgplnnjkjamcmbepjdjdnpdp.crx", "2.0.0"); 1098 test_app_id(), "ajoggoflpgplnnjkjamcmbepjdjdnpdp.crx", "2.0.0");
931 1099
932 PrepareAppLaunch(); 1100 StartUIForAppLaunch();
933 SimulateNetworkOnline(); 1101 SimulateNetworkOnline();
934 SetupAppProfile("chromeos/app_mode/offline_enabled_app_profile");
935
936 LaunchApp(test_app_id(), false); 1102 LaunchApp(test_app_id(), false);
937 WaitForAppLaunchSuccess(); 1103 WaitForAppLaunchSuccess();
938 1104
939 EXPECT_EQ("2.0.0", GetInstalledAppVersion().GetString()); 1105 EXPECT_EQ("2.0.0", GetInstalledAppVersion().GetString());
940 } 1106 }
941 1107
1108 IN_PROC_BROWSER_TEST_F(KioskUpdateTest, PRE_PermissionChange) {
1109 PreCacheAndLaunchApp(kTestOfflineEnabledKioskApp,
1110 "2.0.0",
1111 std::string(kTestOfflineEnabledKioskApp) + ".crx");
1112 }
1113
942 IN_PROC_BROWSER_TEST_F(KioskUpdateTest, PermissionChange) { 1114 IN_PROC_BROWSER_TEST_F(KioskUpdateTest, PermissionChange) {
943 set_test_app_id(kTestOfflineEnabledKioskApp); 1115 set_test_app_id(kTestOfflineEnabledKioskApp);
944 1116 set_test_app_version("2.0.0");
945 fake_cws()->SetUpdateCrx( 1117 set_test_crx_file(test_app_id() + "_v2_permission_change.crx");
946 test_app_id(), 1118
947 "ajoggoflpgplnnjkjamcmbepjdjdnpdp_v2_permission_change.crx", 1119 StartUIForAppLaunch();
948 "2.0.0");
949
950 PrepareAppLaunch();
951 SimulateNetworkOnline(); 1120 SimulateNetworkOnline();
952 SetupAppProfile("chromeos/app_mode/offline_enabled_app_profile"); 1121 LaunchApp(test_app_id(), false);
953 1122 WaitForAppLaunchSuccess();
954 LaunchApp(test_app_id(), false); 1123
955 WaitForAppLaunchSuccess();
956
957 EXPECT_EQ("2.0.0", GetInstalledAppVersion().GetString()); 1124 EXPECT_EQ("2.0.0", GetInstalledAppVersion().GetString());
958 } 1125 }
959 1126
960 IN_PROC_BROWSER_TEST_F(KioskUpdateTest, PRE_PreserveLocalData) { 1127 IN_PROC_BROWSER_TEST_F(KioskUpdateTest, PRE_PreserveLocalData) {
961 // Installs v1 app and writes some local data. 1128 // Installs v1 app and writes some local data.
962 set_test_app_id(kTestLocalFsKioskApp); 1129 set_test_app_id(kTestLocalFsKioskApp);
1130 set_test_app_version("1.0.0");
1131 set_test_crx_file(test_app_id() + ".crx");
963 1132
964 ResultCatcher catcher; 1133 ResultCatcher catcher;
965 StartAppLaunchFromLoginScreen(SimulateNetworkOnlineClosure()); 1134 StartAppLaunchFromLoginScreen(SimulateNetworkOnlineClosure());
966 WaitForAppLaunchSuccess(); 1135 WaitForAppLaunchSuccess();
967 ASSERT_TRUE(catcher.GetNextResult()) << catcher.message(); 1136 ASSERT_TRUE(catcher.GetNextResult()) << catcher.message();
968 } 1137 }
969 1138
970 IN_PROC_BROWSER_TEST_F(KioskUpdateTest, PreserveLocalData) { 1139 IN_PROC_BROWSER_TEST_F(KioskUpdateTest, PreserveLocalData) {
971 // Update existing v1 app installed in PRE_PreserveLocalData to v2 1140 // Update existing v1 app installed in PRE_PreserveLocalData to v2
972 // that reads and verifies the local data. 1141 // that reads and verifies the local data.
973 set_test_app_id(kTestLocalFsKioskApp); 1142 set_test_app_id(kTestLocalFsKioskApp);
974 1143 set_test_app_version("2.0.0");
975 fake_cws()->SetUpdateCrx( 1144 set_test_crx_file(test_app_id() + "_v2_read_and_verify_data.crx");
976 test_app_id(),
977 "bmbpicmpniaclbbpdkfglgipkkebnbjf_v2_read_and_verify_data.crx",
978 "2.0.0");
979
980 ResultCatcher catcher; 1145 ResultCatcher catcher;
981 StartAppLaunchFromLoginScreen(SimulateNetworkOnlineClosure()); 1146 StartAppLaunchFromLoginScreen(SimulateNetworkOnlineClosure());
982 WaitForAppLaunchSuccess(); 1147 WaitForAppLaunchSuccess();
983 1148
984 EXPECT_EQ("2.0.0", GetInstalledAppVersion().GetString()); 1149 EXPECT_EQ("2.0.0", GetInstalledAppVersion().GetString());
985 ASSERT_TRUE(catcher.GetNextResult()) << catcher.message(); 1150 ASSERT_TRUE(catcher.GetNextResult()) << catcher.message();
986 } 1151 }
987 1152
988 class KioskEnterpriseTest : public KioskTest { 1153 class KioskEnterpriseTest : public KioskTest {
989 protected: 1154 protected:
990 KioskEnterpriseTest() {} 1155 KioskEnterpriseTest() {}
991 1156
992 virtual void SetUpInProcessBrowserTestFixture() OVERRIDE { 1157 virtual void SetUpInProcessBrowserTestFixture() OVERRIDE {
993 device_policy_test_helper_.MarkAsEnterpriseOwned(); 1158 device_policy_test_helper_.MarkAsEnterpriseOwned();
994 device_policy_test_helper_.InstallOwnerKey(); 1159 device_policy_test_helper_.InstallOwnerKey();
995 1160
996 KioskTest::SetUpInProcessBrowserTestFixture(); 1161 KioskTest::SetUpInProcessBrowserTestFixture();
997 } 1162 }
998 1163
999 virtual void SetUpOnMainThread() OVERRIDE { 1164 virtual void SetUpOnMainThread() OVERRIDE {
1165 set_test_app_id(kTestEnterpriseKioskApp);
1166 set_test_app_version("1.0.0");
1167 set_test_crx_file(test_app_id() + ".crx");
1168 SetupTestAppUpdateCheck();
1169
1000 KioskTest::SetUpOnMainThread(); 1170 KioskTest::SetUpOnMainThread();
1001 // Configure kTestEnterpriseKioskApp in device policy. 1171 // Configure kTestEnterpriseKioskApp in device policy.
1002 em::DeviceLocalAccountsProto* accounts = 1172 em::DeviceLocalAccountsProto* accounts =
1003 device_policy_test_helper_.device_policy()->payload() 1173 device_policy_test_helper_.device_policy()->payload()
1004 .mutable_device_local_accounts(); 1174 .mutable_device_local_accounts();
1005 em::DeviceLocalAccountInfoProto* account = accounts->add_account(); 1175 em::DeviceLocalAccountInfoProto* account = accounts->add_account();
1006 account->set_account_id(kTestEnterpriseAccountId); 1176 account->set_account_id(kTestEnterpriseAccountId);
1007 account->set_type( 1177 account->set_type(
1008 em::DeviceLocalAccountInfoProto::ACCOUNT_TYPE_KIOSK_APP); 1178 em::DeviceLocalAccountInfoProto::ACCOUNT_TYPE_KIOSK_APP);
1009 account->mutable_kiosk_app()->set_app_id(kTestEnterpriseKioskApp); 1179 account->mutable_kiosk_app()->set_app_id(kTestEnterpriseKioskApp);
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after
1193 content::WindowedNotificationObserver( 1363 content::WindowedNotificationObserver(
1194 chrome::NOTIFICATION_KIOSK_AUTOLAUNCH_WARNING_VISIBLE, 1364 chrome::NOTIFICATION_KIOSK_AUTOLAUNCH_WARNING_VISIBLE,
1195 content::NotificationService::AllSources()).Wait(); 1365 content::NotificationService::AllSources()).Wait();
1196 1366
1197 // Wait for the wallpaper to load. 1367 // Wait for the wallpaper to load.
1198 WaitForWallpaper(); 1368 WaitForWallpaper();
1199 EXPECT_TRUE(wallpaper_loaded()); 1369 EXPECT_TRUE(wallpaper_loaded());
1200 } 1370 }
1201 1371
1202 } // namespace chromeos 1372 } // namespace chromeos
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/extensions/external_cache.cc ('k') | chrome/browser/extensions/external_provider_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698