Commit 5f6d6a2c authored by Alexander Hendrich's avatar Alexander Hendrich Committed by Commit Bot

[Extensions] Add kFlagLoadForLoginScreen flag to API tests

This CL adds a flag that can be used to load an extension as login
screen extension during API tests.

Bug: 957573
Change-Id: Iba6299721df654d66856c7a24a4292f82938063b
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1599177
Commit-Queue: Alexander Hendrich <hendrich@chromium.org>
Reviewed-by: default avatarDevlin <rdevlin.cronin@chromium.org>
Cr-Commit-Position: refs/heads/master@{#664567}
parent 253a1185
......@@ -259,6 +259,8 @@ bool ExtensionApiTest::RunExtensionTestImpl(const std::string& extension_name,
browser_test_flags |=
ExtensionBrowserTest::kFlagAllowOldManifestVersions;
}
if (flags & kFlagLoadForLoginScreen)
browser_test_flags |= ExtensionBrowserTest::kFlagLoadForLoginScreen;
extension = LoadExtensionWithFlags(extension_path, browser_test_flags);
}
if (!extension) {
......
......@@ -61,6 +61,11 @@ class ExtensionApiTest : public ExtensionBrowserTest {
// Load the extension using //extensions/test/data/ as the root path instead
// of loading from //chrome/test/data/extensions/api_test/.
kFlagUseRootExtensionsDir = 1 << 7,
// Pass the FOR_LOGIN_SCREEN flag when loading the extension. This flag is
// usually provided for force-installed extension on the login screen. This
// also sets the location to EXTERNAL_POLICY.
kFlagLoadForLoginScreen = 1 << 8,
};
ExtensionApiTest();
......@@ -152,9 +157,8 @@ class ExtensionApiTest : public ExtensionBrowserTest {
// Similar to RunPlatformAppTest, except sets an additional string argument
// |customArg| to the test config object.
bool RunPlatformAppTestWithArg(
const std::string& extension_name, const char* custom_arg);
bool RunPlatformAppTestWithArg(const std::string& extension_name,
const char* custom_arg);
// Similar to RunPlatformAppTest, with custom |flags| (as defined in the Flags
// enum). The kFlagLaunchPlatformApp flag is automatically added.
......
......@@ -252,6 +252,10 @@ const Extension* ExtensionBrowserTest::LoadExtensionWithInstallParam(
loader.set_allow_incognito_access((flags & kFlagEnableIncognito) != 0);
loader.set_allow_file_access((flags & kFlagEnableFileAccess) != 0);
loader.set_install_param(install_param);
if ((flags & kFlagLoadForLoginScreen) != 0) {
loader.add_creation_flag(Extension::FOR_LOGIN_SCREEN);
loader.set_location(Manifest::EXTERNAL_POLICY);
}
scoped_refptr<const Extension> extension = loader.LoadExtension(path);
if (extension)
observer_->set_last_loaded_extension_id(extension->id());
......
......@@ -62,6 +62,10 @@ class ExtensionBrowserTest : virtual public InProcessBrowserTest {
// Allow older manifest versions (typically these can't be loaded - we allow
// them for testing).
kFlagAllowOldManifestVersions = 1 << 3,
// Pass the FOR_LOGIN_SCREEN flag when loading the extension. This flag is
// usually provided for force-installed extension on the login screen.
kFlagLoadForLoginScreen = 1 << 4,
};
ExtensionBrowserTest();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment