Commit 25d72b08 authored by Mike Baxley's avatar Mike Baxley Committed by Commit Bot

Create helper EarlGrey method to tap Tools sub-menu.

Update call sites that were manually scrolling to find Tools
menu items to use this new shared method.

Bug: 638674
Cq-Include-Trybots: master.tryserver.chromium.mac:ios-simulator-cronet;master.tryserver.chromium.mac:ios-simulator-full-configs
Change-Id: I144e8c5872ae350e2697f8da474bfd110ae145cb
Reviewed-on: https://chromium-review.googlesource.com/779040Reviewed-by: default avatarEugene But <eugenebut@chromium.org>
Reviewed-by: default avatarMike Baxley <baxley@chromium.org>
Commit-Queue: Mike Baxley <baxley@chromium.org>
Cr-Commit-Position: refs/heads/master@{#517875}
parent 8eccc8c7
......@@ -30,8 +30,6 @@
using chrome_test_util::NavigationBarDoneButton;
const CGFloat kScrollDisplacement = 50.0;
// Test cases to verify that keyboard commands are and are not registered when
// expected.
@interface KeyboardCommandsTestCase : ChromeTestCase
......@@ -95,18 +93,6 @@ const CGFloat kScrollDisplacement = 50.0;
GREYAssert(success, @"The bookmark editor was not displayed.");
}
// Open tools menu, find and tap on item specified by |toolsMenuItem| matcher.
// TODO(crbug.com/638674): Evaluate if this can move to shared code.
- (void)selectToolsMenuItem:(id<GREYMatcher>)toolsMenuItem {
[ChromeEarlGreyUI openToolsMenu];
id<GREYMatcher> toolsMenuTableView = chrome_test_util::ToolsMenuView();
[[[EarlGrey selectElementWithMatcher:toolsMenuItem]
usingSearchAction:grey_scrollInDirection(kGREYDirectionDown,
kScrollDisplacement)
onElementWithMatcher:toolsMenuTableView] performAction:grey_tap()];
}
#pragma mark - Tests
// Tests that keyboard commands are registered when the BVC is showing without
......@@ -166,7 +152,9 @@ const CGFloat kScrollDisplacement = 50.0;
scoped_feature_list.InitAndDisableFeature(kBookmarkNewGeneration);
// Open Bookmarks
[self selectToolsMenuItem:grey_accessibilityID(kToolsMenuBookmarksId)];
[ChromeEarlGreyUI openToolsMenu];
[ChromeEarlGreyUI
tapToolsMenuButton:grey_accessibilityID(kToolsMenuBookmarksId)];
if (IsIPadIdiom()) {
[self verifyKeyboardCommandsAreRegistered];
......@@ -183,7 +171,8 @@ const CGFloat kScrollDisplacement = 50.0;
- (void)testKeyboardCommands_RecentTabsPresented {
// Open Recent Tabs
id<GREYMatcher> recentTabs = grey_accessibilityID(kToolsMenuOtherDevicesId);
[self selectToolsMenuItem:recentTabs];
[ChromeEarlGreyUI openToolsMenu];
[ChromeEarlGreyUI tapToolsMenuButton:recentTabs];
if (IsIPadIdiom()) {
[self verifyKeyboardCommandsAreRegistered];
......
......@@ -475,14 +475,9 @@ void WaitForMatcher(id<GREYMatcher> matcher) {
identity);
// Open Bookmarks and tap on Sign In promo button.
const CGFloat scroll_displacement = 50.0;
[ChromeEarlGreyUI openToolsMenu];
[[[EarlGrey
selectElementWithMatcher:grey_accessibilityID(kToolsMenuBookmarksId)]
usingSearchAction:grey_scrollInDirection(kGREYDirectionDown,
scroll_displacement)
onElementWithMatcher:chrome_test_util::ToolsMenuView()]
performAction:grey_tap()];
[ChromeEarlGreyUI
tapToolsMenuButton:grey_accessibilityID(kToolsMenuBookmarksId)];
if (!IsIPadIdiom()) {
// Opens the bookmark manager sidebar on handsets.
......@@ -514,12 +509,8 @@ void WaitForMatcher(id<GREYMatcher> matcher) {
// Re-open the sign-in screen. If it wasn't correctly dismissed previously,
// this will fail.
[ChromeEarlGreyUI openToolsMenu];
[[[EarlGrey
selectElementWithMatcher:grey_accessibilityID(kToolsMenuBookmarksId)]
usingSearchAction:grey_scrollInDirection(kGREYDirectionDown,
scroll_displacement)
onElementWithMatcher:chrome_test_util::ToolsMenuView()]
performAction:grey_tap()];
[ChromeEarlGreyUI
tapToolsMenuButton:grey_accessibilityID(kToolsMenuBookmarksId)];
if (!IsIPadIdiom()) {
[[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"Menu")]
performAction:grey_tap()];
......
......@@ -22,6 +22,11 @@
// calling this method.
+ (void)openSettingsMenu;
// Scrolls to find the button in the Tools menu with the corresponding
// |buttonMatcher|, and then taps it. If |buttonMatcher| is not found, or
// the Tools menu is not open when this is called there will be a GREYAssert.
+ (void)tapToolsMenuButton:(id<GREYMatcher>)buttonMatcher;
// Scrolls to find the button in the Settings menu with the corresponding
// |buttonMatcher|, and then taps it. If |buttonMatcher| is not found, or
// the Settings menu is not open when this is called there will be a GREYAssert.
......
......@@ -29,6 +29,7 @@ using chrome_test_util::AccountConsistencySetupSigninButton;
using chrome_test_util::ButtonWithAccessibilityLabel;
using chrome_test_util::ClearBrowsingDataCollectionView;
using chrome_test_util::SettingsMenuButton;
using chrome_test_util::ToolsMenuView;
using testing::WaitUntilConditionOrTimeout;
using testing::kWaitForPageLoadTimeout;
......@@ -71,12 +72,15 @@ id<GREYAction> ScrollDown() {
+ (void)openSettingsMenu {
[ChromeEarlGreyUI openToolsMenu];
[ChromeEarlGreyUI tapToolsMenuButton:SettingsMenuButton()];
}
+ (void)tapToolsMenuButton:(id<GREYMatcher>)buttonMatcher {
id<GREYMatcher> interactableSettingsButton =
grey_allOf(SettingsMenuButton(), grey_interactable(), nil);
grey_allOf(buttonMatcher, grey_interactable(), nil);
[[[EarlGrey selectElementWithMatcher:interactableSettingsButton]
usingSearchAction:ScrollDown()
onElementWithMatcher:grey_accessibilityID(kToolsMenuTableViewId)]
performAction:grey_tap()];
onElementWithMatcher:ToolsMenuView()] performAction:grey_tap()];
}
+ (void)tapSettingsMenuButton:(id<GREYMatcher>)buttonMatcher {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment