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

Unified Diff: chrome/test/ui_test_utils.cc

Issue 6662001: ui_test_utils::NavigateToURLBlockUntilNavigationsComplete can be raced (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 9 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 | « no previous file | 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 c66f12c1c1d6e182e259414c6f2709b23bf8bcba..3663309fa3c3cc697fe3261754fc737a72b401a9 100644
--- a/chrome/test/ui_test_utils.cc
+++ b/chrome/test/ui_test_utils.cc
@@ -68,6 +68,9 @@ class NavigationNotificationObserver : public NotificationObserver {
Source<NavigationController>(controller));
registrar_.Add(this, NotificationType::LOAD_STOP,
Source<NavigationController>(controller));
+ }
+
+ void Run() {
RunMessageLoop();
}
@@ -412,6 +415,7 @@ void WaitForNavigation(NavigationController* controller) {
void WaitForNavigations(NavigationController* controller,
int number_of_navigations) {
NavigationNotificationObserver observer(controller, number_of_navigations);
+ observer.Run();
}
void WaitForNewTab(Browser* browser) {
@@ -472,6 +476,10 @@ static void NavigateToURLWithDispositionBlockUntilNavigationsComplete(
int number_of_navigations,
WindowOpenDisposition disposition,
int browser_test_flags) {
+ NavigationNotificationObserver
+ same_tab_observer(&browser->GetSelectedTabContents()->controller(),
+ number_of_navigations);
+
std::set<Browser*> initial_browsers;
for (std::vector<Browser*>::const_iterator iter = BrowserList::begin();
iter != BrowserList::end();
@@ -501,7 +509,10 @@ static void NavigateToURLWithDispositionBlockUntilNavigationsComplete(
// The currently selected tab is the right one.
tab_contents = browser->GetSelectedTabContents();
}
- if (tab_contents) {
+ if (disposition == CURRENT_TAB) {
+ same_tab_observer.Run();
+ return;
+ } else if (tab_contents) {
NavigationController* controller = &tab_contents->controller();
WaitForNavigations(controller, number_of_navigations);
return;
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698