| 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 #if defined(OS_WIN) | 7 #if defined(OS_WIN) |
| 8 #include <windows.h> | 8 #include <windows.h> |
| 9 #endif | 9 #endif |
| 10 | 10 |
| (...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 186 NavigationEntry* last_entry = web_contents->GetController().GetActiveEntry(); | 186 NavigationEntry* last_entry = web_contents->GetController().GetActiveEntry(); |
| 187 if (!last_entry) | 187 if (!last_entry) |
| 188 return false; | 188 return false; |
| 189 title->assign(last_entry->GetTitleForDisplay("")); | 189 title->assign(last_entry->GetTitleForDisplay("")); |
| 190 return true; | 190 return true; |
| 191 } | 191 } |
| 192 | 192 |
| 193 void WaitForNavigations(NavigationController* controller, | 193 void WaitForNavigations(NavigationController* controller, |
| 194 int number_of_navigations) { | 194 int number_of_navigations) { |
| 195 content::TestNavigationObserver observer( | 195 content::TestNavigationObserver observer( |
| 196 content::Source<NavigationController>(controller), NULL, | 196 content::Source<NavigationController>(controller), |
| 197 number_of_navigations); | 197 number_of_navigations); |
| 198 base::RunLoop run_loop; | 198 base::RunLoop run_loop; |
| 199 observer.WaitForObservation( | 199 observer.WaitForObservation( |
| 200 base::Bind(&content::RunThisRunLoop, base::Unretained(&run_loop)), | 200 base::Bind(&content::RunThisRunLoop, base::Unretained(&run_loop)), |
| 201 content::GetQuitTaskForRunLoop(&run_loop)); | 201 content::GetQuitTaskForRunLoop(&run_loop)); |
| 202 } | 202 } |
| 203 | 203 |
| 204 Browser* WaitForBrowserNotInSet(std::set<Browser*> excluded_browsers) { | 204 Browser* WaitForBrowserNotInSet(std::set<Browser*> excluded_browsers) { |
| 205 Browser* new_browser = GetBrowserNotInSet(excluded_browsers); | 205 Browser* new_browser = GetBrowserNotInSet(excluded_browsers); |
| 206 if (new_browser == NULL) { | 206 if (new_browser == NULL) { |
| (...skipping 12 matching lines...) Expand all Loading... |
| 219 false, | 219 false, |
| 220 chrome::HOST_DESKTOP_TYPE_NATIVE); | 220 chrome::HOST_DESKTOP_TYPE_NATIVE); |
| 221 WaitForNavigations( | 221 WaitForNavigations( |
| 222 &browser->tab_strip_model()->GetActiveWebContents()->GetController(), | 222 &browser->tab_strip_model()->GetActiveWebContents()->GetController(), |
| 223 1); | 223 1); |
| 224 return browser; | 224 return browser; |
| 225 } | 225 } |
| 226 | 226 |
| 227 void NavigateToURL(chrome::NavigateParams* params) { | 227 void NavigateToURL(chrome::NavigateParams* params) { |
| 228 content::TestNavigationObserver observer( | 228 content::TestNavigationObserver observer( |
| 229 content::NotificationService::AllSources(), NULL, 1); | 229 content::NotificationService::AllSources(), 1); |
| 230 chrome::Navigate(params); | 230 chrome::Navigate(params); |
| 231 base::RunLoop run_loop; | 231 base::RunLoop run_loop; |
| 232 observer.WaitForObservation( | 232 observer.WaitForObservation( |
| 233 base::Bind(&content::RunThisRunLoop, base::Unretained(&run_loop)), | 233 base::Bind(&content::RunThisRunLoop, base::Unretained(&run_loop)), |
| 234 content::GetQuitTaskForRunLoop(&run_loop)); | 234 content::GetQuitTaskForRunLoop(&run_loop)); |
| 235 } | 235 } |
| 236 | 236 |
| 237 void NavigateToURL(Browser* browser, const GURL& url) { | 237 void NavigateToURL(Browser* browser, const GURL& url) { |
| 238 NavigateToURLWithDisposition(browser, url, CURRENT_TAB, | 238 NavigateToURLWithDisposition(browser, url, CURRENT_TAB, |
| 239 BROWSER_TEST_WAIT_FOR_NAVIGATION); | 239 BROWSER_TEST_WAIT_FOR_NAVIGATION); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 250 WindowOpenDisposition disposition, | 250 WindowOpenDisposition disposition, |
| 251 int browser_test_flags) { | 251 int browser_test_flags) { |
| 252 TabStripModel* tab_strip = browser->tab_strip_model(); | 252 TabStripModel* tab_strip = browser->tab_strip_model(); |
| 253 if (disposition == CURRENT_TAB && tab_strip->GetActiveWebContents()) | 253 if (disposition == CURRENT_TAB && tab_strip->GetActiveWebContents()) |
| 254 content::WaitForLoadStop(tab_strip->GetActiveWebContents()); | 254 content::WaitForLoadStop(tab_strip->GetActiveWebContents()); |
| 255 NavigationController* controller = | 255 NavigationController* controller = |
| 256 tab_strip->GetActiveWebContents() ? | 256 tab_strip->GetActiveWebContents() ? |
| 257 &tab_strip->GetActiveWebContents()->GetController() : NULL; | 257 &tab_strip->GetActiveWebContents()->GetController() : NULL; |
| 258 content::TestNavigationObserver same_tab_observer( | 258 content::TestNavigationObserver same_tab_observer( |
| 259 content::Source<NavigationController>(controller), | 259 content::Source<NavigationController>(controller), |
| 260 NULL, | |
| 261 number_of_navigations); | 260 number_of_navigations); |
| 262 | 261 |
| 263 std::set<Browser*> initial_browsers; | 262 std::set<Browser*> initial_browsers; |
| 264 for (chrome::BrowserIterator it; !it.done(); it.Next()) | 263 for (chrome::BrowserIterator it; !it.done(); it.Next()) |
| 265 initial_browsers.insert(*it); | 264 initial_browsers.insert(*it); |
| 266 | 265 |
| 267 content::WindowedNotificationObserver tab_added_observer( | 266 content::WindowedNotificationObserver tab_added_observer( |
| 268 chrome::NOTIFICATION_TAB_ADDED, | 267 chrome::NOTIFICATION_TAB_ADDED, |
| 269 content::NotificationService::AllSources()); | 268 content::NotificationService::AllSources()); |
| 270 | 269 |
| (...skipping 413 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 684 void HistoryEnumerator::HistoryQueryComplete( | 683 void HistoryEnumerator::HistoryQueryComplete( |
| 685 const base::Closure& quit_task, | 684 const base::Closure& quit_task, |
| 686 HistoryService::Handle request_handle, | 685 HistoryService::Handle request_handle, |
| 687 history::QueryResults* results) { | 686 history::QueryResults* results) { |
| 688 for (size_t i = 0; i < results->size(); ++i) | 687 for (size_t i = 0; i < results->size(); ++i) |
| 689 urls_.push_back((*results)[i].url()); | 688 urls_.push_back((*results)[i].url()); |
| 690 quit_task.Run(); | 689 quit_task.Run(); |
| 691 } | 690 } |
| 692 | 691 |
| 693 } // namespace ui_test_utils | 692 } // namespace ui_test_utils |
| OLD | NEW |