diff options
author | phajdan.jr@chromium.org <phajdan.jr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-07-10 19:33:18 +0000 |
---|---|---|
committer | phajdan.jr@chromium.org <phajdan.jr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-07-10 19:33:18 +0000 |
commit | a1d5396ed9f2101d021031675eab55aafb3a2894 (patch) | |
tree | 256d3e518348bbc962075591a9922720422f3dd8 /chrome/test/ui_test_utils.cc | |
parent | 7a2a9ce8a5fd79c2fbb5bf3db7a7d58bbd73ce80 (diff) | |
download | chromium_src-a1d5396ed9f2101d021031675eab55aafb3a2894.zip chromium_src-a1d5396ed9f2101d021031675eab55aafb3a2894.tar.gz chromium_src-a1d5396ed9f2101d021031675eab55aafb3a2894.tar.bz2 |
Convert JavascriptAlertActivatesTab to browser_tests framework.
This should make it non-flaky, so I un-disabled the test. I also added necessary plumbing so we can
wait for AppModalDialog to appear and close it.
TEST=Covered by browser_tests.
http://crbug.com/16062
Review URL: http://codereview.chromium.org/149460
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@20400 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/test/ui_test_utils.cc')
-rw-r--r-- | chrome/test/ui_test_utils.cc | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/chrome/test/ui_test_utils.cc b/chrome/test/ui_test_utils.cc index 4f65c35..8167968 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 |