Commit b21880d1 authored by Mike Baxley's avatar Mike Baxley Committed by Commit Bot

Create matchers for Bookmarks and Recent Tabs menu items.

These Tools menu items are used in several tests. Remove the
dependency of tests on tools_menu_constants.h.

Bug: 787015
Cq-Include-Trybots: master.tryserver.chromium.mac:ios-simulator-cronet;master.tryserver.chromium.mac:ios-simulator-full-configs
Change-Id: Ie5d6b180f86d2628737c96feed96245c095d374a
Reviewed-on: https://chromium-review.googlesource.com/780051
Commit-Queue: Mike Baxley <baxley@chromium.org>
Reviewed-by: default avatarMenglu Huang <huangml@chromium.org>
Reviewed-by: default avatarEugene But <eugenebut@chromium.org>
Cr-Commit-Position: refs/heads/master@{#518356}
parent 4527bad8
......@@ -470,7 +470,6 @@ source_set("eg_tests") {
"//ios/chrome/browser/bookmarks:features",
"//ios/chrome/browser/ui/commands",
"//ios/chrome/browser/ui/ntp:ntp_controller",
"//ios/chrome/browser/ui/tools_menu/public",
"//ios/chrome/test/app:test_support",
"//ios/chrome/test/earl_grey:test_support",
"//ios/testing:ios_test_support",
......
......@@ -206,7 +206,6 @@ source_set("eg_tests") {
"//ios/chrome/browser/ui/bookmarks:bookmarks",
"//ios/chrome/browser/ui/commands",
"//ios/chrome/browser/ui/toolbar/public",
"//ios/chrome/browser/ui/tools_menu/public",
"//ios/chrome/test/app:test_support",
"//ios/chrome/test/earl_grey:test_support",
"//ios/public/provider/chrome/browser/signin:test_support",
......
......@@ -22,7 +22,6 @@
#import "ios/chrome/browser/ui/authentication/signin_earlgrey_utils.h"
#import "ios/chrome/browser/ui/authentication/signin_promo_view.h"
#import "ios/chrome/browser/ui/toolbar/public/toolbar_controller_constants.h"
#include "ios/chrome/browser/ui/tools_menu/public/tools_menu_constants.h"
#import "ios/chrome/browser/ui/uikit_ui_util.h"
#include "ios/chrome/grit/ios_strings.h"
#import "ios/chrome/test/app/bookmarks_test_util.h"
......@@ -47,6 +46,7 @@
#error "This file requires ARC support."
#endif
using chrome_test_util::BookmarksMenuButton;
using chrome_test_util::ButtonWithAccessibilityLabel;
using chrome_test_util::ButtonWithAccessibilityLabelId;
using chrome_test_util::PrimarySignInButton;
......@@ -1405,16 +1405,12 @@ id<GREYMatcher> ActionSheet(Action action) {
// Navigates to the bookmark manager UI.
+ (void)openBookmarks {
[ChromeEarlGreyUI openToolsMenu];
// Opens the bookmark manager.
[[EarlGrey
selectElementWithMatcher:grey_accessibilityID(kToolsMenuBookmarksId)]
performAction:grey_tap()];
[ChromeEarlGreyUI openToolsMenu];
[ChromeEarlGreyUI tapToolsMenuButton:BookmarksMenuButton()];
// Wait for it to load, and the menu to go away.
[[EarlGrey
selectElementWithMatcher:grey_accessibilityID(kToolsMenuBookmarksId)]
// Assert the menu is gone.
[[EarlGrey selectElementWithMatcher:BookmarksMenuButton()]
assertWithMatcher:grey_nil()];
}
......
......@@ -21,7 +21,6 @@
#import "ios/chrome/browser/ui/authentication/signin_earlgrey_utils.h"
#import "ios/chrome/browser/ui/authentication/signin_promo_view.h"
#import "ios/chrome/browser/ui/bookmarks/bookmark_utils_ios.h"
#include "ios/chrome/browser/ui/tools_menu/public/tools_menu_constants.h"
#import "ios/chrome/browser/ui/uikit_ui_util.h"
#include "ios/chrome/grit/ios_strings.h"
#import "ios/chrome/test/app/bookmarks_test_util.h"
......@@ -44,6 +43,7 @@
#error "This file requires ARC support."
#endif
using chrome_test_util::BookmarksMenuButton;
using chrome_test_util::ButtonWithAccessibilityLabel;
using chrome_test_util::ButtonWithAccessibilityLabelId;
using chrome_test_util::PrimarySignInButton;
......@@ -2463,16 +2463,12 @@ id<GREYMatcher> TappableBookmarkNodeWithLabel(NSString* label) {
// Navigates to the bookmark manager UI.
+ (void)openBookmarks {
[ChromeEarlGreyUI openToolsMenu];
// Opens the bookmark manager.
[[EarlGrey
selectElementWithMatcher:grey_accessibilityID(kToolsMenuBookmarksId)]
performAction:grey_tap()];
[ChromeEarlGreyUI openToolsMenu];
[ChromeEarlGreyUI tapToolsMenuButton:BookmarksMenuButton()];
// Wait for it to load, and the menu to go away.
[[EarlGrey
selectElementWithMatcher:grey_accessibilityID(kToolsMenuBookmarksId)]
// Assert the menu is gone.
[[EarlGrey selectElementWithMatcher:BookmarksMenuButton()]
assertWithMatcher:grey_nil()];
}
......
......@@ -10,7 +10,6 @@
#include "ios/chrome/browser/bookmarks/bookmark_new_generation_features.h"
#import "ios/chrome/browser/ui/browser_view_controller.h"
#import "ios/chrome/browser/ui/ntp/new_tab_page_controller.h"
#include "ios/chrome/browser/ui/tools_menu/public/tools_menu_constants.h"
#include "ios/chrome/browser/ui/ui_util.h"
#import "ios/chrome/browser/ui/uikit_ui_util.h"
#include "ios/chrome/grit/ios_strings.h"
......@@ -29,6 +28,7 @@
#endif
using chrome_test_util::NavigationBarDoneButton;
using chrome_test_util::RecentTabsMenuButton;
// Test cases to verify that keyboard commands are and are not registered when
// expected.
......@@ -153,8 +153,7 @@ using chrome_test_util::NavigationBarDoneButton;
// Open Bookmarks
[ChromeEarlGreyUI openToolsMenu];
[ChromeEarlGreyUI
tapToolsMenuButton:grey_accessibilityID(kToolsMenuBookmarksId)];
[ChromeEarlGreyUI tapToolsMenuButton:chrome_test_util::BookmarksMenuButton()];
if (IsIPadIdiom()) {
[self verifyKeyboardCommandsAreRegistered];
......@@ -170,9 +169,8 @@ using chrome_test_util::NavigationBarDoneButton;
// shown on iPhone and registered on iPad.
- (void)testKeyboardCommands_RecentTabsPresented {
// Open Recent Tabs
id<GREYMatcher> recentTabs = grey_accessibilityID(kToolsMenuOtherDevicesId);
[ChromeEarlGreyUI openToolsMenu];
[ChromeEarlGreyUI tapToolsMenuButton:recentTabs];
[ChromeEarlGreyUI tapToolsMenuButton:RecentTabsMenuButton()];
if (IsIPadIdiom()) {
[self verifyKeyboardCommandsAreRegistered];
......
......@@ -89,7 +89,6 @@ source_set("eg_tests") {
"//ios/chrome/app/strings",
"//ios/chrome/browser/bookmarks:features",
"//ios/chrome/browser/ui",
"//ios/chrome/browser/ui/tools_menu/public",
"//ios/chrome/test/app:test_support",
"//ios/chrome/test/earl_grey:test_support",
"//ios/third_party/earl_grey:earl_grey+link",
......
......@@ -11,7 +11,6 @@
#include "base/test/scoped_feature_list.h"
#include "components/strings/grit/components_strings.h"
#include "ios/chrome/browser/bookmarks/bookmark_new_generation_features.h"
#include "ios/chrome/browser/ui/tools_menu/public/tools_menu_constants.h"
#include "ios/chrome/browser/ui/ui_util.h"
#include "ios/chrome/grit/ios_strings.h"
#import "ios/chrome/test/app/tab_test_util.h"
......@@ -27,6 +26,8 @@
#error "This file requires ARC support."
#endif
using chrome_test_util::RecentTabsMenuButton;
namespace {
const char kURLOfTestPage[] = "http://testPage";
const char kHTMLOfTestPage[] =
......@@ -40,10 +41,7 @@ void OpenRecentTabsPanel() {
chrome_test_util::OpenNewTab();
[ChromeEarlGreyUI openToolsMenu];
id<GREYMatcher> open_recent_tabs_button_matcher =
grey_accessibilityID(kToolsMenuOtherDevicesId);
[[EarlGrey selectElementWithMatcher:open_recent_tabs_button_matcher]
performAction:grey_tap()];
[ChromeEarlGreyUI tapToolsMenuButton:RecentTabsMenuButton()];
}
// Closes the recent tabs panel, on iPhone.
......
......@@ -47,7 +47,6 @@ source_set("eg_tests") {
"//ios/chrome/browser/ui/content_suggestions:content_suggestions_constant",
"//ios/chrome/browser/ui/ntp:ntp_controller",
"//ios/chrome/browser/ui/settings",
"//ios/chrome/browser/ui/tools_menu/public",
"//ios/chrome/test/app:test_support",
"//ios/chrome/test/earl_grey:test_support",
"//ios/public/provider/chrome/browser/signin:test_support",
......
......@@ -18,7 +18,6 @@
#import "ios/chrome/browser/ui/commands/open_url_command.h"
#import "ios/chrome/browser/ui/content_suggestions/ntp_home_constant.h"
#import "ios/chrome/browser/ui/ntp/new_tab_page_controller.h"
#include "ios/chrome/browser/ui/tools_menu/public/tools_menu_constants.h"
#include "ios/chrome/browser/ui/ui_util.h"
#include "ios/chrome/grit/ios_strings.h"
#import "ios/chrome/test/app/chrome_test_util.h"
......@@ -476,8 +475,7 @@ void WaitForMatcher(id<GREYMatcher> matcher) {
// Open Bookmarks and tap on Sign In promo button.
[ChromeEarlGreyUI openToolsMenu];
[ChromeEarlGreyUI
tapToolsMenuButton:grey_accessibilityID(kToolsMenuBookmarksId)];
[ChromeEarlGreyUI tapToolsMenuButton:chrome_test_util::BookmarksMenuButton()];
if (!IsIPadIdiom()) {
// Opens the bookmark manager sidebar on handsets.
......@@ -509,8 +507,7 @@ void WaitForMatcher(id<GREYMatcher> matcher) {
// Re-open the sign-in screen. If it wasn't correctly dismissed previously,
// this will fail.
[ChromeEarlGreyUI openToolsMenu];
[ChromeEarlGreyUI
tapToolsMenuButton:grey_accessibilityID(kToolsMenuBookmarksId)];
[ChromeEarlGreyUI tapToolsMenuButton:chrome_test_util::BookmarksMenuButton()];
if (!IsIPadIdiom()) {
[[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"Menu")]
performAction:grey_tap()];
......
......@@ -188,6 +188,12 @@ id<GREYMatcher> PaymentRequestPickerRow();
// Returns matcher for the payment request search bar.
id<GREYMatcher> PaymentRequestPickerSearchBar();
// Returns matcher for the bookmarks button on the Tools menu.
id<GREYMatcher> BookmarksMenuButton();
// Returns matcher for the recent tabs button on the Tools menu.
id<GREYMatcher> RecentTabsMenuButton();
} // namespace chrome_test_util
#endif // IOS_CHROME_TEST_EARL_GREY_CHROME_MATCHERS_H_
......@@ -322,4 +322,12 @@ id<GREYMatcher> PaymentRequestPickerSearchBar() {
return grey_accessibilityID(kPaymentRequestPickerSearchBarAccessibilityID);
}
id<GREYMatcher> BookmarksMenuButton() {
return grey_accessibilityID(kToolsMenuBookmarksId);
}
id<GREYMatcher> RecentTabsMenuButton() {
return grey_accessibilityID(kToolsMenuOtherDevicesId);
}
} // namespace chrome_test_util
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