Commit 903f480f authored by Mark Cogan's avatar Mark Cogan Committed by Commit Bot

[iOS] Remove support for old tab switchers from unit tests.

This CL:
  - Removes support for non-GRID tab switchers from the feature engagement egtest.
  - Simplifies tab_usage_recorder_test_util to only support the tab grid.
  - Removes non-grid support from the UKM egtest
  - Moves the TabletTabSwitcherOpenButton() helper function to chrome_matchers, out of the moribund tab_switcher/ directory.


Cq-Include-Trybots: luci.chromium.try:ios-simulator-cronet;luci.chromium.try:ios-simulator-full-configs
Change-Id: I6cbcfa88f13bdad6407e56746e9e76bd9e4a5d38
Reviewed-on: https://chromium-review.googlesource.com/1233195
Commit-Queue: Mark Cogan <marq@chromium.org>
Reviewed-by: default avatarGauthier Ambard <gambard@chromium.org>
Cr-Commit-Position: refs/heads/master@{#592824}
parent a7d715ae
...@@ -42,10 +42,8 @@ source_set("eg_tests") { ...@@ -42,10 +42,8 @@ source_set("eg_tests") {
"//ios/chrome/browser", "//ios/chrome/browser",
"//ios/chrome/browser/browser_state", "//ios/chrome/browser/browser_state",
"//ios/chrome/browser/ui:ui_util", "//ios/chrome/browser/ui:ui_util",
"//ios/chrome/browser/ui/main:tab_switcher",
"//ios/chrome/browser/ui/popup_menu:constants", "//ios/chrome/browser/ui/popup_menu:constants",
"//ios/chrome/browser/ui/tab_grid:egtest_support", "//ios/chrome/browser/ui/tab_grid:egtest_support",
"//ios/chrome/browser/ui/tab_switcher:egtest_support",
"//ios/chrome/browser/ui/table_view", "//ios/chrome/browser/ui/table_view",
"//ios/chrome/browser/ui/tools_menu/public", "//ios/chrome/browser/ui/tools_menu/public",
"//ios/chrome/test/app:test_support", "//ios/chrome/test/app:test_support",
......
...@@ -15,10 +15,8 @@ ...@@ -15,10 +15,8 @@
#include "ios/chrome/browser/browser_state/chrome_browser_state.h" #include "ios/chrome/browser/browser_state/chrome_browser_state.h"
#include "ios/chrome/browser/experimental_flags.h" #include "ios/chrome/browser/experimental_flags.h"
#include "ios/chrome/browser/feature_engagement/tracker_factory.h" #include "ios/chrome/browser/feature_engagement/tracker_factory.h"
#import "ios/chrome/browser/ui/main/tab_switcher_mode.h"
#import "ios/chrome/browser/ui/popup_menu/popup_menu_constants.h" #import "ios/chrome/browser/ui/popup_menu/popup_menu_constants.h"
#import "ios/chrome/browser/ui/tab_grid/tab_grid_egtest_util.h" #import "ios/chrome/browser/ui/tab_grid/tab_grid_egtest_util.h"
#import "ios/chrome/browser/ui/tab_switcher/tab_switcher_egtest_util.h"
#import "ios/chrome/browser/ui/table_view/table_view_navigation_controller_constants.h" #import "ios/chrome/browser/ui/table_view/table_view_navigation_controller_constants.h"
#include "ios/chrome/browser/ui/tools_menu/public/tools_menu_constants.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"
...@@ -79,8 +77,6 @@ id<GREYMatcher> LongPressTipBubble() { ...@@ -79,8 +77,6 @@ id<GREYMatcher> LongPressTipBubble() {
// Opens the TabGrid and then opens a new tab. // Opens the TabGrid and then opens a new tab.
void OpenTabGridAndOpenTab() { void OpenTabGridAndOpenTab() {
DCHECK(IsUIRefreshPhase1Enabled());
id<GREYMatcher> openTabSwitcherMatcher = id<GREYMatcher> openTabSwitcherMatcher =
IsIPadIdiom() ? chrome_test_util::TabletTabSwitcherOpenButton() IsIPadIdiom() ? chrome_test_util::TabletTabSwitcherOpenButton()
: chrome_test_util::ShowTabsButton(); : chrome_test_util::ShowTabsButton();
...@@ -99,20 +95,8 @@ void OpenAndCloseTabSwitcher() { ...@@ -99,20 +95,8 @@ void OpenAndCloseTabSwitcher() {
[[EarlGrey selectElementWithMatcher:openTabSwitcherMatcher] [[EarlGrey selectElementWithMatcher:openTabSwitcherMatcher]
performAction:grey_tap()]; performAction:grey_tap()];
switch (GetTabSwitcherMode()) { [[EarlGrey selectElementWithMatcher:chrome_test_util::TabGridDoneButton()]
case TabSwitcherMode::GRID: performAction:grey_tap()];
[[EarlGrey selectElementWithMatcher:chrome_test_util::TabGridDoneButton()]
performAction:grey_tap()];
break;
case TabSwitcherMode::TABLET_SWITCHER:
case TabSwitcherMode::STACK:
id<GREYMatcher> closeTabSwitcherMatcher =
IsIPadIdiom() ? chrome_test_util::TabletTabSwitcherCloseButton()
: chrome_test_util::ShowTabsButton();
[[EarlGrey selectElementWithMatcher:closeTabSwitcherMatcher]
performAction:grey_tap()];
break;
}
} }
// Create a test FeatureEngagementTracker. // Create a test FeatureEngagementTracker.
......
...@@ -173,10 +173,8 @@ source_set("eg_tests") { ...@@ -173,10 +173,8 @@ source_set("eg_tests") {
"//ios/chrome/browser/ui/authentication", "//ios/chrome/browser/ui/authentication",
"//ios/chrome/browser/ui/authentication:authentication_ui", "//ios/chrome/browser/ui/authentication:authentication_ui",
"//ios/chrome/browser/ui/authentication:eg_test_support", "//ios/chrome/browser/ui/authentication:eg_test_support",
"//ios/chrome/browser/ui/main:tab_switcher",
"//ios/chrome/browser/ui/settings", "//ios/chrome/browser/ui/settings",
"//ios/chrome/browser/ui/tab_grid:egtest_support", "//ios/chrome/browser/ui/tab_grid:egtest_support",
"//ios/chrome/browser/ui/tab_switcher:egtest_support",
"//ios/chrome/browser/ui/toolbar/buttons", "//ios/chrome/browser/ui/toolbar/buttons",
"//ios/chrome/browser/ui/toolbar/legacy", "//ios/chrome/browser/ui/toolbar/legacy",
"//ios/chrome/browser/ui/toolbar/public", "//ios/chrome/browser/ui/toolbar/public",
...@@ -206,9 +204,7 @@ source_set("test_support") { ...@@ -206,9 +204,7 @@ source_set("test_support") {
"//ios/chrome/browser/tabs", "//ios/chrome/browser/tabs",
"//ios/chrome/browser/ui", "//ios/chrome/browser/ui",
"//ios/chrome/browser/ui/main", "//ios/chrome/browser/ui/main",
"//ios/chrome/browser/ui/main:tab_switcher",
"//ios/chrome/browser/ui/tab_grid:egtest_support", "//ios/chrome/browser/ui/tab_grid:egtest_support",
"//ios/chrome/browser/ui/tab_switcher:egtest_support",
"//ios/chrome/browser/ui/tools_menu/public", "//ios/chrome/browser/ui/tools_menu/public",
"//ios/chrome/browser/web_state_list", "//ios/chrome/browser/web_state_list",
"//ios/chrome/test/app:test_support", "//ios/chrome/test/app:test_support",
......
...@@ -11,9 +11,7 @@ ...@@ -11,9 +11,7 @@
#import "ios/chrome/app/main_controller.h" #import "ios/chrome/app/main_controller.h"
#import "ios/chrome/browser/tabs/tab_model.h" #import "ios/chrome/browser/tabs/tab_model.h"
#import "ios/chrome/browser/ui/main/browser_view_information.h" #import "ios/chrome/browser/ui/main/browser_view_information.h"
#import "ios/chrome/browser/ui/main/tab_switcher_mode.h"
#include "ios/chrome/browser/ui/tab_grid/tab_grid_egtest_util.h" #include "ios/chrome/browser/ui/tab_grid/tab_grid_egtest_util.h"
#include "ios/chrome/browser/ui/tab_switcher/tab_switcher_egtest_util.h"
#include "ios/chrome/browser/ui/tools_menu/public/tools_menu_constants.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/browser/web_state_list/web_state_list.h" #include "ios/chrome/browser/web_state_list/web_state_list.h"
...@@ -37,20 +35,7 @@ const NSTimeInterval kWaitElementTimeout = 3; ...@@ -37,20 +35,7 @@ const NSTimeInterval kWaitElementTimeout = 3;
// Shows the tab switcher by tapping the switcher button. Works on both phone // Shows the tab switcher by tapping the switcher button. Works on both phone
// and tablet. // and tablet.
void ShowTabSwitcher() { void ShowTabSwitcher() {
id<GREYMatcher> matcher = nil; id<GREYMatcher> matcher = chrome_test_util::TabGridOpenButton();
switch (GetTabSwitcherMode()) {
case TabSwitcherMode::STACK:
matcher = chrome_test_util::ShowTabsButton();
break;
case TabSwitcherMode::TABLET_SWITCHER:
matcher = chrome_test_util::TabletTabSwitcherOpenButton();
break;
case TabSwitcherMode::GRID:
matcher = chrome_test_util::TabGridOpenButton();
break;
}
DCHECK(matcher);
// Perform a tap with a timeout. Occasionally EG doesn't sync up properly to // Perform a tap with a timeout. Occasionally EG doesn't sync up properly to
// the animations of tab switcher, so it is necessary to poll here. // the animations of tab switcher, so it is necessary to poll here.
GREYCondition* tapTabSwitcher = GREYCondition* tapTabSwitcher =
...@@ -68,25 +53,6 @@ void ShowTabSwitcher() { ...@@ -68,25 +53,6 @@ void ShowTabSwitcher() {
GREYAssertTrue(hasClicked, @"Tab switcher could not be tapped."); GREYAssertTrue(hasClicked, @"Tab switcher could not be tapped.");
} }
// Closes the tabs switcher.
void CloseTabSwitcher() {
id<GREYMatcher> matcher = nil;
switch (GetTabSwitcherMode()) {
case TabSwitcherMode::STACK:
matcher = chrome_test_util::ShowTabsButton();
break;
case TabSwitcherMode::TABLET_SWITCHER:
matcher = chrome_test_util::TabletTabSwitcherCloseButton();
break;
case TabSwitcherMode::GRID:
matcher = chrome_test_util::TabGridDoneButton();
break;
}
DCHECK(matcher);
[[EarlGrey selectElementWithMatcher:matcher] performAction:grey_tap()];
}
} // namespace } // namespace
namespace tab_usage_recorder_test_util { namespace tab_usage_recorder_test_util {
...@@ -112,36 +78,18 @@ void SwitchToNormalMode() { ...@@ -112,36 +78,18 @@ void SwitchToNormalMode() {
GREYAssertTrue(chrome_test_util::IsIncognitoMode(), GREYAssertTrue(chrome_test_util::IsIncognitoMode(),
@"Switching to normal mode is only allowed from Incognito."); @"Switching to normal mode is only allowed from Incognito.");
// Enter the tab switcher to switch modes. // Enter the tab grid to switch modes.
ShowTabSwitcher(); ShowTabSwitcher();
// Switch modes and exit the tab switcher. // Switch modes and exit the tab grid.
switch (GetTabSwitcherMode()) { TabModel* model = [[chrome_test_util::GetMainController()
case TabSwitcherMode::STACK: browserViewInformation] mainTabModel];
[[EarlGrey selectElementWithMatcher: const int tab_index = model.webStateList->active_index();
chrome_test_util::ButtonWithAccessibilityLabelId( [[EarlGrey
IDS_IOS_TOOLS_MENU_NEW_INCOGNITO_TAB)] selectElementWithMatcher:chrome_test_util::TabGridOpenTabsPanelButton()]
performAction:grey_swipeSlowInDirection(kGREYDirectionRight)]; performAction:grey_tap()];
CloseTabSwitcher(); [[EarlGrey selectElementWithMatcher:chrome_test_util::TabGridCellAtIndex(
break; tab_index)] performAction:grey_tap()];
case TabSwitcherMode::TABLET_SWITCHER:
[[EarlGrey selectElementWithMatcher:
chrome_test_util::TabletTabSwitcherOpenTabsPanelButton()]
performAction:grey_tap()];
CloseTabSwitcher();
break;
case TabSwitcherMode::GRID:
TabModel* model = [[chrome_test_util::GetMainController()
browserViewInformation] mainTabModel];
const int tab_index = model.webStateList->active_index();
[[EarlGrey selectElementWithMatcher:chrome_test_util::
TabGridOpenTabsPanelButton()]
performAction:grey_tap()];
[[EarlGrey selectElementWithMatcher:chrome_test_util::TabGridCellAtIndex(
tab_index)]
performAction:grey_tap()];
break;
}
// Turn off synchronization of GREYAssert to test the pending states. // Turn off synchronization of GREYAssert to test the pending states.
[[GREYConfiguration sharedInstance] [[GREYConfiguration sharedInstance]
......
...@@ -16,9 +16,7 @@ ...@@ -16,9 +16,7 @@
#import "ios/chrome/browser/ui/authentication/signin_earl_grey_ui.h" #import "ios/chrome/browser/ui/authentication/signin_earl_grey_ui.h"
#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/main/tab_switcher_mode.h"
#import "ios/chrome/browser/ui/tab_grid/tab_grid_egtest_util.h" #import "ios/chrome/browser/ui/tab_grid/tab_grid_egtest_util.h"
#import "ios/chrome/browser/ui/tab_switcher/tab_switcher_egtest_util.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"
...@@ -50,8 +48,6 @@ using chrome_test_util::SettingsDoneButton; ...@@ -50,8 +48,6 @@ using chrome_test_util::SettingsDoneButton;
using chrome_test_util::SettingsMenuPrivacyButton; using chrome_test_util::SettingsMenuPrivacyButton;
using chrome_test_util::SignOutAccountsButton; using chrome_test_util::SignOutAccountsButton;
using chrome_test_util::SyncSwitchCell; using chrome_test_util::SyncSwitchCell;
using chrome_test_util::TabletTabSwitcherCloseButton;
using chrome_test_util::TabletTabSwitcherOpenTabsPanelButton;
using chrome_test_util::TurnSyncSwitchOn; using chrome_test_util::TurnSyncSwitchOn;
namespace metrics { namespace metrics {
...@@ -162,27 +158,13 @@ void CloseAllIncognitoTabs() { ...@@ -162,27 +158,13 @@ void CloseAllIncognitoTabs() {
GREYAssert(chrome_test_util::CloseAllIncognitoTabs(), @"Tabs did not close"); GREYAssert(chrome_test_util::CloseAllIncognitoTabs(), @"Tabs did not close");
[ChromeEarlGrey waitForIncognitoTabCount:0]; [ChromeEarlGrey waitForIncognitoTabCount:0];
// When the tablet tab switcher is enabled, the user is dropped into the tab // The user is dropped into the tab grid after closing the last incognito tab.
// switcher after closing the last incognito tab. Therefore this test must // Therefore this test must manually switch back to showing the normal tabs.
// manually switch back to showing the normal tabs. The stackview and tabgrid [[EarlGrey
// show the normal tabs immediately, without entering the switcher, so when selectElementWithMatcher:chrome_test_util::TabGridOpenTabsPanelButton()]
// those are enabled this step is not necessary. performAction:grey_tap()];
// [[EarlGrey selectElementWithMatcher:chrome_test_util::TabGridDoneButton()]
// TODO(crbug.com/836812): This may need to include GRID as well, depending on performAction:grey_tap()];
// how Issue 836812 is resolved.
if (GetTabSwitcherMode() == TabSwitcherMode::TABLET_SWITCHER) {
// Switch to the non-incognito panel and leave the tab switcher.
[[EarlGrey selectElementWithMatcher:TabletTabSwitcherOpenTabsPanelButton()]
performAction:grey_tap()];
[[EarlGrey selectElementWithMatcher:TabletTabSwitcherCloseButton()]
performAction:grey_tap()];
} else if (GetTabSwitcherMode() == TabSwitcherMode::GRID) {
[[EarlGrey
selectElementWithMatcher:chrome_test_util::TabGridOpenTabsPanelButton()]
performAction:grey_tap()];
[[EarlGrey selectElementWithMatcher:chrome_test_util::TabGridDoneButton()]
performAction:grey_tap()];
}
GREYAssert(!IsIncognitoMode(), @"Failed to switch to normal mode."); GREYAssert(!IsIncognitoMode(), @"Failed to switch to normal mode.");
} }
......
...@@ -18,10 +18,6 @@ ...@@ -18,10 +18,6 @@
namespace chrome_test_util { namespace chrome_test_util {
id<GREYMatcher> TabletTabSwitcherOpenButton() {
return ButtonWithAccessibilityLabelId(IDS_IOS_TAB_STRIP_ENTER_TAB_SWITCHER);
}
id<GREYMatcher> TabletTabSwitcherCloseButton() { id<GREYMatcher> TabletTabSwitcherCloseButton() {
return ButtonWithAccessibilityLabelId(IDS_IOS_TAB_STRIP_LEAVE_TAB_SWITCHER); return ButtonWithAccessibilityLabelId(IDS_IOS_TAB_STRIP_LEAVE_TAB_SWITCHER);
} }
......
...@@ -83,6 +83,9 @@ id<GREYMatcher> ToolsMenuButton(); ...@@ -83,6 +83,9 @@ id<GREYMatcher> ToolsMenuButton();
// Matcher for the Share menu button. // Matcher for the Share menu button.
id<GREYMatcher> ShareButton(); id<GREYMatcher> ShareButton();
// Returns the GREYMatcher for the button that opens the tab switcher.
id<GREYMatcher> TabletTabSwitcherOpenButton();
// Matcher for show tabs button. // Matcher for show tabs button.
id<GREYMatcher> ShowTabsButton(); id<GREYMatcher> ShowTabsButton();
......
...@@ -247,6 +247,10 @@ id<GREYMatcher> ShareButton() { ...@@ -247,6 +247,10 @@ id<GREYMatcher> ShareButton() {
grey_sufficientlyVisible(), nil); grey_sufficientlyVisible(), nil);
} }
id<GREYMatcher> TabletTabSwitcherOpenButton() {
return ButtonWithAccessibilityLabelId(IDS_IOS_TAB_STRIP_ENTER_TAB_SWITCHER);
}
id<GREYMatcher> ShowTabsButton() { id<GREYMatcher> ShowTabsButton() {
return grey_allOf(grey_accessibilityID(kToolbarStackButtonIdentifier), return grey_allOf(grey_accessibilityID(kToolbarStackButtonIdentifier),
grey_sufficientlyVisible(), nil); grey_sufficientlyVisible(), nil);
......
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