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 @@ ...@@ -30,8 +30,6 @@
using chrome_test_util::NavigationBarDoneButton; using chrome_test_util::NavigationBarDoneButton;
const CGFloat kScrollDisplacement = 50.0;
// Test cases to verify that keyboard commands are and are not registered when // Test cases to verify that keyboard commands are and are not registered when
// expected. // expected.
@interface KeyboardCommandsTestCase : ChromeTestCase @interface KeyboardCommandsTestCase : ChromeTestCase
...@@ -95,18 +93,6 @@ const CGFloat kScrollDisplacement = 50.0; ...@@ -95,18 +93,6 @@ const CGFloat kScrollDisplacement = 50.0;
GREYAssert(success, @"The bookmark editor was not displayed."); 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 #pragma mark - Tests
// Tests that keyboard commands are registered when the BVC is showing without // Tests that keyboard commands are registered when the BVC is showing without
...@@ -166,7 +152,9 @@ const CGFloat kScrollDisplacement = 50.0; ...@@ -166,7 +152,9 @@ const CGFloat kScrollDisplacement = 50.0;
scoped_feature_list.InitAndDisableFeature(kBookmarkNewGeneration); scoped_feature_list.InitAndDisableFeature(kBookmarkNewGeneration);
// Open Bookmarks // Open Bookmarks
[self selectToolsMenuItem:grey_accessibilityID(kToolsMenuBookmarksId)]; [ChromeEarlGreyUI openToolsMenu];
[ChromeEarlGreyUI
tapToolsMenuButton:grey_accessibilityID(kToolsMenuBookmarksId)];
if (IsIPadIdiom()) { if (IsIPadIdiom()) {
[self verifyKeyboardCommandsAreRegistered]; [self verifyKeyboardCommandsAreRegistered];
...@@ -183,7 +171,8 @@ const CGFloat kScrollDisplacement = 50.0; ...@@ -183,7 +171,8 @@ const CGFloat kScrollDisplacement = 50.0;
- (void)testKeyboardCommands_RecentTabsPresented { - (void)testKeyboardCommands_RecentTabsPresented {
// Open Recent Tabs // Open Recent Tabs
id<GREYMatcher> recentTabs = grey_accessibilityID(kToolsMenuOtherDevicesId); id<GREYMatcher> recentTabs = grey_accessibilityID(kToolsMenuOtherDevicesId);
[self selectToolsMenuItem:recentTabs]; [ChromeEarlGreyUI openToolsMenu];
[ChromeEarlGreyUI tapToolsMenuButton:recentTabs];
if (IsIPadIdiom()) { if (IsIPadIdiom()) {
[self verifyKeyboardCommandsAreRegistered]; [self verifyKeyboardCommandsAreRegistered];
......
...@@ -475,14 +475,9 @@ void WaitForMatcher(id<GREYMatcher> matcher) { ...@@ -475,14 +475,9 @@ void WaitForMatcher(id<GREYMatcher> matcher) {
identity); identity);
// Open Bookmarks and tap on Sign In promo button. // Open Bookmarks and tap on Sign In promo button.
const CGFloat scroll_displacement = 50.0;
[ChromeEarlGreyUI openToolsMenu]; [ChromeEarlGreyUI openToolsMenu];
[[[EarlGrey [ChromeEarlGreyUI
selectElementWithMatcher:grey_accessibilityID(kToolsMenuBookmarksId)] tapToolsMenuButton:grey_accessibilityID(kToolsMenuBookmarksId)];
usingSearchAction:grey_scrollInDirection(kGREYDirectionDown,
scroll_displacement)
onElementWithMatcher:chrome_test_util::ToolsMenuView()]
performAction:grey_tap()];
if (!IsIPadIdiom()) { if (!IsIPadIdiom()) {
// Opens the bookmark manager sidebar on handsets. // Opens the bookmark manager sidebar on handsets.
...@@ -514,12 +509,8 @@ void WaitForMatcher(id<GREYMatcher> matcher) { ...@@ -514,12 +509,8 @@ void WaitForMatcher(id<GREYMatcher> matcher) {
// Re-open the sign-in screen. If it wasn't correctly dismissed previously, // Re-open the sign-in screen. If it wasn't correctly dismissed previously,
// this will fail. // this will fail.
[ChromeEarlGreyUI openToolsMenu]; [ChromeEarlGreyUI openToolsMenu];
[[[EarlGrey [ChromeEarlGreyUI
selectElementWithMatcher:grey_accessibilityID(kToolsMenuBookmarksId)] tapToolsMenuButton:grey_accessibilityID(kToolsMenuBookmarksId)];
usingSearchAction:grey_scrollInDirection(kGREYDirectionDown,
scroll_displacement)
onElementWithMatcher:chrome_test_util::ToolsMenuView()]
performAction:grey_tap()];
if (!IsIPadIdiom()) { if (!IsIPadIdiom()) {
[[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"Menu")] [[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"Menu")]
performAction:grey_tap()]; performAction:grey_tap()];
......
...@@ -22,6 +22,11 @@ ...@@ -22,6 +22,11 @@
// calling this method. // calling this method.
+ (void)openSettingsMenu; + (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 // Scrolls to find the button in the Settings menu with the corresponding
// |buttonMatcher|, and then taps it. If |buttonMatcher| is not found, or // |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. // the Settings menu is not open when this is called there will be a GREYAssert.
......
...@@ -29,6 +29,7 @@ using chrome_test_util::AccountConsistencySetupSigninButton; ...@@ -29,6 +29,7 @@ using chrome_test_util::AccountConsistencySetupSigninButton;
using chrome_test_util::ButtonWithAccessibilityLabel; using chrome_test_util::ButtonWithAccessibilityLabel;
using chrome_test_util::ClearBrowsingDataCollectionView; using chrome_test_util::ClearBrowsingDataCollectionView;
using chrome_test_util::SettingsMenuButton; using chrome_test_util::SettingsMenuButton;
using chrome_test_util::ToolsMenuView;
using testing::WaitUntilConditionOrTimeout; using testing::WaitUntilConditionOrTimeout;
using testing::kWaitForPageLoadTimeout; using testing::kWaitForPageLoadTimeout;
...@@ -71,12 +72,15 @@ id<GREYAction> ScrollDown() { ...@@ -71,12 +72,15 @@ id<GREYAction> ScrollDown() {
+ (void)openSettingsMenu { + (void)openSettingsMenu {
[ChromeEarlGreyUI openToolsMenu]; [ChromeEarlGreyUI openToolsMenu];
[ChromeEarlGreyUI tapToolsMenuButton:SettingsMenuButton()];
}
+ (void)tapToolsMenuButton:(id<GREYMatcher>)buttonMatcher {
id<GREYMatcher> interactableSettingsButton = id<GREYMatcher> interactableSettingsButton =
grey_allOf(SettingsMenuButton(), grey_interactable(), nil); grey_allOf(buttonMatcher, grey_interactable(), nil);
[[[EarlGrey selectElementWithMatcher:interactableSettingsButton] [[[EarlGrey selectElementWithMatcher:interactableSettingsButton]
usingSearchAction:ScrollDown() usingSearchAction:ScrollDown()
onElementWithMatcher:grey_accessibilityID(kToolsMenuTableViewId)] onElementWithMatcher:ToolsMenuView()] performAction:grey_tap()];
performAction:grey_tap()];
} }
+ (void)tapSettingsMenuButton:(id<GREYMatcher>)buttonMatcher { + (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