Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(5726)

Unified Diff: chrome/test/base/in_process_browser_test.cc

Issue 10408030: [Mac] Ensure that browser tests' teardown destroys all browser objects. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: rebase Created 8 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/test/base/in_process_browser_test.cc
===================================================================
--- chrome/test/base/in_process_browser_test.cc (revision 137975)
+++ chrome/test/base/in_process_browser_test.cc (working copy)
@@ -374,20 +374,31 @@
#endif
QuitBrowsers();
+ CHECK(BrowserList::empty());
}
void InProcessBrowserTest::QuitBrowsers() {
if (BrowserList::empty())
return;
- // Invoke CloseAllBrowsersAndMayExit on a running message loop.
- // CloseAllBrowsersAndMayExit exits the message loop after everything has been
+ // Invoke AttemptExit on a running message loop.
+ // AttemptExit exits the message loop after everything has been
// shut down properly.
MessageLoopForUI::current()->PostTask(FROM_HERE,
base::Bind(&browser::AttemptExit));
ui_test_utils::RunMessageLoop();
#if defined(OS_MACOSX)
+ // browser::AttemptExit() will attempt to close all browsers by deleting
+ // their tab contents. The last tab contents being removed triggers closing of
+ // the browser window.
+ //
+ // On the Mac, this eventually reaches
+ // -[BrowserWindowController windowWillClose:], which will post a deferred
+ // -autorelease on itself to ultimately destroy the Browser object. The line
+ // below is necessary to pump these pending messages to ensure all Browsers
+ // get deleted.
+ ui_test_utils::RunAllPendingInMessageLoop();
delete autorelease_pool_;
autorelease_pool_ = NULL;
#endif
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698