| Index: chrome/browser/extensions/extension_browsertest.cc
|
| diff --git a/chrome/browser/extensions/extension_browsertest.cc b/chrome/browser/extensions/extension_browsertest.cc
|
| index 7ef3239356530a0819df270ee5ec79648a0efa09..9ab0cc07d86e22e8a37e800fe8d138339a41e05f 100644
|
| --- a/chrome/browser/extensions/extension_browsertest.cc
|
| +++ b/chrome/browser/extensions/extension_browsertest.cc
|
| @@ -42,14 +42,15 @@ void ExtensionBrowserTest::SetUpCommandLine(CommandLine* command_line) {
|
| bool ExtensionBrowserTest::LoadExtension(const FilePath& path) {
|
| ExtensionsService* service = browser()->profile()->GetExtensionsService();
|
| size_t num_before = service->extensions()->size();
|
| - registrar_.Add(this, NotificationType::EXTENSIONS_LOADED,
|
| - NotificationService::AllSources());
|
| - service->LoadExtension(path);
|
| - MessageLoop::current()->PostDelayedTask(FROM_HERE, new MessageLoop::QuitTask,
|
| - kTimeoutMs);
|
| - ui_test_utils::RunMessageLoop();
|
| - registrar_.Remove(this, NotificationType::EXTENSIONS_LOADED,
|
| - NotificationService::AllSources());
|
| + {
|
| + NotificationRegistrar registrar;
|
| + registrar.Add(this, NotificationType::EXTENSIONS_LOADED,
|
| + NotificationService::AllSources());
|
| + service->LoadExtension(path);
|
| + MessageLoop::current()->PostDelayedTask(
|
| + FROM_HERE, new MessageLoop::QuitTask, kTimeoutMs);
|
| + ui_test_utils::RunMessageLoop();
|
| + }
|
| size_t num_after = service->extensions()->size();
|
| if (num_after != (num_before + 1))
|
| return false;
|
| @@ -57,21 +58,26 @@ bool ExtensionBrowserTest::LoadExtension(const FilePath& path) {
|
| return WaitForExtensionHostsToLoad();
|
| }
|
|
|
| -bool ExtensionBrowserTest::InstallExtension(const FilePath& path) {
|
| +bool ExtensionBrowserTest::InstallExtension(const FilePath& path,
|
| + int expected_change) {
|
| ExtensionsService* service = browser()->profile()->GetExtensionsService();
|
| service->set_show_extensions_prompts(false);
|
| size_t num_before = service->extensions()->size();
|
|
|
| - registrar_.Add(this, NotificationType::EXTENSIONS_LOADED,
|
| - NotificationService::AllSources());
|
| - service->InstallExtension(path);
|
| - MessageLoop::current()->PostDelayedTask(FROM_HERE, new MessageLoop::QuitTask,
|
| - kTimeoutMs);
|
| - ui_test_utils::RunMessageLoop();
|
| - registrar_.Remove(this, NotificationType::EXTENSIONS_LOADED,
|
| - NotificationService::AllSources());
|
| + {
|
| + NotificationRegistrar registrar;
|
| + registrar.Add(this, NotificationType::EXTENSIONS_LOADED,
|
| + NotificationService::AllSources());
|
| + registrar.Add(this, NotificationType::EXTENSION_LOAD_DISABLED,
|
| + NotificationService::AllSources());
|
| + service->InstallExtension(path);
|
| + MessageLoop::current()->PostDelayedTask(
|
| + FROM_HERE, new MessageLoop::QuitTask, kTimeoutMs);
|
| + ui_test_utils::RunMessageLoop();
|
| + }
|
| +
|
| size_t num_after = service->extensions()->size();
|
| - if (num_after != (num_before + 1)) {
|
| + if (num_after != (num_before + expected_change)) {
|
| std::cout << "Num extensions before: " << IntToString(num_before) << " "
|
| << "num after: " << IntToString(num_after) << " "
|
| << "Installed extensions follow:\n";
|
| @@ -147,14 +153,19 @@ bool ExtensionBrowserTest::WaitForExtensionHostsToLoad() {
|
| }
|
|
|
| void ExtensionBrowserTest::Observe(NotificationType type,
|
| - const NotificationSource& source,
|
| - const NotificationDetails& details) {
|
| + const NotificationSource& source,
|
| + const NotificationDetails& details) {
|
| switch (type.value) {
|
| case NotificationType::EXTENSIONS_LOADED:
|
| std::cout << "Got EXTENSION_LOADED notification.\n";
|
| MessageLoopForUI::current()->Quit();
|
| break;
|
|
|
| + case NotificationType::EXTENSION_LOAD_DISABLED:
|
| + std::cout << "Got EXTENSIONS_DISABLED_LOAD notification.\n";
|
| + MessageLoopForUI::current()->Quit();
|
| + break;
|
| +
|
| default:
|
| NOTREACHED();
|
| break;
|
|
|