| Index: ios/web/public/test/earl_grey/web_view_matchers.mm
|
| diff --git a/ios/web/public/test/earl_grey/web_view_matchers.mm b/ios/web/public/test/earl_grey/web_view_matchers.mm
|
| index b75a1655b568d305f755e8fd7a0c24e6b3937024..01b2fafb14f21d0bb9f26248c12ac9fd472406d7 100644
|
| --- a/ios/web/public/test/earl_grey/web_view_matchers.mm
|
| +++ b/ios/web/public/test/earl_grey/web_view_matchers.mm
|
| @@ -79,6 +79,11 @@ id<GREYMatcher> webViewScrollView(web::WebState* webState) {
|
| return [GREYMatchers matcherForWebViewScrollViewInWebState:webState];
|
| }
|
|
|
| +id<GREYMatcher> webViewMimeType(const std::string& mimeType,
|
| + web::WebState* webState) {
|
| + return [GREYMatchers matcherForWebViewMIMEType:mimeType inWebState:webState];
|
| +}
|
| +
|
| } // namespace web
|
|
|
| @implementation GREYMatchers (WebViewAdditions)
|
| @@ -163,4 +168,34 @@ id<GREYMatcher> webViewScrollView(web::WebState* webState) {
|
| autorelease];
|
| }
|
|
|
| ++ (id<GREYMatcher>)matcherForWebViewMIMEType:(const std::string&)MIMEType
|
| + inWebState:(web::WebState*)webState {
|
| + std::string MIMETypeCopy = MIMEType;
|
| + MatchesBlock matches = ^BOOL(UIView* view) {
|
| + __block BOOL didSucceed = NO;
|
| + NSDate* deadline =
|
| + [NSDate dateWithTimeIntervalSinceNow:testing::kWaitForUIElementTimeout];
|
| + while ([[NSDate date] compare:deadline] != NSOrderedDescending) {
|
| + if (webState->GetContentsMimeType() == MIMETypeCopy) {
|
| + didSucceed = YES;
|
| + break;
|
| + }
|
| + base::test::ios::SpinRunLoopWithMaxDelay(
|
| + base::TimeDelta::FromSecondsD(testing::kSpinDelaySeconds));
|
| + }
|
| + return didSucceed;
|
| + };
|
| +
|
| + DescribeToBlock describe = ^(id<GREYDescription> description) {
|
| + [description appendText:@"web view MIME type "];
|
| + [description appendText:base::SysUTF8ToNSString(MIMETypeCopy)];
|
| + };
|
| +
|
| + return grey_allOf(webViewInWebState(webState),
|
| + [[[GREYElementMatcherBlock alloc]
|
| + initWithMatchesBlock:matches
|
| + descriptionBlock:describe] autorelease],
|
| + nil);
|
| +}
|
| +
|
| @end
|
|
|