Commit 1059261b authored by Gauthier Ambard's avatar Gauthier Ambard Committed by Commit Bot

Change the layout of the toolbar's buttons

This CL changes the layout of the toolbar buttons.
The tab switcher is now always on the trailing side, and the bookmarks
button is only visible on iPad.

Bug: 831151
Cq-Include-Trybots: master.tryserver.chromium.mac:ios-simulator-cronet;master.tryserver.chromium.mac:ios-simulator-full-configs
Change-Id: I903e4b702439c23a01e2cf4ef8e2edecae11fdf4
Reviewed-on: https://chromium-review.googlesource.com/1013558
Commit-Queue: Gauthier Ambard <gambard@chromium.org>
Reviewed-by: default avatarOlivier Robin <olivierrobin@chromium.org>
Cr-Commit-Position: refs/heads/master@{#551286}
parent c06f87b1
...@@ -25,6 +25,7 @@ ...@@ -25,6 +25,7 @@
#import "ios/chrome/test/earl_grey/chrome_matchers.h" #import "ios/chrome/test/earl_grey/chrome_matchers.h"
#import "ios/chrome/test/earl_grey/chrome_test_case.h" #import "ios/chrome/test/earl_grey/chrome_test_case.h"
#include "ios/testing/earl_grey/disabled_test_macros.h" #include "ios/testing/earl_grey/disabled_test_macros.h"
#import "ios/testing/earl_grey/disabled_test_macros.h"
#import "ios/web/public/test/earl_grey/web_view_matchers.h" #import "ios/web/public/test/earl_grey/web_view_matchers.h"
#include "net/test/embedded_test_server/http_request.h" #include "net/test/embedded_test_server/http_request.h"
#include "net/test/embedded_test_server/http_response.h" #include "net/test/embedded_test_server/http_response.h"
...@@ -238,7 +239,9 @@ void CheckToolbarButtonVisibility(UITraitCollection* traitCollection, ...@@ -238,7 +239,9 @@ void CheckToolbarButtonVisibility(UITraitCollection* traitCollection,
assertWithMatcher:VisibleInPrimaryToolbar()]; assertWithMatcher:VisibleInPrimaryToolbar()];
[[EarlGrey selectElementWithMatcher:ShareButton()] [[EarlGrey selectElementWithMatcher:ShareButton()]
assertWithMatcher:VisibleInPrimaryToolbar()]; assertWithMatcher:VisibleInPrimaryToolbar()];
[[EarlGrey selectElementWithMatcher:BookmarkButton()] [[EarlGrey selectElementWithMatcher:chrome_test_util::
ButtonWithAccessibilityLabelId(
IDS_IOS_ACCNAME_RELOAD)]
assertWithMatcher:VisibleInPrimaryToolbar()]; assertWithMatcher:VisibleInPrimaryToolbar()];
[[EarlGrey selectElementWithMatcher:chrome_test_util:: [[EarlGrey selectElementWithMatcher:chrome_test_util::
ButtonWithAccessibilityLabelId( ButtonWithAccessibilityLabelId(
...@@ -257,10 +260,15 @@ void CheckToolbarButtonVisibility(UITraitCollection* traitCollection, ...@@ -257,10 +260,15 @@ void CheckToolbarButtonVisibility(UITraitCollection* traitCollection,
IDS_IOS_TOOLBAR_SHOW_TABS)] IDS_IOS_TOOLBAR_SHOW_TABS)]
assertWithMatcher:VisibleInPrimaryToolbar()]; assertWithMatcher:VisibleInPrimaryToolbar()];
} else { } else {
// Unsplit in Regular x Regular, the reload/stop button is visible. // Unsplit in Regular x Regular, the bookmark button is visible, the stack
[[EarlGrey selectElementWithMatcher:chrome_test_util:: // view button is hidden.
ButtonWithAccessibilityLabelId( [[EarlGrey
IDS_IOS_ACCNAME_RELOAD)] selectElementWithMatcher:
grey_allOf(chrome_test_util::ButtonWithAccessibilityLabelId(
IDS_IOS_TOOLBAR_SHOW_TABS),
VisibleInPrimaryToolbar(), nil)]
assertWithMatcher:grey_nil()];
[[EarlGrey selectElementWithMatcher:BookmarkButton()]
assertWithMatcher:VisibleInPrimaryToolbar()]; assertWithMatcher:VisibleInPrimaryToolbar()];
} }
} }
...@@ -321,10 +329,10 @@ void FocusOmnibox() { ...@@ -321,10 +329,10 @@ void FocusOmnibox() {
// Tests that bookmarks button is spotlighted for the bookmarked pages. // Tests that bookmarks button is spotlighted for the bookmarked pages.
- (void)testBookmarkButton { - (void)testBookmarkButton {
if (!IsIPadIdiom()) { if (!IsRegularXRegularSizeClass()) {
// If this test is run on an iPhone, rotate it to have the unsplit toolbar. EARL_GREY_TEST_SKIPPED(
[EarlGrey rotateDeviceToOrientation:UIDeviceOrientationLandscapeLeft @"The bookmark button is only visible on Regular x Regular size "
errorOrNil:nil]; @"classes.");
} }
// Setup the bookmarks. // Setup the bookmarks.
...@@ -363,12 +371,6 @@ void FocusOmnibox() { ...@@ -363,12 +371,6 @@ void FocusOmnibox() {
// Clean the bookmarks // Clean the bookmarks
GREYAssert(chrome_test_util::ClearBookmarks(), GREYAssert(chrome_test_util::ClearBookmarks(),
@"Not all bookmarks were removed."); @"Not all bookmarks were removed.");
if (!IsIPadIdiom()) {
// Cancel rotation.
[EarlGrey rotateDeviceToOrientation:UIDeviceOrientationPortrait
errorOrNil:nil];
}
} }
// Tests that tapping a button cancels the focus on the omnibox. // Tests that tapping a button cancels the focus on the omnibox.
......
...@@ -201,14 +201,12 @@ ...@@ -201,14 +201,12 @@
- (void)setUpLeadingStackView { - (void)setUpLeadingStackView {
self.backButton = [self.buttonFactory backButton]; self.backButton = [self.buttonFactory backButton];
self.forwardButton = [self.buttonFactory forwardButton]; self.forwardButton = [self.buttonFactory forwardButton];
self.tabGridButton = [self.buttonFactory tabGridButton];
self.stopButton = [self.buttonFactory stopButton]; self.stopButton = [self.buttonFactory stopButton];
self.stopButton.hiddenInCurrentState = YES; self.stopButton.hiddenInCurrentState = YES;
self.reloadButton = [self.buttonFactory reloadButton]; self.reloadButton = [self.buttonFactory reloadButton];
self.leadingStackViewButtons = @[ self.leadingStackViewButtons = @[
self.backButton, self.forwardButton, self.tabGridButton, self.stopButton, self.backButton, self.forwardButton, self.stopButton, self.reloadButton
self.reloadButton
]; ];
self.leadingStackView = [[UIStackView alloc] self.leadingStackView = [[UIStackView alloc]
initWithArrangedSubviews:self.leadingStackViewButtons]; initWithArrangedSubviews:self.leadingStackViewButtons];
...@@ -225,10 +223,13 @@ ...@@ -225,10 +223,13 @@
- (void)setUpTrailingStackView { - (void)setUpTrailingStackView {
self.shareButton = [self.buttonFactory shareButton]; self.shareButton = [self.buttonFactory shareButton];
self.bookmarkButton = [self.buttonFactory bookmarkButton]; self.bookmarkButton = [self.buttonFactory bookmarkButton];
self.tabGridButton = [self.buttonFactory tabGridButton];
self.toolsMenuButton = [self.buttonFactory toolsMenuButton]; self.toolsMenuButton = [self.buttonFactory toolsMenuButton];
self.trailingStackViewButtons = self.trailingStackViewButtons = @[
@[ self.shareButton, self.bookmarkButton, self.toolsMenuButton ]; self.shareButton, self.bookmarkButton, self.tabGridButton,
self.toolsMenuButton
];
self.trailingStackView = [[UIStackView alloc] self.trailingStackView = [[UIStackView alloc]
initWithArrangedSubviews:self.trailingStackViewButtons]; initWithArrangedSubviews:self.trailingStackViewButtons];
self.trailingStackView.translatesAutoresizingMaskIntoConstraints = NO; self.trailingStackView.translatesAutoresizingMaskIntoConstraints = NO;
......
...@@ -63,7 +63,7 @@ ...@@ -63,7 +63,7 @@
switch (self.type) { switch (self.type) {
case PRIMARY: case PRIMARY:
return ToolbarComponentVisibilityAlways & return ToolbarComponentVisibilityAlways &
~ToolbarComponentVisibilityCompactWidthRegularHeight; ~ToolbarComponentVisibilitySplit;
case SECONDARY: case SECONDARY:
return ToolbarComponentVisibilitySplit; return ToolbarComponentVisibilitySplit;
case LEGACY: case LEGACY:
...@@ -86,7 +86,8 @@ ...@@ -86,7 +86,8 @@
- (ToolbarComponentVisibility)reloadButtonVisibility { - (ToolbarComponentVisibility)reloadButtonVisibility {
switch (self.type) { switch (self.type) {
case PRIMARY: case PRIMARY:
return ToolbarComponentVisibilityRegularWidthRegularHeight; return ToolbarComponentVisibilityAlways &
~ToolbarComponentVisibilitySplit;
case SECONDARY: case SECONDARY:
return ToolbarComponentVisibilityNone; return ToolbarComponentVisibilityNone;
case LEGACY: case LEGACY:
...@@ -97,7 +98,8 @@ ...@@ -97,7 +98,8 @@
- (ToolbarComponentVisibility)stopButtonVisibility { - (ToolbarComponentVisibility)stopButtonVisibility {
switch (self.type) { switch (self.type) {
case PRIMARY: case PRIMARY:
return ToolbarComponentVisibilityRegularWidthRegularHeight; return ToolbarComponentVisibilityAlways &
~ToolbarComponentVisibilitySplit;
case SECONDARY: case SECONDARY:
return ToolbarComponentVisibilityNone; return ToolbarComponentVisibilityNone;
case LEGACY: case LEGACY:
...@@ -108,8 +110,7 @@ ...@@ -108,8 +110,7 @@
- (ToolbarComponentVisibility)bookmarkButtonVisibility { - (ToolbarComponentVisibility)bookmarkButtonVisibility {
switch (self.type) { switch (self.type) {
case PRIMARY: case PRIMARY:
return ToolbarComponentVisibilityAlways & return ToolbarComponentVisibilityRegularWidthRegularHeight;
~ToolbarComponentVisibilityCompactWidthRegularHeight;
case SECONDARY: case SECONDARY:
return ToolbarComponentVisibilityNone; return ToolbarComponentVisibilityNone;
case LEGACY: case LEGACY:
......
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