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") {
"//ios/chrome/browser",
"//ios/chrome/browser/browser_state",
"//ios/chrome/browser/ui:ui_util",
"//ios/chrome/browser/ui/main:tab_switcher",
"//ios/chrome/browser/ui/popup_menu:constants",
"//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/tools_menu/public",
"//ios/chrome/test/app:test_support",
......
......@@ -15,10 +15,8 @@
#include "ios/chrome/browser/browser_state/chrome_browser_state.h"
#include "ios/chrome/browser/experimental_flags.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/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"
#include "ios/chrome/browser/ui/tools_menu/public/tools_menu_constants.h"
#include "ios/chrome/browser/ui/ui_util.h"
......@@ -79,8 +77,6 @@ id<GREYMatcher> LongPressTipBubble() {
// Opens the TabGrid and then opens a new tab.
void OpenTabGridAndOpenTab() {
DCHECK(IsUIRefreshPhase1Enabled());
id<GREYMatcher> openTabSwitcherMatcher =
IsIPadIdiom() ? chrome_test_util::TabletTabSwitcherOpenButton()
: chrome_test_util::ShowTabsButton();
......@@ -99,20 +95,8 @@ void OpenAndCloseTabSwitcher() {
[[EarlGrey selectElementWithMatcher:openTabSwitcherMatcher]
performAction:grey_tap()];
switch (GetTabSwitcherMode()) {
case TabSwitcherMode::GRID:
[[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;
}
[[EarlGrey selectElementWithMatcher:chrome_test_util::TabGridDoneButton()]
performAction:grey_tap()];
}
// Create a test FeatureEngagementTracker.
......
......@@ -173,10 +173,8 @@ source_set("eg_tests") {
"//ios/chrome/browser/ui/authentication",
"//ios/chrome/browser/ui/authentication:authentication_ui",
"//ios/chrome/browser/ui/authentication:eg_test_support",
"//ios/chrome/browser/ui/main:tab_switcher",
"//ios/chrome/browser/ui/settings",
"//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/legacy",
"//ios/chrome/browser/ui/toolbar/public",
......@@ -206,9 +204,7 @@ source_set("test_support") {
"//ios/chrome/browser/tabs",
"//ios/chrome/browser/ui",
"//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_switcher:egtest_support",
"//ios/chrome/browser/ui/tools_menu/public",
"//ios/chrome/browser/web_state_list",
"//ios/chrome/test/app:test_support",
......
......@@ -11,9 +11,7 @@
#import "ios/chrome/app/main_controller.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/tab_switcher_mode.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/ui_util.h"
#include "ios/chrome/browser/web_state_list/web_state_list.h"
......@@ -37,20 +35,7 @@ const NSTimeInterval kWaitElementTimeout = 3;
// Shows the tab switcher by tapping the switcher button. Works on both phone
// and tablet.
void ShowTabSwitcher() {
id<GREYMatcher> matcher = nil;
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);
id<GREYMatcher> matcher = chrome_test_util::TabGridOpenButton();
// 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.
GREYCondition* tapTabSwitcher =
......@@ -68,25 +53,6 @@ void ShowTabSwitcher() {
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 tab_usage_recorder_test_util {
......@@ -112,36 +78,18 @@ void SwitchToNormalMode() {
GREYAssertTrue(chrome_test_util::IsIncognitoMode(),
@"Switching to normal mode is only allowed from Incognito.");
// Enter the tab switcher to switch modes.
// Enter the tab grid to switch modes.
ShowTabSwitcher();
// Switch modes and exit the tab switcher.
switch (GetTabSwitcherMode()) {
case TabSwitcherMode::STACK:
[[EarlGrey selectElementWithMatcher:
chrome_test_util::ButtonWithAccessibilityLabelId(
IDS_IOS_TOOLS_MENU_NEW_INCOGNITO_TAB)]
performAction:grey_swipeSlowInDirection(kGREYDirectionRight)];
CloseTabSwitcher();
break;
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;
}
// Switch modes and exit the tab 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()];
// Turn off synchronization of GREYAssert to test the pending states.
[[GREYConfiguration sharedInstance]
......
......@@ -16,9 +16,7 @@
#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_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_switcher/tab_switcher_egtest_util.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"
......@@ -50,8 +48,6 @@ using chrome_test_util::SettingsDoneButton;
using chrome_test_util::SettingsMenuPrivacyButton;
using chrome_test_util::SignOutAccountsButton;
using chrome_test_util::SyncSwitchCell;
using chrome_test_util::TabletTabSwitcherCloseButton;
using chrome_test_util::TabletTabSwitcherOpenTabsPanelButton;
using chrome_test_util::TurnSyncSwitchOn;
namespace metrics {
......@@ -162,27 +158,13 @@ void CloseAllIncognitoTabs() {
GREYAssert(chrome_test_util::CloseAllIncognitoTabs(), @"Tabs did not close");
[ChromeEarlGrey waitForIncognitoTabCount:0];
// When the tablet tab switcher is enabled, the user is dropped into the tab
// switcher after closing the last incognito tab. Therefore this test must
// manually switch back to showing the normal tabs. The stackview and tabgrid
// show the normal tabs immediately, without entering the switcher, so when
// those are enabled this step is not necessary.
//
// TODO(crbug.com/836812): This may need to include GRID as well, depending on
// 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()];
}
// The user is dropped into the tab grid after closing the last incognito tab.
// Therefore this test must manually switch back to showing the normal tabs.
[[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.");
}
......
......@@ -18,10 +18,6 @@
namespace chrome_test_util {
id<GREYMatcher> TabletTabSwitcherOpenButton() {
return ButtonWithAccessibilityLabelId(IDS_IOS_TAB_STRIP_ENTER_TAB_SWITCHER);
}
id<GREYMatcher> TabletTabSwitcherCloseButton() {
return ButtonWithAccessibilityLabelId(IDS_IOS_TAB_STRIP_LEAVE_TAB_SWITCHER);
}
......
......@@ -83,6 +83,9 @@ id<GREYMatcher> ToolsMenuButton();
// Matcher for the Share menu button.
id<GREYMatcher> ShareButton();
// Returns the GREYMatcher for the button that opens the tab switcher.
id<GREYMatcher> TabletTabSwitcherOpenButton();
// Matcher for show tabs button.
id<GREYMatcher> ShowTabsButton();
......
......@@ -247,6 +247,10 @@ id<GREYMatcher> ShareButton() {
grey_sufficientlyVisible(), nil);
}
id<GREYMatcher> TabletTabSwitcherOpenButton() {
return ButtonWithAccessibilityLabelId(IDS_IOS_TAB_STRIP_ENTER_TAB_SWITCHER);
}
id<GREYMatcher> ShowTabsButton() {
return grey_allOf(grey_accessibilityID(kToolbarStackButtonIdentifier),
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