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

Unified Diff: ios/chrome/test/earl_grey/chrome_earl_grey_ui.mm

Issue 2867553002: Make settings_egtest.mm work in landscape on small phones. (Closed)
Patch Set: comment cleanup Created 3 years, 7 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/chrome/test/earl_grey/chrome_earl_grey_ui.mm
diff --git a/ios/chrome/test/earl_grey/chrome_earl_grey_ui.mm b/ios/chrome/test/earl_grey/chrome_earl_grey_ui.mm
index ef0722b5e2401a44b886c718d8783f9e9507b8b1..53fde59bef3cbeca78f1878deae68bc999350fdb 100644
--- a/ios/chrome/test/earl_grey/chrome_earl_grey_ui.mm
+++ b/ios/chrome/test/earl_grey/chrome_earl_grey_ui.mm
@@ -4,6 +4,9 @@
#import "ios/chrome/test/earl_grey/chrome_earl_grey_ui.h"
+#import "ios/chrome/browser/ui/settings/clear_browsing_data_collection_view_controller.h"
+#import "ios/chrome/browser/ui/settings/privacy_collection_view_controller.h"
+#import "ios/chrome/browser/ui/settings/settings_collection_view_controller.h"
#import "ios/chrome/browser/ui/tools_menu/tools_menu_constants.h"
#import "ios/chrome/browser/ui/tools_menu/tools_popup_controller.h"
#import "ios/chrome/browser/ui/uikit_ui_util.h"
@@ -18,9 +21,23 @@
#error "This file requires ARC support."
#endif
+using chrome_test_util::ButtonWithAccessibilityLabel;
using testing::WaitUntilConditionOrTimeout;
using testing::kWaitForPageLoadTimeout;
+namespace {
+
+// Returns a GREYAction to scroll down (swipe up) for a reasonably small amount.
+id<GREYAction> ScrollDown() {
+ // 150 is a reasonable value to ensure all menu items are seen, without too
+ // much delay. With a larger value, some menu items could be skipped while
+ // searching. A smaller value increses the area that is searched, but slows
+ // down the scroll.
+ CGFloat const kMenuScrollDisplacement = 150;
+ return grey_scrollInDirection(kGREYDirectionDown, kMenuScrollDisplacement);
+}
+} // namespace
+
@implementation ChromeEarlGreyUI
+ (void)openToolsMenu {
@@ -47,12 +64,41 @@ using testing::kWaitForPageLoadTimeout;
+ (void)openSettingsMenu {
[ChromeEarlGreyUI openToolsMenu];
- id<GREYMatcher> toolsMenuTableViewMatcher =
- grey_accessibilityID(kToolsMenuTableViewId);
- [[[EarlGrey
- selectElementWithMatcher:grey_accessibilityID(kToolsMenuSettingsId)]
- usingSearchAction:grey_scrollToContentEdge(kGREYContentEdgeBottom)
- onElementWithMatcher:toolsMenuTableViewMatcher] performAction:grey_tap()];
+ id<GREYMatcher> interactableSettingsButton = grey_allOf(
Eugene But (OOO till 7-30) 2017/05/09 00:15:04 nit: Do you want to make a function for this match
baxley 2017/05/09 18:39:19 I created a function for SettingsButton, but not t
+ grey_accessibilityID(kToolsMenuSettingsId), grey_interactable(), nil);
+ [[[EarlGrey selectElementWithMatcher:interactableSettingsButton]
+ usingSearchAction:ScrollDown()
+ onElementWithMatcher:grey_accessibilityID(kToolsMenuTableViewId)]
+ performAction:grey_tap()];
+}
+
++ (void)tapButtonInSettingsMenu:(id<GREYMatcher>)buttonMatcher {
+ id<GREYMatcher> interactableButtonMatcher =
+ grey_allOf(buttonMatcher, grey_interactable(), nil);
+ [[[EarlGrey selectElementWithMatcher:interactableButtonMatcher]
+ usingSearchAction:ScrollDown()
+ onElementWithMatcher:grey_accessibilityID(kSettingsCollectionViewId)]
+ performAction:grey_tap()];
+}
+
++ (void)tapButtonInClearBrowsingDataMenu:(id<GREYMatcher>)buttonMatcher {
+ id<GREYMatcher> clearBrowsingDataViewMatcher =
Eugene But (OOO till 7-30) 2017/05/09 00:15:03 ditto
baxley 2017/05/09 18:39:19 Done.
+ grey_accessibilityID(kClearBrowsingDataCollectionViewId);
+ id<GREYMatcher> interactableButtonMatcher =
+ grey_allOf(buttonMatcher, grey_interactable(), nil);
+ [[[EarlGrey selectElementWithMatcher:interactableButtonMatcher]
+ usingSearchAction:ScrollDown()
+ onElementWithMatcher:clearBrowsingDataViewMatcher]
+ performAction:grey_tap()];
+}
+
++ (void)tapButtonInPrivacyMenu:(id<GREYMatcher>)buttonMatcher {
+ id<GREYMatcher> interactableButtonMatcher =
+ grey_allOf(buttonMatcher, grey_interactable(), nil);
+ [[[EarlGrey selectElementWithMatcher:interactableButtonMatcher]
+ usingSearchAction:ScrollDown()
+ onElementWithMatcher:grey_accessibilityID(kPrivacyCollectionViewId)]
+ performAction:grey_tap()];
}
+ (void)openNewTab {

Powered by Google App Engine
This is Rietveld 408576698