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

Side by Side Diff: chrome/test/base/in_process_browser_test.cc

Issue 10479018: Add base::RunLoop and update ui_test_utils to use it to reduce flakiness (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: win compile Created 8 years, 5 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
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
Paweł Hajdan Jr. 2012/06/27 07:33:28 nit: Please add TODO(phajdan.jr) to maybe detect t
jbates 2012/06/28 20:46:11 Done.
377 // run all pending messages here to avoid preempting the QuitBrowsers tasks.
378 ui_test_utils::RunAllPendingInMessageLoop();
379
376 QuitBrowsers(); 380 QuitBrowsers();
377 CHECK(BrowserList::empty()); 381 CHECK(BrowserList::empty());
378 } 382 }
379 383
380 void InProcessBrowserTest::QuitBrowsers() { 384 void InProcessBrowserTest::QuitBrowsers() {
381 if (BrowserList::empty()) 385 if (BrowserList::empty())
382 return; 386 return;
383 387
384 // Invoke AttemptExit on a running message loop. 388 // Invoke AttemptExit on a running message loop.
385 // AttemptExit exits the message loop after everything has been 389 // AttemptExit exits the message loop after everything has been
(...skipping 10 matching lines...) Expand all
396 // On the Mac, this eventually reaches 400 // On the Mac, this eventually reaches
397 // -[BrowserWindowController windowWillClose:], which will post a deferred 401 // -[BrowserWindowController windowWillClose:], which will post a deferred
398 // -autorelease on itself to ultimately destroy the Browser object. The line 402 // -autorelease on itself to ultimately destroy the Browser object. The line
399 // below is necessary to pump these pending messages to ensure all Browsers 403 // below is necessary to pump these pending messages to ensure all Browsers
400 // get deleted. 404 // get deleted.
401 ui_test_utils::RunAllPendingInMessageLoop(); 405 ui_test_utils::RunAllPendingInMessageLoop();
402 delete autorelease_pool_; 406 delete autorelease_pool_;
403 autorelease_pool_ = NULL; 407 autorelease_pool_ = NULL;
404 #endif 408 #endif
405 } 409 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698