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

Side by Side Diff: chrome/test/base/ui_test_utils.cc

Issue 10823029: Move WaitForLoadStop from ui_test_utils to browser_test_utils so that it can be reused in content_b… (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 8 years, 4 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/test/base/ui_test_utils.h ('k') | chrome/test/perf/rendering/throughput_tests.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/test/base/ui_test_utils.h" 5 #include "chrome/test/base/ui_test_utils.h"
6 6
7 #if defined(OS_WIN) 7 #if defined(OS_WIN)
8 #include <windows.h> 8 #include <windows.h>
9 #endif 9 #endif
10 10
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after
205 content::GetQuitTaskForRunLoop(&run_loop)); 205 content::GetQuitTaskForRunLoop(&run_loop));
206 } 206 }
207 207
208 void WaitForNewTab(Browser* browser) { 208 void WaitForNewTab(Browser* browser) {
209 content::WindowedNotificationObserver observer( 209 content::WindowedNotificationObserver observer(
210 chrome::NOTIFICATION_TAB_ADDED, 210 chrome::NOTIFICATION_TAB_ADDED,
211 content::Source<content::WebContentsDelegate>(browser)); 211 content::Source<content::WebContentsDelegate>(browser));
212 observer.Wait(); 212 observer.Wait();
213 } 213 }
214 214
215 void WaitForLoadStop(WebContents* tab) {
216 content::WindowedNotificationObserver load_stop_observer(
217 content::NOTIFICATION_LOAD_STOP,
218 content::Source<NavigationController>(&tab->GetController()));
219 // In many cases, the load may have finished before we get here. Only wait if
220 // the tab still has a pending navigation.
221 if (!tab->IsLoading())
222 return;
223 load_stop_observer.Wait();
224 }
225
226 Browser* WaitForBrowserNotInSet(std::set<Browser*> excluded_browsers) { 215 Browser* WaitForBrowserNotInSet(std::set<Browser*> excluded_browsers) {
227 Browser* new_browser = GetBrowserNotInSet(excluded_browsers); 216 Browser* new_browser = GetBrowserNotInSet(excluded_browsers);
228 if (new_browser == NULL) { 217 if (new_browser == NULL) {
229 BrowserAddedObserver observer; 218 BrowserAddedObserver observer;
230 new_browser = observer.WaitForSingleNewBrowser(); 219 new_browser = observer.WaitForSingleNewBrowser();
231 // The new browser should never be in |excluded_browsers|. 220 // The new browser should never be in |excluded_browsers|.
232 DCHECK(!ContainsKey(excluded_browsers, new_browser)); 221 DCHECK(!ContainsKey(excluded_browsers, new_browser));
233 } 222 }
234 return new_browser; 223 return new_browser;
235 } 224 }
(...skipping 26 matching lines...) Expand all
262 // blocking until the |number_of_navigations| specified complete. 251 // blocking until the |number_of_navigations| specified complete.
263 // |disposition| indicates what tab the download occurs in, and 252 // |disposition| indicates what tab the download occurs in, and
264 // |browser_test_flags| controls what to wait for before continuing. 253 // |browser_test_flags| controls what to wait for before continuing.
265 static void NavigateToURLWithDispositionBlockUntilNavigationsComplete( 254 static void NavigateToURLWithDispositionBlockUntilNavigationsComplete(
266 Browser* browser, 255 Browser* browser,
267 const GURL& url, 256 const GURL& url,
268 int number_of_navigations, 257 int number_of_navigations,
269 WindowOpenDisposition disposition, 258 WindowOpenDisposition disposition,
270 int browser_test_flags) { 259 int browser_test_flags) {
271 if (disposition == CURRENT_TAB && chrome::GetActiveWebContents(browser)) 260 if (disposition == CURRENT_TAB && chrome::GetActiveWebContents(browser))
272 WaitForLoadStop(chrome::GetActiveWebContents(browser)); 261 content::WaitForLoadStop(chrome::GetActiveWebContents(browser));
273 NavigationController* controller = 262 NavigationController* controller =
274 chrome::GetActiveWebContents(browser) ? 263 chrome::GetActiveWebContents(browser) ?
275 &chrome::GetActiveWebContents(browser)->GetController() : NULL; 264 &chrome::GetActiveWebContents(browser)->GetController() : NULL;
276 content::TestNavigationObserver same_tab_observer( 265 content::TestNavigationObserver same_tab_observer(
277 content::Source<NavigationController>(controller), 266 content::Source<NavigationController>(controller),
278 NULL, 267 NULL,
279 number_of_navigations); 268 number_of_navigations);
280 269
281 std::set<Browser*> initial_browsers; 270 std::set<Browser*> initial_browsers;
282 for (std::vector<Browser*>::const_iterator iter = BrowserList::begin(); 271 for (std::vector<Browser*>::const_iterator iter = BrowserList::begin();
(...skipping 434 matching lines...) Expand 10 before | Expand all | Expand 10 after
717 int state, 706 int state,
718 const base::Closure& followup) { 707 const base::Closure& followup) {
719 if (!followup.is_null()) 708 if (!followup.is_null())
720 ui_controls::SendMouseEventsNotifyWhenDone(button, state, followup); 709 ui_controls::SendMouseEventsNotifyWhenDone(button, state, followup);
721 else 710 else
722 ui_controls::SendMouseEvents(button, state); 711 ui_controls::SendMouseEvents(button, state);
723 } 712 }
724 713
725 } // namespace internal 714 } // namespace internal
726 } // namespace ui_test_utils 715 } // namespace ui_test_utils
OLDNEW
« no previous file with comments | « chrome/test/base/ui_test_utils.h ('k') | chrome/test/perf/rendering/throughput_tests.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698