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

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

Issue 1488393002: Check import module update before launching the primary kiosk app. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix browser tests and address code review commnents. Created 5 years 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
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 <vector> 5 #include <vector>
6 6
7 #include "ash/desktop_background/desktop_background_controller.h" 7 #include "ash/desktop_background/desktop_background_controller.h"
8 #include "ash/desktop_background/desktop_background_controller_observer.h" 8 #include "ash/desktop_background/desktop_background_controller_observer.h"
9 #include "ash/shell.h" 9 #include "ash/shell.h"
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
110 // An app to test local fs data persistence across app update. V1 app writes 110 // An app to test local fs data persistence across app update. V1 app writes
111 // data into local fs. V2 app reads and verifies the data. 111 // data into local fs. V2 app reads and verifies the data.
112 // Webstore data json is in 112 // Webstore data json is in
113 // chrome/test/data/chromeos/app_mode/webstore/inlineinstall/ 113 // chrome/test/data/chromeos/app_mode/webstore/inlineinstall/
114 // detail/bmbpicmpniaclbbpdkfglgipkkebnbjf 114 // detail/bmbpicmpniaclbbpdkfglgipkkebnbjf
115 const char kTestLocalFsKioskApp[] = "bmbpicmpniaclbbpdkfglgipkkebnbjf"; 115 const char kTestLocalFsKioskApp[] = "bmbpicmpniaclbbpdkfglgipkkebnbjf";
116 116
117 // An app to test local access to file systems via the 117 // An app to test local access to file systems via the
118 // chrome.fileSystem.requestFileSystem API. 118 // chrome.fileSystem.requestFileSystem API.
119 // Webstore data json is in 119 // Webstore data json is in
120 // chrome/test/data/chromeos/app_mode/webstore/inlineinstall/ 120 // chrome/test/data/chromeos/app_mode/webstore/inlineinstall/
121 // detail/aaedpojejpghjkedenggihopfhfijcko 121 // detail/aaedpojejpghjkedenggihopfhfijcko
122 const char kTestGetVolumeListKioskApp[] = "aaedpojejpghjkedenggihopfhfijcko"; 122 const char kTestGetVolumeListKioskApp[] = "aaedpojejpghjkedenggihopfhfijcko";
123 123
124 // Testing apps for testing kiosk multi-app feature. 124 // Testing apps for testing kiosk multi-app feature. All the crx files are in
125 const char kTestPrimaryKioskApp[] = "ceobkcclegcliomogfoeoheahogoecgl"; 125 // chrome/test/data/chromeos/app_mode/webstore/downloads.
126 const char kTestSecondaryApp1[] = "ihplaomghjbeafnpnjkhppmfpnmdihgd"; 126
127 const char kTestSecondaryApp2[] = "fiehokkcgaojmbhfhlpiheggjhaedjoc"; 127 // Source files are in
128 const char kTestSecondaryApp3[] = "aabnpdpieclcikafhdkkpldcaodmfoai"; 128 // chrome/test/data/chromeos/app_mode/multi_app_kiosk/src/primary_app
129 const char kTestSecondaryExtension[] = "imlgadjgphbjkaceoiapiephhgeofhic"; 129 const char kTestPrimaryKioskApp[] = "dpejijbnadgcgmabkmcoajkgongfgnii";
130
131 // Source files are in
132 // chrome/test/data/chromeos/app_mode/multi_app_kiosk/src/secondary_app_1
133 const char kTestSecondaryApp1[] = "emnbflhfbllbehnpjmjddklbkeeoaaeg";
134
135 // Source files are in
136 // chrome/test/data/chromeos/app_mode/multi_app_kiosk/src/secondary_app_2
137 const char kTestSecondaryApp2[] = "blmjgfbajihimkjmepbhgmjbopjchlda";
138
139 // Source files are in
140 // chrome/test/data/chromeos/app_mode/multi_app_kiosk/src/secondary_app_3
141 const char kTestSecondaryApp3[] = "jkofhenkpndpdflehcjpcekgecjkpggg";
142
143 // Source files are in
144 // chrome/test/data/chromeos/app_mode/multi_app_kiosk/src/
145 // secondary_extensions_1
146 const char kTestSecondaryExtension[] = "gdmgkkoghcihimdfoabkefdkccllcfea";
147
148 // Source files are in
149 // chrome/test/data/chromeos/app_mode/multi_app_kiosk/src/
150 // shared_module_primary_app
130 const char kTestSharedModulePrimaryApp[] = "ofmeihgcmabfalhhgooajcijiaoekhkg"; 151 const char kTestSharedModulePrimaryApp[] = "ofmeihgcmabfalhhgooajcijiaoekhkg";
152
153 // Source files are in
154 // chrome/test/data/chromeos/app_mode/multi_app_kiosk/src/secondary_app
131 const char kTestSecondaryApp[] = "bbmaiojbgkkmfaglfhaplfomobgojhke"; 155 const char kTestSecondaryApp[] = "bbmaiojbgkkmfaglfhaplfomobgojhke";
156
157 // Source files are in
158 // chrome/test/data/chromeos/app_mode/multi_app_kiosk/src/shared_module
132 const char kTestSharedModuleId[] = "biebhpdepndljbnkadldcbjkiedldnmn"; 159 const char kTestSharedModuleId[] = "biebhpdepndljbnkadldcbjkiedldnmn";
160
161 // Source files are in
162 // chrome/test/data/chromeos/app_mode/multi_app_kiosk/src/
163 // secondary_extension
133 const char kTestSecondaryExt[] = "kcoobopfcjmbfeppibolpaolbgbmkcjd"; 164 const char kTestSecondaryExt[] = "kcoobopfcjmbfeppibolpaolbgbmkcjd";
134 165
135 // Fake usb stick mount path. 166 // Fake usb stick mount path.
136 const char kFakeUsbMountPathUpdatePass[] = 167 const char kFakeUsbMountPathUpdatePass[] =
137 "chromeos/app_mode/external_update/update_pass"; 168 "chromeos/app_mode/external_update/update_pass";
138 const char kFakeUsbMountPathNoManifest[] = 169 const char kFakeUsbMountPathNoManifest[] =
139 "chromeos/app_mode/external_update/no_manifest"; 170 "chromeos/app_mode/external_update/no_manifest";
140 const char kFakeUsbMountPathBadManifest[] = 171 const char kFakeUsbMountPathBadManifest[] =
141 "chromeos/app_mode/external_update/bad_manifest"; 172 "chromeos/app_mode/external_update/bad_manifest";
142 const char kFakeUsbMountPathLowerAppVersion[] = 173 const char kFakeUsbMountPathLowerAppVersion[] =
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
196 void OnNetworkWaitTimedOut(const base::Closure& runner_quit_task) { 227 void OnNetworkWaitTimedOut(const base::Closure& runner_quit_task) {
197 runner_quit_task.Run(); 228 runner_quit_task.Run();
198 } 229 }
199 230
200 // Helper function for LockFileThread. 231 // Helper function for LockFileThread.
201 void LockAndUnlock(scoped_ptr<base::Lock> lock) { 232 void LockAndUnlock(scoped_ptr<base::Lock> lock) {
202 lock->Acquire(); 233 lock->Acquire();
203 lock->Release(); 234 lock->Release();
204 } 235 }
205 236
206 bool IsAppInstalled(const std::string& app_id) { 237 bool IsAppInstalled(const std::string& app_id, const std::string& version) {
207 Profile* app_profile = ProfileManager::GetPrimaryUserProfile(); 238 Profile* app_profile = ProfileManager::GetPrimaryUserProfile();
208 DCHECK(app_profile); 239 DCHECK(app_profile);
209 const extensions::Extension* app = 240 const extensions::Extension* app =
210 extensions::ExtensionSystem::Get(app_profile) 241 extensions::ExtensionSystem::Get(app_profile)
211 ->extension_service() 242 ->extension_service()
212 ->GetInstalledExtension(app_id); 243 ->GetInstalledExtension(app_id);
213 return app != nullptr; 244 return app != nullptr && version == app->version()->GetString();
214 } 245 }
215 246
216 extensions::Manifest::Type GetAppType(const std::string& app_id) { 247 extensions::Manifest::Type GetAppType(const std::string& app_id) {
217 Profile* app_profile = ProfileManager::GetPrimaryUserProfile(); 248 Profile* app_profile = ProfileManager::GetPrimaryUserProfile();
218 DCHECK(app_profile); 249 DCHECK(app_profile);
219 const extensions::Extension* app = 250 const extensions::Extension* app =
220 extensions::ExtensionSystem::Get(app_profile) 251 extensions::ExtensionSystem::Get(app_profile)
221 ->extension_service() 252 ->extension_service()
222 ->GetInstalledExtension(app_id); 253 ->GetInstalledExtension(app_id);
223 DCHECK(app); 254 DCHECK(app);
(...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after
477 } 508 }
478 509
479 void SetUpOnMainThread() override { 510 void SetUpOnMainThread() override {
480 OobeBaseTest::SetUpOnMainThread(); 511 OobeBaseTest::SetUpOnMainThread();
481 // Needed to avoid showing Gaia screen instead of owner signin for 512 // Needed to avoid showing Gaia screen instead of owner signin for
482 // consumer network down test cases. 513 // consumer network down test cases.
483 StartupUtils::MarkDeviceRegistered(base::Closure()); 514 StartupUtils::MarkDeviceRegistered(base::Closure());
484 settings_helper_.ReplaceProvider(kAccountsPrefDeviceLocalAccounts); 515 settings_helper_.ReplaceProvider(kAccountsPrefDeviceLocalAccounts);
485 owner_settings_service_ = settings_helper_.CreateOwnerSettingsService( 516 owner_settings_service_ = settings_helper_.CreateOwnerSettingsService(
486 ProfileManager::GetPrimaryUserProfile()); 517 ProfileManager::GetPrimaryUserProfile());
518
519 // Set up local cache for app update check.
520 CreateAndInitializeLocalCache();
487 } 521 }
488 522
489 void TearDownOnMainThread() override { 523 void TearDownOnMainThread() override {
490 settings_helper_.RestoreProvider(); 524 settings_helper_.RestoreProvider();
491 AppLaunchController::SetNetworkTimeoutCallbackForTesting(NULL); 525 AppLaunchController::SetNetworkTimeoutCallbackForTesting(NULL);
492 AppLaunchSigninScreen::SetUserManagerForTesting(NULL); 526 AppLaunchSigninScreen::SetUserManagerForTesting(NULL);
493 527
494 OobeBaseTest::TearDownOnMainThread(); 528 OobeBaseTest::TearDownOnMainThread();
495 529
496 // Clean up while main thread still runs. 530 // Clean up while main thread still runs.
497 // See http://crbug.com/176659. 531 // See http://crbug.com/176659.
498 KioskAppManager::Get()->CleanUp(); 532 KioskAppManager::Get()->CleanUp();
499 } 533 }
500 534
535 // The local cache is supposed to be initialized on chromeos device, and a
536 // ready flag file will be pre-created to mark the ready state, before chrome
537 // starts. In order for the tests to run without being on real chromeos
538 // device, we need to manually create this file.
539 void CreateAndInitializeLocalCache() {
540 base::FilePath extension_cache_dir;
541 CHECK(PathService::Get(chromeos::DIR_DEVICE_EXTENSION_LOCAL_CACHE,
542 &extension_cache_dir));
xiyuan 2015/12/03 00:46:53 Oops. We really should not be doing this. We shoul
jennyz 2015/12/03 01:23:47 It looks like the path is already overrided at Reg
xiyuan 2015/12/03 03:05:38 I see. Never mind then.
543 base::FilePath cache_init_file = extension_cache_dir.Append(
544 extensions::LocalExtensionCache::kCacheReadyFlagFileName);
545 EXPECT_EQ(base::WriteFile(cache_init_file, "", 0), 0);
546 }
547
501 void SetUpCommandLine(base::CommandLine* command_line) override { 548 void SetUpCommandLine(base::CommandLine* command_line) override {
502 OobeBaseTest::SetUpCommandLine(command_line); 549 OobeBaseTest::SetUpCommandLine(command_line);
503 fake_cws_->Init(embedded_test_server()); 550 fake_cws_->Init(embedded_test_server());
504 } 551 }
505 552
506 void LaunchApp(const std::string& app_id, bool diagnostic_mode) { 553 void LaunchApp(const std::string& app_id, bool diagnostic_mode) {
507 bool new_kiosk_ui = KioskAppMenuHandler::EnableNewKioskUI(); 554 bool new_kiosk_ui = KioskAppMenuHandler::EnableNewKioskUI();
508 GetLoginUI()->CallJavascriptFunction(new_kiosk_ui ? 555 GetLoginUI()->CallJavascriptFunction(new_kiosk_ui ?
509 kLaunchAppForTestNewAPI : kLaunchAppForTestOldAPI, 556 kLaunchAppForTestNewAPI : kLaunchAppForTestOldAPI,
510 base::StringValue(app_id), 557 base::StringValue(app_id),
(...skipping 810 matching lines...) Expand 10 before | Expand all | Expand 10 after
1321 KioskTest::TearDown(); 1368 KioskTest::TearDown();
1322 } 1369 }
1323 1370
1324 void SetUpOnMainThread() override { 1371 void SetUpOnMainThread() override {
1325 // For update tests, we cache the app in the PRE part, and then we load it 1372 // For update tests, we cache the app in the PRE part, and then we load it
1326 // in the test, so we need to both store the apps list on teardown (so that 1373 // in the test, so we need to both store the apps list on teardown (so that
1327 // the app manager would accept existing files in its extension cache on the 1374 // the app manager would accept existing files in its extension cache on the
1328 // next startup) and copy the list to our stub settings provider as well. 1375 // next startup) and copy the list to our stub settings provider as well.
1329 settings_helper_.CopyStoredValue(kAccountsPrefDeviceLocalAccounts); 1376 settings_helper_.CopyStoredValue(kAccountsPrefDeviceLocalAccounts);
1330 1377
1331 CreateAndInitializeLocalCache();
1332
1333 KioskTest::SetUpOnMainThread(); 1378 KioskTest::SetUpOnMainThread();
1334 } 1379 }
1335 1380
1336 void TearDownOnMainThread() override { 1381 void TearDownOnMainThread() override {
1337 settings_helper_.StoreCachedDeviceSetting(kAccountsPrefDeviceLocalAccounts); 1382 settings_helper_.StoreCachedDeviceSetting(kAccountsPrefDeviceLocalAccounts);
1338 KioskTest::TearDownOnMainThread(); 1383 KioskTest::TearDownOnMainThread();
1339 } 1384 }
1340 1385
1341 void PreCacheApp(const std::string& app_id, 1386 void PreCacheApp(const std::string& app_id,
1342 const std::string& version, 1387 const std::string& version,
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
1418 fake_cws()->SetUpdateCrx(app.id, app.crx_filename, app.version); 1463 fake_cws()->SetUpdateCrx(app.id, app.crx_filename, app.version);
1419 } 1464 }
1420 1465
1421 // Launch the primary app. 1466 // Launch the primary app.
1422 StartUIForAppLaunch(); 1467 StartUIForAppLaunch();
1423 SimulateNetworkOnline(); 1468 SimulateNetworkOnline();
1424 LaunchApp(test_app_id(), false); 1469 LaunchApp(test_app_id(), false);
1425 WaitForAppLaunchWithOptions(false, true); 1470 WaitForAppLaunchWithOptions(false, true);
1426 1471
1427 // Verify the primary app and the secondary apps are all installed. 1472 // Verify the primary app and the secondary apps are all installed.
1428 EXPECT_EQ(primary_app.version, GetInstalledAppVersion().GetString()); 1473 EXPECT_TRUE(IsAppInstalled(primary_app.id, primary_app.version));
1429 for (const auto& app : secondary_apps) { 1474 for (const auto& app : secondary_apps) {
1430 EXPECT_TRUE(IsAppInstalled(app.id)); 1475 EXPECT_TRUE(IsAppInstalled(app.id, app.version));
1431 EXPECT_EQ(GetAppType(app.id), app.type); 1476 EXPECT_EQ(GetAppType(app.id), app.type);
1432 } 1477 }
1433 } 1478 }
1434 1479
1435 void LaunchTestKioskAppWithTwoSecondaryApps() { 1480 void LaunchTestKioskAppWithTwoSecondaryApps() {
1436 TestAppInfo primary_app(kTestPrimaryKioskApp, "1.0.0", 1481 TestAppInfo primary_app(kTestPrimaryKioskApp, "1.0.0",
1437 std::string(kTestPrimaryKioskApp) + "-1.0.0.crx", 1482 std::string(kTestPrimaryKioskApp) + "-1.0.0.crx",
1438 extensions::Manifest::TYPE_PLATFORM_APP); 1483 extensions::Manifest::TYPE_PLATFORM_APP);
1439 1484
1440 std::vector<TestAppInfo> secondary_apps; 1485 std::vector<TestAppInfo> secondary_apps;
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
1477 extensions::Manifest::TYPE_PLATFORM_APP); 1522 extensions::Manifest::TYPE_PLATFORM_APP);
1478 secondary_apps.push_back(secondary_app); 1523 secondary_apps.push_back(secondary_app);
1479 // Setting up FakeCWS for shared module is the same for shared module as 1524 // Setting up FakeCWS for shared module is the same for shared module as
1480 // for kiosk secondary apps. 1525 // for kiosk secondary apps.
1481 TestAppInfo shared_module(kTestSharedModuleId, "1.0.0", 1526 TestAppInfo shared_module(kTestSharedModuleId, "1.0.0",
1482 std::string(kTestSharedModuleId) + "-1.0.0.crx", 1527 std::string(kTestSharedModuleId) + "-1.0.0.crx",
1483 extensions::Manifest::TYPE_SHARED_MODULE); 1528 extensions::Manifest::TYPE_SHARED_MODULE);
1484 secondary_apps.push_back(shared_module); 1529 secondary_apps.push_back(shared_module);
1485 1530
1486 LaunchKioskWithSecondaryApps(primary_app, secondary_apps); 1531 LaunchKioskWithSecondaryApps(primary_app, secondary_apps);
1487 EXPECT_TRUE(IsAppInstalled(kTestSharedModuleId)); 1532 EXPECT_TRUE(IsAppInstalled(shared_module.id, shared_module.version));
1533 }
1534
1535 void LaunchAppWithSharedModule() {
1536 TestAppInfo primary_app(
1537 kTestSharedModulePrimaryApp, "2.0.0",
1538 std::string(kTestSharedModulePrimaryApp) + "-2.0.0.crx",
1539 extensions::Manifest::TYPE_PLATFORM_APP);
1540
1541 std::vector<TestAppInfo> secondary_apps;
1542 // Setting up FakeCWS for shared module is the same for shared module as
1543 // for kiosk secondary apps.
1544 TestAppInfo shared_module(kTestSharedModuleId, "1.0.0",
1545 std::string(kTestSharedModuleId) + "-1.0.0.crx",
1546 extensions::Manifest::TYPE_SHARED_MODULE);
1547 secondary_apps.push_back(shared_module);
1548
1549 LaunchKioskWithSecondaryApps(primary_app, secondary_apps);
1488 } 1550 }
1489 1551
1490 private: 1552 private:
1491 class KioskAppExternalUpdateWaiter : public KioskAppManagerObserver { 1553 class KioskAppExternalUpdateWaiter : public KioskAppManagerObserver {
1492 public: 1554 public:
1493 KioskAppExternalUpdateWaiter(KioskAppManager* manager, 1555 KioskAppExternalUpdateWaiter(KioskAppManager* manager,
1494 const std::string& app_id) 1556 const std::string& app_id)
1495 : runner_(NULL), 1557 : runner_(NULL),
1496 manager_(manager), 1558 manager_(manager),
1497 app_id_(app_id), 1559 app_id_(app_id),
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
1532 scoped_refptr<content::MessageLoopRunner> runner_; 1594 scoped_refptr<content::MessageLoopRunner> runner_;
1533 KioskAppManager* manager_; 1595 KioskAppManager* manager_;
1534 const std::string app_id_; 1596 const std::string app_id_;
1535 bool quit_; 1597 bool quit_;
1536 bool update_success_; 1598 bool update_success_;
1537 bool app_update_notified_; 1599 bool app_update_notified_;
1538 1600
1539 DISALLOW_COPY_AND_ASSIGN(KioskAppExternalUpdateWaiter); 1601 DISALLOW_COPY_AND_ASSIGN(KioskAppExternalUpdateWaiter);
1540 }; 1602 };
1541 1603
1542 // The local cache is supposed to be initialized on chromeos device, and a
1543 // ready flag file will be pre-created to mark the ready state, before chrome
1544 // starts. In order for the tests to run without being on real chromeos
1545 // device, we need to manually create this file.
1546 void CreateAndInitializeLocalCache() {
1547 base::FilePath extension_cache_dir;
1548 CHECK(PathService::Get(chromeos::DIR_DEVICE_EXTENSION_LOCAL_CACHE,
1549 &extension_cache_dir));
1550 base::FilePath cache_init_file = extension_cache_dir.Append(
1551 extensions::LocalExtensionCache::kCacheReadyFlagFileName);
1552 EXPECT_EQ(base::WriteFile(cache_init_file, "", 0), 0);
1553 }
1554
1555 // Owned by DiskMountManager. 1604 // Owned by DiskMountManager.
1556 KioskFakeDiskMountManager* fake_disk_mount_manager_; 1605 KioskFakeDiskMountManager* fake_disk_mount_manager_;
1557 1606
1558 DISALLOW_COPY_AND_ASSIGN(KioskUpdateTest); 1607 DISALLOW_COPY_AND_ASSIGN(KioskUpdateTest);
1559 }; 1608 };
1560 1609
1561 IN_PROC_BROWSER_TEST_F(KioskUpdateTest, PRE_LaunchOfflineEnabledAppNoNetwork) { 1610 IN_PROC_BROWSER_TEST_F(KioskUpdateTest, PRE_LaunchOfflineEnabledAppNoNetwork) {
1562 PreCacheAndLaunchApp(kTestOfflineEnabledKioskApp, 1611 PreCacheAndLaunchApp(kTestOfflineEnabledKioskApp,
1563 "1.0.0", 1612 "1.0.0",
1564 std::string(kTestOfflineEnabledKioskApp) + "_v1.crx"); 1613 std::string(kTestOfflineEnabledKioskApp) + "_v1.crx");
(...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after
1879 } 1928 }
1880 1929
1881 IN_PROC_BROWSER_TEST_F(KioskUpdateTest, PRE_UpdateMultiAppKioskRemoveOneApp) { 1930 IN_PROC_BROWSER_TEST_F(KioskUpdateTest, PRE_UpdateMultiAppKioskRemoveOneApp) {
1882 LaunchTestKioskAppWithTwoSecondaryApps(); 1931 LaunchTestKioskAppWithTwoSecondaryApps();
1883 } 1932 }
1884 1933
1885 // Update the primary app to version 2 which removes one of the secondary app 1934 // Update the primary app to version 2 which removes one of the secondary app
1886 // from its manifest. 1935 // from its manifest.
1887 IN_PROC_BROWSER_TEST_F(KioskUpdateTest, UpdateMultiAppKioskRemoveOneApp) { 1936 IN_PROC_BROWSER_TEST_F(KioskUpdateTest, UpdateMultiAppKioskRemoveOneApp) {
1888 set_test_app_id(kTestPrimaryKioskApp); 1937 set_test_app_id(kTestPrimaryKioskApp);
1889 fake_cws()->SetUpdateCrx( 1938 fake_cws()->SetUpdateCrx(kTestPrimaryKioskApp,
1890 kTestPrimaryKioskApp, 1939 std::string(kTestPrimaryKioskApp) + "-2.0.0.crx",
1891 std::string(kTestPrimaryKioskApp) + "-2.0.0-1app.crx", "2.0.0"); 1940 "2.0.0");
1892 fake_cws()->SetNoUpdate(kTestSecondaryApp1); 1941 fake_cws()->SetNoUpdate(kTestSecondaryApp1);
1893 fake_cws()->SetNoUpdate(kTestSecondaryApp2); 1942 fake_cws()->SetNoUpdate(kTestSecondaryApp2);
1894 1943
1895 StartUIForAppLaunch(); 1944 StartUIForAppLaunch();
1896 SimulateNetworkOnline(); 1945 SimulateNetworkOnline();
1897 LaunchApp(test_app_id(), false); 1946 LaunchApp(test_app_id(), false);
1898 WaitForAppLaunchWithOptions(false, true); 1947 WaitForAppLaunchWithOptions(false, true);
1899 1948
1900 // Verify the secondary app kTestSecondaryApp1 is removed. 1949 // Verify the secondary app kTestSecondaryApp1 is removed.
1901 EXPECT_EQ("2.0.0", GetInstalledAppVersion().GetString()); 1950 EXPECT_EQ("2.0.0", GetInstalledAppVersion().GetString());
1902 EXPECT_FALSE(IsAppInstalled(kTestSecondaryApp1)); 1951 EXPECT_FALSE(IsAppInstalled(kTestSecondaryApp1, "1.0.0"));
1903 EXPECT_TRUE(IsAppInstalled(kTestSecondaryApp2)); 1952 EXPECT_TRUE(IsAppInstalled(kTestSecondaryApp2, "1.0.0"));
1904 } 1953 }
1905 1954
1906 IN_PROC_BROWSER_TEST_F(KioskUpdateTest, PRE_UpdateMultiAppKioskAddOneApp) { 1955 IN_PROC_BROWSER_TEST_F(KioskUpdateTest, PRE_UpdateMultiAppKioskAddOneApp) {
1907 LaunchTestKioskAppWithTwoSecondaryApps(); 1956 LaunchTestKioskAppWithTwoSecondaryApps();
1908 } 1957 }
1909 1958
1910 // Update the primary app to version 3 which adds a new secondary app in its 1959 // Update the primary app to version 3 which adds a new secondary app in its
1911 // manifest. 1960 // manifest.
1912 IN_PROC_BROWSER_TEST_F(KioskUpdateTest, UpdateMultiAppKioskAddOneApp) { 1961 IN_PROC_BROWSER_TEST_F(KioskUpdateTest, UpdateMultiAppKioskAddOneApp) {
1913 set_test_app_id(kTestPrimaryKioskApp); 1962 set_test_app_id(kTestPrimaryKioskApp);
1914 fake_cws()->SetUpdateCrx( 1963 fake_cws()->SetUpdateCrx(kTestPrimaryKioskApp,
1915 kTestPrimaryKioskApp, 1964 std::string(kTestPrimaryKioskApp) + "-3.0.0.crx",
1916 std::string(kTestPrimaryKioskApp) + "-3.0.0-3app.crx", "3.0.0"); 1965 "3.0.0");
1917 fake_cws()->SetNoUpdate(kTestSecondaryApp1); 1966 fake_cws()->SetNoUpdate(kTestSecondaryApp1);
1918 fake_cws()->SetNoUpdate(kTestSecondaryApp2); 1967 fake_cws()->SetNoUpdate(kTestSecondaryApp2);
1919 fake_cws()->SetUpdateCrx(kTestSecondaryApp3, 1968 fake_cws()->SetUpdateCrx(kTestSecondaryApp3,
1920 std::string(kTestSecondaryApp3) + "-1.0.0.crx", 1969 std::string(kTestSecondaryApp3) + "-1.0.0.crx",
1921 "1.0.0"); 1970 "1.0.0");
1922 1971
1923 StartUIForAppLaunch(); 1972 StartUIForAppLaunch();
1924 SimulateNetworkOnline(); 1973 SimulateNetworkOnline();
1925 LaunchApp(test_app_id(), false); 1974 LaunchApp(test_app_id(), false);
1926 WaitForAppLaunchWithOptions(false, true); 1975 WaitForAppLaunchWithOptions(false, true);
1927 1976
1928 // Verify the secondary app kTestSecondaryApp3 is installed. 1977 // Verify the secondary app kTestSecondaryApp3 is installed.
1929 EXPECT_EQ("3.0.0", GetInstalledAppVersion().GetString()); 1978 EXPECT_EQ("3.0.0", GetInstalledAppVersion().GetString());
1930 EXPECT_TRUE(IsAppInstalled(kTestSecondaryApp1)); 1979 EXPECT_TRUE(IsAppInstalled(kTestSecondaryApp1, "1.0.0"));
1931 EXPECT_TRUE(IsAppInstalled(kTestSecondaryApp2)); 1980 EXPECT_TRUE(IsAppInstalled(kTestSecondaryApp2, "1.0.0"));
1932 EXPECT_TRUE(IsAppInstalled(kTestSecondaryApp3)); 1981 EXPECT_TRUE(IsAppInstalled(kTestSecondaryApp3, "1.0.0"));
1933 } 1982 }
1934 1983
1935 IN_PROC_BROWSER_TEST_F(KioskUpdateTest, LaunchKioskAppWithSecondaryExtension) { 1984 IN_PROC_BROWSER_TEST_F(KioskUpdateTest, LaunchKioskAppWithSecondaryExtension) {
1936 LaunchTestKioskAppWithSeconadayExtension(); 1985 LaunchTestKioskAppWithSeconadayExtension();
1937 } 1986 }
1938 1987
1939 IN_PROC_BROWSER_TEST_F(KioskUpdateTest, 1988 IN_PROC_BROWSER_TEST_F(KioskUpdateTest,
1940 LaunchAppWithSharedModuleAndSecondaryApp) { 1989 LaunchAppWithSharedModuleAndSecondaryApp) {
1941 LaunchAppWithSharedModuleAndSecondaryApp(); 1990 LaunchAppWithSharedModuleAndSecondaryApp();
1942 } 1991 }
(...skipping 11 matching lines...) Expand all
1954 std::string(kTestSharedModulePrimaryApp) + "-2.0.0.crx", "2.0.0"); 2003 std::string(kTestSharedModulePrimaryApp) + "-2.0.0.crx", "2.0.0");
1955 fake_cws()->SetNoUpdate(kTestSecondaryApp1); 2004 fake_cws()->SetNoUpdate(kTestSecondaryApp1);
1956 fake_cws()->SetNoUpdate(kTestSharedModuleId); 2005 fake_cws()->SetNoUpdate(kTestSharedModuleId);
1957 2006
1958 StartUIForAppLaunch(); 2007 StartUIForAppLaunch();
1959 SimulateNetworkOnline(); 2008 SimulateNetworkOnline();
1960 LaunchApp(test_app_id(), false); 2009 LaunchApp(test_app_id(), false);
1961 WaitForAppLaunchWithOptions(false, true); 2010 WaitForAppLaunchWithOptions(false, true);
1962 2011
1963 // Verify the secondary app is removed. 2012 // Verify the secondary app is removed.
1964 EXPECT_TRUE(IsAppInstalled(kTestSharedModuleId)); 2013 EXPECT_TRUE(IsAppInstalled(kTestSharedModuleId, "1.0.0"));
1965 EXPECT_FALSE(IsAppInstalled(kTestSecondaryApp1)); 2014 EXPECT_FALSE(IsAppInstalled(kTestSecondaryApp1, "1.0.0"));
1966 } 2015 }
1967 2016
1968 // This simulates the stand-alone ARC kiosk app case. The primary app has a 2017 // This simulates the stand-alone ARC kiosk app case. The primary app has a
1969 // shared ARC runtime but no secondary apps. 2018 // shared ARC runtime but no secondary apps.
1970 IN_PROC_BROWSER_TEST_F(KioskUpdateTest, LaunchAppWithSharedModuleNoSecondary) { 2019 IN_PROC_BROWSER_TEST_F(KioskUpdateTest, LaunchAppWithSharedModuleNoSecondary) {
1971 TestAppInfo primary_app( 2020 LaunchAppWithSharedModule();
1972 kTestSharedModulePrimaryApp, "2.0.0", 2021 }
1973 std::string(kTestSharedModulePrimaryApp) + "-2.0.0.crx",
1974 extensions::Manifest::TYPE_PLATFORM_APP);
1975 2022
1976 std::vector<TestAppInfo> secondary_apps; 2023 IN_PROC_BROWSER_TEST_F(KioskUpdateTest, PRE_LaunchAppWithUpdatedModule) {
1977 // Setting up FakeCWS for shared module is the same for shared module as 2024 LaunchAppWithSharedModule();
1978 // for kiosk secondary apps. 2025 // Verify the shared module is installed with version 1.0.0.
1979 TestAppInfo shared_module(kTestSharedModuleId, "1.0.0", 2026 EXPECT_TRUE(IsAppInstalled(kTestSharedModuleId, "1.0.0"));
1980 std::string(kTestSharedModuleId) + "-1.0.0.crx", 2027 }
1981 extensions::Manifest::TYPE_SHARED_MODULE);
1982 secondary_apps.push_back(shared_module);
1983 2028
1984 LaunchKioskWithSecondaryApps(primary_app, secondary_apps); 2029 // This simulates the case the shared module is updated to a newer version.
2030 // See crbug.com/555083.
2031 IN_PROC_BROWSER_TEST_F(KioskUpdateTest, LaunchAppWithUpdatedModule) {
2032 // No update for primary app, while the shared module is set up to a new
2033 // version on cws.
2034 set_test_app_id(kTestSharedModulePrimaryApp);
2035 fake_cws()->SetNoUpdate(kTestSharedModulePrimaryApp);
2036 fake_cws()->SetUpdateCrx(kTestSharedModuleId,
2037 std::string(kTestSharedModuleId) + "-2.0.0.crx",
2038 "2.0.0");
2039
2040 StartUIForAppLaunch();
2041 SimulateNetworkOnline();
2042 LaunchApp(test_app_id(), false);
2043 WaitForAppLaunchWithOptions(false, true);
2044
2045 // Verify the shared module is updated to the new version after primary app
2046 // is launched.
2047 EXPECT_TRUE(IsAppInstalled(kTestSharedModuleId, "2.0.0"));
1985 } 2048 }
1986 2049
1987 IN_PROC_BROWSER_TEST_F(KioskUpdateTest, 2050 IN_PROC_BROWSER_TEST_F(KioskUpdateTest,
1988 LaunchAppWithSecondaryArcLikeAppAndExtension) { 2051 LaunchAppWithSecondaryArcLikeAppAndExtension) {
1989 TestAppInfo primary_app( 2052 TestAppInfo primary_app(
1990 kTestSharedModulePrimaryApp, "3.0.0", 2053 kTestSharedModulePrimaryApp, "3.0.0",
1991 std::string(kTestSharedModulePrimaryApp) + "-3.0.0.crx", 2054 std::string(kTestSharedModulePrimaryApp) + "-3.0.0.crx",
1992 extensions::Manifest::TYPE_PLATFORM_APP); 2055 extensions::Manifest::TYPE_PLATFORM_APP);
1993 2056
1994 std::vector<TestAppInfo> secondary_apps; 2057 std::vector<TestAppInfo> secondary_apps;
(...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after
2252 content::WindowedNotificationObserver( 2315 content::WindowedNotificationObserver(
2253 chrome::NOTIFICATION_KIOSK_AUTOLAUNCH_WARNING_VISIBLE, 2316 chrome::NOTIFICATION_KIOSK_AUTOLAUNCH_WARNING_VISIBLE,
2254 content::NotificationService::AllSources()).Wait(); 2317 content::NotificationService::AllSources()).Wait();
2255 2318
2256 // Wait for the wallpaper to load. 2319 // Wait for the wallpaper to load.
2257 WaitForWallpaper(); 2320 WaitForWallpaper();
2258 EXPECT_TRUE(wallpaper_loaded()); 2321 EXPECT_TRUE(wallpaper_loaded());
2259 } 2322 }
2260 2323
2261 } // namespace chromeos 2324 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698