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/debug/stack_trace.h" | 10 #include "base/debug/stack_trace.h" |
11 #include "base/file_path.h" | 11 #include "base/file_path.h" |
12 #include "base/file_util.h" | 12 #include "base/file_util.h" |
13 #include "base/path_service.h" | 13 #include "base/path_service.h" |
14 #include "base/string_number_conversions.h" | 14 #include "base/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/io_thread.h" | 17 #include "chrome/browser/io_thread.h" |
| 18 #include "chrome/browser/lifetime/application_lifetime.h" |
18 #include "chrome/browser/profiles/profile.h" | 19 #include "chrome/browser/profiles/profile.h" |
19 #include "chrome/browser/profiles/profile_manager.h" | 20 #include "chrome/browser/profiles/profile_manager.h" |
20 #include "chrome/browser/ui/browser.h" | 21 #include "chrome/browser/ui/browser.h" |
21 #include "chrome/browser/ui/browser_list.h" | 22 #include "chrome/browser/ui/browser_list.h" |
22 #include "chrome/browser/ui/browser_navigator.h" | 23 #include "chrome/browser/ui/browser_navigator.h" |
23 #include "chrome/browser/ui/browser_window.h" | 24 #include "chrome/browser/ui/browser_window.h" |
24 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 25 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
25 #include "chrome/common/chrome_constants.h" | 26 #include "chrome/common/chrome_constants.h" |
26 #include "chrome/common/chrome_paths.h" | 27 #include "chrome/common/chrome_paths.h" |
27 #include "chrome/common/chrome_switches.h" | 28 #include "chrome/common/chrome_switches.h" |
(...skipping 310 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
338 signal(SIGTERM, DumpStackTraceSignalHandler); | 339 signal(SIGTERM, DumpStackTraceSignalHandler); |
339 #endif // defined(OS_POSIX) | 340 #endif // defined(OS_POSIX) |
340 | 341 |
341 // Pump startup related events. | 342 // Pump startup related events. |
342 ui_test_utils::RunAllPendingInMessageLoop(); | 343 ui_test_utils::RunAllPendingInMessageLoop(); |
343 | 344 |
344 #if defined(OS_MACOSX) | 345 #if defined(OS_MACOSX) |
345 autorelease_pool_->Recycle(); | 346 autorelease_pool_->Recycle(); |
346 #endif | 347 #endif |
347 | 348 |
348 if (BrowserList::size()) { | 349 if (!BrowserList::empty()) { |
349 browser_ = *BrowserList::begin(); | 350 browser_ = *BrowserList::begin(); |
350 ui_test_utils::WaitForLoadStop(browser_->GetSelectedWebContents()); | 351 ui_test_utils::WaitForLoadStop(browser_->GetSelectedWebContents()); |
351 } | 352 } |
352 | 353 |
353 // Pump any pending events that were created as a result of creating a | 354 // Pump any pending events that were created as a result of creating a |
354 // browser. | 355 // browser. |
355 ui_test_utils::RunAllPendingInMessageLoop(); | 356 ui_test_utils::RunAllPendingInMessageLoop(); |
356 | 357 |
357 SetUpOnMainThread(); | 358 SetUpOnMainThread(); |
358 #if defined(OS_MACOSX) | 359 #if defined(OS_MACOSX) |
(...skipping 10 matching lines...) Expand all Loading... |
369 // gtest in that it invokes TearDown even if Setup fails. | 370 // gtest in that it invokes TearDown even if Setup fails. |
370 CleanUpOnMainThread(); | 371 CleanUpOnMainThread(); |
371 #if defined(OS_MACOSX) | 372 #if defined(OS_MACOSX) |
372 autorelease_pool_->Recycle(); | 373 autorelease_pool_->Recycle(); |
373 #endif | 374 #endif |
374 | 375 |
375 QuitBrowsers(); | 376 QuitBrowsers(); |
376 } | 377 } |
377 | 378 |
378 void InProcessBrowserTest::QuitBrowsers() { | 379 void InProcessBrowserTest::QuitBrowsers() { |
379 if (BrowserList::size() == 0) | 380 if (BrowserList::empty()) |
380 return; | 381 return; |
381 | 382 |
382 // Invoke CloseAllBrowsersAndMayExit on a running message loop. | 383 // Invoke CloseAllBrowsersAndMayExit on a running message loop. |
383 // CloseAllBrowsersAndMayExit exits the message loop after everything has been | 384 // CloseAllBrowsersAndMayExit exits the message loop after everything has been |
384 // shut down properly. | 385 // shut down properly. |
385 MessageLoopForUI::current()->PostTask(FROM_HERE, | 386 MessageLoopForUI::current()->PostTask(FROM_HERE, |
386 base::Bind(&BrowserList::AttemptExit)); | 387 base::Bind(&browser::AttemptExit)); |
387 ui_test_utils::RunMessageLoop(); | 388 ui_test_utils::RunMessageLoop(); |
388 | 389 |
389 #if defined(OS_MACOSX) | 390 #if defined(OS_MACOSX) |
390 delete autorelease_pool_; | 391 delete autorelease_pool_; |
391 autorelease_pool_ = NULL; | 392 autorelease_pool_ = NULL; |
392 #endif | 393 #endif |
393 } | 394 } |
OLD | NEW |