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

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

Issue 2546193002: [ios] Matcher for a generic interstitial page. (Closed)
Patch Set: Self review Created 4 years 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/public/test/earl_grey/web_view_matchers.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 9d4c554578cba881b3dfc5d45d0a897be20a2ed2..c09b876eac520c5333e33aba55f79d8246d363f3 100644
--- a/ios/web/public/test/earl_grey/web_view_matchers.mm
+++ b/ios/web/public/test/earl_grey/web_view_matchers.mm
@@ -174,16 +174,29 @@ id<GREYMatcher> webViewScrollView(WebState* web_state) {
autorelease];
}
+id<GREYMatcher> interstitial(WebState* web_state) {
+ MatchesBlock matches = ^BOOL(WKWebView* view) {
+ web::WebInterstitialImpl* interstitial =
+ static_cast<web::WebInterstitialImpl*>(web_state->GetWebInterstitial());
+ return interstitial &&
+ [view isDescendantOfView:interstitial->GetContentView()];
+ };
+
+ DescribeToBlock describe = ^(id<GREYDescription> description) {
+ [description appendText:@"interstitial displayed"];
+ };
+
+ return grey_allOf(webViewInWebState(web_state),
+ [[[GREYElementMatcherBlock alloc]
+ initWithMatchesBlock:matches
+ descriptionBlock:describe] autorelease],
+ nil);
+}
+
id<GREYMatcher> interstitialContainingText(NSString* text,
WebState* web_state) {
MatchesBlock matches = ^BOOL(WKWebView* view) {
return WaitUntilConditionOrTimeout(testing::kWaitForUIElementTimeout, ^{
- web::WebInterstitialImpl* interstitial =
- static_cast<web::WebInterstitialImpl*>(
- web_state->GetWebInterstitial());
- if (![view isDescendantOfView:interstitial->GetContentView()])
- return false;
-
NSString* script = base::SysUTF8ToNSString(kGetDocumentBodyJavaScript);
id body = ExecuteScriptOnInterstitial(web_state, script);
return [body containsString:text] ? true : false;
@@ -195,7 +208,7 @@ id<GREYMatcher> interstitialContainingText(NSString* text,
[description appendText:text];
};
- return grey_allOf(webViewInWebState(web_state),
+ return grey_allOf(interstitial(web_state),
[[[GREYElementMatcherBlock alloc]
initWithMatchesBlock:matches
descriptionBlock:describe] autorelease],
« no previous file with comments | « ios/web/public/test/earl_grey/web_view_matchers.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698