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

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

Issue 2448753002: Refactor wait_util so it isn't coupled to EarlGrey. (Closed)
Patch Set: compile Created 4 years, 2 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 | « ios/web/public/test/web_view_interaction_test_util.h ('k') | ios/web/shell/test/BUILD.gn » ('j') | 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 bf7d5bbbce468c3d1ec9a85b926f79d0e89f8a28..277d4daf43d153961f2e80f1b0c29066a53ac4fb 100644
--- a/ios/web/public/test/web_view_interaction_test_util.mm
+++ b/ios/web/public/test/web_view_interaction_test_util.mm
@@ -8,7 +8,7 @@
#include "base/strings/stringprintf.h"
#include "base/strings/utf_string_conversions.h"
#include "base/test/ios/wait_util.h"
-#include "ios/testing/earl_grey/wait_util.h"
+#include "ios/testing/wait_util.h"
#import "ios/web/public/web_state/crw_web_view_scroll_view_proxy.h"
#import "ios/web/web_state/crw_web_view_proxy_impl.h"
#import "ios/web/web_state/ui/crw_web_controller.h"
@@ -36,9 +36,13 @@ std::unique_ptr<base::Value> ExecuteJavaScript(web::WebState* web_state,
did_finish = true;
}));
- testing::WaitUntilCondition(testing::kWaitForJSCompletionTimeout, ^{
- return did_finish;
- });
+ bool completed = testing::WaitUntilConditionOrTimeout(
+ testing::kWaitForJSCompletionTimeout, ^{
+ return did_finish;
+ });
+ if (!completed) {
+ return nullptr;
+ }
// As result is marked __block, this return call does a copy and not a move
// (marking the variable as __block mean it is allocated in the block object
@@ -72,26 +76,24 @@ CGRect GetBoundingRectOfElementWithId(web::WebState* web_state,
" };"
"})();";
- base::DictionaryValue const* rect = nullptr;
- bool found = false;
- NSDate* deadline =
- [NSDate dateWithTimeIntervalSinceNow:testing::kWaitForUIElementTimeout];
- while (([[NSDate date] compare:deadline] != NSOrderedDescending) && !found) {
- std::unique_ptr<base::Value> value =
- ExecuteJavaScript(web_state, kGetBoundsScript);
- base::DictionaryValue* dictionary = nullptr;
- if (value && value->GetAsDictionary(&dictionary)) {
- std::string error;
- if (dictionary->GetString("error", &error)) {
- DLOG(ERROR) << "Error getting rect: " << error << ", retrying..";
- } else {
- rect = dictionary->DeepCopy();
- found = true;
- }
- }
- base::test::ios::SpinRunLoopWithMaxDelay(
- base::TimeDelta::FromSecondsD(testing::kSpinDelaySeconds));
- }
+ __block base::DictionaryValue const* rect = nullptr;
+
+ bool found =
+ testing::WaitUntilConditionOrTimeout(testing::kWaitForUIElementTimeout, ^{
+ std::unique_ptr<base::Value> value =
+ ExecuteJavaScript(web_state, kGetBoundsScript);
+ base::DictionaryValue* dictionary = nullptr;
+ if (value && value->GetAsDictionary(&dictionary)) {
+ std::string error;
+ if (dictionary->GetString("error", &error)) {
+ DLOG(ERROR) << "Error getting rect: " << error << ", retrying..";
+ } else {
+ rect = dictionary->DeepCopy();
+ return true;
+ }
+ }
+ return false;
+ });
if (!found)
return CGRectNull;
@@ -145,7 +147,7 @@ bool RunActionOnWebViewElementWithId(web::WebState* web_state,
element_found = [result boolValue];
}];
- testing::WaitUntilCondition(testing::kWaitForJSCompletionTimeout, ^{
+ testing::WaitUntilConditionOrTimeout(testing::kWaitForJSCompletionTimeout, ^{
return did_complete;
});
« no previous file with comments | « ios/web/public/test/web_view_interaction_test_util.h ('k') | ios/web/shell/test/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698