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 #include "chrome/browser/extensions/extension_apitest.h" | 5 #include "chrome/browser/extensions/extension_apitest.h" |
6 | 6 |
7 #include "base/string_util.h" | 7 #include "base/string_util.h" |
8 #include "base/stringprintf.h" | 8 #include "base/stringprintf.h" |
9 #include "chrome/browser/extensions/extension_service.h" | 9 #include "chrome/browser/extensions/extension_service.h" |
10 #include "chrome/browser/extensions/extension_test_api.h" | 10 #include "chrome/browser/extensions/extension_test_api.h" |
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
167 bool enable_incognito = (flags & kFlagEnableIncognito) != 0; | 167 bool enable_incognito = (flags & kFlagEnableIncognito) != 0; |
168 bool enable_fileaccess = (flags & kFlagEnableFileAccess) != 0; | 168 bool enable_fileaccess = (flags & kFlagEnableFileAccess) != 0; |
169 bool load_as_component = (flags & kFlagLoadAsComponent) != 0; | 169 bool load_as_component = (flags & kFlagLoadAsComponent) != 0; |
170 bool launch_platform_app = (flags & kFlagLaunchPlatformApp) != 0; | 170 bool launch_platform_app = (flags & kFlagLaunchPlatformApp) != 0; |
171 bool use_incognito = (flags & kFlagUseIncognito) != 0; | 171 bool use_incognito = (flags & kFlagUseIncognito) != 0; |
172 | 172 |
173 ResultCatcher catcher; | 173 ResultCatcher catcher; |
174 DCHECK(!std::string(extension_name).empty() || !page_url.empty()) << | 174 DCHECK(!std::string(extension_name).empty() || !page_url.empty()) << |
175 "extension_name and page_url cannot both be empty"; | 175 "extension_name and page_url cannot both be empty"; |
176 | 176 |
177 const Extension* extension = NULL; | 177 const extensions::Extension* extension = NULL; |
178 if (!std::string(extension_name).empty()) { | 178 if (!std::string(extension_name).empty()) { |
179 FilePath extension_path = test_data_dir_.AppendASCII(extension_name); | 179 FilePath extension_path = test_data_dir_.AppendASCII(extension_name); |
180 if (load_as_component) { | 180 if (load_as_component) { |
181 extension = LoadExtensionAsComponent(extension_path); | 181 extension = LoadExtensionAsComponent(extension_path); |
182 } else { | 182 } else { |
183 extension = LoadExtensionWithOptions(extension_path, | 183 extension = LoadExtensionWithOptions(extension_path, |
184 enable_incognito, enable_fileaccess); | 184 enable_incognito, enable_fileaccess); |
185 } | 185 } |
186 if (!extension) { | 186 if (!extension) { |
187 message_ = "Failed to load extension."; | 187 message_ = "Failed to load extension."; |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
219 | 219 |
220 if (!catcher.GetNextResult()) { | 220 if (!catcher.GetNextResult()) { |
221 message_ = catcher.message(); | 221 message_ = catcher.message(); |
222 return false; | 222 return false; |
223 } else { | 223 } else { |
224 return true; | 224 return true; |
225 } | 225 } |
226 } | 226 } |
227 | 227 |
228 // Test that exactly one extension is loaded, and return it. | 228 // Test that exactly one extension is loaded, and return it. |
229 const Extension* ExtensionApiTest::GetSingleLoadedExtension() { | 229 const extensions::Extension* ExtensionApiTest::GetSingleLoadedExtension() { |
230 ExtensionService* service = browser()->profile()->GetExtensionService(); | 230 ExtensionService* service = browser()->profile()->GetExtensionService(); |
231 | 231 |
232 const Extension* extension = NULL; | 232 const extensions::Extension* extension = NULL; |
233 for (ExtensionSet::const_iterator it = service->extensions()->begin(); | 233 for (ExtensionSet::const_iterator it = service->extensions()->begin(); |
234 it != service->extensions()->end(); ++it) { | 234 it != service->extensions()->end(); ++it) { |
235 // Ignore any component extensions. They are automatically loaded into all | 235 // Ignore any component extensions. They are automatically loaded into all |
236 // profiles and aren't the extension we're looking for here. | 236 // profiles and aren't the extension we're looking for here. |
237 if ((*it)->location() == Extension::COMPONENT) | 237 if ((*it)->location() == extensions::Extension::COMPONENT) |
238 continue; | 238 continue; |
239 | 239 |
240 if (extension != NULL) { | 240 if (extension != NULL) { |
241 // TODO(yoz): this is misleading; it counts component extensions. | 241 // TODO(yoz): this is misleading; it counts component extensions. |
242 message_ = base::StringPrintf( | 242 message_ = base::StringPrintf( |
243 "Expected only one extension to be present. Found %u.", | 243 "Expected only one extension to be present. Found %u.", |
244 static_cast<unsigned>(service->extensions()->size())); | 244 static_cast<unsigned>(service->extensions()->size())); |
245 return NULL; | 245 return NULL; |
246 } | 246 } |
247 | 247 |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
291 ExtensionApiTest::SetUpCommandLine(command_line); | 291 ExtensionApiTest::SetUpCommandLine(command_line); |
292 | 292 |
293 // If someone is using this class, we're going to insist on management of the | 293 // If someone is using this class, we're going to insist on management of the |
294 // relevant flags. If these flags are already set, die. | 294 // relevant flags. If these flags are already set, die. |
295 DCHECK(!command_line->HasSwitch(switches::kEnablePlatformApps)); | 295 DCHECK(!command_line->HasSwitch(switches::kEnablePlatformApps)); |
296 DCHECK(!command_line->HasSwitch(switches::kEnableExperimentalExtensionApis)); | 296 DCHECK(!command_line->HasSwitch(switches::kEnableExperimentalExtensionApis)); |
297 | 297 |
298 command_line->AppendSwitch(switches::kEnableExperimentalExtensionApis); | 298 command_line->AppendSwitch(switches::kEnableExperimentalExtensionApis); |
299 command_line->AppendSwitch(switches::kEnablePlatformApps); | 299 command_line->AppendSwitch(switches::kEnablePlatformApps); |
300 } | 300 } |
OLD | NEW |