Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2016 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/testing/earl_grey/matchers.h" | |
| 6 | |
| 7 namespace testing { | |
| 8 | |
| 9 id<GREYMatcher> contextMenuItemContainingText(NSString* text) { | |
| 10 // Both tablet and phone house context menu views inside an alert controller | |
| 11 // view (on tablet that view is itself inside a popover view). | |
| 12 id<GREYMatcher> context_menu_container = | |
| 13 grey_kindOfClass(NSClassFromString(@"_UIAlertControllerView")); | |
| 14 | |
| 15 return grey_allOf(grey_ancestor(context_menu_container), | |
| 16 grey_interactable(), | |
| 17 grey_text(text), | |
| 18 nil); | |
| 19 } | |
| 20 | |
| 21 id<GREYMatcher> elementToDismissContextMenu() { | |
| 22 UIUserInterfaceIdiom idiom = [[UIDevice currentDevice] userInterfaceIdiom]; | |
| 23 if (idiom == UIUserInterfaceIdiomPad) { | |
| 24 // On iPad the context menu is dismissed by tapping on something | |
| 25 // that isn't the popover. The web controller container view is an easy | |
| 26 // choice, although it needs to be not-underneath the popover. | |
| 27 id<GREYMatcher> popover = | |
| 28 grey_kindOfClass(NSClassFromString(@"_UIPopoverView")); | |
| 29 return grey_allOf(grey_not(grey_ancestor(popover)), | |
| 30 grey_kindOfClass( | |
| 31 NSClassFromString(@"CRWWebControllerContainerView")), | |
|
Eugene But (OOO till 7-30)
2016/08/30 18:11:04
CRWWebControllerContainerView is a private web cla
baxley
2016/08/31 04:25:43
nit: grey_allOf is more efficient if the matchers
marq (ping after 24h)
2016/08/31 13:07:57
Done.
marq (ping after 24h)
2016/08/31 13:07:57
Yep, turns out UIKit makes this very easy by label
| |
| 32 nil); | |
| 33 } else { | |
| 34 // On iPhone the context menu is dismissed by tapping on the "Cancel" item. | |
| 35 return contextMenuItemContainingText(@"Cancel"); | |
|
Eugene But (OOO till 7-30)
2016/08/30 18:11:04
Can this string be localized somehow?
marq (ping after 24h)
2016/08/31 13:07:57
Yes, now callers pass in a string; if they use loc
| |
| 36 } | |
| 37 } | |
| 38 | |
| 39 } // namespace testing | |
| 40 | |
| OLD | NEW |