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

Unified Diff: ios/web/public/test/web_view_interaction_test_util.mm

Issue 2282823002: Remove dependency on Earl Grey from WebViewInteractionTestUtil (Closed)
Patch Set: Created 4 years, 4 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ios/web/public/test/web_view_interaction_test_util.mm
diff --git a/ios/web/public/test/web_view_interaction_test_util.mm b/ios/web/public/test/web_view_interaction_test_util.mm
index db4000300e857f21bb245d6c750af05017db6fbd..73bbedeb05e23b4d9b8bb9a8e022a5ca162d0e85 100644
--- a/ios/web/public/test/web_view_interaction_test_util.mm
+++ b/ios/web/public/test/web_view_interaction_test_util.mm
@@ -6,7 +6,7 @@
#import <Foundation/Foundation.h>
-#include "ios/testing/earl_grey/wait_util.h"
+#include "base/test/ios/wait_util.h"
#import "ios/web/web_state/ui/crw_web_controller.h"
#include "ios/web/web_state/web_state_impl.h"
@@ -15,6 +15,9 @@ using web::NavigationManager;
namespace web {
namespace test {
+const NSTimeInterval kWaitForJSCompletionTimeout = 2.0;
+const NSTimeInterval kSpinDelaySeconds = 0.01;
+
enum ElementAction { ELEMENT_ACTION_CLICK, ELEMENT_ACTION_FOCUS };
// Returns whether the Javascript action specified by |action| ran on
@@ -51,11 +54,15 @@ bool RunActionOnWebViewElementWithId(web::WebState* web_state,
element_found = [result boolValue];
}];
- testing::WaitUntilCondition(testing::kWaitForJSCompletionTimeout, ^{
- return did_complete;
- });
+ NSDate* deadline =
+ [NSDate dateWithTimeIntervalSinceNow:kWaitForJSCompletionTimeout];
+ while (!did_complete &&
+ [[NSDate date] compare:deadline] != NSOrderedDescending) {
+ base::test::ios::SpinRunLoopWithMaxDelay(
+ base::TimeDelta::FromSecondsD(kSpinDelaySeconds));
+ }
- return element_found;
+ return did_complete && element_found;
}
bool TapWebViewElementWithId(web::WebState* web_state,
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698