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

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

Issue 1869483002: kiosk: Defer app update until platform matches (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: for comments from jenny Created 4 years, 8 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
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 <memory> 5 #include <memory>
6 #include <vector> 6 #include <vector>
7 7
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"
11 #include "base/bind.h" 11 #include "base/bind.h"
12 #include "base/bind_helpers.h" 12 #include "base/bind_helpers.h"
13 #include "base/files/file_util.h" 13 #include "base/files/file_util.h"
14 #include "base/location.h" 14 #include "base/location.h"
15 #include "base/macros.h" 15 #include "base/macros.h"
16 #include "base/path_service.h" 16 #include "base/path_service.h"
17 #include "base/run_loop.h" 17 #include "base/run_loop.h"
18 #include "base/strings/string_number_conversions.h" 18 #include "base/strings/string_number_conversions.h"
19 #include "base/strings/string_util.h" 19 #include "base/strings/string_util.h"
20 #include "base/synchronization/lock.h" 20 #include "base/synchronization/lock.h"
21 #include "base/sys_info.h"
21 #include "chrome/browser/chrome_notification_types.h" 22 #include "chrome/browser/chrome_notification_types.h"
22 #include "chrome/browser/chromeos/app_mode/fake_cws.h" 23 #include "chrome/browser/chromeos/app_mode/fake_cws.h"
23 #include "chrome/browser/chromeos/app_mode/kiosk_app_launch_error.h" 24 #include "chrome/browser/chromeos/app_mode/kiosk_app_launch_error.h"
24 #include "chrome/browser/chromeos/app_mode/kiosk_app_manager.h" 25 #include "chrome/browser/chromeos/app_mode/kiosk_app_manager.h"
25 #include "chrome/browser/chromeos/file_manager/fake_disk_mount_manager.h" 26 #include "chrome/browser/chromeos/file_manager/fake_disk_mount_manager.h"
26 #include "chrome/browser/chromeos/login/app_launch_controller.h" 27 #include "chrome/browser/chromeos/login/app_launch_controller.h"
27 #include "chrome/browser/chromeos/login/startup_utils.h" 28 #include "chrome/browser/chromeos/login/startup_utils.h"
28 #include "chrome/browser/chromeos/login/test/app_window_waiter.h" 29 #include "chrome/browser/chromeos/login/test/app_window_waiter.h"
29 #include "chrome/browser/chromeos/login/test/oobe_base_test.h" 30 #include "chrome/browser/chromeos/login/test/oobe_base_test.h"
30 #include "chrome/browser/chromeos/login/test/oobe_screen_waiter.h" 31 #include "chrome/browser/chromeos/login/test/oobe_screen_waiter.h"
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after
248 Profile* app_profile = ProfileManager::GetPrimaryUserProfile(); 249 Profile* app_profile = ProfileManager::GetPrimaryUserProfile();
249 DCHECK(app_profile); 250 DCHECK(app_profile);
250 const extensions::Extension* app = 251 const extensions::Extension* app =
251 extensions::ExtensionSystem::Get(app_profile) 252 extensions::ExtensionSystem::Get(app_profile)
252 ->extension_service() 253 ->extension_service()
253 ->GetInstalledExtension(app_id); 254 ->GetInstalledExtension(app_id);
254 DCHECK(app); 255 DCHECK(app);
255 return app->GetType(); 256 return app->GetType();
256 } 257 }
257 258
259 void SetPlatformVersion(const std::string& platform_version) {
260 const std::string lsb_release = base::StringPrintf(
261 "CHROMEOS_RELEASE_VERSION=%s", platform_version.c_str());
262 base::SysInfo::SetChromeOSVersionInfoForTest(lsb_release, base::Time::Now());
263 }
264
258 // Helper functions for CanConfigureNetwork mock. 265 // Helper functions for CanConfigureNetwork mock.
259 class ScopedCanConfigureNetwork { 266 class ScopedCanConfigureNetwork {
260 public: 267 public:
261 ScopedCanConfigureNetwork(bool can_configure, bool needs_owner_auth) 268 ScopedCanConfigureNetwork(bool can_configure, bool needs_owner_auth)
262 : can_configure_(can_configure), 269 : can_configure_(can_configure),
263 needs_owner_auth_(needs_owner_auth), 270 needs_owner_auth_(needs_owner_auth),
264 can_configure_network_callback_( 271 can_configure_network_callback_(
265 base::Bind(&ScopedCanConfigureNetwork::CanConfigureNetwork, 272 base::Bind(&ScopedCanConfigureNetwork::CanConfigureNetwork,
266 base::Unretained(this))), 273 base::Unretained(this))),
267 needs_owner_auth_callback_(base::Bind( 274 needs_owner_auth_callback_(base::Bind(
(...skipping 1270 matching lines...) Expand 10 before | Expand all | Expand 10 after
1538 // Setting up FakeCWS for shared module is the same for shared module as 1545 // Setting up FakeCWS for shared module is the same for shared module as
1539 // for kiosk secondary apps. 1546 // for kiosk secondary apps.
1540 TestAppInfo shared_module(kTestSharedModuleId, "1.0.0", 1547 TestAppInfo shared_module(kTestSharedModuleId, "1.0.0",
1541 std::string(kTestSharedModuleId) + "-1.0.0.crx", 1548 std::string(kTestSharedModuleId) + "-1.0.0.crx",
1542 extensions::Manifest::TYPE_SHARED_MODULE); 1549 extensions::Manifest::TYPE_SHARED_MODULE);
1543 secondary_apps.push_back(shared_module); 1550 secondary_apps.push_back(shared_module);
1544 1551
1545 LaunchKioskWithSecondaryApps(primary_app, secondary_apps); 1552 LaunchKioskWithSecondaryApps(primary_app, secondary_apps);
1546 } 1553 }
1547 1554
1555 bool PrimaryAppUpdateIsPending() const {
1556 Profile* app_profile = ProfileManager::GetPrimaryUserProfile();
1557 return !!extensions::ExtensionSystem::Get(app_profile)
1558 ->extension_service()
1559 ->GetPendingExtensionUpdate(test_app_id());
1560 }
1561
1548 private: 1562 private:
1549 class KioskAppExternalUpdateWaiter : public KioskAppManagerObserver { 1563 class KioskAppExternalUpdateWaiter : public KioskAppManagerObserver {
1550 public: 1564 public:
1551 KioskAppExternalUpdateWaiter(KioskAppManager* manager, 1565 KioskAppExternalUpdateWaiter(KioskAppManager* manager,
1552 const std::string& app_id) 1566 const std::string& app_id)
1553 : runner_(NULL), 1567 : runner_(NULL),
1554 manager_(manager), 1568 manager_(manager),
1555 app_id_(app_id), 1569 app_id_(app_id),
1556 quit_(false), 1570 quit_(false),
1557 update_success_(false), 1571 update_success_(false),
(...skipping 350 matching lines...) Expand 10 before | Expand all | Expand 10 after
1908 set_test_crx_file(test_app_id() + "_v2_read_and_verify_data.crx"); 1922 set_test_crx_file(test_app_id() + "_v2_read_and_verify_data.crx");
1909 extensions::ResultCatcher catcher; 1923 extensions::ResultCatcher catcher;
1910 StartAppLaunchFromLoginScreen(SimulateNetworkOnlineClosure()); 1924 StartAppLaunchFromLoginScreen(SimulateNetworkOnlineClosure());
1911 WaitForAppLaunchWithOptions(true /* check_launch_data */, 1925 WaitForAppLaunchWithOptions(true /* check_launch_data */,
1912 false /* terminate_app */); 1926 false /* terminate_app */);
1913 1927
1914 EXPECT_EQ("2.0.0", GetInstalledAppVersion().GetString()); 1928 EXPECT_EQ("2.0.0", GetInstalledAppVersion().GetString());
1915 ASSERT_TRUE(catcher.GetNextResult()) << catcher.message(); 1929 ASSERT_TRUE(catcher.GetNextResult()) << catcher.message();
1916 } 1930 }
1917 1931
1932 // Tests the primary app install with required platform version. The test
1933 // has three runs:
1934 // 1. Install an app.
1935 // 2. App update is delayed because the required platform version is not
1936 // compliant.
1937 // 3. Platform version changed and the new app is installed because it is
1938 // compliant now.
1939 IN_PROC_BROWSER_TEST_F(KioskUpdateTest,
1940 PRE_PRE_IncompliantPlatformDelayInstall) {
1941 PreCacheAndLaunchApp(kTestOfflineEnabledKioskApp, "1.0.0",
1942 std::string(kTestOfflineEnabledKioskApp) + "_v1.crx");
1943 }
1944
1945 IN_PROC_BROWSER_TEST_F(KioskUpdateTest, PRE_IncompliantPlatformDelayInstall) {
1946 SetPlatformVersion("1233.0.0");
1947
1948 set_test_app_id(kTestOfflineEnabledKioskApp);
1949 set_test_app_version("2.0.0");
1950 set_test_crx_file(test_app_id() + "_v2_required_platform_version_added.crx");
1951
1952 // Fake auto launch.
1953 ReloadAutolaunchKioskApps();
1954 KioskAppManager::Get()->SetAppWasAutoLaunchedWithZeroDelay(
1955 kTestOfflineEnabledKioskApp);
1956
1957 StartUIForAppLaunch();
1958 SimulateNetworkOnline();
1959 LaunchApp(test_app_id(), false);
1960 WaitForAppLaunchSuccess();
1961
1962 EXPECT_EQ("1.0.0", GetInstalledAppVersion().GetString());
1963 EXPECT_TRUE(PrimaryAppUpdateIsPending());
1964 }
1965
1966 IN_PROC_BROWSER_TEST_F(KioskUpdateTest, IncompliantPlatformDelayInstall) {
1967 SetPlatformVersion("1234.0.0");
1968
1969 set_test_app_id(kTestOfflineEnabledKioskApp);
1970 set_test_app_version("2.0.0");
1971 set_test_crx_file(test_app_id() + "_v2_required_platform_version_added.crx");
1972
1973 // Fake auto launch.
1974 ReloadAutolaunchKioskApps();
1975 KioskAppManager::Get()->SetAppWasAutoLaunchedWithZeroDelay(
1976 kTestOfflineEnabledKioskApp);
1977
1978 StartUIForAppLaunch();
1979 SimulateNetworkOnline();
1980 LaunchApp(test_app_id(), false);
1981 WaitForAppLaunchSuccess();
1982
1983 EXPECT_EQ("2.0.0", GetInstalledAppVersion().GetString());
1984 EXPECT_FALSE(PrimaryAppUpdateIsPending());
1985 }
1986
1987 // Tests that app is installed for the first time even on an incompliant
1988 // platform.
1989 IN_PROC_BROWSER_TEST_F(KioskUpdateTest, IncompliantPlatformFirstInstall) {
1990 SetPlatformVersion("1233.0.0");
1991
1992 set_test_app_id(kTestOfflineEnabledKioskApp);
1993 set_test_app_version("2.0.0");
1994 set_test_crx_file(test_app_id() + "_v2_required_platform_version_added.crx");
1995
1996 // Fake auto launch.
1997 ReloadAutolaunchKioskApps();
1998 KioskAppManager::Get()->SetAppWasAutoLaunchedWithZeroDelay(
1999 kTestOfflineEnabledKioskApp);
2000
2001 StartUIForAppLaunch();
2002 SimulateNetworkOnline();
2003 LaunchApp(test_app_id(), false);
2004 WaitForAppLaunchSuccess();
2005
2006 EXPECT_EQ("2.0.0", GetInstalledAppVersion().GetString());
2007 EXPECT_FALSE(PrimaryAppUpdateIsPending());
2008 }
2009
1918 /* ***** Test Kiosk multi-app feature ***** */ 2010 /* ***** Test Kiosk multi-app feature ***** */
1919 2011
1920 // Launch a primary kiosk app which has two secondary apps. 2012 // Launch a primary kiosk app which has two secondary apps.
1921 IN_PROC_BROWSER_TEST_F(KioskUpdateTest, 2013 IN_PROC_BROWSER_TEST_F(KioskUpdateTest,
1922 LaunchTestKioskAppWithTwoSecondaryApps) { 2014 LaunchTestKioskAppWithTwoSecondaryApps) {
1923 LaunchTestKioskAppWithTwoSecondaryApps(); 2015 LaunchTestKioskAppWithTwoSecondaryApps();
1924 } 2016 }
1925 2017
1926 IN_PROC_BROWSER_TEST_F(KioskUpdateTest, PRE_UpdateMultiAppKioskRemoveOneApp) { 2018 IN_PROC_BROWSER_TEST_F(KioskUpdateTest, PRE_UpdateMultiAppKioskRemoveOneApp) {
1927 LaunchTestKioskAppWithTwoSecondaryApps(); 2019 LaunchTestKioskAppWithTwoSecondaryApps();
(...skipping 383 matching lines...) Expand 10 before | Expand all | Expand 10 after
2311 content::WindowedNotificationObserver( 2403 content::WindowedNotificationObserver(
2312 chrome::NOTIFICATION_KIOSK_AUTOLAUNCH_WARNING_VISIBLE, 2404 chrome::NOTIFICATION_KIOSK_AUTOLAUNCH_WARNING_VISIBLE,
2313 content::NotificationService::AllSources()).Wait(); 2405 content::NotificationService::AllSources()).Wait();
2314 2406
2315 // Wait for the wallpaper to load. 2407 // Wait for the wallpaper to load.
2316 WaitForWallpaper(); 2408 WaitForWallpaper();
2317 EXPECT_TRUE(wallpaper_loaded()); 2409 EXPECT_TRUE(wallpaper_loaded());
2318 } 2410 }
2319 2411
2320 } // namespace chromeos 2412 } // namespace chromeos
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/app_mode/startup_app_launcher.cc ('k') | chrome/browser/extensions/extension_system_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698