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

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

Issue 2736243003: Add ios_web_view_shell_egtests target and accessibility labels to shell. (Closed)
Patch Set: rename matchers file. 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/web_view_shell_matchers.h"
6
7 #include "base/mac/foundation_util.h"
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 bool success = testing::WaitUntilConditionOrTimeout(
33 testing::kWaitForUIElementTimeout, ^{
34 return base::SysNSStringToUTF8(text_field.text) == text;
35 });
36 GREYAssert(success, error_message);
37 return YES;
38 };
39
40 DescribeToBlock describe = ^(id<GREYDescription> description) {
41 [description appendText:@"address field containing "];
42 [description appendText:base::SysUTF8ToNSString(text)];
43 };
44
45 return [[GREYElementMatcherBlock alloc] initWithMatchesBlock:matches
46 descriptionBlock:describe];
47 }
48
49 id<GREYMatcher> BackButton() {
50 return grey_accessibilityLabel(kWebViewShellBackButtonAccessibilityLabel);
51 }
52
53 id<GREYMatcher> ForwardButton() {
54 return grey_accessibilityLabel(kWebViewShellForwardButtonAccessibilityLabel);
55 }
56
57 id<GREYMatcher> AddressField() {
58 return grey_accessibilityLabel(kWebViewShellAddressFieldAccessibilityLabel);
59 }
60
61 } // namespace ios_web_view
OLDNEW
« no previous file with comments | « ios/web_view/shell/test/earl_grey/web_view_shell_matchers.h ('k') | ios/web_view/shell/test/shell_egtest.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698