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") { ...@@ -470,7 +470,6 @@ source_set("eg_tests") {
"//ios/chrome/browser/bookmarks:features", "//ios/chrome/browser/bookmarks:features",
"//ios/chrome/browser/ui/commands", "//ios/chrome/browser/ui/commands",
"//ios/chrome/browser/ui/ntp:ntp_controller", "//ios/chrome/browser/ui/ntp:ntp_controller",
"//ios/chrome/browser/ui/tools_menu/public",
"//ios/chrome/test/app:test_support", "//ios/chrome/test/app:test_support",
"//ios/chrome/test/earl_grey:test_support", "//ios/chrome/test/earl_grey:test_support",
"//ios/testing:ios_test_support", "//ios/testing:ios_test_support",
......
...@@ -206,7 +206,6 @@ source_set("eg_tests") { ...@@ -206,7 +206,6 @@ source_set("eg_tests") {
"//ios/chrome/browser/ui/bookmarks:bookmarks", "//ios/chrome/browser/ui/bookmarks:bookmarks",
"//ios/chrome/browser/ui/commands", "//ios/chrome/browser/ui/commands",
"//ios/chrome/browser/ui/toolbar/public", "//ios/chrome/browser/ui/toolbar/public",
"//ios/chrome/browser/ui/tools_menu/public",
"//ios/chrome/test/app:test_support", "//ios/chrome/test/app:test_support",
"//ios/chrome/test/earl_grey:test_support", "//ios/chrome/test/earl_grey:test_support",
"//ios/public/provider/chrome/browser/signin:test_support", "//ios/public/provider/chrome/browser/signin:test_support",
......
...@@ -22,7 +22,6 @@ ...@@ -22,7 +22,6 @@
#import "ios/chrome/browser/ui/authentication/signin_earlgrey_utils.h" #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/authentication/signin_promo_view.h"
#import "ios/chrome/browser/ui/toolbar/public/toolbar_controller_constants.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" #import "ios/chrome/browser/ui/uikit_ui_util.h"
#include "ios/chrome/grit/ios_strings.h" #include "ios/chrome/grit/ios_strings.h"
#import "ios/chrome/test/app/bookmarks_test_util.h" #import "ios/chrome/test/app/bookmarks_test_util.h"
...@@ -47,6 +46,7 @@ ...@@ -47,6 +46,7 @@
#error "This file requires ARC support." #error "This file requires ARC support."
#endif #endif
using chrome_test_util::BookmarksMenuButton;
using chrome_test_util::ButtonWithAccessibilityLabel; using chrome_test_util::ButtonWithAccessibilityLabel;
using chrome_test_util::ButtonWithAccessibilityLabelId; using chrome_test_util::ButtonWithAccessibilityLabelId;
using chrome_test_util::PrimarySignInButton; using chrome_test_util::PrimarySignInButton;
...@@ -1405,16 +1405,12 @@ id<GREYMatcher> ActionSheet(Action action) { ...@@ -1405,16 +1405,12 @@ id<GREYMatcher> ActionSheet(Action action) {
// Navigates to the bookmark manager UI. // Navigates to the bookmark manager UI.
+ (void)openBookmarks { + (void)openBookmarks {
[ChromeEarlGreyUI openToolsMenu];
// Opens the bookmark manager. // Opens the bookmark manager.
[[EarlGrey [ChromeEarlGreyUI openToolsMenu];
selectElementWithMatcher:grey_accessibilityID(kToolsMenuBookmarksId)] [ChromeEarlGreyUI tapToolsMenuButton:BookmarksMenuButton()];
performAction:grey_tap()];
// Wait for it to load, and the menu to go away. // Assert the menu is gone.
[[EarlGrey [[EarlGrey selectElementWithMatcher:BookmarksMenuButton()]
selectElementWithMatcher:grey_accessibilityID(kToolsMenuBookmarksId)]
assertWithMatcher:grey_nil()]; assertWithMatcher:grey_nil()];
} }
......
...@@ -21,7 +21,6 @@ ...@@ -21,7 +21,6 @@
#import "ios/chrome/browser/ui/authentication/signin_earlgrey_utils.h" #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/authentication/signin_promo_view.h"
#import "ios/chrome/browser/ui/bookmarks/bookmark_utils_ios.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" #import "ios/chrome/browser/ui/uikit_ui_util.h"
#include "ios/chrome/grit/ios_strings.h" #include "ios/chrome/grit/ios_strings.h"
#import "ios/chrome/test/app/bookmarks_test_util.h" #import "ios/chrome/test/app/bookmarks_test_util.h"
...@@ -44,6 +43,7 @@ ...@@ -44,6 +43,7 @@
#error "This file requires ARC support." #error "This file requires ARC support."
#endif #endif
using chrome_test_util::BookmarksMenuButton;
using chrome_test_util::ButtonWithAccessibilityLabel; using chrome_test_util::ButtonWithAccessibilityLabel;
using chrome_test_util::ButtonWithAccessibilityLabelId; using chrome_test_util::ButtonWithAccessibilityLabelId;
using chrome_test_util::PrimarySignInButton; using chrome_test_util::PrimarySignInButton;
...@@ -2463,16 +2463,12 @@ id<GREYMatcher> TappableBookmarkNodeWithLabel(NSString* label) { ...@@ -2463,16 +2463,12 @@ id<GREYMatcher> TappableBookmarkNodeWithLabel(NSString* label) {
// Navigates to the bookmark manager UI. // Navigates to the bookmark manager UI.
+ (void)openBookmarks { + (void)openBookmarks {
[ChromeEarlGreyUI openToolsMenu];
// Opens the bookmark manager. // Opens the bookmark manager.
[[EarlGrey [ChromeEarlGreyUI openToolsMenu];
selectElementWithMatcher:grey_accessibilityID(kToolsMenuBookmarksId)] [ChromeEarlGreyUI tapToolsMenuButton:BookmarksMenuButton()];
performAction:grey_tap()];
// Wait for it to load, and the menu to go away. // Assert the menu is gone.
[[EarlGrey [[EarlGrey selectElementWithMatcher:BookmarksMenuButton()]
selectElementWithMatcher:grey_accessibilityID(kToolsMenuBookmarksId)]
assertWithMatcher:grey_nil()]; assertWithMatcher:grey_nil()];
} }
......
...@@ -10,7 +10,6 @@ ...@@ -10,7 +10,6 @@
#include "ios/chrome/browser/bookmarks/bookmark_new_generation_features.h" #include "ios/chrome/browser/bookmarks/bookmark_new_generation_features.h"
#import "ios/chrome/browser/ui/browser_view_controller.h" #import "ios/chrome/browser/ui/browser_view_controller.h"
#import "ios/chrome/browser/ui/ntp/new_tab_page_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" #include "ios/chrome/browser/ui/ui_util.h"
#import "ios/chrome/browser/ui/uikit_ui_util.h" #import "ios/chrome/browser/ui/uikit_ui_util.h"
#include "ios/chrome/grit/ios_strings.h" #include "ios/chrome/grit/ios_strings.h"
...@@ -29,6 +28,7 @@ ...@@ -29,6 +28,7 @@
#endif #endif
using chrome_test_util::NavigationBarDoneButton; using chrome_test_util::NavigationBarDoneButton;
using chrome_test_util::RecentTabsMenuButton;
// 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.
...@@ -153,8 +153,7 @@ using chrome_test_util::NavigationBarDoneButton; ...@@ -153,8 +153,7 @@ using chrome_test_util::NavigationBarDoneButton;
// Open Bookmarks // Open Bookmarks
[ChromeEarlGreyUI openToolsMenu]; [ChromeEarlGreyUI openToolsMenu];
[ChromeEarlGreyUI [ChromeEarlGreyUI tapToolsMenuButton:chrome_test_util::BookmarksMenuButton()];
tapToolsMenuButton:grey_accessibilityID(kToolsMenuBookmarksId)];
if (IsIPadIdiom()) { if (IsIPadIdiom()) {
[self verifyKeyboardCommandsAreRegistered]; [self verifyKeyboardCommandsAreRegistered];
...@@ -170,9 +169,8 @@ using chrome_test_util::NavigationBarDoneButton; ...@@ -170,9 +169,8 @@ using chrome_test_util::NavigationBarDoneButton;
// shown on iPhone and registered on iPad. // shown on iPhone and registered on iPad.
- (void)testKeyboardCommands_RecentTabsPresented { - (void)testKeyboardCommands_RecentTabsPresented {
// Open Recent Tabs // Open Recent Tabs
id<GREYMatcher> recentTabs = grey_accessibilityID(kToolsMenuOtherDevicesId);
[ChromeEarlGreyUI openToolsMenu]; [ChromeEarlGreyUI openToolsMenu];
[ChromeEarlGreyUI tapToolsMenuButton:recentTabs]; [ChromeEarlGreyUI tapToolsMenuButton:RecentTabsMenuButton()];
if (IsIPadIdiom()) { if (IsIPadIdiom()) {
[self verifyKeyboardCommandsAreRegistered]; [self verifyKeyboardCommandsAreRegistered];
......
...@@ -89,7 +89,6 @@ source_set("eg_tests") { ...@@ -89,7 +89,6 @@ source_set("eg_tests") {
"//ios/chrome/app/strings", "//ios/chrome/app/strings",
"//ios/chrome/browser/bookmarks:features", "//ios/chrome/browser/bookmarks:features",
"//ios/chrome/browser/ui", "//ios/chrome/browser/ui",
"//ios/chrome/browser/ui/tools_menu/public",
"//ios/chrome/test/app:test_support", "//ios/chrome/test/app:test_support",
"//ios/chrome/test/earl_grey:test_support", "//ios/chrome/test/earl_grey:test_support",
"//ios/third_party/earl_grey:earl_grey+link", "//ios/third_party/earl_grey:earl_grey+link",
......
...@@ -11,7 +11,6 @@ ...@@ -11,7 +11,6 @@
#include "base/test/scoped_feature_list.h" #include "base/test/scoped_feature_list.h"
#include "components/strings/grit/components_strings.h" #include "components/strings/grit/components_strings.h"
#include "ios/chrome/browser/bookmarks/bookmark_new_generation_features.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/browser/ui/ui_util.h"
#include "ios/chrome/grit/ios_strings.h" #include "ios/chrome/grit/ios_strings.h"
#import "ios/chrome/test/app/tab_test_util.h" #import "ios/chrome/test/app/tab_test_util.h"
...@@ -27,6 +26,8 @@ ...@@ -27,6 +26,8 @@
#error "This file requires ARC support." #error "This file requires ARC support."
#endif #endif
using chrome_test_util::RecentTabsMenuButton;
namespace { namespace {
const char kURLOfTestPage[] = "http://testPage"; const char kURLOfTestPage[] = "http://testPage";
const char kHTMLOfTestPage[] = const char kHTMLOfTestPage[] =
...@@ -40,10 +41,7 @@ void OpenRecentTabsPanel() { ...@@ -40,10 +41,7 @@ void OpenRecentTabsPanel() {
chrome_test_util::OpenNewTab(); chrome_test_util::OpenNewTab();
[ChromeEarlGreyUI openToolsMenu]; [ChromeEarlGreyUI openToolsMenu];
id<GREYMatcher> open_recent_tabs_button_matcher = [ChromeEarlGreyUI tapToolsMenuButton:RecentTabsMenuButton()];
grey_accessibilityID(kToolsMenuOtherDevicesId);
[[EarlGrey selectElementWithMatcher:open_recent_tabs_button_matcher]
performAction:grey_tap()];
} }
// Closes the recent tabs panel, on iPhone. // Closes the recent tabs panel, on iPhone.
......
...@@ -47,7 +47,6 @@ source_set("eg_tests") { ...@@ -47,7 +47,6 @@ source_set("eg_tests") {
"//ios/chrome/browser/ui/content_suggestions:content_suggestions_constant", "//ios/chrome/browser/ui/content_suggestions:content_suggestions_constant",
"//ios/chrome/browser/ui/ntp:ntp_controller", "//ios/chrome/browser/ui/ntp:ntp_controller",
"//ios/chrome/browser/ui/settings", "//ios/chrome/browser/ui/settings",
"//ios/chrome/browser/ui/tools_menu/public",
"//ios/chrome/test/app:test_support", "//ios/chrome/test/app:test_support",
"//ios/chrome/test/earl_grey:test_support", "//ios/chrome/test/earl_grey:test_support",
"//ios/public/provider/chrome/browser/signin:test_support", "//ios/public/provider/chrome/browser/signin:test_support",
......
...@@ -18,7 +18,6 @@ ...@@ -18,7 +18,6 @@
#import "ios/chrome/browser/ui/commands/open_url_command.h" #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/content_suggestions/ntp_home_constant.h"
#import "ios/chrome/browser/ui/ntp/new_tab_page_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" #include "ios/chrome/browser/ui/ui_util.h"
#include "ios/chrome/grit/ios_strings.h" #include "ios/chrome/grit/ios_strings.h"
#import "ios/chrome/test/app/chrome_test_util.h" #import "ios/chrome/test/app/chrome_test_util.h"
...@@ -476,8 +475,7 @@ void WaitForMatcher(id<GREYMatcher> matcher) { ...@@ -476,8 +475,7 @@ void WaitForMatcher(id<GREYMatcher> matcher) {
// Open Bookmarks and tap on Sign In promo button. // Open Bookmarks and tap on Sign In promo button.
[ChromeEarlGreyUI openToolsMenu]; [ChromeEarlGreyUI openToolsMenu];
[ChromeEarlGreyUI [ChromeEarlGreyUI tapToolsMenuButton:chrome_test_util::BookmarksMenuButton()];
tapToolsMenuButton:grey_accessibilityID(kToolsMenuBookmarksId)];
if (!IsIPadIdiom()) { if (!IsIPadIdiom()) {
// Opens the bookmark manager sidebar on handsets. // Opens the bookmark manager sidebar on handsets.
...@@ -509,8 +507,7 @@ void WaitForMatcher(id<GREYMatcher> matcher) { ...@@ -509,8 +507,7 @@ 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];
[ChromeEarlGreyUI [ChromeEarlGreyUI tapToolsMenuButton:chrome_test_util::BookmarksMenuButton()];
tapToolsMenuButton:grey_accessibilityID(kToolsMenuBookmarksId)];
if (!IsIPadIdiom()) { if (!IsIPadIdiom()) {
[[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"Menu")] [[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"Menu")]
performAction:grey_tap()]; performAction:grey_tap()];
......
...@@ -188,6 +188,12 @@ id<GREYMatcher> PaymentRequestPickerRow(); ...@@ -188,6 +188,12 @@ id<GREYMatcher> PaymentRequestPickerRow();
// Returns matcher for the payment request search bar. // Returns matcher for the payment request search bar.
id<GREYMatcher> PaymentRequestPickerSearchBar(); 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 } // namespace chrome_test_util
#endif // IOS_CHROME_TEST_EARL_GREY_CHROME_MATCHERS_H_ #endif // IOS_CHROME_TEST_EARL_GREY_CHROME_MATCHERS_H_
...@@ -322,4 +322,12 @@ id<GREYMatcher> PaymentRequestPickerSearchBar() { ...@@ -322,4 +322,12 @@ id<GREYMatcher> PaymentRequestPickerSearchBar() {
return grey_accessibilityID(kPaymentRequestPickerSearchBarAccessibilityID); return grey_accessibilityID(kPaymentRequestPickerSearchBarAccessibilityID);
} }
id<GREYMatcher> BookmarksMenuButton() {
return grey_accessibilityID(kToolsMenuBookmarksId);
}
id<GREYMatcher> RecentTabsMenuButton() {
return grey_accessibilityID(kToolsMenuOtherDevicesId);
}
} // namespace chrome_test_util } // 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