| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #import "ios/web/public/test/earl_grey/web_view_matchers.h" | 5 #import "ios/web/public/test/earl_grey/web_view_matchers.h" |
| 6 | 6 |
| 7 #import <WebKit/WebKit.h> | 7 #import <WebKit/WebKit.h> |
| 8 | 8 |
| 9 #include "base/mac/bind_objc_block.h" | 9 #include "base/mac/bind_objc_block.h" |
| 10 #include "base/strings/sys_string_conversions.h" | 10 #include "base/strings/sys_string_conversions.h" |
| (...skipping 10 matching lines...) Expand all Loading... |
| 21 } | 21 } |
| 22 | 22 |
| 23 namespace web { | 23 namespace web { |
| 24 | 24 |
| 25 id<GREYMatcher> webViewContainingText(const std::string& text, | 25 id<GREYMatcher> webViewContainingText(const std::string& text, |
| 26 web::WebState* webState) { | 26 web::WebState* webState) { |
| 27 return | 27 return |
| 28 [GREYMatchers matcherForWebViewContainingText:text inWebState:webState]; | 28 [GREYMatchers matcherForWebViewContainingText:text inWebState:webState]; |
| 29 } | 29 } |
| 30 | 30 |
| 31 id<GREYMatcher> webViewScrollView(web::WebState* webState) { |
| 32 return [GREYMatchers matcherForWebViewScrollViewInWebState:webState]; |
| 33 } |
| 34 |
| 31 } // namespace web | 35 } // namespace web |
| 32 | 36 |
| 33 @implementation GREYMatchers (WebViewAdditions) | 37 @implementation GREYMatchers (WebViewAdditions) |
| 34 | 38 |
| 35 + (id<GREYMatcher>)matcherForWebViewContainingText:(const std::string&)text | 39 + (id<GREYMatcher>)matcherForWebViewContainingText:(const std::string&)text |
| 36 inWebState:(web::WebState*)webState { | 40 inWebState:(web::WebState*)webState { |
| 37 MatchesBlock matches = ^BOOL(UIView* view) { | 41 MatchesBlock matches = ^BOOL(UIView* view) { |
| 38 if (![view isKindOfClass:[WKWebView class]]) { | 42 if (![view isKindOfClass:[WKWebView class]]) { |
| 39 return NO; | 43 return NO; |
| 40 } | 44 } |
| (...skipping 24 matching lines...) Expand all Loading... |
| 65 DescribeToBlock describe = ^(id<GREYDescription> description) { | 69 DescribeToBlock describe = ^(id<GREYDescription> description) { |
| 66 [description appendText:@"web view containing "]; | 70 [description appendText:@"web view containing "]; |
| 67 [description appendText:base::SysUTF8ToNSString(text)]; | 71 [description appendText:base::SysUTF8ToNSString(text)]; |
| 68 }; | 72 }; |
| 69 | 73 |
| 70 return [[[GREYElementMatcherBlock alloc] initWithMatchesBlock:matches | 74 return [[[GREYElementMatcherBlock alloc] initWithMatchesBlock:matches |
| 71 descriptionBlock:describe] | 75 descriptionBlock:describe] |
| 72 autorelease]; | 76 autorelease]; |
| 73 } | 77 } |
| 74 | 78 |
| 79 + (id<GREYMatcher>)matcherForWebViewScrollViewInWebState: |
| 80 (web::WebState*)webState { |
| 81 MatchesBlock matches = ^BOOL(UIView* view) { |
| 82 return [view isKindOfClass:[UIScrollView class]] && |
| 83 [view.superview isKindOfClass:[WKWebView class]] && |
| 84 [view isDescendantOfView:webState->GetView()]; |
| 85 }; |
| 86 |
| 87 DescribeToBlock describe = ^(id<GREYDescription> description) { |
| 88 [description appendText:@"web view scroll view"]; |
| 89 }; |
| 90 |
| 91 return [[[GREYElementMatcherBlock alloc] initWithMatchesBlock:matches |
| 92 descriptionBlock:describe] |
| 93 autorelease]; |
| 94 } |
| 95 |
| 75 @end | 96 @end |
| OLD | NEW |