Index: chrome/test/base/ui_test_utils.cc |
diff --git a/chrome/test/base/ui_test_utils.cc b/chrome/test/base/ui_test_utils.cc |
index cfa65023b18a41a1567aad26b6d5e500621cb714..53cbd29787484bb547695eb4d5b0d8e6c76f3b83 100644 |
--- a/chrome/test/base/ui_test_utils.cc |
+++ b/chrome/test/base/ui_test_utils.cc |
@@ -405,6 +405,23 @@ void GetCookies(const GURL& url, |
} |
} |
+bool RunLoopUntil(const base::Callback<bool()>& condition) { |
+ const base::TimeTicks start_time = base::TimeTicks::Now(); |
+ while (!condition.Run()) { |
+ const base::TimeTicks current_time = base::TimeTicks::Now(); |
+ if (current_time - start_time > base::TimeDelta::FromSeconds(5)) { |
Lei Zhang
2015/10/21 07:24:52
Didn't some other test have a 10 second timeout? D
tommycli
2015/10/21 18:16:04
Yeah, one of them did. The ConstrainedDialog* test
|
+ ADD_FAILURE() << "Condition not met within five seconds."; |
+ return false; |
+ } |
+ |
+ base::MessageLoop::current()->task_runner()->PostDelayedTask( |
+ FROM_HERE, base::MessageLoop::QuitWhenIdleClosure(), |
+ base::TimeDelta::FromMilliseconds(20)); |
+ content::RunMessageLoop(); |
+ } |
+ return true; |
+} |
+ |
WindowedTabAddedNotificationObserver::WindowedTabAddedNotificationObserver( |
const content::NotificationSource& source) |
: WindowedNotificationObserver(chrome::NOTIFICATION_TAB_ADDED, source), |