| 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 271 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 282 for (std::vector<Browser*>::const_iterator iter = BrowserList::begin(); | 282 for (std::vector<Browser*>::const_iterator iter = BrowserList::begin(); |
| 283 iter != BrowserList::end(); | 283 iter != BrowserList::end(); |
| 284 ++iter) { | 284 ++iter) { |
| 285 initial_browsers.insert(*iter); | 285 initial_browsers.insert(*iter); |
| 286 } | 286 } |
| 287 | 287 |
| 288 content::WindowedNotificationObserver tab_added_observer( | 288 content::WindowedNotificationObserver tab_added_observer( |
| 289 chrome::NOTIFICATION_TAB_ADDED, | 289 chrome::NOTIFICATION_TAB_ADDED, |
| 290 content::NotificationService::AllSources()); | 290 content::NotificationService::AllSources()); |
| 291 | 291 |
| 292 content::WindowedNotificationObserver auth_observer( | |
| 293 chrome::NOTIFICATION_AUTH_NEEDED, | |
| 294 content::NotificationService::AllSources()); | |
| 295 | |
| 296 browser->OpenURL(OpenURLParams( | 292 browser->OpenURL(OpenURLParams( |
| 297 url, Referrer(), disposition, content::PAGE_TRANSITION_TYPED, false)); | 293 url, Referrer(), disposition, content::PAGE_TRANSITION_TYPED, false)); |
| 298 if (browser_test_flags & BROWSER_TEST_WAIT_FOR_BROWSER) | 294 if (browser_test_flags & BROWSER_TEST_WAIT_FOR_BROWSER) |
| 299 browser = WaitForBrowserNotInSet(initial_browsers); | 295 browser = WaitForBrowserNotInSet(initial_browsers); |
| 300 if (browser_test_flags & BROWSER_TEST_WAIT_FOR_TAB) | 296 if (browser_test_flags & BROWSER_TEST_WAIT_FOR_TAB) |
| 301 tab_added_observer.Wait(); | 297 tab_added_observer.Wait(); |
| 302 if (browser_test_flags & BROWSER_TEST_WAIT_FOR_AUTH) | |
| 303 auth_observer.Wait(); | |
| 304 if (!(browser_test_flags & BROWSER_TEST_WAIT_FOR_NAVIGATION)) { | 298 if (!(browser_test_flags & BROWSER_TEST_WAIT_FOR_NAVIGATION)) { |
| 305 // Some other flag caused the wait prior to this. | 299 // Some other flag caused the wait prior to this. |
| 306 return; | 300 return; |
| 307 } | 301 } |
| 308 WebContents* web_contents = NULL; | 302 WebContents* web_contents = NULL; |
| 309 if (disposition == NEW_BACKGROUND_TAB) { | 303 if (disposition == NEW_BACKGROUND_TAB) { |
| 310 // We've opened up a new tab, but not selected it. | 304 // We've opened up a new tab, but not selected it. |
| 311 web_contents = | 305 web_contents = |
| 312 chrome::GetWebContentsAt(browser, browser->active_index() + 1); | 306 chrome::GetWebContentsAt(browser, browser->active_index() + 1); |
| 313 EXPECT_TRUE(web_contents != NULL) | 307 EXPECT_TRUE(web_contents != NULL) |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 362 FilePath GetTestFilePath(const FilePath& dir, const FilePath& file) { | 356 FilePath GetTestFilePath(const FilePath& dir, const FilePath& file) { |
| 363 FilePath path; | 357 FilePath path; |
| 364 PathService::Get(chrome::DIR_TEST_DATA, &path); | 358 PathService::Get(chrome::DIR_TEST_DATA, &path); |
| 365 return path.Append(dir).Append(file); | 359 return path.Append(dir).Append(file); |
| 366 } | 360 } |
| 367 | 361 |
| 368 GURL GetTestUrl(const FilePath& dir, const FilePath& file) { | 362 GURL GetTestUrl(const FilePath& dir, const FilePath& file) { |
| 369 return net::FilePathToFileURL(GetTestFilePath(dir, file)); | 363 return net::FilePathToFileURL(GetTestFilePath(dir, file)); |
| 370 } | 364 } |
| 371 | 365 |
| 372 GURL GetFileUrlWithQuery(const FilePath& path, | |
| 373 const std::string& query_string) { | |
| 374 GURL url = net::FilePathToFileURL(path); | |
| 375 if (!query_string.empty()) { | |
| 376 GURL::Replacements replacements; | |
| 377 replacements.SetQueryStr(query_string); | |
| 378 return url.ReplaceComponents(replacements); | |
| 379 } | |
| 380 return url; | |
| 381 } | |
| 382 | |
| 383 AppModalDialog* WaitForAppModalDialog() { | 366 AppModalDialog* WaitForAppModalDialog() { |
| 384 content::WindowedNotificationObserver observer( | 367 content::WindowedNotificationObserver observer( |
| 385 chrome::NOTIFICATION_APP_MODAL_DIALOG_SHOWN, | 368 chrome::NOTIFICATION_APP_MODAL_DIALOG_SHOWN, |
| 386 content::NotificationService::AllSources()); | 369 content::NotificationService::AllSources()); |
| 387 observer.Wait(); | 370 observer.Wait(); |
| 388 return content::Source<AppModalDialog>(observer.source()).ptr(); | 371 return content::Source<AppModalDialog>(observer.source()).ptr(); |
| 389 } | 372 } |
| 390 | 373 |
| 391 void CrashTab(WebContents* tab) { | 374 void CrashTab(WebContents* tab) { |
| 392 content::RenderProcessHost* rph = tab->GetRenderProcessHost(); | 375 content::RenderProcessHost* rph = tab->GetRenderProcessHost(); |
| (...skipping 341 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 734 int state, | 717 int state, |
| 735 const base::Closure& followup) { | 718 const base::Closure& followup) { |
| 736 if (!followup.is_null()) | 719 if (!followup.is_null()) |
| 737 ui_controls::SendMouseEventsNotifyWhenDone(button, state, followup); | 720 ui_controls::SendMouseEventsNotifyWhenDone(button, state, followup); |
| 738 else | 721 else |
| 739 ui_controls::SendMouseEvents(button, state); | 722 ui_controls::SendMouseEvents(button, state); |
| 740 } | 723 } |
| 741 | 724 |
| 742 } // namespace internal | 725 } // namespace internal |
| 743 } // namespace ui_test_utils | 726 } // namespace ui_test_utils |
| OLD | NEW |