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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/chromeos/login/kiosk_browsertest.cc
diff --git a/chrome/browser/chromeos/login/kiosk_browsertest.cc b/chrome/browser/chromeos/login/kiosk_browsertest.cc
index 58dcec28978dbe15488e2f8a4686c01e5c9a2eb0..7c262c4fa57fdb86cc86e6e768002a66f33dc44e 100644
--- a/chrome/browser/chromeos/login/kiosk_browsertest.cc
+++ b/chrome/browser/chromeos/login/kiosk_browsertest.cc
@@ -18,6 +18,7 @@
#include "base/strings/string_number_conversions.h"
#include "base/strings/string_util.h"
#include "base/synchronization/lock.h"
+#include "base/sys_info.h"
#include "chrome/browser/chrome_notification_types.h"
#include "chrome/browser/chromeos/app_mode/fake_cws.h"
#include "chrome/browser/chromeos/app_mode/kiosk_app_launch_error.h"
@@ -255,6 +256,12 @@ extensions::Manifest::Type GetAppType(const std::string& app_id) {
return app->GetType();
}
+void SetPlatformVersion(const std::string& platform_version) {
+ const std::string lsb_release = base::StringPrintf(
+ "CHROMEOS_RELEASE_VERSION=%s", platform_version.c_str());
+ base::SysInfo::SetChromeOSVersionInfoForTest(lsb_release, base::Time::Now());
+}
+
// Helper functions for CanConfigureNetwork mock.
class ScopedCanConfigureNetwork {
public:
@@ -1545,6 +1552,13 @@ class KioskUpdateTest : public KioskTest {
LaunchKioskWithSecondaryApps(primary_app, secondary_apps);
}
+ bool PrimaryAppUpdateIsPending() const {
+ Profile* app_profile = ProfileManager::GetPrimaryUserProfile();
+ return !!extensions::ExtensionSystem::Get(app_profile)
+ ->extension_service()
+ ->GetPendingExtensionUpdate(test_app_id());
+ }
+
private:
class KioskAppExternalUpdateWaiter : public KioskAppManagerObserver {
public:
@@ -1915,6 +1929,84 @@ IN_PROC_BROWSER_TEST_F(KioskUpdateTest, PreserveLocalData) {
ASSERT_TRUE(catcher.GetNextResult()) << catcher.message();
}
+// Tests the primary app install with required platform version. The test
+// has three runs:
+// 1. Install an app.
+// 2. App update is delayed because the required platform version is not
+// compliant.
+// 3. Platform version changed and the new app is installed because it is
+// compliant now.
+IN_PROC_BROWSER_TEST_F(KioskUpdateTest,
+ PRE_PRE_IncompliantPlatformDelayInstall) {
+ PreCacheAndLaunchApp(kTestOfflineEnabledKioskApp, "1.0.0",
+ std::string(kTestOfflineEnabledKioskApp) + "_v1.crx");
+}
+
+IN_PROC_BROWSER_TEST_F(KioskUpdateTest, PRE_IncompliantPlatformDelayInstall) {
+ SetPlatformVersion("1233.0.0");
+
+ set_test_app_id(kTestOfflineEnabledKioskApp);
+ set_test_app_version("2.0.0");
+ set_test_crx_file(test_app_id() + "_v2_required_platform_version_added.crx");
+
+ // Fake auto launch.
+ ReloadAutolaunchKioskApps();
+ KioskAppManager::Get()->SetAppWasAutoLaunchedWithZeroDelay(
+ kTestOfflineEnabledKioskApp);
+
+ StartUIForAppLaunch();
+ SimulateNetworkOnline();
+ LaunchApp(test_app_id(), false);
+ WaitForAppLaunchSuccess();
+
+ EXPECT_EQ("1.0.0", GetInstalledAppVersion().GetString());
+ EXPECT_TRUE(PrimaryAppUpdateIsPending());
+}
+
+IN_PROC_BROWSER_TEST_F(KioskUpdateTest, IncompliantPlatformDelayInstall) {
+ SetPlatformVersion("1234.0.0");
+
+ set_test_app_id(kTestOfflineEnabledKioskApp);
+ set_test_app_version("2.0.0");
+ set_test_crx_file(test_app_id() + "_v2_required_platform_version_added.crx");
+
+ // Fake auto launch.
+ ReloadAutolaunchKioskApps();
+ KioskAppManager::Get()->SetAppWasAutoLaunchedWithZeroDelay(
+ kTestOfflineEnabledKioskApp);
+
+ StartUIForAppLaunch();
+ SimulateNetworkOnline();
+ LaunchApp(test_app_id(), false);
+ WaitForAppLaunchSuccess();
+
+ EXPECT_EQ("2.0.0", GetInstalledAppVersion().GetString());
+ EXPECT_FALSE(PrimaryAppUpdateIsPending());
+}
+
+// Tests that app is installed for the first time even on an incompliant
+// platform.
+IN_PROC_BROWSER_TEST_F(KioskUpdateTest, IncompliantPlatformFirstInstall) {
+ SetPlatformVersion("1233.0.0");
+
+ set_test_app_id(kTestOfflineEnabledKioskApp);
+ set_test_app_version("2.0.0");
+ set_test_crx_file(test_app_id() + "_v2_required_platform_version_added.crx");
+
+ // Fake auto launch.
+ ReloadAutolaunchKioskApps();
+ KioskAppManager::Get()->SetAppWasAutoLaunchedWithZeroDelay(
+ kTestOfflineEnabledKioskApp);
+
+ StartUIForAppLaunch();
+ SimulateNetworkOnline();
+ LaunchApp(test_app_id(), false);
+ WaitForAppLaunchSuccess();
+
+ EXPECT_EQ("2.0.0", GetInstalledAppVersion().GetString());
+ EXPECT_FALSE(PrimaryAppUpdateIsPending());
+}
+
/* ***** Test Kiosk multi-app feature ***** */
// Launch a primary kiosk app which has two secondary apps.
« 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