Chromium Code Reviews| 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_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 18 matching lines...) Expand all Loading... | |
| 29 #include "chrome/common/chrome_paths.h" | 29 #include "chrome/common/chrome_paths.h" |
| 30 #include "chrome/common/chrome_switches.h" | 30 #include "chrome/common/chrome_switches.h" |
| 31 #include "chrome/test/base/ui_test_utils.h" | 31 #include "chrome/test/base/ui_test_utils.h" |
| 32 #include "content/public/browser/notification_registrar.h" | 32 #include "content/public/browser/notification_registrar.h" |
| 33 #include "content/public/browser/notification_service.h" | 33 #include "content/public/browser/notification_service.h" |
| 34 | 34 |
| 35 ExtensionBrowserTest::ExtensionBrowserTest() | 35 ExtensionBrowserTest::ExtensionBrowserTest() |
| 36 : loaded_(false), | 36 : loaded_(false), |
| 37 installed_(false), | 37 installed_(false), |
| 38 extension_installs_observed_(0), | 38 extension_installs_observed_(0), |
| 39 extension_load_errors_observed_(0), | |
| 39 target_page_action_count_(-1), | 40 target_page_action_count_(-1), |
| 40 target_visible_page_action_count_(-1) { | 41 target_visible_page_action_count_(-1) { |
| 41 EXPECT_TRUE(temp_dir_.CreateUniqueTempDir()); | 42 EXPECT_TRUE(temp_dir_.CreateUniqueTempDir()); |
| 42 AppShortcutManager::SetShortcutCreationDisabledForTesting(true); | 43 AppShortcutManager::SetShortcutCreationDisabledForTesting(true); |
| 43 } | 44 } |
| 44 | 45 |
| 45 ExtensionBrowserTest::~ExtensionBrowserTest() { | 46 ExtensionBrowserTest::~ExtensionBrowserTest() { |
| 46 AppShortcutManager::SetShortcutCreationDisabledForTesting(false); | 47 AppShortcutManager::SetShortcutCreationDisabledForTesting(false); |
| 47 } | 48 } |
| 48 | 49 |
| (...skipping 369 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 418 content::NotificationService::AllSources()); | 419 content::NotificationService::AllSources()); |
| 419 return extension_installs_observed_ == before; | 420 return extension_installs_observed_ == before; |
| 420 } | 421 } |
| 421 | 422 |
| 422 void ExtensionBrowserTest::WaitForExtensionLoad() { | 423 void ExtensionBrowserTest::WaitForExtensionLoad() { |
| 423 ui_test_utils::RegisterAndWait(this, chrome::NOTIFICATION_EXTENSION_LOADED, | 424 ui_test_utils::RegisterAndWait(this, chrome::NOTIFICATION_EXTENSION_LOADED, |
| 424 content::NotificationService::AllSources()); | 425 content::NotificationService::AllSources()); |
| 425 WaitForExtensionHostsToLoad(); | 426 WaitForExtensionHostsToLoad(); |
| 426 } | 427 } |
| 427 | 428 |
| 429 bool ExtensionBrowserTest::WaitForExtensionLoadError() { | |
| 430 int before = extension_load_errors_observed_; | |
|
jstritar
2012/03/27 15:16:09
Is there a specific reason you need to count the e
miket_OOO
2012/03/28 17:28:47
I'm following the idiom established in the other W
| |
| 431 ui_test_utils::RegisterAndWait(this, | |
| 432 chrome::NOTIFICATION_EXTENSION_LOAD_ERROR, | |
| 433 content::NotificationService::AllSources()); | |
| 434 return extension_load_errors_observed_ != before; | |
| 435 } | |
| 436 | |
| 428 bool ExtensionBrowserTest::WaitForExtensionCrash( | 437 bool ExtensionBrowserTest::WaitForExtensionCrash( |
| 429 const std::string& extension_id) { | 438 const std::string& extension_id) { |
| 430 ExtensionService* service = browser()->profile()->GetExtensionService(); | 439 ExtensionService* service = browser()->profile()->GetExtensionService(); |
| 431 | 440 |
| 432 if (!service->GetExtensionById(extension_id, true)) { | 441 if (!service->GetExtensionById(extension_id, true)) { |
| 433 // The extension is already unloaded, presumably due to a crash. | 442 // The extension is already unloaded, presumably due to a crash. |
| 434 return true; | 443 return true; |
| 435 } | 444 } |
| 436 ui_test_utils::RegisterAndWait( | 445 ui_test_utils::RegisterAndWait( |
| 437 this, chrome::NOTIFICATION_EXTENSION_PROCESS_TERMINATED, | 446 this, chrome::NOTIFICATION_EXTENSION_PROCESS_TERMINATED, |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 478 case chrome::NOTIFICATION_EXTENSION_INSTALL_ERROR: | 487 case chrome::NOTIFICATION_EXTENSION_INSTALL_ERROR: |
| 479 VLOG(1) << "Got EXTENSION_INSTALL_ERROR notification."; | 488 VLOG(1) << "Got EXTENSION_INSTALL_ERROR notification."; |
| 480 MessageLoopForUI::current()->Quit(); | 489 MessageLoopForUI::current()->Quit(); |
| 481 break; | 490 break; |
| 482 | 491 |
| 483 case chrome::NOTIFICATION_EXTENSION_PROCESS_TERMINATED: | 492 case chrome::NOTIFICATION_EXTENSION_PROCESS_TERMINATED: |
| 484 VLOG(1) << "Got EXTENSION_PROCESS_TERMINATED notification."; | 493 VLOG(1) << "Got EXTENSION_PROCESS_TERMINATED notification."; |
| 485 MessageLoopForUI::current()->Quit(); | 494 MessageLoopForUI::current()->Quit(); |
| 486 break; | 495 break; |
| 487 | 496 |
| 497 case chrome::NOTIFICATION_EXTENSION_LOAD_ERROR: | |
| 498 VLOG(1) << "Got EXTENSION_LOAD_ERROR notification."; | |
| 499 ++extension_load_errors_observed_; | |
| 500 MessageLoopForUI::current()->Quit(); | |
| 501 break; | |
| 502 | |
| 488 case chrome::NOTIFICATION_EXTENSION_PAGE_ACTION_COUNT_CHANGED: { | 503 case chrome::NOTIFICATION_EXTENSION_PAGE_ACTION_COUNT_CHANGED: { |
| 489 LocationBarTesting* location_bar = | 504 LocationBarTesting* location_bar = |
| 490 browser()->window()->GetLocationBar()->GetLocationBarForTesting(); | 505 browser()->window()->GetLocationBar()->GetLocationBarForTesting(); |
| 491 VLOG(1) << "Got EXTENSION_PAGE_ACTION_COUNT_CHANGED notification. Number " | 506 VLOG(1) << "Got EXTENSION_PAGE_ACTION_COUNT_CHANGED notification. Number " |
| 492 "of page actions: " << location_bar->PageActionCount(); | 507 "of page actions: " << location_bar->PageActionCount(); |
| 493 if (location_bar->PageActionCount() == | 508 if (location_bar->PageActionCount() == |
| 494 target_page_action_count_) { | 509 target_page_action_count_) { |
| 495 target_page_action_count_ = -1; | 510 target_page_action_count_ = -1; |
| 496 MessageLoopForUI::current()->Quit(); | 511 MessageLoopForUI::current()->Quit(); |
| 497 } | 512 } |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 510 MessageLoopForUI::current()->Quit(); | 525 MessageLoopForUI::current()->Quit(); |
| 511 } | 526 } |
| 512 break; | 527 break; |
| 513 } | 528 } |
| 514 | 529 |
| 515 default: | 530 default: |
| 516 NOTREACHED(); | 531 NOTREACHED(); |
| 517 break; | 532 break; |
| 518 } | 533 } |
| 519 } | 534 } |
| OLD | NEW |