diff options
author | ben@chromium.org <ben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-04-09 19:10:41 +0000 |
---|---|---|
committer | ben@chromium.org <ben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-04-09 19:10:41 +0000 |
commit | 71a742d202c338aff094c0dd62f8b8603130d9cf (patch) | |
tree | 07bc3b247bd9978915083a56502a187f95500676 /chrome/test/ui_test_utils.cc | |
parent | 72eb68c9482f4dcdd397e5744bcb046b514e224c (diff) | |
download | chromium_src-71a742d202c338aff094c0dd62f8b8603130d9cf.zip chromium_src-71a742d202c338aff094c0dd62f8b8603130d9cf.tar.gz chromium_src-71a742d202c338aff094c0dd62f8b8603130d9cf.tar.bz2 |
Scrape search definitions from forms that have onsubmit handlers. The scraping is done after submit events are handled by the page DOM so doing this is safe.
Adds test infrastructure for determining that scraping occurs on submit:
- allow testserver to be configured to serve pages from / on the server
- provide a ui test util that navigates and waits for N subsequent redirections/navigations before returning control to the test to handle automated submission
Eric, please review the test server changes.
Scott, please look over everything else.
Review URL: http://codereview.chromium.org/62145
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@13444 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/test/ui_test_utils.cc')
-rw-r--r-- | chrome/test/ui_test_utils.cc | 31 |
1 files changed, 26 insertions, 5 deletions
diff --git a/chrome/test/ui_test_utils.cc b/chrome/test/ui_test_utils.cc index 47e3ef2..6af1091 100644 --- a/chrome/test/ui_test_utils.cc +++ b/chrome/test/ui_test_utils.cc @@ -20,8 +20,11 @@ namespace { // Used to block until a navigation completes. class NavigationNotificationObserver : public NotificationObserver { public: - explicit NavigationNotificationObserver(NavigationController* controller) - : navigation_started_(false) { + NavigationNotificationObserver(NavigationController* controller, + int number_of_navigations) + : navigation_started_(false), + navigations_completed_(0), + number_of_navigations_(number_of_navigations) { registrar_.Add(this, NotificationType::NAV_ENTRY_COMMITTED, Source<NavigationController>(controller)); registrar_.Add(this, NotificationType::LOAD_START, @@ -38,7 +41,8 @@ class NavigationNotificationObserver : public NotificationObserver { type == NotificationType::LOAD_START) { navigation_started_ = true; } else if (type == NotificationType::LOAD_STOP) { - if (navigation_started_) { + if (navigation_started_ && + ++navigations_completed_ == number_of_navigations_) { navigation_started_ = false; MessageLoopForUI::current()->Quit(); } @@ -51,6 +55,12 @@ class NavigationNotificationObserver : public NotificationObserver { // If true the navigation has started. bool navigation_started_; + // The number of navigations that have been completed. + int navigations_completed_; + + // The number of navigations to wait for. + int number_of_navigations_; + DISALLOW_COPY_AND_ASSIGN(NavigationNotificationObserver); }; @@ -66,15 +76,26 @@ void RunMessageLoop() { } void WaitForNavigation(NavigationController* controller) { - NavigationNotificationObserver observer(controller); + WaitForNavigations(controller, 1); +} + +void WaitForNavigations(NavigationController* controller, + int number_of_navigations) { + NavigationNotificationObserver observer(controller, number_of_navigations); } void NavigateToURL(Browser* browser, const GURL& url) { + NavigateToURLBlockUntilNavigationsComplete(browser, url, 1); +} + +void NavigateToURLBlockUntilNavigationsComplete(Browser* browser, + const GURL& url, + int number_of_navigations) { NavigationController* controller = browser->GetSelectedTabContents()->controller(); browser->OpenURLFromTab(browser->GetSelectedTabContents(), url, GURL(), CURRENT_TAB, PageTransition::TYPED); - WaitForNavigation(controller); + WaitForNavigations(controller, number_of_navigations); } } // namespace ui_test_utils |