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/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" |
| (...skipping 355 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 366 #endif | 366 #endif |
| 367 | 367 |
| 368 // Invoke cleanup and quit even if there are failures. This is similar to | 368 // Invoke cleanup and quit even if there are failures. This is similar to |
| 369 // gtest in that it invokes TearDown even if Setup fails. | 369 // gtest in that it invokes TearDown even if Setup fails. |
| 370 CleanUpOnMainThread(); | 370 CleanUpOnMainThread(); |
| 371 #if defined(OS_MACOSX) | 371 #if defined(OS_MACOSX) |
| 372 autorelease_pool_->Recycle(); | 372 autorelease_pool_->Recycle(); |
| 373 #endif | 373 #endif |
| 374 | 374 |
| 375 QuitBrowsers(); | 375 QuitBrowsers(); |
| 376 CHECK(BrowserList::empty()); | |
| 376 } | 377 } |
| 377 | 378 |
| 378 void InProcessBrowserTest::QuitBrowsers() { | 379 void InProcessBrowserTest::QuitBrowsers() { |
| 379 if (BrowserList::size() == 0) | 380 if (BrowserList::size() == 0) |
| 380 return; | 381 return; |
| 381 | 382 |
| 382 // Invoke CloseAllBrowsersAndMayExit on a running message loop. | 383 // Invoke AttemptExit on a running message loop. |
| 383 // CloseAllBrowsersAndMayExit exits the message loop after everything has been | 384 // AttemptExit 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(&BrowserList::AttemptExit)); |
| 387 ui_test_utils::RunMessageLoop(); | 388 ui_test_utils::RunMessageLoop(); |
| 388 | 389 |
| 389 #if defined(OS_MACOSX) | 390 #if defined(OS_MACOSX) |
| 391 // BrowserList::AttemptExit() will attempt to close all browsers by deleting | |
| 392 // their tab contents. The last tab contents being removed triggers closing of | |
| 393 // the browser window. | |
| 394 // | |
| 395 // On the Mac, this eventually reaches -windowWillClose: on | |
|
Robert Sesek
2012/05/18 20:10:15
nit: just write this as -[BrowserWindowController
| |
| 396 // BrowserWindowController, which will post a deferred -autorelease on itself | |
| 397 // to ultimately destroy the Browser object. The line below is necessary to | |
| 398 // pump these pending tasks to ensure all Browsers get deleted. | |
|
Robert Sesek
2012/05/18 20:10:15
nit: I'd use the word "messages" instead of "tasks
| |
| 399 ui_test_utils::RunAllPendingInMessageLoop(); | |
| 390 delete autorelease_pool_; | 400 delete autorelease_pool_; |
| 391 autorelease_pool_ = NULL; | 401 autorelease_pool_ = NULL; |
| 392 #endif | 402 #endif |
| 393 } | 403 } |
| OLD | NEW |