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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: ios/web_view/shell/test/earl_grey/web_view_shell_matchers.mm
diff --git a/ios/web_view/shell/test/earl_grey/web_view_shell_matchers.mm b/ios/web_view/shell/test/earl_grey/web_view_shell_matchers.mm
new file mode 100644
index 0000000000000000000000000000000000000000..466bc22efc8165b0a4227732a3eff11fefa04b18
--- /dev/null
+++ b/ios/web_view/shell/test/earl_grey/web_view_shell_matchers.mm
@@ -0,0 +1,61 @@
+// Copyright 2017 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#import "ios/web_view/shell/test/earl_grey/web_view_shell_matchers.h"
+
+#include "base/mac/foundation_util.h"
+#include "base/strings/sys_string_conversions.h"
+#import "ios/testing/wait_util.h"
+#import "ios/web_view/shell/shell_view_controller.h"
+
+#if !defined(__has_feature) || !__has_feature(objc_arc)
+#error "This file requires ARC support."
+#endif
+
+namespace ios_web_view {
+
+id<GREYMatcher> AddressFieldText(const std::string& text) {
+ MatchesBlock matches = ^BOOL(UIView* view) {
+ if (![view isKindOfClass:[UITextField class]]) {
+ return NO;
+ }
+ if (![[view accessibilityLabel]
+ isEqualToString:kWebViewShellAddressFieldAccessibilityLabel]) {
+ return NO;
+ }
+ UITextField* text_field = base::mac::ObjCCastStrict<UITextField>(view);
+ NSString* error_message = [NSString
+ stringWithFormat:
+ @"Address field text did not match. expected: %@, actual: %@",
+ base::SysUTF8ToNSString(text), text_field.text];
+ bool success = testing::WaitUntilConditionOrTimeout(
+ testing::kWaitForUIElementTimeout, ^{
+ return base::SysNSStringToUTF8(text_field.text) == text;
+ });
+ GREYAssert(success, error_message);
+ return YES;
+ };
+
+ DescribeToBlock describe = ^(id<GREYDescription> description) {
+ [description appendText:@"address field containing "];
+ [description appendText:base::SysUTF8ToNSString(text)];
+ };
+
+ return [[GREYElementMatcherBlock alloc] initWithMatchesBlock:matches
+ descriptionBlock:describe];
+}
+
+id<GREYMatcher> BackButton() {
+ return grey_accessibilityLabel(kWebViewShellBackButtonAccessibilityLabel);
+}
+
+id<GREYMatcher> ForwardButton() {
+ return grey_accessibilityLabel(kWebViewShellForwardButtonAccessibilityLabel);
+}
+
+id<GREYMatcher> AddressField() {
+ return grey_accessibilityLabel(kWebViewShellAddressFieldAccessibilityLabel);
+}
+
+} // namespace ios_web_view
« 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