| OLD | NEW |
| 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 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 #include "base/test/test_timeouts.h" | 22 #include "base/test/test_timeouts.h" |
| 23 #include "base/time/time.h" | 23 #include "base/time/time.h" |
| 24 #include "build/build_config.h" | 24 #include "build/build_config.h" |
| 25 #include "chrome/browser/bookmarks/bookmark_model_factory.h" | 25 #include "chrome/browser/bookmarks/bookmark_model_factory.h" |
| 26 #include "chrome/browser/chrome_notification_types.h" | 26 #include "chrome/browser/chrome_notification_types.h" |
| 27 #include "chrome/browser/history/history_service_factory.h" | 27 #include "chrome/browser/history/history_service_factory.h" |
| 28 #include "chrome/browser/profiles/profile.h" | 28 #include "chrome/browser/profiles/profile.h" |
| 29 #include "chrome/browser/ui/browser.h" | 29 #include "chrome/browser/ui/browser.h" |
| 30 #include "chrome/browser/ui/browser_commands.h" | 30 #include "chrome/browser/ui/browser_commands.h" |
| 31 #include "chrome/browser/ui/browser_finder.h" | 31 #include "chrome/browser/ui/browser_finder.h" |
| 32 #include "chrome/browser/ui/browser_iterator.h" | |
| 33 #include "chrome/browser/ui/browser_list.h" | 32 #include "chrome/browser/ui/browser_list.h" |
| 34 #include "chrome/browser/ui/browser_navigator.h" | 33 #include "chrome/browser/ui/browser_navigator.h" |
| 35 #include "chrome/browser/ui/browser_navigator_params.h" | 34 #include "chrome/browser/ui/browser_navigator_params.h" |
| 36 #include "chrome/browser/ui/browser_window.h" | 35 #include "chrome/browser/ui/browser_window.h" |
| 37 #include "chrome/browser/ui/find_bar/find_notification_details.h" | 36 #include "chrome/browser/ui/find_bar/find_notification_details.h" |
| 38 #include "chrome/browser/ui/find_bar/find_tab_helper.h" | 37 #include "chrome/browser/ui/find_bar/find_tab_helper.h" |
| 39 #include "chrome/browser/ui/host_desktop.h" | 38 #include "chrome/browser/ui/host_desktop.h" |
| 40 #include "chrome/browser/ui/location_bar/location_bar.h" | 39 #include "chrome/browser/ui/location_bar/location_bar.h" |
| 41 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 40 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
| 42 #include "chrome/common/chrome_paths.h" | 41 #include "chrome/common/chrome_paths.h" |
| (...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 171 WindowOpenDisposition disposition, | 170 WindowOpenDisposition disposition, |
| 172 int browser_test_flags) { | 171 int browser_test_flags) { |
| 173 TabStripModel* tab_strip = browser->tab_strip_model(); | 172 TabStripModel* tab_strip = browser->tab_strip_model(); |
| 174 if (disposition == CURRENT_TAB && tab_strip->GetActiveWebContents()) | 173 if (disposition == CURRENT_TAB && tab_strip->GetActiveWebContents()) |
| 175 content::WaitForLoadStop(tab_strip->GetActiveWebContents()); | 174 content::WaitForLoadStop(tab_strip->GetActiveWebContents()); |
| 176 content::TestNavigationObserver same_tab_observer( | 175 content::TestNavigationObserver same_tab_observer( |
| 177 tab_strip->GetActiveWebContents(), | 176 tab_strip->GetActiveWebContents(), |
| 178 number_of_navigations); | 177 number_of_navigations); |
| 179 | 178 |
| 180 std::set<Browser*> initial_browsers; | 179 std::set<Browser*> initial_browsers; |
| 181 for (chrome::BrowserIterator it; !it.done(); it.Next()) | 180 for (auto& browser : *BrowserList::GetInstance()) |
| 182 initial_browsers.insert(*it); | 181 initial_browsers.insert(browser); |
| 183 | 182 |
| 184 content::WindowedNotificationObserver tab_added_observer( | 183 content::WindowedNotificationObserver tab_added_observer( |
| 185 chrome::NOTIFICATION_TAB_ADDED, | 184 chrome::NOTIFICATION_TAB_ADDED, |
| 186 content::NotificationService::AllSources()); | 185 content::NotificationService::AllSources()); |
| 187 | 186 |
| 188 browser->OpenURL(OpenURLParams( | 187 browser->OpenURL(OpenURLParams( |
| 189 url, Referrer(), disposition, ui::PAGE_TRANSITION_TYPED, false)); | 188 url, Referrer(), disposition, ui::PAGE_TRANSITION_TYPED, false)); |
| 190 if (browser_test_flags & BROWSER_TEST_WAIT_FOR_BROWSER) | 189 if (browser_test_flags & BROWSER_TEST_WAIT_FOR_BROWSER) |
| 191 browser = WaitForBrowserNotInSet(initial_browsers); | 190 browser = WaitForBrowserNotInSet(initial_browsers); |
| 192 if (browser_test_flags & BROWSER_TEST_WAIT_FOR_TAB) | 191 if (browser_test_flags & BROWSER_TEST_WAIT_FOR_TAB) |
| (...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 353 location_bar->AcceptInput(); | 352 location_bar->AcceptInput(); |
| 354 while (!omnibox->model()->autocomplete_controller()->done()) { | 353 while (!omnibox->model()->autocomplete_controller()->done()) { |
| 355 content::WindowedNotificationObserver observer( | 354 content::WindowedNotificationObserver observer( |
| 356 chrome::NOTIFICATION_AUTOCOMPLETE_CONTROLLER_RESULT_READY, | 355 chrome::NOTIFICATION_AUTOCOMPLETE_CONTROLLER_RESULT_READY, |
| 357 content::NotificationService::AllSources()); | 356 content::NotificationService::AllSources()); |
| 358 observer.Wait(); | 357 observer.Wait(); |
| 359 } | 358 } |
| 360 } | 359 } |
| 361 | 360 |
| 362 Browser* GetBrowserNotInSet(const std::set<Browser*>& excluded_browsers) { | 361 Browser* GetBrowserNotInSet(const std::set<Browser*>& excluded_browsers) { |
| 363 for (chrome::BrowserIterator it; !it.done(); it.Next()) { | 362 for (auto& browser : *BrowserList::GetInstance()) { |
| 364 if (excluded_browsers.find(*it) == excluded_browsers.end()) | 363 if (excluded_browsers.find(browser) == excluded_browsers.end()) |
| 365 return *it; | 364 return browser; |
| 366 } | 365 } |
| 367 return nullptr; | 366 return nullptr; |
| 368 } | 367 } |
| 369 | 368 |
| 370 namespace { | 369 namespace { |
| 371 | 370 |
| 372 void GetCookiesCallback(base::WaitableEvent* event, | 371 void GetCookiesCallback(base::WaitableEvent* event, |
| 373 std::string* cookies, | 372 std::string* cookies, |
| 374 const std::string& cookie_line) { | 373 const std::string& cookie_line) { |
| 375 *cookies = cookie_line; | 374 *cookies = cookie_line; |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 440 if (controller->GetWebContents()->GetURL() != url_) | 439 if (controller->GetWebContents()->GetURL() != url_) |
| 441 return; | 440 return; |
| 442 | 441 |
| 443 WindowedNotificationObserver::Observe(type, source, details); | 442 WindowedNotificationObserver::Observe(type, source, details); |
| 444 } | 443 } |
| 445 | 444 |
| 446 BrowserAddedObserver::BrowserAddedObserver() | 445 BrowserAddedObserver::BrowserAddedObserver() |
| 447 : notification_observer_( | 446 : notification_observer_( |
| 448 chrome::NOTIFICATION_BROWSER_OPENED, | 447 chrome::NOTIFICATION_BROWSER_OPENED, |
| 449 content::NotificationService::AllSources()) { | 448 content::NotificationService::AllSources()) { |
| 450 for (chrome::BrowserIterator it; !it.done(); it.Next()) | 449 for (auto& browser : *BrowserList::GetInstance()) |
| 451 original_browsers_.insert(*it); | 450 original_browsers_.insert(browser); |
| 452 } | 451 } |
| 453 | 452 |
| 454 BrowserAddedObserver::~BrowserAddedObserver() { | 453 BrowserAddedObserver::~BrowserAddedObserver() { |
| 455 } | 454 } |
| 456 | 455 |
| 457 Browser* BrowserAddedObserver::WaitForSingleNewBrowser() { | 456 Browser* BrowserAddedObserver::WaitForSingleNewBrowser() { |
| 458 notification_observer_.Wait(); | 457 notification_observer_.Wait(); |
| 459 // Ensure that only a single new browser has appeared. | 458 // Ensure that only a single new browser has appeared. |
| 460 EXPECT_EQ(original_browsers_.size() + 1, chrome::GetTotalBrowserCount()); | 459 EXPECT_EQ(original_browsers_.size() + 1, chrome::GetTotalBrowserCount()); |
| 461 return GetBrowserNotInSet(original_browsers_); | 460 return GetBrowserNotInSet(original_browsers_); |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 530 new content::MessageLoopRunner; | 529 new content::MessageLoopRunner; |
| 531 WaitHistoryLoadedObserver observer(runner.get()); | 530 WaitHistoryLoadedObserver observer(runner.get()); |
| 532 ScopedObserver<history::HistoryService, history::HistoryServiceObserver> | 531 ScopedObserver<history::HistoryService, history::HistoryServiceObserver> |
| 533 scoped_observer(&observer); | 532 scoped_observer(&observer); |
| 534 scoped_observer.Add(history_service); | 533 scoped_observer.Add(history_service); |
| 535 runner->Run(); | 534 runner->Run(); |
| 536 } | 535 } |
| 537 } | 536 } |
| 538 | 537 |
| 539 } // namespace ui_test_utils | 538 } // namespace ui_test_utils |
| OLD | NEW |