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/scoped_temp_dir.h" | 13 #include "base/scoped_temp_dir.h" |
14 #include "chrome/browser/extensions/extension_host.h" | 14 #include "chrome/browser/extensions/extension_host.h" |
15 #include "chrome/common/extensions/extension.h" | 15 #include "chrome/common/extensions/extension.h" |
16 #include "chrome/test/base/in_process_browser_test.h" | 16 #include "chrome/test/base/in_process_browser_test.h" |
17 #include "content/public/browser/notification_details.h" | 17 #include "content/public/browser/notification_details.h" |
18 #include "content/public/browser/notification_observer.h" | 18 #include "content/public/browser/notification_observer.h" |
19 #include "content/public/browser/notification_types.h" | 19 #include "content/public/browser/notification_types.h" |
20 #include "content/public/browser/web_contents.h" | 20 #include "content/public/browser/web_contents.h" |
21 | 21 |
22 // Base class for extension browser tests. Provides utilities for loading, | 22 // Base class for extension browser tests. Provides utilities for loading, |
23 // unloading, and installing extensions. | 23 // unloading, and installing extensions. |
24 class ExtensionBrowserTest : virtual public InProcessBrowserTest, | 24 class ExtensionBrowserTest : virtual public InProcessBrowserTest, |
25 public content::NotificationObserver { | 25 public content::NotificationObserver { |
26 protected: | 26 protected: |
| 27 // Flags used to configure how the tests are run. |
| 28 enum Flags { |
| 29 kFlagNone = 0, |
| 30 |
| 31 // Allow the extension to run in incognito mode. |
| 32 kFlagEnableIncognito = 1 << 0, |
| 33 |
| 34 // Allow file access for the extension. |
| 35 kFlagEnableFileAccess = 1 << 1, |
| 36 |
| 37 // Don't fail when the loaded manifest has warnings (should only be used |
| 38 // when testing deprecated features). |
| 39 kFlagIgnoreManifestWarnings = 1 << 2 |
| 40 }; |
| 41 |
27 ExtensionBrowserTest(); | 42 ExtensionBrowserTest(); |
28 virtual ~ExtensionBrowserTest(); | 43 virtual ~ExtensionBrowserTest(); |
29 | 44 |
30 // InProcessBrowserTest | 45 // InProcessBrowserTest |
31 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE; | 46 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE; |
32 | 47 |
33 const extensions::Extension* LoadExtension(const FilePath& path); | 48 const extensions::Extension* LoadExtension(const FilePath& path); |
34 | 49 |
35 // Same as above, but enables the extension in incognito mode first. | 50 // Same as above, but enables the extension in incognito mode first. |
36 const extensions::Extension* LoadExtensionIncognito(const FilePath& path); | 51 const extensions::Extension* LoadExtensionIncognito(const FilePath& path); |
37 | 52 |
38 const extensions::Extension* LoadExtensionWithOptions( | 53 const extensions::Extension* LoadExtensionWithFlags( |
39 const FilePath& path, | 54 const FilePath& path, int flags); |
40 bool incognito_enabled, | |
41 bool fileaccess_enabled); | |
42 | 55 |
43 // Loads extension and imitates that it is a component extension. | 56 // Loads extension and imitates that it is a component extension. |
44 const extensions::Extension* LoadExtensionAsComponent(const FilePath& path); | 57 const extensions::Extension* LoadExtensionAsComponent(const FilePath& path); |
45 | 58 |
46 // Pack the extension in |dir_path| into a crx file and return its path. | 59 // Pack the extension in |dir_path| into a crx file and return its path. |
47 // Return an empty FilePath if there were errors. | 60 // Return an empty FilePath if there were errors. |
48 FilePath PackExtension(const FilePath& dir_path); | 61 FilePath PackExtension(const FilePath& dir_path); |
49 | 62 |
50 // Pack the extension in |dir_path| into a crx file at |crx_path|, using the | 63 // Pack the extension in |dir_path| into a crx file at |crx_path|, using the |
51 // key |pem_path|. If |pem_path| does not exist, create a new key at | 64 // key |pem_path|. If |pem_path| does not exist, create a new key at |
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
224 // When waiting for page action count to change, we wait until it reaches this | 237 // When waiting for page action count to change, we wait until it reaches this |
225 // value. | 238 // value. |
226 int target_page_action_count_; | 239 int target_page_action_count_; |
227 | 240 |
228 // When waiting for visible page action count to change, we wait until it | 241 // When waiting for visible page action count to change, we wait until it |
229 // reaches this value. | 242 // reaches this value. |
230 int target_visible_page_action_count_; | 243 int target_visible_page_action_count_; |
231 }; | 244 }; |
232 | 245 |
233 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_BROWSERTEST_H_ | 246 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_BROWSERTEST_H_ |
OLD | NEW |