OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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_browsertest.h" | 5 #include "chrome/browser/extensions/extension_browsertest.h" |
6 | 6 |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/file_path.h" | 10 #include "base/file_path.h" |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
65 content::NotificationRegistrar registrar; | 65 content::NotificationRegistrar registrar; |
66 registrar.Add(this, chrome::NOTIFICATION_EXTENSION_LOADED, | 66 registrar.Add(this, chrome::NOTIFICATION_EXTENSION_LOADED, |
67 content::NotificationService::AllSources()); | 67 content::NotificationService::AllSources()); |
68 scoped_refptr<extensions::UnpackedInstaller> installer( | 68 scoped_refptr<extensions::UnpackedInstaller> installer( |
69 extensions::UnpackedInstaller::Create(service)); | 69 extensions::UnpackedInstaller::Create(service)); |
70 installer->set_prompt_for_plugins(false); | 70 installer->set_prompt_for_plugins(false); |
71 installer->Load(path); | 71 installer->Load(path); |
72 ui_test_utils::RunMessageLoop(); | 72 ui_test_utils::RunMessageLoop(); |
73 } | 73 } |
74 | 74 |
75 // Find the extension by iterating backwards since it is likely last. | 75 // Find the loaded extension by its path. See crbug.com/59531 for why |
| 76 // we cannot just use last_loaded_extension_id_. |
76 FilePath extension_path = path; | 77 FilePath extension_path = path; |
77 file_util::AbsolutePath(&extension_path); | 78 file_util::AbsolutePath(&extension_path); |
78 const Extension* extension = NULL; | 79 const Extension* extension = NULL; |
79 for (ExtensionList::const_reverse_iterator iter = | 80 for (ExtensionSet::const_iterator iter = service->extensions()->begin(); |
80 service->extensions()->rbegin(); | 81 iter != service->extensions()->end(); ++iter) { |
81 iter != service->extensions()->rend(); ++iter) { | |
82 if ((*iter)->path() == extension_path) { | 82 if ((*iter)->path() == extension_path) { |
83 extension = *iter; | 83 extension = *iter; |
84 break; | 84 break; |
85 } | 85 } |
86 } | 86 } |
87 if (!extension) | 87 if (!extension) |
88 return NULL; | 88 return NULL; |
89 | 89 |
90 const std::string extension_id = extension->id(); | 90 const std::string extension_id = extension->id(); |
91 | 91 |
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
289 ui_test_utils::RunMessageLoop(); | 289 ui_test_utils::RunMessageLoop(); |
290 } | 290 } |
291 | 291 |
292 size_t num_after = service->extensions()->size(); | 292 size_t num_after = service->extensions()->size(); |
293 EXPECT_EQ(num_before + expected_change, num_after); | 293 EXPECT_EQ(num_before + expected_change, num_after); |
294 if (num_before + expected_change != num_after) { | 294 if (num_before + expected_change != num_after) { |
295 VLOG(1) << "Num extensions before: " << base::IntToString(num_before) | 295 VLOG(1) << "Num extensions before: " << base::IntToString(num_before) |
296 << " num after: " << base::IntToString(num_after) | 296 << " num after: " << base::IntToString(num_after) |
297 << " Installed extensions follow:"; | 297 << " Installed extensions follow:"; |
298 | 298 |
299 for (size_t i = 0; i < service->extensions()->size(); ++i) | 299 for (ExtensionSet::const_iterator it = service->extensions()->begin(); |
300 VLOG(1) << " " << (*service->extensions())[i]->id(); | 300 it != service->extensions()->end(); ++it) |
| 301 VLOG(1) << " " << (*it)->id(); |
301 | 302 |
302 VLOG(1) << "Errors follow:"; | 303 VLOG(1) << "Errors follow:"; |
303 const std::vector<std::string>* errors = | 304 const std::vector<std::string>* errors = |
304 ExtensionErrorReporter::GetInstance()->GetErrors(); | 305 ExtensionErrorReporter::GetInstance()->GetErrors(); |
305 for (std::vector<std::string>::const_iterator iter = errors->begin(); | 306 for (std::vector<std::string>::const_iterator iter = errors->begin(); |
306 iter != errors->end(); ++iter) | 307 iter != errors->end(); ++iter) |
307 VLOG(1) << *iter; | 308 VLOG(1) << *iter; |
308 | 309 |
309 return NULL; | 310 return NULL; |
310 } | 311 } |
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
497 MessageLoopForUI::current()->Quit(); | 498 MessageLoopForUI::current()->Quit(); |
498 } | 499 } |
499 break; | 500 break; |
500 } | 501 } |
501 | 502 |
502 default: | 503 default: |
503 NOTREACHED(); | 504 NOTREACHED(); |
504 break; | 505 break; |
505 } | 506 } |
506 } | 507 } |
OLD | NEW |