OLD | NEW |
---|---|
(Empty) | |
1 // Copyright 2017 The Chromium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 #import "ios/web_view/shell/test/earl_grey/shell_matchers.h" | |
6 | |
7 #import "base/mac/foundation_util.h" | |
Eugene But (OOO till 7-30)
2017/03/08 21:42:44
Do we need this? If so, then it should be include,
michaeldo
2017/03/08 21:58:31
Done.
| |
8 #include "base/strings/sys_string_conversions.h" | |
9 #import "ios/testing/wait_util.h" | |
10 #import "ios/web_view/shell/shell_view_controller.h" | |
11 | |
12 #if !defined(__has_feature) || !__has_feature(objc_arc) | |
13 #error "This file requires ARC support." | |
14 #endif | |
15 | |
16 namespace ios_web_view { | |
17 | |
18 id<GREYMatcher> AddressFieldText(const std::string& text) { | |
19 MatchesBlock matches = ^BOOL(UIView* view) { | |
20 if (![view isKindOfClass:[UITextField class]]) { | |
21 return NO; | |
22 } | |
23 if (![[view accessibilityLabel] | |
24 isEqualToString:kWebViewShellAddressFieldAccessibilityLabel]) { | |
25 return NO; | |
26 } | |
27 UITextField* text_field = base::mac::ObjCCastStrict<UITextField>(view); | |
28 NSString* error_message = [NSString | |
29 stringWithFormat: | |
30 @"Address field text did not match. expected: %@, actual: %@", | |
31 base::SysUTF8ToNSString(text), text_field.text]; | |
32 GREYAssert(testing::WaitUntilConditionOrTimeout( | |
33 testing::kWaitForUIElementTimeout, | |
Eugene But (OOO till 7-30)
2017/03/08 21:42:44
Do you want to use local variables to improve form
michaeldo
2017/03/08 21:58:31
Done.
| |
34 ^{ | |
35 return base::SysNSStringToUTF8(text_field.text) == text; | |
36 }), | |
37 error_message); | |
38 return YES; | |
39 }; | |
40 | |
41 DescribeToBlock describe = ^(id<GREYDescription> description) { | |
42 [description appendText:@"address field containing "]; | |
43 [description appendText:base::SysUTF8ToNSString(text)]; | |
44 }; | |
45 | |
46 return [[GREYElementMatcherBlock alloc] initWithMatchesBlock:matches | |
47 descriptionBlock:describe]; | |
48 } | |
49 | |
50 id<GREYMatcher> BackButton() { | |
51 return grey_accessibilityLabel(kWebViewShellBackButtonAccessibilityLabel); | |
52 } | |
53 | |
54 id<GREYMatcher> ForwardButton() { | |
55 return grey_accessibilityLabel(kWebViewShellForwardButtonAccessibilityLabel); | |
56 } | |
57 | |
58 id<GREYMatcher> AddressField() { | |
59 return grey_accessibilityLabel(kWebViewShellAddressFieldAccessibilityLabel); | |
60 } | |
61 | |
62 } // namespace ios_web_view | |
OLD | NEW |