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

Side by Side Diff: ios/testing/earl_grey/wait_util.mm

Issue 2448753002: Refactor wait_util so it isn't coupled to EarlGrey. (Closed)
Patch Set: compile Created 4 years, 1 month 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
« no previous file with comments | « ios/testing/earl_grey/wait_util.h ('k') | ios/testing/wait_util.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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> 7 #import <EarlGrey/EarlGrey.h>
8 8
9 #include "base/test/ios/wait_util.h" 9 #include "base/test/ios/wait_util.h"
10 #include "ios/testing/wait_util.h"
10 11
11 namespace testing { 12 namespace testing {
12 13
13 const NSTimeInterval kSpinDelaySeconds = 0.01;
14 const NSTimeInterval kWaitForJSCompletionTimeout = 2.0;
15 const NSTimeInterval kWaitForUIElementTimeout = 4.0;
16 const NSTimeInterval kWaitForDownloadTimeout = 10.0;
17
18 void WaitUntilCondition(NSTimeInterval timeout, 14 void WaitUntilCondition(NSTimeInterval timeout,
19 NSString* timeoutDescription, 15 NSString* timeoutDescription,
20 bool (^condition)(void)) { 16 bool (^condition)(void)) {
21 NSDate* deadline = [NSDate dateWithTimeIntervalSinceNow:timeout]; 17 GREYAssert(testing::WaitUntilConditionOrTimeout(timeout, condition),
22 while (!condition() && 18 timeoutDescription);
23 [[NSDate date] compare:deadline] != NSOrderedDescending) {
24 base::test::ios::SpinRunLoopWithMaxDelay(
25 base::TimeDelta::FromSecondsD(testing::kSpinDelaySeconds));
26 }
27 GREYAssert(condition(), timeoutDescription);
28 } 19 }
29 20
30 void WaitUntilCondition(NSTimeInterval timeout, bool (^condition)(void)) { 21 void WaitUntilCondition(NSTimeInterval timeout, bool (^condition)(void)) {
31 WaitUntilCondition(timeout, @"Timeout waiting for condition.", condition); 22 WaitUntilCondition(timeout, @"Timeout waiting for condition.", condition);
32 } 23 }
33 24
34 } // namespace testing 25 } // namespace testing
OLDNEW
« no previous file with comments | « ios/testing/earl_grey/wait_util.h ('k') | ios/testing/wait_util.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698