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

Side by Side Diff: ios/web_view/shell/test/earl_grey/shell_matchers.mm

Issue 2736243003: Add ios_web_view_shell_egtests target and accessibility labels to shell. (Closed)
Patch Set: Created 3 years, 9 months 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 unified diff | Download patch
OLDNEW
(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
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698