| 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/shell/test/earl_grey/shell_matchers.h" | 5 #import "ios/web/shell/test/earl_grey/shell_matchers.h" |
| 6 | 6 |
| 7 #import "base/mac/foundation_util.h" | 7 #import "base/mac/foundation_util.h" |
| 8 #include "base/strings/sys_string_conversions.h" | 8 #include "base/strings/sys_string_conversions.h" |
| 9 #include "base/test/ios/wait_util.h" | 9 #include "base/test/ios/wait_util.h" |
| 10 #include "ios/testing/earl_grey/wait_util.h" | 10 #include "ios/testing/earl_grey/wait_util.h" |
| 11 #import "ios/web/public/web_state/web_state.h" | 11 #import "ios/web/public/web_state/web_state.h" |
| 12 #import "ios/web/public/test/earl_grey/web_view_matchers.h" | 12 #import "ios/web/public/test/earl_grey/web_view_matchers.h" |
| 13 #import "ios/web/shell/test/app/web_shell_test_util.h" | 13 #import "ios/web/shell/test/app/web_shell_test_util.h" |
| 14 #import "ios/web/shell/view_controller.h" | 14 #import "ios/web/shell/view_controller.h" |
| 15 | 15 |
| 16 namespace web { | 16 namespace web { |
| 17 | 17 |
| 18 id<GREYMatcher> webViewContainingText(const std::string& text) { | 18 id<GREYMatcher> webViewContainingText(const std::string& text) { |
| 19 return [GREYMatchers matcherForWebViewContainingText:text]; | 19 return [GREYMatchers matcherForWebViewContainingText:text]; |
| 20 } | 20 } |
| 21 | 21 |
| 22 id<GREYMatcher> webViewCssSelector(const std::string& selector) { | 22 id<GREYMatcher> webViewCssSelector(const std::string& selector) { |
| 23 return [GREYMatchers matcherForWebWithCSSSelector:selector]; | 23 return [GREYMatchers matcherForWebWithCSSSelector:selector]; |
| 24 } | 24 } |
| 25 | 25 |
| 26 id<GREYMatcher> webViewScrollView() { | 26 id<GREYMatcher> webViewScrollView() { |
| 27 return [GREYMatchers matcherForWebViewScrollView]; | 27 return [GREYMatchers matcherForWebViewScrollView]; |
| 28 } | 28 } |
| 29 | 29 |
| 30 id<GREYMatcher> webViewMimeType(const std::string& mime_type) { |
| 31 return [GREYMatchers matcherForWebViewMIMETYPE:mime_type]; |
| 32 } |
| 33 |
| 30 id<GREYMatcher> addressFieldText(const std::string& text) { | 34 id<GREYMatcher> addressFieldText(const std::string& text) { |
| 31 return [GREYMatchers matcherForAddressFieldEqualToText:text]; | 35 return [GREYMatchers matcherForAddressFieldEqualToText:text]; |
| 32 } | 36 } |
| 33 | 37 |
| 34 id<GREYMatcher> backButton() { | 38 id<GREYMatcher> backButton() { |
| 35 return [GREYMatchers matcherForWebShellBackButton]; | 39 return [GREYMatchers matcherForWebShellBackButton]; |
| 36 } | 40 } |
| 37 | 41 |
| 38 id<GREYMatcher> forwardButton() { | 42 id<GREYMatcher> forwardButton() { |
| 39 return [GREYMatchers matcherForWebShellForwardButton]; | 43 return [GREYMatchers matcherForWebShellForwardButton]; |
| (...skipping 14 matching lines...) Expand all Loading... |
| 54 | 58 |
| 55 + (id<GREYMatcher>)matcherForWebWithCSSSelector:(const std::string&)selector { | 59 + (id<GREYMatcher>)matcherForWebWithCSSSelector:(const std::string&)selector { |
| 56 web::WebState* webState = web::shell_test_util::GetCurrentWebState(); | 60 web::WebState* webState = web::shell_test_util::GetCurrentWebState(); |
| 57 return web::webViewCssSelector(selector, webState); | 61 return web::webViewCssSelector(selector, webState); |
| 58 } | 62 } |
| 59 | 63 |
| 60 + (id<GREYMatcher>)matcherForWebViewScrollView { | 64 + (id<GREYMatcher>)matcherForWebViewScrollView { |
| 61 return web::webViewScrollView(web::shell_test_util::GetCurrentWebState()); | 65 return web::webViewScrollView(web::shell_test_util::GetCurrentWebState()); |
| 62 } | 66 } |
| 63 | 67 |
| 68 + (id<GREYMatcher>)matcherForWebViewMIMEType:(const std::string&)MIMEType { |
| 69 web::WebState* webState = web::shell_test_util::GetCurrentWebState(); |
| 70 return web::webViewMimeType(MIMEType, webState); |
| 71 } |
| 72 |
| 64 + (id<GREYMatcher>)matcherForAddressFieldEqualToText:(const std::string&)text { | 73 + (id<GREYMatcher>)matcherForAddressFieldEqualToText:(const std::string&)text { |
| 65 MatchesBlock matches = ^BOOL(UIView* view) { | 74 MatchesBlock matches = ^BOOL(UIView* view) { |
| 66 if (![view isKindOfClass:[UITextField class]]) { | 75 if (![view isKindOfClass:[UITextField class]]) { |
| 67 return NO; | 76 return NO; |
| 68 } | 77 } |
| 69 if (![[view accessibilityLabel] | 78 if (![[view accessibilityLabel] |
| 70 isEqualToString:kWebShellAddressFieldAccessibilityLabel]) { | 79 isEqualToString:kWebShellAddressFieldAccessibilityLabel]) { |
| 71 return NO; | 80 return NO; |
| 72 } | 81 } |
| 73 UITextField* textField = base::mac::ObjCCastStrict<UITextField>(view); | 82 UITextField* textField = base::mac::ObjCCastStrict<UITextField>(view); |
| (...skipping 19 matching lines...) Expand all Loading... |
| 93 | 102 |
| 94 + (id<GREYMatcher>)matcherForWebShellForwardButton { | 103 + (id<GREYMatcher>)matcherForWebShellForwardButton { |
| 95 return grey_accessibilityLabel(kWebShellForwardButtonAccessibilityLabel); | 104 return grey_accessibilityLabel(kWebShellForwardButtonAccessibilityLabel); |
| 96 } | 105 } |
| 97 | 106 |
| 98 + (id<GREYMatcher>)matcherForWebShellAddressField { | 107 + (id<GREYMatcher>)matcherForWebShellAddressField { |
| 99 return grey_accessibilityLabel(kWebShellAddressFieldAccessibilityLabel); | 108 return grey_accessibilityLabel(kWebShellAddressFieldAccessibilityLabel); |
| 100 } | 109 } |
| 101 | 110 |
| 102 @end | 111 @end |
| OLD | NEW |