Commit 50e77170 authored by Ewann's avatar Ewann Committed by Chromium LUCI CQ

[iOS][CloseAllTabs] Fixes Done button

This CL enables the Done button if tabs are not closed from the
confirmation action sheet.
It also correctly enables the button when switching from incognito
to normal tabs slowly.

Bug: 1151299, 1147770
Change-Id: Icfc5d601333a326ae9eb5c5c74f87d085c2361a5
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2566816
Commit-Queue: Ewann Pellé <ewannpv@chromium.org>
Reviewed-by: default avatarGauthier Ambard <gambard@chromium.org>
Reviewed-by: default avataredchin <edchin@chromium.org>
Cr-Commit-Position: refs/heads/master@{#833276}
parent 6fa5ee31
...@@ -7,6 +7,8 @@ ...@@ -7,6 +7,8 @@
#include "base/bind.h" #include "base/bind.h"
#include "base/strings/sys_string_conversions.h" #include "base/strings/sys_string_conversions.h"
#import "ios/chrome/browser/ui/tab_switcher/tab_grid/features.h"
#import "ios/chrome/browser/ui/util/ui_util.h"
#include "ios/chrome/grit/ios_strings.h" #include "ios/chrome/grit/ios_strings.h"
#import "ios/chrome/test/earl_grey/chrome_earl_grey.h" #import "ios/chrome/test/earl_grey/chrome_earl_grey.h"
#import "ios/chrome/test/earl_grey/chrome_earl_grey_ui.h" #import "ios/chrome/test/earl_grey/chrome_earl_grey_ui.h"
...@@ -21,6 +23,7 @@ ...@@ -21,6 +23,7 @@
#error "This file requires ARC support." #error "This file requires ARC support."
#endif #endif
using chrome_test_util::TabGridCloseAllButton;
using chrome_test_util::TabGridDoneButton; using chrome_test_util::TabGridDoneButton;
using chrome_test_util::TabGridIncognitoTabsPanelButton; using chrome_test_util::TabGridIncognitoTabsPanelButton;
using chrome_test_util::TabGridNewIncognitoTabButton; using chrome_test_util::TabGridNewIncognitoTabButton;
...@@ -70,6 +73,12 @@ std::unique_ptr<net::test_server::HttpResponse> HandleQueryTitle( ...@@ -70,6 +73,12 @@ std::unique_ptr<net::test_server::HttpResponse> HandleQueryTitle(
// to fail. // to fail.
@implementation TabSwitcherTransitionTestCase @implementation TabSwitcherTransitionTestCase
- (AppLaunchConfiguration)appConfigurationForTestCase {
AppLaunchConfiguration config;
config.features_enabled.push_back(kEnableCloseAllTabsConfirmation);
return config;
}
// Rotate the device back to portrait if needed, since some tests attempt to run // Rotate the device back to portrait if needed, since some tests attempt to run
// in landscape. // in landscape.
- (void)tearDown { - (void)tearDown {
...@@ -353,4 +362,45 @@ std::unique_ptr<net::test_server::HttpResponse> HandleQueryTitle( ...@@ -353,4 +362,45 @@ std::unique_ptr<net::test_server::HttpResponse> HandleQueryTitle(
waitForWebStateContainingText:base::SysNSStringToUTF8(tab_title)]; waitForWebStateContainingText:base::SysNSStringToUTF8(tab_title)];
} }
// Tests navigating through the switcher displays correctly the Done button.
- (void)testNavigateSwitcherDoneButton {
// Rotate the iPhone in lanscape mode in order to see the Done button when the
// confirmation action sheet is presented.
if (!IsIPadIdiom()) {
[EarlGrey rotateDeviceToOrientation:UIDeviceOrientationLandscapeLeft
error:nil];
}
// Check that the Done button is not greyed out when the tab grid is not
// empty.
[ChromeEarlGrey showTabSwitcher];
[[EarlGrey selectElementWithMatcher:TabGridDoneButton()]
assertWithMatcher:grey_accessibilityTrait(UIAccessibilityTraitButton)];
// Check that the Done button is greyed out when the close all tabs
// confirmation is displayed.
[[EarlGrey selectElementWithMatcher:TabGridCloseAllButton()]
performAction:grey_tap()];
[[EarlGrey selectElementWithMatcher:TabGridDoneButton()]
assertWithMatcher:grey_accessibilityTrait(
UIAccessibilityTraitNotEnabled)];
// Cancel the close all tabs confirmation & check that the Done button is not
// greyed out.
[[EarlGrey selectElementWithMatcher:chrome_test_util::TabGridCellAtIndex(0)]
performAction:grey_tap()];
[[EarlGrey selectElementWithMatcher:TabGridDoneButton()]
assertWithMatcher:grey_accessibilityTrait(UIAccessibilityTraitButton)];
// Close all tabs & check that the Done button is greyed out.
[ChromeEarlGrey closeAllNormalTabs];
[[EarlGrey selectElementWithMatcher:TabGridDoneButton()]
assertWithMatcher:grey_accessibilityTrait(
UIAccessibilityTraitNotEnabled)];
if (!IsIPadIdiom()) {
[EarlGrey rotateDeviceToOrientation:UIDeviceOrientationPortrait error:nil];
}
}
@end @end
...@@ -130,6 +130,8 @@ NSUInteger GetPageIndexFromPage(TabGridPage page) { ...@@ -130,6 +130,8 @@ NSUInteger GetPageIndexFromPage(TabGridPage page) {
@property(nonatomic, weak) UIBarButtonItem* doneButton; @property(nonatomic, weak) UIBarButtonItem* doneButton;
@property(nonatomic, weak) UIBarButtonItem* closeAllButton; @property(nonatomic, weak) UIBarButtonItem* closeAllButton;
@property(nonatomic, assign) BOOL undoCloseAllAvailable; @property(nonatomic, assign) BOOL undoCloseAllAvailable;
// Bool informing if the confirmation action sheet is displayed.
@property(nonatomic, assign) BOOL closeAllConfirmationDisplayed;
@property(nonatomic, assign) TabGridConfiguration configuration; @property(nonatomic, assign) TabGridConfiguration configuration;
// Setting the current page doesn't scroll the scroll view; use // Setting the current page doesn't scroll the scroll view; use
// -scrollToPage:animated: for that. // -scrollToPage:animated: for that.
...@@ -160,6 +162,7 @@ NSUInteger GetPageIndexFromPage(TabGridPage page) { ...@@ -160,6 +162,7 @@ NSUInteger GetPageIndexFromPage(TabGridPage page) {
_regularTabsViewController = [[GridViewController alloc] init]; _regularTabsViewController = [[GridViewController alloc] init];
_incognitoTabsViewController = [[GridViewController alloc] init]; _incognitoTabsViewController = [[GridViewController alloc] init];
_remoteTabsViewController = [[RecentTabsTableViewController alloc] init]; _remoteTabsViewController = [[RecentTabsTableViewController alloc] init];
_closeAllConfirmationDisplayed = NO;
_pageViewControllers = @[ _pageViewControllers = @[
_incognitoTabsViewController, _regularTabsViewController, _incognitoTabsViewController, _regularTabsViewController,
_remoteTabsViewController _remoteTabsViewController
...@@ -414,7 +417,8 @@ NSUInteger GetPageIndexFromPage(TabGridPage page) { ...@@ -414,7 +417,8 @@ NSUInteger GetPageIndexFromPage(TabGridPage page) {
} }
- (void)closeAllTabsConfirmationClosed { - (void)closeAllTabsConfirmationClosed {
self.topToolbar.pageControl.userInteractionEnabled = YES; self.closeAllConfirmationDisplayed = NO;
[self configureButtonsForActiveAndCurrentPage];
} }
#pragma mark - Public Properties #pragma mark - Public Properties
...@@ -1068,6 +1072,10 @@ NSUInteger GetPageIndexFromPage(TabGridPage page) { ...@@ -1068,6 +1072,10 @@ NSUInteger GetPageIndexFromPage(TabGridPage page) {
NOTREACHED() << "The done button should not be configured based on the " NOTREACHED() << "The done button should not be configured based on the "
"contents of the recent tabs page."; "contents of the recent tabs page.";
} }
if (!self.closeAllConfirmationDisplayed)
self.topToolbar.pageControl.userInteractionEnabled = YES;
// The Done button should have the same behavior as the other buttons on the // The Done button should have the same behavior as the other buttons on the
// top Toolbar. // top Toolbar.
BOOL incognitoTabsNeedsAuth = BOOL incognitoTabsNeedsAuth =
...@@ -1498,6 +1506,7 @@ NSUInteger GetPageIndexFromPage(TabGridPage page) { ...@@ -1498,6 +1506,7 @@ NSUInteger GetPageIndexFromPage(TabGridPage page) {
// toolbar in order to avoid alignment issues when changing the device // toolbar in order to avoid alignment issues when changing the device
// orientation to landscape in multi window mode. // orientation to landscape in multi window mode.
UIBarButtonItem* buttonAnchor = self.topToolbar.leadingButton; UIBarButtonItem* buttonAnchor = self.topToolbar.leadingButton;
self.closeAllConfirmationDisplayed = YES;
self.topToolbar.pageControl.userInteractionEnabled = NO; self.topToolbar.pageControl.userInteractionEnabled = NO;
switch (self.currentPage) { switch (self.currentPage) {
case TabGridPageIncognitoTabs: case TabGridPageIncognitoTabs:
......
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