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

Unified Diff: ios/web/public/test/earl_grey/web_view_matchers.mm

Issue 2183583002: [ios] EarlGrey test for PDF Mime type. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@css_selector_matcher
Patch Set: Fixed dangling reference inside the block Created 4 years, 5 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
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

Powered by Google App Engine
This is Rietveld 408576698