| 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/bind.h" | 8 #include "base/bind.h" |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/file_path.h" | 10 #include "base/file_path.h" |
| 11 #include "base/file_util.h" | 11 #include "base/file_util.h" |
| 12 #include "base/lazy_instance.h" | 12 #include "base/lazy_instance.h" |
| 13 #include "base/path_service.h" | 13 #include "base/path_service.h" |
| 14 #include "base/strings/string_number_conversions.h" | 14 #include "base/strings/string_number_conversions.h" |
| 15 #include "base/test/test_file_util.h" | 15 #include "base/test/test_file_util.h" |
| 16 #include "chrome/browser/browser_process.h" | 16 #include "chrome/browser/browser_process.h" |
| 17 #include "chrome/browser/google/google_util.h" | 17 #include "chrome/browser/google/google_util.h" |
| 18 #include "chrome/browser/io_thread.h" | 18 #include "chrome/browser/io_thread.h" |
| 19 #include "chrome/browser/lifetime/application_lifetime.h" | 19 #include "chrome/browser/lifetime/application_lifetime.h" |
| 20 #include "chrome/browser/net/net_error_tab_helper.h" | 20 #include "chrome/browser/net/net_error_tab_helper.h" |
| 21 #include "chrome/browser/profiles/profile.h" | 21 #include "chrome/browser/profiles/profile.h" |
| 22 #include "chrome/browser/profiles/profile_manager.h" | 22 #include "chrome/browser/profiles/profile_manager.h" |
| 23 #include "chrome/browser/ui/browser.h" | 23 #include "chrome/browser/ui/browser.h" |
| 24 #include "chrome/browser/ui/browser_list.h" | 24 #include "chrome/browser/ui/browser_list.h" |
| 25 #include "chrome/browser/ui/browser_list_impl.h" |
| 25 #include "chrome/browser/ui/browser_navigator.h" | 26 #include "chrome/browser/ui/browser_navigator.h" |
| 26 #include "chrome/browser/ui/browser_tabstrip.h" | 27 #include "chrome/browser/ui/browser_tabstrip.h" |
| 27 #include "chrome/browser/ui/browser_window.h" | 28 #include "chrome/browser/ui/browser_window.h" |
| 29 #include "chrome/browser/ui/host_desktop.h" |
| 28 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 30 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
| 29 #include "chrome/common/chrome_constants.h" | 31 #include "chrome/common/chrome_constants.h" |
| 30 #include "chrome/common/chrome_paths.h" | 32 #include "chrome/common/chrome_paths.h" |
| 31 #include "chrome/common/chrome_switches.h" | 33 #include "chrome/common/chrome_switches.h" |
| 32 #include "chrome/common/logging_chrome.h" | 34 #include "chrome/common/logging_chrome.h" |
| 33 #include "chrome/common/url_constants.h" | 35 #include "chrome/common/url_constants.h" |
| 34 #include "chrome/renderer/chrome_content_renderer_client.h" | 36 #include "chrome/renderer/chrome_content_renderer_client.h" |
| 35 #include "chrome/test/base/chrome_test_suite.h" | 37 #include "chrome/test/base/chrome_test_suite.h" |
| 36 #include "chrome/test/base/test_launcher_utils.h" | 38 #include "chrome/test/base/test_launcher_utils.h" |
| 37 #include "chrome/test/base/testing_browser_process.h" | 39 #include "chrome/test/base/testing_browser_process.h" |
| (...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 319 #endif | 321 #endif |
| 320 | 322 |
| 321 void InProcessBrowserTest::RunTestOnMainThreadLoop() { | 323 void InProcessBrowserTest::RunTestOnMainThreadLoop() { |
| 322 // Pump startup related events. | 324 // Pump startup related events. |
| 323 content::RunAllPendingInMessageLoop(); | 325 content::RunAllPendingInMessageLoop(); |
| 324 | 326 |
| 325 #if defined(OS_MACOSX) | 327 #if defined(OS_MACOSX) |
| 326 autorelease_pool_->Recycle(); | 328 autorelease_pool_->Recycle(); |
| 327 #endif | 329 #endif |
| 328 | 330 |
| 329 if (!BrowserList::empty()) { | 331 // Browser tests do not support multi-desktop for now. |
| 330 browser_ = *BrowserList::begin(); | 332 const chrome::BrowserListImpl* native_browser_list = |
| 333 chrome::BrowserListImpl::GetInstance(chrome::HOST_DESKTOP_TYPE_NATIVE); |
| 334 if (!native_browser_list->empty()) { |
| 335 browser_ = native_browser_list->get(0); |
| 331 #if defined(USE_ASH) | 336 #if defined(USE_ASH) |
| 332 // There are cases where windows get created maximized by default. | 337 // There are cases where windows get created maximized by default. |
| 333 if (browser_->window()->IsMaximized()) | 338 if (browser_->window()->IsMaximized()) |
| 334 browser_->window()->Restore(); | 339 browser_->window()->Restore(); |
| 335 #endif | 340 #endif |
| 336 content::WaitForLoadStop( | 341 content::WaitForLoadStop( |
| 337 browser_->tab_strip_model()->GetActiveWebContents()); | 342 browser_->tab_strip_model()->GetActiveWebContents()); |
| 338 } | 343 } |
| 339 | 344 |
| 340 // Pump any pending events that were created as a result of creating a | 345 // Pump any pending events that were created as a result of creating a |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 388 // On the Mac, this eventually reaches | 393 // On the Mac, this eventually reaches |
| 389 // -[BrowserWindowController windowWillClose:], which will post a deferred | 394 // -[BrowserWindowController windowWillClose:], which will post a deferred |
| 390 // -autorelease on itself to ultimately destroy the Browser object. The line | 395 // -autorelease on itself to ultimately destroy the Browser object. The line |
| 391 // below is necessary to pump these pending messages to ensure all Browsers | 396 // below is necessary to pump these pending messages to ensure all Browsers |
| 392 // get deleted. | 397 // get deleted. |
| 393 content::RunAllPendingInMessageLoop(); | 398 content::RunAllPendingInMessageLoop(); |
| 394 delete autorelease_pool_; | 399 delete autorelease_pool_; |
| 395 autorelease_pool_ = NULL; | 400 autorelease_pool_ = NULL; |
| 396 #endif | 401 #endif |
| 397 } | 402 } |
| OLD | NEW |