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

Unified Diff: chrome/test/in_process_browser_test.cc

Issue 151158: Adding time-out to browser tests (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 6 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 | « chrome/test/in_process_browser_test.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/test/in_process_browser_test.cc
===================================================================
--- chrome/test/in_process_browser_test.cc (revision 19688)
+++ chrome/test/in_process_browser_test.cc (working copy)
@@ -33,6 +33,13 @@
const wchar_t kUnitTestShowWindows[] = L"show-windows";
+// Delay for the time-out at which we stop the inner-message loop the first
+// time.
+const int kInitialTimeoutInMS = 30000;
+
+// Delay for sub-sequent time-outs once the initial time-out happened.
+const int kSubsequentTimeoutInMS = 5000;
+
namespace {
bool DieFileDie(const std::wstring& file, bool recurse) {
@@ -205,6 +212,11 @@
browser_ = CreateBrowser(profile);
+ // Start the timeout timer to prevent hangs.
+ MessageLoopForUI::current()->PostDelayedTask(FROM_HERE,
+ NewRunnableMethod(this, &InProcessBrowserTest::TimedOut),
+ kInitialTimeoutInMS);
+
RunTestOnMainThread();
BrowserList::const_iterator browser = BrowserList::begin();
@@ -224,3 +236,16 @@
// We don't want the test code to use it.
host_mapper->AddSimulatedFailure("wpad");
}
+
+void InProcessBrowserTest::TimedOut() {
+ DCHECK(MessageLoopForUI::current()->IsNested());
+
+ GTEST_NONFATAL_FAILURE_("Timed-out");
+
+ // Start the timeout timer to prevent hangs.
+ MessageLoopForUI::current()->PostDelayedTask(FROM_HERE,
+ NewRunnableMethod(this, &InProcessBrowserTest::TimedOut),
+ kSubsequentTimeoutInMS);
+
+ MessageLoopForUI::current()->Quit();
+}
« no previous file with comments | « chrome/test/in_process_browser_test.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698