Chromium Code Reviews| 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..19975652a7e84207510732bc737b298a9738e608 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,40 @@ 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::kWaitForElementTimeout]; |
| + 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 |
|
Eugene But (OOO till 7-30)
2016/05/09 17:58:35
[description appendText:@"web view containing "];
baxley
2016/05/09 18:42:27
Gah. Feel free to preface these comments with "Hey
|
| + appendText:[NSString stringWithFormat:@"web view containing "]]; |
| + [description appendText:text]; |
| + }; |
| + |
| + return [[[GREYElementMatcherBlock alloc] initWithMatchesBlock:matches |
| + descriptionBlock:describe] |
| + autorelease]; |
| +} |
| + |
| + (id<GREYMatcher>)matcherForWebShellBackButton { |
| return grey_accessibilityLabel(kWebShellBackButtonAccessibilityLabel); |
| } |