| 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);
|
| }
|
|
|