| 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 autorelease_pool_->Recycle(); | 366 autorelease_pool_->Recycle(); |
| 367 #endif | 367 #endif |
| 368 | 368 |
| 369 // Invoke cleanup and quit even if there are failures. This is similar to | 369 // Invoke cleanup and quit even if there are failures. This is similar to |
| 370 // gtest in that it invokes TearDown even if Setup fails. | 370 // gtest in that it invokes TearDown even if Setup fails. |
| 371 CleanUpOnMainThread(); | 371 CleanUpOnMainThread(); |
| 372 #if defined(OS_MACOSX) | 372 #if defined(OS_MACOSX) |
| 373 autorelease_pool_->Recycle(); | 373 autorelease_pool_->Recycle(); |
| 374 #endif | 374 #endif |
| 375 | 375 |
| 376 // Sometimes tests leave Quit tasks in the MessageLoop (for shame), so let's |
| 377 // run all pending messages here to avoid preempting the QuitBrowsers tasks. |
| 378 // TODO(jbates) Once crbug.com/134753 is fixed, this can be removed because it |
| 379 // will not be possible to post Quit tasks. |
| 380 ui_test_utils::RunAllPendingInMessageLoop(); |
| 381 |
| 376 QuitBrowsers(); | 382 QuitBrowsers(); |
| 377 CHECK(BrowserList::empty()); | 383 CHECK(BrowserList::empty()); |
| 378 } | 384 } |
| 379 | 385 |
| 380 void InProcessBrowserTest::QuitBrowsers() { | 386 void InProcessBrowserTest::QuitBrowsers() { |
| 381 if (BrowserList::empty()) | 387 if (BrowserList::empty()) |
| 382 return; | 388 return; |
| 383 | 389 |
| 384 // Invoke AttemptExit on a running message loop. | 390 // Invoke AttemptExit on a running message loop. |
| 385 // AttemptExit exits the message loop after everything has been | 391 // AttemptExit exits the message loop after everything has been |
| (...skipping 10 matching lines...) Expand all Loading... |
| 396 // On the Mac, this eventually reaches | 402 // On the Mac, this eventually reaches |
| 397 // -[BrowserWindowController windowWillClose:], which will post a deferred | 403 // -[BrowserWindowController windowWillClose:], which will post a deferred |
| 398 // -autorelease on itself to ultimately destroy the Browser object. The line | 404 // -autorelease on itself to ultimately destroy the Browser object. The line |
| 399 // below is necessary to pump these pending messages to ensure all Browsers | 405 // below is necessary to pump these pending messages to ensure all Browsers |
| 400 // get deleted. | 406 // get deleted. |
| 401 ui_test_utils::RunAllPendingInMessageLoop(); | 407 ui_test_utils::RunAllPendingInMessageLoop(); |
| 402 delete autorelease_pool_; | 408 delete autorelease_pool_; |
| 403 autorelease_pool_ = NULL; | 409 autorelease_pool_ = NULL; |
| 404 #endif | 410 #endif |
| 405 } | 411 } |
| OLD | NEW |