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

Unified Diff: ios/testing/earl_grey/matchers.mm

Issue 2275303004: Context menu egtests, plus related utilities. (Closed)
Patch Set: Fewer References. Created 4 years, 4 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
« no previous file with comments | « ios/testing/earl_grey/matchers.h ('k') | ios/web/BUILD.gn » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ios/testing/earl_grey/matchers.mm
diff --git a/ios/testing/earl_grey/matchers.mm b/ios/testing/earl_grey/matchers.mm
new file mode 100644
index 0000000000000000000000000000000000000000..6138ab3e09c1f9297e869da659f65f56aaf8f3c6
--- /dev/null
+++ b/ios/testing/earl_grey/matchers.mm
@@ -0,0 +1,31 @@
+// Copyright 2016 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/testing/earl_grey/matchers.h"
+
+namespace testing {
+
+id<GREYMatcher> contextMenuItemWithText(NSString* text) {
+ // Both tablet and phone house context menu views inside an alert controller
+ // view (on tablet that view is itself inside a popover view).
+ id<GREYMatcher> context_menu_container =
+ grey_kindOfClass(NSClassFromString(@"_UIAlertControllerView"));
+
+ return grey_allOf(grey_ancestor(context_menu_container), grey_interactable(),
+ grey_text(text), nil);
+}
+
+id<GREYMatcher> elementToDismissContextMenu(NSString* cancel_text) {
+ UIUserInterfaceIdiom idiom = [[UIDevice currentDevice] userInterfaceIdiom];
+ if (idiom == UIUserInterfaceIdiomPad) {
+ // On iPad the context menu is dismissed by tapping on something
+ // that isn't the popover. UIKit conveniently labels this element.
+ return grey_accessibilityID(@"PopoverDismissRegion");
+ } else {
+ // On iPhone the context menu is dismissed by tapping on the "Cancel" item.
+ return contextMenuItemWithText(cancel_text);
+ }
+}
+
+} // namespace testing
« no previous file with comments | « ios/testing/earl_grey/matchers.h ('k') | ios/web/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698