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

Unified Diff: ios/testing/earl_grey/wait_util.mm

Issue 2044433003: Create EarlGrey wait utility. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix blocks Created 4 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 | « ios/testing/earl_grey/wait_util.h ('k') | ios/web/public/test/web_view_interaction_test_util.mm » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ios/testing/earl_grey/wait_util.mm
diff --git a/ios/testing/earl_grey/wait_util.mm b/ios/testing/earl_grey/wait_util.mm
index 798ce1cb2ad812e760b54665184021122269268e..962a20a2a00b02647307e8bce3e75cc50d64bb5e 100644
--- a/ios/testing/earl_grey/wait_util.mm
+++ b/ios/testing/earl_grey/wait_util.mm
@@ -4,9 +4,24 @@
#include "ios/testing/earl_grey/wait_util.h"
+#import <EarlGrey/EarlGrey.h>
+
+#include "base/test/ios/wait_util.h"
+
namespace testing {
const NSTimeInterval kSpinDelaySeconds = 0.01;
-const NSTimeInterval kWaitForUIElementTimeout = 4.0;
const NSTimeInterval kWaitForJSCompletionTimeout = 2.0;
+const NSTimeInterval kWaitForUIElementTimeout = 4.0;
+
+void WaitUntilCondition(NSTimeInterval timeout, bool (^condition)(void)) {
+ NSDate* deadline = [NSDate dateWithTimeIntervalSinceNow:timeout];
+ while (!condition() &&
+ [[NSDate date] compare:deadline] != NSOrderedDescending) {
+ base::test::ios::SpinRunLoopWithMaxDelay(
+ base::TimeDelta::FromSecondsD(testing::kSpinDelaySeconds));
+ }
+ GREYAssert(condition(), @"Timeout waiting for condition.");
}
+
+} // namespace testing
« no previous file with comments | « ios/testing/earl_grey/wait_util.h ('k') | ios/web/public/test/web_view_interaction_test_util.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698