| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 : public InProcessBrowserTest, public NotificationObserver { | 22 : public InProcessBrowserTest, public NotificationObserver { |
| 23 protected: | 23 protected: |
| 24 ExtensionBrowserTest(); | 24 ExtensionBrowserTest(); |
| 25 | 25 |
| 26 virtual void SetUpCommandLine(CommandLine* command_line); | 26 virtual void SetUpCommandLine(CommandLine* command_line); |
| 27 bool LoadExtension(const FilePath& path); | 27 bool LoadExtension(const FilePath& path); |
| 28 | 28 |
| 29 // Same as above, but enables the extension in incognito mode first. | 29 // Same as above, but enables the extension in incognito mode first. |
| 30 bool LoadExtensionIncognito(const FilePath& path); | 30 bool LoadExtensionIncognito(const FilePath& path); |
| 31 | 31 |
| 32 // Pack the extension in |dir_path| into a crx file and return its path. |
| 33 // Return an empty FilePath if there were errors. |
| 34 FilePath PackExtension(const FilePath& dir_path); |
| 35 |
| 32 // |expected_change| indicates how many extensions should be installed (or | 36 // |expected_change| indicates how many extensions should be installed (or |
| 33 // disabled, if negative). | 37 // disabled, if negative). |
| 34 // 1 means you expect a new install, 0 means you expect an upgrade, -1 means | 38 // 1 means you expect a new install, 0 means you expect an upgrade, -1 means |
| 35 // you expect a failed upgrade. | 39 // you expect a failed upgrade. |
| 36 bool InstallExtension(const FilePath& path, int expected_change) { | 40 bool InstallExtension(const FilePath& path, int expected_change) { |
| 37 return InstallOrUpdateExtension("", path, INSTALL_UI_TYPE_NONE, | 41 return InstallOrUpdateExtension("", path, INSTALL_UI_TYPE_NONE, |
| 38 expected_change); | 42 expected_change); |
| 39 } | 43 } |
| 40 | 44 |
| 41 // Same as above but passes an id to CrxInstaller and does not allow a | 45 // Same as above but passes an id to CrxInstaller and does not allow a |
| 42 // privilege increase. | 46 // privilege increase. |
| 43 bool UpdateExtension(const std::string& id, const FilePath& path, | 47 bool UpdateExtension(const std::string& id, const FilePath& path, |
| 44 int expected_change) { | 48 int expected_change) { |
| 45 return InstallOrUpdateExtension(id, path, INSTALL_UI_TYPE_NONE, | 49 return InstallOrUpdateExtension(id, path, INSTALL_UI_TYPE_NONE, |
| 46 expected_change); | 50 expected_change); |
| 47 } | 51 } |
| 48 | 52 |
| 49 // Same as |InstallExtension| but with the normal extension UI showing up | 53 // Same as |InstallExtension| but with the normal extension UI showing up |
| 50 // (for e.g. info bar on success). | 54 // (for e.g. info bar on success). |
| 51 bool InstallExtensionWithUI(const FilePath& path, int expected_change) { | 55 bool InstallExtensionWithUI(const FilePath& path, int expected_change) { |
| 52 return InstallOrUpdateExtension("", path, INSTALL_UI_TYPE_NORMAL, | 56 return InstallOrUpdateExtension("", path, INSTALL_UI_TYPE_NORMAL, |
| 53 expected_change); | 57 expected_change); |
| 54 } | 58 } |
| 59 bool InstallExtensionWithUIAutoConfirm(const FilePath& path, |
| 60 int expected_change, |
| 61 Profile* profile) { |
| 62 return InstallOrUpdateExtension("", path, INSTALL_UI_TYPE_AUTO_CONFIRM, |
| 63 expected_change, profile); |
| 64 } |
| 55 | 65 |
| 56 // Begins install process but simulates a user cancel. | 66 // Begins install process but simulates a user cancel. |
| 57 bool StartInstallButCancel(const FilePath& path) { | 67 bool StartInstallButCancel(const FilePath& path) { |
| 58 return InstallOrUpdateExtension("", path, INSTALL_UI_TYPE_CANCEL, 0); | 68 return InstallOrUpdateExtension("", path, INSTALL_UI_TYPE_CANCEL, 0); |
| 59 } | 69 } |
| 60 | 70 |
| 61 void ReloadExtension(const std::string& extension_id); | 71 void ReloadExtension(const std::string& extension_id); |
| 62 | 72 |
| 63 void UnloadExtension(const std::string& extension_id); | 73 void UnloadExtension(const std::string& extension_id); |
| 64 | 74 |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 102 std::string last_loaded_extension_id_; | 112 std::string last_loaded_extension_id_; |
| 103 int extension_installs_observed_; | 113 int extension_installs_observed_; |
| 104 | 114 |
| 105 private: | 115 private: |
| 106 // Specifies the type of UI (if any) to show during installation and what | 116 // Specifies the type of UI (if any) to show during installation and what |
| 107 // user action to simulate. | 117 // user action to simulate. |
| 108 enum InstallUIType { | 118 enum InstallUIType { |
| 109 INSTALL_UI_TYPE_NONE, | 119 INSTALL_UI_TYPE_NONE, |
| 110 INSTALL_UI_TYPE_CANCEL, | 120 INSTALL_UI_TYPE_CANCEL, |
| 111 INSTALL_UI_TYPE_NORMAL, | 121 INSTALL_UI_TYPE_NORMAL, |
| 122 INSTALL_UI_TYPE_AUTO_CONFIRM, |
| 112 }; | 123 }; |
| 113 | 124 |
| 114 bool InstallOrUpdateExtension(const std::string& id, const FilePath& path, | 125 bool InstallOrUpdateExtension(const std::string& id, const FilePath& path, |
| 115 InstallUIType ui_type, | 126 InstallUIType ui_type, |
| 116 int expected_change); | 127 int expected_change); |
| 128 bool InstallOrUpdateExtension(const std::string& id, const FilePath& path, |
| 129 InstallUIType ui_type, |
| 130 int expected_change, |
| 131 Profile* profile); |
| 117 bool LoadExtensionImpl(const FilePath& path, bool incognito_enabled); | 132 bool LoadExtensionImpl(const FilePath& path, bool incognito_enabled); |
| 118 | 133 |
| 119 bool WaitForExtensionHostsToLoad(); | 134 bool WaitForExtensionHostsToLoad(); |
| 120 | 135 |
| 121 // When waiting for page action count to change, we wait until it reaches this | 136 // When waiting for page action count to change, we wait until it reaches this |
| 122 // value. | 137 // value. |
| 123 int target_page_action_count_; | 138 int target_page_action_count_; |
| 124 | 139 |
| 125 // When waiting for visible page action count to change, we wait until it | 140 // When waiting for visible page action count to change, we wait until it |
| 126 // reaches this value. | 141 // reaches this value. |
| 127 int target_visible_page_action_count_; | 142 int target_visible_page_action_count_; |
| 128 }; | 143 }; |
| 129 | 144 |
| 130 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_BROWSERTEST_H_ | 145 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_BROWSERTEST_H_ |
| OLD | NEW |