| Index: chrome/browser/extensions/extension_apitest.cc
|
| ===================================================================
|
| --- chrome/browser/extensions/extension_apitest.cc (revision 113231)
|
| +++ chrome/browser/extensions/extension_apitest.cc (working copy)
|
| @@ -202,28 +202,29 @@
|
| }
|
| }
|
|
|
| -// Test that exactly one extension loaded.
|
| +// Test that exactly one extension is loaded, and return it.
|
| const Extension* ExtensionApiTest::GetSingleLoadedExtension() {
|
| ExtensionService* service = browser()->profile()->GetExtensionService();
|
|
|
| - int found_extension_index = -1;
|
| - for (size_t i = 0; i < service->extensions()->size(); ++i) {
|
| + const Extension* extension = NULL;
|
| + for (ExtensionSet::const_iterator it = service->extensions()->begin();
|
| + it != service->extensions()->end(); ++it) {
|
| // Ignore any component extensions. They are automatically loaded into all
|
| // profiles and aren't the extension we're looking for here.
|
| - if (service->extensions()->at(i)->location() == Extension::COMPONENT)
|
| + if ((*it)->location() == Extension::COMPONENT)
|
| continue;
|
|
|
| - if (found_extension_index != -1) {
|
| + if (extension != NULL) {
|
| + // TODO(yoz): this is misleading; it counts component extensions.
|
| message_ = base::StringPrintf(
|
| "Expected only one extension to be present. Found %u.",
|
| static_cast<unsigned>(service->extensions()->size()));
|
| return NULL;
|
| }
|
|
|
| - found_extension_index = static_cast<int>(i);
|
| + extension = *it;
|
| }
|
|
|
| - const Extension* extension = service->extensions()->at(found_extension_index);
|
| if (!extension) {
|
| message_ = "extension pointer is NULL.";
|
| return NULL;
|
|
|