| 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
|
|
|