Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(5015)

Unified Diff: chrome/test/ui_test_utils.cc

Issue 149460: Convert JavascriptAlertActivatesTab to browser_tests framework. (Closed)
Patch Set: kill duplication Created 11 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« chrome/common/notification_type.h ('K') | « chrome/test/ui_test_utils.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
« chrome/common/notification_type.h ('K') | « chrome/test/ui_test_utils.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698