| 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 <memory> | 9 #include <memory> |
| 10 | 10 |
| (...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 173 Browser* browser, | 173 Browser* browser, |
| 174 const GURL& url, | 174 const GURL& url, |
| 175 int number_of_navigations, | 175 int number_of_navigations, |
| 176 WindowOpenDisposition disposition, | 176 WindowOpenDisposition disposition, |
| 177 int browser_test_flags) { | 177 int browser_test_flags) { |
| 178 TabStripModel* tab_strip = browser->tab_strip_model(); | 178 TabStripModel* tab_strip = browser->tab_strip_model(); |
| 179 if (disposition == WindowOpenDisposition::CURRENT_TAB && | 179 if (disposition == WindowOpenDisposition::CURRENT_TAB && |
| 180 tab_strip->GetActiveWebContents()) | 180 tab_strip->GetActiveWebContents()) |
| 181 content::WaitForLoadStop(tab_strip->GetActiveWebContents()); | 181 content::WaitForLoadStop(tab_strip->GetActiveWebContents()); |
| 182 content::TestNavigationObserver same_tab_observer( | 182 content::TestNavigationObserver same_tab_observer( |
| 183 tab_strip->GetActiveWebContents(), | 183 tab_strip->GetActiveWebContents(), number_of_navigations, |
| 184 number_of_navigations); | 184 content::MessageLoopRunner::QuitMode::DEFERRED); |
| 185 | 185 |
| 186 std::set<Browser*> initial_browsers; | 186 std::set<Browser*> initial_browsers; |
| 187 for (auto* browser : *BrowserList::GetInstance()) | 187 for (auto* browser : *BrowserList::GetInstance()) |
| 188 initial_browsers.insert(browser); | 188 initial_browsers.insert(browser); |
| 189 | 189 |
| 190 content::WindowedNotificationObserver tab_added_observer( | 190 content::WindowedNotificationObserver tab_added_observer( |
| 191 chrome::NOTIFICATION_TAB_ADDED, | 191 chrome::NOTIFICATION_TAB_ADDED, |
| 192 content::NotificationService::AllSources()); | 192 content::NotificationService::AllSources()); |
| 193 | 193 |
| 194 browser->OpenURL(OpenURLParams( | 194 browser->OpenURL(OpenURLParams( |
| (...skipping 19 matching lines...) Expand all Loading... |
| 214 } else if ((disposition == WindowOpenDisposition::CURRENT_TAB) || | 214 } else if ((disposition == WindowOpenDisposition::CURRENT_TAB) || |
| 215 (disposition == WindowOpenDisposition::NEW_FOREGROUND_TAB) || | 215 (disposition == WindowOpenDisposition::NEW_FOREGROUND_TAB) || |
| 216 (disposition == WindowOpenDisposition::SINGLETON_TAB)) { | 216 (disposition == WindowOpenDisposition::SINGLETON_TAB)) { |
| 217 // The currently selected tab is the right one. | 217 // The currently selected tab is the right one. |
| 218 web_contents = browser->tab_strip_model()->GetActiveWebContents(); | 218 web_contents = browser->tab_strip_model()->GetActiveWebContents(); |
| 219 } | 219 } |
| 220 if (disposition == WindowOpenDisposition::CURRENT_TAB) { | 220 if (disposition == WindowOpenDisposition::CURRENT_TAB) { |
| 221 same_tab_observer.Wait(); | 221 same_tab_observer.Wait(); |
| 222 return; | 222 return; |
| 223 } else if (web_contents) { | 223 } else if (web_contents) { |
| 224 content::TestNavigationObserver observer(web_contents, | 224 content::TestNavigationObserver observer( |
| 225 number_of_navigations); | 225 web_contents, number_of_navigations, |
| 226 content::MessageLoopRunner::QuitMode::DEFERRED); |
| 226 observer.Wait(); | 227 observer.Wait(); |
| 227 return; | 228 return; |
| 228 } | 229 } |
| 229 EXPECT_TRUE(NULL != web_contents) << " Unable to wait for navigation to \"" | 230 EXPECT_TRUE(NULL != web_contents) << " Unable to wait for navigation to \"" |
| 230 << url.spec() << "\"" | 231 << url.spec() << "\"" |
| 231 << " because we can't get the tab contents"; | 232 << " because we can't get the tab contents"; |
| 232 } | 233 } |
| 233 | 234 |
| 234 void NavigateToURLWithDisposition(Browser* browser, | 235 void NavigateToURLWithDisposition(Browser* browser, |
| 235 const GURL& url, | 236 const GURL& url, |
| (...skipping 325 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 561 if (browser != browser_) | 562 if (browser != browser_) |
| 562 return; | 563 return; |
| 563 | 564 |
| 564 observed_ = true; | 565 observed_ = true; |
| 565 BrowserList::RemoveObserver(this); | 566 BrowserList::RemoveObserver(this); |
| 566 if (message_loop_runner_.get() && message_loop_runner_->loop_running()) | 567 if (message_loop_runner_.get() && message_loop_runner_->loop_running()) |
| 567 message_loop_runner_->Quit(); | 568 message_loop_runner_->Quit(); |
| 568 } | 569 } |
| 569 | 570 |
| 570 } // namespace ui_test_utils | 571 } // namespace ui_test_utils |
| OLD | NEW |