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

Unified Diff: chrome/browser/extensions/crx_installer_browsertest.cc

Issue 1752293002: The command line flag is now set during the test startup. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 10 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
« no previous file with comments | « no previous file | chrome/test/data/extensions/experimental.crx » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/extensions/crx_installer_browsertest.cc
diff --git a/chrome/browser/extensions/crx_installer_browsertest.cc b/chrome/browser/extensions/crx_installer_browsertest.cc
index 45b651f616dfd877d7cf7239010ef893c057b089..093311d66b7cad1644be9300c68a34980596fa3d 100644
--- a/chrome/browser/extensions/crx_installer_browsertest.cc
+++ b/chrome/browser/extensions/crx_installer_browsertest.cc
@@ -203,24 +203,6 @@ class ManagementPolicyMock : public extensions::ManagementPolicy::Provider {
}
};
-// Appends "enable-experimental-extension-apis" to the command line for the
-// lifetime of this class.
-class ScopedExperimentalCommandLine {
- public:
- ScopedExperimentalCommandLine()
- : saved_(*base::CommandLine::ForCurrentProcess()) {
- base::CommandLine::ForCurrentProcess()->AppendSwitch(
- switches::kEnableExperimentalExtensionApis);
- }
-
- ~ScopedExperimentalCommandLine() {
- *base::CommandLine::ForCurrentProcess() = saved_;
- }
-
- private:
- base::CommandLine saved_;
-};
-
} // namespace
class ExtensionCrxInstallerTest : public ExtensionBrowserTest {
@@ -279,8 +261,6 @@ class ExtensionCrxInstallerTest : public ExtensionBrowserTest {
// |record_oauth2_grant| is true.
void CheckHasEmptyScopesAfterInstall(const std::string& ext_relpath,
bool record_oauth2_grant) {
- ScopedExperimentalCommandLine scope;
-
scoped_ptr<MockPromptProxy> mock_prompt =
CreateMockPromptProxyForBrowser(browser());
@@ -292,18 +272,6 @@ class ExtensionCrxInstallerTest : public ExtensionBrowserTest {
ASSERT_TRUE(permissions.get());
}
- // Returns a FilePath to an unpacked "experimental" extension (a test
- // Extension which requests the "experimental" permission).
- base::FilePath PackExperimentalExtension() {
- // We must modify the command line temporarily in order to pack an
- // extension that requests the experimental permission.
- ScopedExperimentalCommandLine scope;
- base::FilePath test_path = test_data_dir_.AppendASCII("experimental");
- base::FilePath crx_path = PackExtension(test_path);
- CHECK(!crx_path.empty()) << "Extension not found at " << test_path.value();
- return crx_path;
- }
-
void InstallWebAppAndVerifyNoErrors() {
ExtensionService* service =
extensions::ExtensionSystem::Get(browser()->profile())
@@ -328,6 +296,15 @@ class ExtensionCrxInstallerTest : public ExtensionBrowserTest {
}
};
+class ExtensionCrxInstallerTestWithExperimentalApis
+ : public ExtensionCrxInstallerTest {
+ protected:
+ void SetUpCommandLine(base::CommandLine* command_line) override {
+ ExtensionCrxInstallerTest::SetUpCommandLine(command_line);
+ command_line->AppendSwitch(switches::kEnableExperimentalExtensionApis);
+ }
+};
+
// This test is skipped on ChromeOS because it requires the NPAPI,
// which is not available on that platform.
#if !defined(OS_CHROMEOS)
@@ -349,8 +326,8 @@ IN_PROC_BROWSER_TEST_F(ExtensionCrxInstallerTest,
ExperimentalExtensionFromGallery) {
// Gallery-installed extensions should have their experimental permission
// preserved, since we allow the Webstore to make that decision.
- base::FilePath crx_path = PackExperimentalExtension();
- const Extension* extension = InstallExtensionFromWebstore(crx_path, 1);
+ const Extension* extension = InstallExtensionFromWebstore(
+ test_data_dir_.AppendASCII("experimental.crx"), 1);
ASSERT_TRUE(extension);
EXPECT_TRUE(extension->permissions_data()->HasAPIPermission(
APIPermission::kExperimental));
@@ -360,27 +337,26 @@ IN_PROC_BROWSER_TEST_F(ExtensionCrxInstallerTest,
ExperimentalExtensionFromOutsideGallery) {
// Non-gallery-installed extensions should lose their experimental
// permission if the flag isn't enabled.
- base::FilePath crx_path = PackExperimentalExtension();
- const Extension* extension = InstallExtension(crx_path, 1);
+ const Extension* extension = InstallExtension(
+ test_data_dir_.AppendASCII("experimental.crx"), 1);
ASSERT_TRUE(extension);
EXPECT_FALSE(extension->permissions_data()->HasAPIPermission(
APIPermission::kExperimental));
}
-IN_PROC_BROWSER_TEST_F(ExtensionCrxInstallerTest,
+IN_PROC_BROWSER_TEST_F(ExtensionCrxInstallerTestWithExperimentalApis,
ExperimentalExtensionFromOutsideGalleryWithFlag) {
// Non-gallery-installed extensions should maintain their experimental
// permission if the flag is enabled.
- base::FilePath crx_path = PackExperimentalExtension();
- ScopedExperimentalCommandLine scope;
- const Extension* extension = InstallExtension(crx_path, 1);
+ const Extension* extension = InstallExtension(
+ test_data_dir_.AppendASCII("experimental.crx"), 1);
ASSERT_TRUE(extension);
EXPECT_TRUE(extension->permissions_data()->HasAPIPermission(
APIPermission::kExperimental));
}
-IN_PROC_BROWSER_TEST_F(ExtensionCrxInstallerTest, PlatformAppCrx) {
- ScopedExperimentalCommandLine scope;
+IN_PROC_BROWSER_TEST_F(ExtensionCrxInstallerTestWithExperimentalApis,
+ PlatformAppCrx) {
EXPECT_TRUE(InstallExtension(
test_data_dir_.AppendASCII("minimal_platform_app.crx"), 1));
}
@@ -429,12 +405,14 @@ IN_PROC_BROWSER_TEST_F(ExtensionCrxInstallerTest, PackAndInstallExtension) {
#else
#define MAYBE_GrantScopes GrantScopes
#endif
-IN_PROC_BROWSER_TEST_F(ExtensionCrxInstallerTest, MAYBE_GrantScopes) {
+IN_PROC_BROWSER_TEST_F(ExtensionCrxInstallerTestWithExperimentalApis,
+ MAYBE_GrantScopes) {
EXPECT_NO_FATAL_FAILURE(CheckHasEmptyScopesAfterInstall("browsertest/scopes",
true));
}
-IN_PROC_BROWSER_TEST_F(ExtensionCrxInstallerTest, DoNotGrantScopes) {
+IN_PROC_BROWSER_TEST_F(ExtensionCrxInstallerTestWithExperimentalApis,
+ DoNotGrantScopes) {
EXPECT_NO_FATAL_FAILURE(CheckHasEmptyScopesAfterInstall("browsertest/scopes",
false));
}
« no previous file with comments | « no previous file | chrome/test/data/extensions/experimental.crx » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698