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

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

Issue 2252723008: Add a custom error message in EG WaitUtil (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@taplink
Patch Set: Rebase Created 4 years, 3 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
« no previous file with comments | « ios/testing/earl_grey/wait_util.h ('k') | no next file » | 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 10
11 namespace testing { 11 namespace testing {
12 12
13 const NSTimeInterval kSpinDelaySeconds = 0.01; 13 const NSTimeInterval kSpinDelaySeconds = 0.01;
14 const NSTimeInterval kWaitForJSCompletionTimeout = 2.0; 14 const NSTimeInterval kWaitForJSCompletionTimeout = 2.0;
15 const NSTimeInterval kWaitForUIElementTimeout = 4.0; 15 const NSTimeInterval kWaitForUIElementTimeout = 4.0;
16 16
17 void WaitUntilCondition(NSTimeInterval timeout, bool (^condition)(void)) { 17 void WaitUntilCondition(NSTimeInterval timeout,
18 NSString* timeoutDescription,
19 bool (^condition)(void)) {
18 NSDate* deadline = [NSDate dateWithTimeIntervalSinceNow:timeout]; 20 NSDate* deadline = [NSDate dateWithTimeIntervalSinceNow:timeout];
19 while (!condition() && 21 while (!condition() &&
20 [[NSDate date] compare:deadline] != NSOrderedDescending) { 22 [[NSDate date] compare:deadline] != NSOrderedDescending) {
21 base::test::ios::SpinRunLoopWithMaxDelay( 23 base::test::ios::SpinRunLoopWithMaxDelay(
22 base::TimeDelta::FromSecondsD(testing::kSpinDelaySeconds)); 24 base::TimeDelta::FromSecondsD(testing::kSpinDelaySeconds));
23 } 25 }
24 GREYAssert(condition(), @"Timeout waiting for condition."); 26 GREYAssert(condition(), timeoutDescription);
27 }
28
29 void WaitUntilCondition(NSTimeInterval timeout, bool (^condition)(void)) {
30 WaitUntilCondition(timeout, @"Timeout waiting for condition.", condition);
25 } 31 }
26 32
27 } // namespace testing 33 } // namespace testing
OLDNEW
« no previous file with comments | « ios/testing/earl_grey/wait_util.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698