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

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

Issue 12210067: Get rid of native-desktop-only BrowserList:: iterator methods in tests. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: merge up to r181832 Created 7 years, 10 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/in_process_browser_test.cc ('k') | no next file » | 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 18 matching lines...) Expand all
29 #include "chrome/browser/extensions/extension_action.h" 29 #include "chrome/browser/extensions/extension_action.h"
30 #include "chrome/browser/history/history_service_factory.h" 30 #include "chrome/browser/history/history_service_factory.h"
31 #include "chrome/browser/profiles/profile.h" 31 #include "chrome/browser/profiles/profile.h"
32 #include "chrome/browser/search_engines/template_url_service.h" 32 #include "chrome/browser/search_engines/template_url_service.h"
33 #include "chrome/browser/search_engines/template_url_service_test_util.h" 33 #include "chrome/browser/search_engines/template_url_service_test_util.h"
34 #include "chrome/browser/thumbnails/render_widget_snapshot_taker.h" 34 #include "chrome/browser/thumbnails/render_widget_snapshot_taker.h"
35 #include "chrome/browser/ui/app_modal_dialogs/app_modal_dialog.h" 35 #include "chrome/browser/ui/app_modal_dialogs/app_modal_dialog.h"
36 #include "chrome/browser/ui/browser.h" 36 #include "chrome/browser/ui/browser.h"
37 #include "chrome/browser/ui/browser_commands.h" 37 #include "chrome/browser/ui/browser_commands.h"
38 #include "chrome/browser/ui/browser_finder.h" 38 #include "chrome/browser/ui/browser_finder.h"
39 #include "chrome/browser/ui/browser_iterator.h"
39 #include "chrome/browser/ui/browser_list.h" 40 #include "chrome/browser/ui/browser_list.h"
40 #include "chrome/browser/ui/browser_navigator.h" 41 #include "chrome/browser/ui/browser_navigator.h"
41 #include "chrome/browser/ui/browser_window.h" 42 #include "chrome/browser/ui/browser_window.h"
42 #include "chrome/browser/ui/find_bar/find_notification_details.h" 43 #include "chrome/browser/ui/find_bar/find_notification_details.h"
43 #include "chrome/browser/ui/find_bar/find_tab_helper.h" 44 #include "chrome/browser/ui/find_bar/find_tab_helper.h"
44 #include "chrome/browser/ui/host_desktop.h" 45 #include "chrome/browser/ui/host_desktop.h"
45 #include "chrome/browser/ui/omnibox/location_bar.h" 46 #include "chrome/browser/ui/omnibox/location_bar.h"
46 #include "chrome/browser/ui/omnibox/omnibox_view.h" 47 #include "chrome/browser/ui/omnibox/omnibox_view.h"
47 #include "chrome/browser/ui/tabs/tab_strip_model.h" 48 #include "chrome/browser/ui/tabs/tab_strip_model.h"
48 #include "chrome/common/chrome_notification_types.h" 49 #include "chrome/common/chrome_notification_types.h"
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after
253 content::WaitForLoadStop(tab_strip->GetActiveWebContents()); 254 content::WaitForLoadStop(tab_strip->GetActiveWebContents());
254 NavigationController* controller = 255 NavigationController* controller =
255 tab_strip->GetActiveWebContents() ? 256 tab_strip->GetActiveWebContents() ?
256 &tab_strip->GetActiveWebContents()->GetController() : NULL; 257 &tab_strip->GetActiveWebContents()->GetController() : NULL;
257 content::TestNavigationObserver same_tab_observer( 258 content::TestNavigationObserver same_tab_observer(
258 content::Source<NavigationController>(controller), 259 content::Source<NavigationController>(controller),
259 NULL, 260 NULL,
260 number_of_navigations); 261 number_of_navigations);
261 262
262 std::set<Browser*> initial_browsers; 263 std::set<Browser*> initial_browsers;
263 for (std::vector<Browser*>::const_iterator iter = BrowserList::begin(); 264 for (chrome::BrowserIterator it; !it.done(); it.Next())
264 iter != BrowserList::end(); 265 initial_browsers.insert(*it);
265 ++iter) {
266 initial_browsers.insert(*iter);
267 }
268 266
269 content::WindowedNotificationObserver tab_added_observer( 267 content::WindowedNotificationObserver tab_added_observer(
270 chrome::NOTIFICATION_TAB_ADDED, 268 chrome::NOTIFICATION_TAB_ADDED,
271 content::NotificationService::AllSources()); 269 content::NotificationService::AllSources());
272 270
273 browser->OpenURL(OpenURLParams( 271 browser->OpenURL(OpenURLParams(
274 url, Referrer(), disposition, content::PAGE_TRANSITION_TYPED, false)); 272 url, Referrer(), disposition, content::PAGE_TRANSITION_TYPED, false));
275 if (browser_test_flags & BROWSER_TEST_WAIT_FOR_BROWSER) 273 if (browser_test_flags & BROWSER_TEST_WAIT_FOR_BROWSER)
276 browser = WaitForBrowserNotInSet(initial_browsers); 274 browser = WaitForBrowserNotInSet(initial_browsers);
277 if (browser_test_flags & BROWSER_TEST_WAIT_FOR_TAB) 275 if (browser_test_flags & BROWSER_TEST_WAIT_FOR_TAB)
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after
470 location_bar->AcceptInput(); 468 location_bar->AcceptInput();
471 while (!omnibox->model()->autocomplete_controller()->done()) { 469 while (!omnibox->model()->autocomplete_controller()->done()) {
472 content::WindowedNotificationObserver observer( 470 content::WindowedNotificationObserver observer(
473 chrome::NOTIFICATION_AUTOCOMPLETE_CONTROLLER_RESULT_READY, 471 chrome::NOTIFICATION_AUTOCOMPLETE_CONTROLLER_RESULT_READY,
474 content::NotificationService::AllSources()); 472 content::NotificationService::AllSources());
475 observer.Wait(); 473 observer.Wait();
476 } 474 }
477 } 475 }
478 476
479 Browser* GetBrowserNotInSet(std::set<Browser*> excluded_browsers) { 477 Browser* GetBrowserNotInSet(std::set<Browser*> excluded_browsers) {
480 for (BrowserList::const_iterator iter = BrowserList::begin(); 478 for (chrome::BrowserIterator it; !it.done(); it.Next()) {
481 iter != BrowserList::end(); 479 if (excluded_browsers.find(*it) == excluded_browsers.end())
482 ++iter) { 480 return *it;
483 if (excluded_browsers.find(*iter) == excluded_browsers.end())
484 return *iter;
485 } 481 }
486
487 return NULL; 482 return NULL;
488 } 483 }
489 484
490 WindowedTabAddedNotificationObserver::WindowedTabAddedNotificationObserver( 485 WindowedTabAddedNotificationObserver::WindowedTabAddedNotificationObserver(
491 const content::NotificationSource& source) 486 const content::NotificationSource& source)
492 : WindowedNotificationObserver(chrome::NOTIFICATION_TAB_ADDED, source), 487 : WindowedNotificationObserver(chrome::NOTIFICATION_TAB_ADDED, source),
493 added_tab_(NULL) { 488 added_tab_(NULL) {
494 } 489 }
495 490
496 void WindowedTabAddedNotificationObserver::Observe( 491 void WindowedTabAddedNotificationObserver::Observe(
(...skipping 21 matching lines...) Expand all
518 if (controller->GetWebContents()->GetURL() != url_) 513 if (controller->GetWebContents()->GetURL() != url_)
519 return; 514 return;
520 515
521 WindowedNotificationObserver::Observe(type, source, details); 516 WindowedNotificationObserver::Observe(type, source, details);
522 } 517 }
523 518
524 BrowserAddedObserver::BrowserAddedObserver() 519 BrowserAddedObserver::BrowserAddedObserver()
525 : notification_observer_( 520 : notification_observer_(
526 chrome::NOTIFICATION_BROWSER_OPENED, 521 chrome::NOTIFICATION_BROWSER_OPENED,
527 content::NotificationService::AllSources()) { 522 content::NotificationService::AllSources()) {
528 original_browsers_.insert(BrowserList::begin(), BrowserList::end()); 523 for (chrome::BrowserIterator it; !it.done(); it.Next())
524 original_browsers_.insert(*it);
529 } 525 }
530 526
531 BrowserAddedObserver::~BrowserAddedObserver() { 527 BrowserAddedObserver::~BrowserAddedObserver() {
532 } 528 }
533 529
534 Browser* BrowserAddedObserver::WaitForSingleNewBrowser() { 530 Browser* BrowserAddedObserver::WaitForSingleNewBrowser() {
535 notification_observer_.Wait(); 531 notification_observer_.Wait();
536 // Ensure that only a single new browser has appeared. 532 // Ensure that only a single new browser has appeared.
537 EXPECT_EQ(original_browsers_.size() + 1, BrowserList::size()); 533 EXPECT_EQ(original_browsers_.size() + 1, BrowserList::size());
538 return GetBrowserNotInSet(original_browsers_); 534 return GetBrowserNotInSet(original_browsers_);
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
688 void HistoryEnumerator::HistoryQueryComplete( 684 void HistoryEnumerator::HistoryQueryComplete(
689 const base::Closure& quit_task, 685 const base::Closure& quit_task,
690 HistoryService::Handle request_handle, 686 HistoryService::Handle request_handle,
691 history::QueryResults* results) { 687 history::QueryResults* results) {
692 for (size_t i = 0; i < results->size(); ++i) 688 for (size_t i = 0; i < results->size(); ++i)
693 urls_.push_back((*results)[i].url()); 689 urls_.push_back((*results)[i].url());
694 quit_task.Run(); 690 quit_task.Run();
695 } 691 }
696 692
697 } // namespace ui_test_utils 693 } // namespace ui_test_utils
OLDNEW
« no previous file with comments | « chrome/test/base/in_process_browser_test.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698