Chromium Code Reviews| 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/in_process_browser_test.h" | 5 #include "chrome/test/base/in_process_browser_test.h" |
| 6 | 6 |
| 7 #include "base/auto_reset.h" | 7 #include "base/auto_reset.h" |
| 8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| 11 #include "base/files/file_path.h" | 11 #include "base/files/file_path.h" |
| 12 #include "base/files/file_util.h" | 12 #include "base/files/file_util.h" |
| 13 #include "base/lazy_instance.h" | 13 #include "base/lazy_instance.h" |
| 14 #include "base/location.h" | 14 #include "base/location.h" |
| 15 #include "base/path_service.h" | 15 #include "base/path_service.h" |
| 16 #include "base/single_thread_task_runner.h" | 16 #include "base/single_thread_task_runner.h" |
| 17 #include "base/strings/string_number_conversions.h" | 17 #include "base/strings/string_number_conversions.h" |
| 18 #include "base/test/test_file_util.h" | 18 #include "base/test/test_file_util.h" |
| 19 #include "base/thread_task_runner_handle.h" | 19 #include "base/thread_task_runner_handle.h" |
| 20 #include "base/threading/non_thread_safe.h" | 20 #include "base/threading/non_thread_safe.h" |
| 21 #include "chrome/browser/browser_process.h" | 21 #include "chrome/browser/browser_process.h" |
| 22 #include "chrome/browser/chrome_notification_types.h" | |
| 22 #include "chrome/browser/lifetime/application_lifetime.h" | 23 #include "chrome/browser/lifetime/application_lifetime.h" |
| 23 #include "chrome/browser/net/net_error_tab_helper.h" | 24 #include "chrome/browser/net/net_error_tab_helper.h" |
| 24 #include "chrome/browser/profiles/profile.h" | 25 #include "chrome/browser/profiles/profile.h" |
| 25 #include "chrome/browser/profiles/profile_manager.h" | 26 #include "chrome/browser/profiles/profile_manager.h" |
| 26 #include "chrome/browser/ui/browser.h" | 27 #include "chrome/browser/ui/browser.h" |
| 27 #include "chrome/browser/ui/browser_finder.h" | 28 #include "chrome/browser/ui/browser_finder.h" |
| 28 #include "chrome/browser/ui/browser_list.h" | 29 #include "chrome/browser/ui/browser_list.h" |
| 29 #include "chrome/browser/ui/browser_list_observer.h" | 30 #include "chrome/browser/ui/browser_list_observer.h" |
| 30 #include "chrome/browser/ui/browser_navigator.h" | 31 #include "chrome/browser/ui/browser_navigator.h" |
| 31 #include "chrome/browser/ui/browser_tabstrip.h" | 32 #include "chrome/browser/ui/browser_tabstrip.h" |
| (...skipping 338 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 370 } | 371 } |
| 371 | 372 |
| 372 void InProcessBrowserTest::TearDown() { | 373 void InProcessBrowserTest::TearDown() { |
| 373 DCHECK(!g_browser_process); | 374 DCHECK(!g_browser_process); |
| 374 #if defined(OS_WIN) | 375 #if defined(OS_WIN) |
| 375 com_initializer_.reset(); | 376 com_initializer_.reset(); |
| 376 #endif | 377 #endif |
| 377 BrowserTestBase::TearDown(); | 378 BrowserTestBase::TearDown(); |
| 378 } | 379 } |
| 379 | 380 |
| 381 void InProcessBrowserTest::CloseBrowserSynchronously(Browser* browser) { | |
| 382 content::WindowedNotificationObserver observer( | |
| 383 chrome::NOTIFICATION_BROWSER_CLOSED, | |
| 384 content::NotificationService::AllSources()); | |
|
Robert Sesek
2015/07/08 22:19:36
May want to limit this to just the |browser| Sourc
| |
| 385 browser->window()->Close(); | |
| 386 #if defined(OS_MACOSX) | |
| 387 // BrowserWindowController depends on the auto release pool being recycled | |
| 388 // in the message loop to delete itself, which frees the Browser object | |
| 389 // which fires this event. | |
| 390 AutoreleasePool()->Recycle(); | |
| 391 #endif | |
| 392 observer.Wait(); | |
| 393 } | |
| 394 | |
| 395 void InProcessBrowserTest::CloseAllBrowsers() { | |
| 396 chrome::CloseAllBrowsers(); | |
| 397 #if defined(OS_MACOSX) | |
| 398 // BrowserWindowController depends on the auto release pool being recycled | |
| 399 // in the message loop to delete itself, which frees the Browser object | |
| 400 // which fires this event. | |
| 401 AutoreleasePool()->Recycle(); | |
| 402 #endif | |
| 403 } | |
| 404 | |
| 380 // TODO(alexmos): This function should expose success of the underlying | 405 // TODO(alexmos): This function should expose success of the underlying |
| 381 // navigation to tests, which should make sure navigations succeed when | 406 // navigation to tests, which should make sure navigations succeed when |
| 382 // appropriate. See https://crbug.com/425335 | 407 // appropriate. See https://crbug.com/425335 |
| 383 void InProcessBrowserTest::AddTabAtIndexToBrowser( | 408 void InProcessBrowserTest::AddTabAtIndexToBrowser( |
| 384 Browser* browser, | 409 Browser* browser, |
| 385 int index, | 410 int index, |
| 386 const GURL& url, | 411 const GURL& url, |
| 387 ui::PageTransition transition, | 412 ui::PageTransition transition, |
| 388 bool check_navigation_success) { | 413 bool check_navigation_success) { |
| 389 chrome::NavigateParams params(browser, url, transition); | 414 chrome::NavigateParams params(browser, url, transition); |
| (...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 591 // On the Mac, this eventually reaches | 616 // On the Mac, this eventually reaches |
| 592 // -[BrowserWindowController windowWillClose:], which will post a deferred | 617 // -[BrowserWindowController windowWillClose:], which will post a deferred |
| 593 // -autorelease on itself to ultimately destroy the Browser object. The line | 618 // -autorelease on itself to ultimately destroy the Browser object. The line |
| 594 // below is necessary to pump these pending messages to ensure all Browsers | 619 // below is necessary to pump these pending messages to ensure all Browsers |
| 595 // get deleted. | 620 // get deleted. |
| 596 content::RunAllPendingInMessageLoop(); | 621 content::RunAllPendingInMessageLoop(); |
| 597 delete autorelease_pool_; | 622 delete autorelease_pool_; |
| 598 autorelease_pool_ = NULL; | 623 autorelease_pool_ = NULL; |
| 599 #endif | 624 #endif |
| 600 } | 625 } |
| OLD | NEW |