| Index: chrome/test/ui_test_utils.cc
|
| diff --git a/chrome/test/ui_test_utils.cc b/chrome/test/ui_test_utils.cc
|
| index 4f65c35c1b18ea7b5eee3c159275a4443c58d6e9..8167968abea45eeb37ca3c9608a5237f9d6f0d71 100644
|
| --- a/chrome/test/ui_test_utils.cc
|
| +++ b/chrome/test/ui_test_utils.cc
|
| @@ -194,6 +194,41 @@ class DownloadsCompleteObserver : public DownloadManager::Observer,
|
| DISALLOW_COPY_AND_ASSIGN(DownloadsCompleteObserver);
|
| };
|
|
|
| +// Used to block until an application modal dialog is shown.
|
| +class AppModalDialogObserver : public NotificationObserver {
|
| + public:
|
| + AppModalDialogObserver() {}
|
| +
|
| + AppModalDialog* WaitForAppModalDialog() {
|
| + registrar_.Add(this, NotificationType::APP_MODAL_DIALOG_SHOWN,
|
| + NotificationService::AllSources());
|
| + dialog_ = NULL;
|
| + ui_test_utils::RunMessageLoop();
|
| + DCHECK(dialog_);
|
| + return dialog_;
|
| + }
|
| +
|
| + virtual void Observe(NotificationType type,
|
| + const NotificationSource& source,
|
| + const NotificationDetails& details) {
|
| + if (type == NotificationType::APP_MODAL_DIALOG_SHOWN) {
|
| + registrar_.Remove(this, NotificationType::APP_MODAL_DIALOG_SHOWN,
|
| + NotificationService::AllSources());
|
| + dialog_ = Source<AppModalDialog>(source).ptr();
|
| + MessageLoopForUI::current()->Quit();
|
| + } else {
|
| + NOTREACHED();
|
| + }
|
| + }
|
| +
|
| + private:
|
| + NotificationRegistrar registrar_;
|
| +
|
| + AppModalDialog* dialog_;
|
| +
|
| + DISALLOW_COPY_AND_ASSIGN(AppModalDialogObserver);
|
| +};
|
| +
|
| } // namespace
|
|
|
| void RunMessageLoop() {
|
| @@ -330,4 +365,9 @@ void WaitForDownloadCount(DownloadManager* download_manager, size_t count) {
|
| DownloadsCompleteObserver download_observer(download_manager, count);
|
| }
|
|
|
| +AppModalDialog* WaitForAppModalDialog() {
|
| + AppModalDialogObserver observer;
|
| + return observer.WaitForAppModalDialog();
|
| +}
|
| +
|
| } // namespace ui_test_utils
|
|
|