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

Side by Side 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 unified diff | Download patch
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 "ios/testing/earl_grey/wait_util.h" 5 #include "ios/testing/earl_grey/wait_util.h"
6 6
7 #import <EarlGrey/EarlGrey.h>
8
9 #include "base/test/ios/wait_util.h"
10
7 namespace testing { 11 namespace testing {
8 12
9 const NSTimeInterval kSpinDelaySeconds = 0.01; 13 const NSTimeInterval kSpinDelaySeconds = 0.01;
14 const NSTimeInterval kWaitForJSCompletionTimeout = 2.0;
10 const NSTimeInterval kWaitForUIElementTimeout = 4.0; 15 const NSTimeInterval kWaitForUIElementTimeout = 4.0;
11 const NSTimeInterval kWaitForJSCompletionTimeout = 2.0; 16
17 void WaitUntilCondition(NSTimeInterval timeout, bool (^condition)(void)) {
18 NSDate* deadline = [NSDate dateWithTimeIntervalSinceNow:timeout];
19 while (!condition() &&
20 [[NSDate date] compare:deadline] != NSOrderedDescending) {
21 base::test::ios::SpinRunLoopWithMaxDelay(
22 base::TimeDelta::FromSecondsD(testing::kSpinDelaySeconds));
23 }
24 GREYAssert(condition(), @"Timeout waiting for condition.");
12 } 25 }
26
27 } // namespace testing
OLDNEW
« 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