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

Unified Diff: chrome/test/ui_test_utils.cc

Issue 62145: Yet another scrape atttempt (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 11 years, 8 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
« no previous file with comments | « chrome/test/ui_test_utils.h ('k') | chrome/test/unit/unittests.vcproj » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/test/ui_test_utils.cc
===================================================================
--- chrome/test/ui_test_utils.cc (revision 13436)
+++ chrome/test/ui_test_utils.cc (working copy)
@@ -20,8 +20,11 @@
// 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 @@
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 @@
// 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 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
« no previous file with comments | « chrome/test/ui_test_utils.h ('k') | chrome/test/unit/unittests.vcproj » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698