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

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

Issue 9837045: Expand usage of platform-apps flag and permission features. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 9 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 | « chrome/browser/extensions/extension_apitest.h ('k') | chrome/browser/extensions/extension_browsertest.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/extensions/extension_apitest.cc
diff --git a/chrome/browser/extensions/extension_apitest.cc b/chrome/browser/extensions/extension_apitest.cc
index 521aa98f6ca22d38b14e9880c1dfdfc96614093a..b0dabe2f5841c4ffbf814e65826744b688fd5c6d 100644
--- a/chrome/browser/extensions/extension_apitest.cc
+++ b/chrome/browser/extensions/extension_apitest.cc
@@ -8,9 +8,12 @@
#include "base/stringprintf.h"
#include "chrome/browser/extensions/extension_service.h"
#include "chrome/browser/extensions/extension_test_api.h"
+#include "chrome/browser/extensions/unpacked_installer.h"
+#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/common/chrome_notification_types.h"
+#include "chrome/common/chrome_switches.h"
#include "chrome/test/base/ui_test_utils.h"
#include "content/public/browser/notification_registrar.h"
#include "content/public/browser/notification_service.h"
@@ -293,3 +296,60 @@ void ExtensionApiTest::SetUpCommandLine(CommandLine* command_line) {
ExtensionBrowserTest::SetUpCommandLine(command_line);
test_data_dir_ = test_data_dir_.AppendASCII("api_test");
}
+
+PlatformAppApiTest::PlatformAppApiTest()
+ : previous_command_line_(CommandLine::NO_PROGRAM) {}
+
+PlatformAppApiTest::~PlatformAppApiTest() {}
+
+void PlatformAppApiTest::SetUpCommandLine(CommandLine* command_line) {
+ ExtensionApiTest::SetUpCommandLine(command_line);
+
+ // If someone is using this class, we're going to insist on management of the
+ // relevant flags. If these flags are already set, die.
+ DCHECK(!command_line->HasSwitch(switches::kEnablePlatformApps));
+ DCHECK(!command_line->HasSwitch(switches::kEnableExperimentalExtensionApis));
+
+ // Squirrel away for potential use in VerifyPermissions.
+ //
+ // TODO(miket): I _could_ just call VerifyPermissions here instead of
+ // requiring everyone who inherits from PlatformAppApiTest to explicitly call
+ // it within a test, but that feels overbearing.
+ previous_command_line_ = *command_line;
+
+ command_line->AppendSwitch(switches::kEnableExperimentalExtensionApis);
+ command_line->AppendSwitch(switches::kEnablePlatformApps);
+}
+
+void PlatformAppApiTest::VerifyPermissions(const FilePath& extension_path) {
+#if defined(OS_WIN)
miket_OOO 2012/03/23 17:12:03 This #ifdef is the only change between this CL and
+ // See http://code.google.com/p/chromium/issues/detail?id=119758.
+ //
+ // TODO(miket): investigate why WaitForExtensionLoadError() doesn't receive
+ // the expected notification on XP/Vista, but succeeds on other platforms.
+#else
+ CommandLine old_command_line(*CommandLine::ForCurrentProcess());
+ ExtensionService* service = browser()->profile()->GetExtensionService();
+
+ // Neither experimental nor platform-app flag.
+ *CommandLine::ForCurrentProcess() = previous_command_line_;
+ extensions::UnpackedInstaller::Create(service)->Load(extension_path);
+ ASSERT_TRUE(WaitForExtensionLoadError());
+
+ // Only experimental flag.
+ *CommandLine::ForCurrentProcess() = previous_command_line_;
+ CommandLine::ForCurrentProcess()->AppendSwitch(
+ switches::kEnableExperimentalExtensionApis);
+ extensions::UnpackedInstaller::Create(service)->Load(extension_path);
+ ASSERT_TRUE(WaitForExtensionLoadError());
+
+ // Only platform-app flag.
+ *CommandLine::ForCurrentProcess() = previous_command_line_;
+ CommandLine::ForCurrentProcess()->AppendSwitch(
+ switches::kEnablePlatformApps);
+ extensions::UnpackedInstaller::Create(service)->Load(extension_path);
+ ASSERT_TRUE(WaitForExtensionLoadError());
+
+ *CommandLine::ForCurrentProcess() = old_command_line;
+#endif
+}
« no previous file with comments | « chrome/browser/extensions/extension_apitest.h ('k') | chrome/browser/extensions/extension_browsertest.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698