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

Unified Diff: ios/web/shell/test/earl_grey/shell_matchers.mm

Issue 1961063002: Add web shell matcher for address field. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: s/Element/UIElement Created 4 years, 7 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/shell/test/earl_grey/shell_matchers.h ('k') | ios/web/shell/test/web_shell_navigation_egtest.mm » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ios/web/shell/test/earl_grey/shell_matchers.mm
diff --git a/ios/web/shell/test/earl_grey/shell_matchers.mm b/ios/web/shell/test/earl_grey/shell_matchers.mm
index e0e37a1818067d389164e6c80388f7c3f3f8ab96..8da81b6c82b2817b6bb3e972584ab8305e3378bb 100644
--- a/ios/web/shell/test/earl_grey/shell_matchers.mm
+++ b/ios/web/shell/test/earl_grey/shell_matchers.mm
@@ -4,6 +4,9 @@
#import "ios/web/shell/test/earl_grey/shell_matchers.h"
+#import "base/mac/foundation_util.h"
+#include "base/test/ios/wait_util.h"
+#include "ios/testing/earl_grey/wait_util.h"
#import "ios/web/public/web_state/web_state.h"
#import "ios/web/public/test/earl_grey/web_view_matchers.h"
#import "ios/web/shell/test/app/web_shell_test_util.h"
@@ -11,11 +14,14 @@
namespace web {
-// Shorthand for GREYMatchers::matcherForWebViewContainingText.
id<GREYMatcher> webViewContainingText(NSString* text) {
return [GREYMatchers matcherForWebViewContainingText:text];
}
+id<GREYMatcher> addressFieldText(NSString* text) {
+ return [GREYMatchers matcherForAddressFieldEqualToText:text];
+}
+
id<GREYMatcher> backButton() {
return [GREYMatchers matcherForWebShellBackButton];
}
@@ -37,6 +43,39 @@ id<GREYMatcher> addressField() {
return web::webViewContainingText(text, webState);
}
++ (id<GREYMatcher>)matcherForAddressFieldEqualToText:(NSString*)text {
+ MatchesBlock matches = ^BOOL(UIView* view) {
+ if (![view isKindOfClass:[UITextField class]]) {
+ return NO;
+ }
+ if (![[view accessibilityLabel]
+ isEqualToString:kWebShellAddressFieldAccessibilityLabel]) {
+ return NO;
+ }
+ UITextField* textField = base::mac::ObjCCastStrict<UITextField>(view);
+
+ NSDate* deadline =
+ [NSDate dateWithTimeIntervalSinceNow:testing::kWaitForUIElementTimeout];
+ while ([[NSDate date] compare:deadline] != NSOrderedDescending) {
+ if ([textField.text isEqualToString:text]) {
+ return YES;
+ }
+ base::test::ios::SpinRunLoopWithMaxDelay(
+ base::TimeDelta::FromSecondsD(testing::kSpinDelaySeconds));
+ }
+ return NO;
+ };
+
+ DescribeToBlock describe = ^(id<GREYDescription> description) {
+ [description appendText:@"web view containing "];
+ [description appendText:text];
+ };
+
+ return [[[GREYElementMatcherBlock alloc] initWithMatchesBlock:matches
+ descriptionBlock:describe]
+ autorelease];
+}
+
+ (id<GREYMatcher>)matcherForWebShellBackButton {
return grey_accessibilityLabel(kWebShellBackButtonAccessibilityLabel);
}
« no previous file with comments | « ios/web/shell/test/earl_grey/shell_matchers.h ('k') | ios/web/shell/test/web_shell_navigation_egtest.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698