| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 #ifndef CHROME_BROWSER_EXTENSIONS_EXTENSION_BROWSERTEST_H_ | 5 #ifndef CHROME_BROWSER_EXTENSIONS_EXTENSION_BROWSERTEST_H_ |
| 6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_BROWSERTEST_H_ | 6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_BROWSERTEST_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| 11 #include "base/compiler_specific.h" | 11 #include "base/compiler_specific.h" |
| 12 #include "base/file_path.h" | 12 #include "base/file_path.h" |
| 13 #include "base/files/scoped_temp_dir.h" | 13 #include "base/files/scoped_temp_dir.h" |
| 14 #include "chrome/browser/extensions/extension_host.h" | 14 #include "chrome/browser/extensions/extension_host.h" |
| 15 #include "chrome/browser/extensions/extension_system.h" |
| 16 #include "chrome/browser/ui/browser.h" |
| 15 #include "chrome/common/extensions/extension.h" | 17 #include "chrome/common/extensions/extension.h" |
| 16 #include "chrome/common/extensions/feature_switch.h" | 18 #include "chrome/common/extensions/feature_switch.h" |
| 17 #include "chrome/common/extensions/features/feature.h" | 19 #include "chrome/common/extensions/features/feature.h" |
| 18 #include "chrome/test/base/in_process_browser_test.h" | 20 #include "chrome/test/base/in_process_browser_test.h" |
| 19 #include "content/public/browser/notification_details.h" | 21 #include "content/public/browser/notification_details.h" |
| 20 #include "content/public/browser/notification_observer.h" | 22 #include "content/public/browser/notification_observer.h" |
| 21 #include "content/public/browser/notification_types.h" | 23 #include "content/public/browser/notification_types.h" |
| 22 #include "content/public/browser/web_contents.h" | 24 #include "content/public/browser/web_contents.h" |
| 23 | 25 |
| 26 class ExtensionService; |
| 24 class ExtensionProcessManager; | 27 class ExtensionProcessManager; |
| 28 class Profile; |
| 25 | 29 |
| 26 // Base class for extension browser tests. Provides utilities for loading, | 30 // Base class for extension browser tests. Provides utilities for loading, |
| 27 // unloading, and installing extensions. | 31 // unloading, and installing extensions. |
| 28 class ExtensionBrowserTest : virtual public InProcessBrowserTest, | 32 class ExtensionBrowserTest : virtual public InProcessBrowserTest, |
| 29 public content::NotificationObserver { | 33 public content::NotificationObserver { |
| 30 protected: | 34 protected: |
| 31 // Flags used to configure how the tests are run. | 35 // Flags used to configure how the tests are run. |
| 32 enum Flags { | 36 enum Flags { |
| 33 kFlagNone = 0, | 37 kFlagNone = 0, |
| 34 | 38 |
| 35 // Allow the extension to run in incognito mode. | 39 // Allow the extension to run in incognito mode. |
| 36 kFlagEnableIncognito = 1 << 0, | 40 kFlagEnableIncognito = 1 << 0, |
| 37 | 41 |
| 38 // Allow file access for the extension. | 42 // Allow file access for the extension. |
| 39 kFlagEnableFileAccess = 1 << 1, | 43 kFlagEnableFileAccess = 1 << 1, |
| 40 | 44 |
| 41 // Don't fail when the loaded manifest has warnings (should only be used | 45 // Don't fail when the loaded manifest has warnings (should only be used |
| 42 // when testing deprecated features). | 46 // when testing deprecated features). |
| 43 kFlagIgnoreManifestWarnings = 1 << 2, | 47 kFlagIgnoreManifestWarnings = 1 << 2, |
| 44 | 48 |
| 45 // Allow older manifest versions (typically these can't be loaded - we allow | 49 // Allow older manifest versions (typically these can't be loaded - we allow |
| 46 // them for testing). | 50 // them for testing). |
| 47 kFlagAllowOldManifestVersions = 1 << 3, | 51 kFlagAllowOldManifestVersions = 1 << 3, |
| 48 }; | 52 }; |
| 49 | 53 |
| 50 ExtensionBrowserTest(); | 54 ExtensionBrowserTest(); |
| 51 virtual ~ExtensionBrowserTest(); | 55 virtual ~ExtensionBrowserTest(); |
| 52 | 56 |
| 57 // Useful accessors. |
| 58 Profile* profile() { return browser()->profile(); } |
| 59 ExtensionService* extension_service() { |
| 60 return extensions::ExtensionSystem::Get(profile())->extension_service(); |
| 61 } |
| 62 |
| 53 // InProcessBrowserTest | 63 // InProcessBrowserTest |
| 54 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE; | 64 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE; |
| 55 | 65 |
| 56 const extensions::Extension* LoadExtension(const FilePath& path); | 66 const extensions::Extension* LoadExtension(const FilePath& path); |
| 57 | 67 |
| 58 // Same as above, but enables the extension in incognito mode first. | 68 // Same as above, but enables the extension in incognito mode first. |
| 59 const extensions::Extension* LoadExtensionIncognito(const FilePath& path); | 69 const extensions::Extension* LoadExtensionIncognito(const FilePath& path); |
| 60 | 70 |
| 61 const extensions::Extension* LoadExtensionWithFlags( | 71 const extensions::Extension* LoadExtensionWithFlags( |
| 62 const FilePath& path, int flags); | 72 const FilePath& path, int flags); |
| (...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 256 // Disable external install UI. | 266 // Disable external install UI. |
| 257 extensions::FeatureSwitch::ScopedOverride | 267 extensions::FeatureSwitch::ScopedOverride |
| 258 override_prompt_for_external_extensions_; | 268 override_prompt_for_external_extensions_; |
| 259 | 269 |
| 260 // Disable the sideload wipeout UI. | 270 // Disable the sideload wipeout UI. |
| 261 extensions::FeatureSwitch::ScopedOverride | 271 extensions::FeatureSwitch::ScopedOverride |
| 262 override_sideload_wipeout_; | 272 override_sideload_wipeout_; |
| 263 }; | 273 }; |
| 264 | 274 |
| 265 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_BROWSERTEST_H_ | 275 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_BROWSERTEST_H_ |
| OLD | NEW |