| 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> webViewScrollView() { |
| 23 return [GREYMatchers matcherForWebViewScrollView]; |
| 24 } |
| 25 |
| 22 id<GREYMatcher> addressFieldText(const std::string& text) { | 26 id<GREYMatcher> addressFieldText(const std::string& text) { |
| 23 return [GREYMatchers matcherForAddressFieldEqualToText:text]; | 27 return [GREYMatchers matcherForAddressFieldEqualToText:text]; |
| 24 } | 28 } |
| 25 | 29 |
| 26 id<GREYMatcher> backButton() { | 30 id<GREYMatcher> backButton() { |
| 27 return [GREYMatchers matcherForWebShellBackButton]; | 31 return [GREYMatchers matcherForWebShellBackButton]; |
| 28 } | 32 } |
| 29 | 33 |
| 30 id<GREYMatcher> forwardButton() { | 34 id<GREYMatcher> forwardButton() { |
| 31 return [GREYMatchers matcherForWebShellForwardButton]; | 35 return [GREYMatchers matcherForWebShellForwardButton]; |
| 32 } | 36 } |
| 33 | 37 |
| 34 id<GREYMatcher> addressField() { | 38 id<GREYMatcher> addressField() { |
| 35 return [GREYMatchers matcherForWebShellAddressField]; | 39 return [GREYMatchers matcherForWebShellAddressField]; |
| 36 } | 40 } |
| 37 | 41 |
| 38 } // namespace web | 42 } // namespace web |
| 39 | 43 |
| 40 @implementation GREYMatchers (WebShellAdditions) | 44 @implementation GREYMatchers (WebShellAdditions) |
| 41 | 45 |
| 42 + (id<GREYMatcher>)matcherForWebViewContainingText:(const std::string&)text { | 46 + (id<GREYMatcher>)matcherForWebViewContainingText:(const std::string&)text { |
| 43 web::WebState* webState = web::shell_test_util::GetCurrentWebState(); | 47 web::WebState* webState = web::shell_test_util::GetCurrentWebState(); |
| 44 return web::webViewContainingText(text, webState); | 48 return web::webViewContainingText(text, webState); |
| 45 } | 49 } |
| 46 | 50 |
| 51 + (id<GREYMatcher>)matcherForWebViewScrollView { |
| 52 return web::webViewScrollView(web::shell_test_util::GetCurrentWebState()); |
| 53 } |
| 54 |
| 47 + (id<GREYMatcher>)matcherForAddressFieldEqualToText:(const std::string&)text { | 55 + (id<GREYMatcher>)matcherForAddressFieldEqualToText:(const std::string&)text { |
| 48 MatchesBlock matches = ^BOOL(UIView* view) { | 56 MatchesBlock matches = ^BOOL(UIView* view) { |
| 49 if (![view isKindOfClass:[UITextField class]]) { | 57 if (![view isKindOfClass:[UITextField class]]) { |
| 50 return NO; | 58 return NO; |
| 51 } | 59 } |
| 52 if (![[view accessibilityLabel] | 60 if (![[view accessibilityLabel] |
| 53 isEqualToString:kWebShellAddressFieldAccessibilityLabel]) { | 61 isEqualToString:kWebShellAddressFieldAccessibilityLabel]) { |
| 54 return NO; | 62 return NO; |
| 55 } | 63 } |
| 56 UITextField* textField = base::mac::ObjCCastStrict<UITextField>(view); | 64 UITextField* textField = base::mac::ObjCCastStrict<UITextField>(view); |
| (...skipping 19 matching lines...) Expand all Loading... |
| 76 | 84 |
| 77 + (id<GREYMatcher>)matcherForWebShellForwardButton { | 85 + (id<GREYMatcher>)matcherForWebShellForwardButton { |
| 78 return grey_accessibilityLabel(kWebShellForwardButtonAccessibilityLabel); | 86 return grey_accessibilityLabel(kWebShellForwardButtonAccessibilityLabel); |
| 79 } | 87 } |
| 80 | 88 |
| 81 + (id<GREYMatcher>)matcherForWebShellAddressField { | 89 + (id<GREYMatcher>)matcherForWebShellAddressField { |
| 82 return grey_accessibilityLabel(kWebShellAddressFieldAccessibilityLabel); | 90 return grey_accessibilityLabel(kWebShellAddressFieldAccessibilityLabel); |
| 83 } | 91 } |
| 84 | 92 |
| 85 @end | 93 @end |
| OLD | NEW |