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 @@
#import "ios/chrome/test/earl_grey/chrome_matchers.h"
#import "ios/chrome/test/earl_grey/chrome_test_case.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"
#include "net/test/embedded_test_server/http_request.h"
#include "net/test/embedded_test_server/http_response.h"
......@@ -238,7 +239,9 @@ void CheckToolbarButtonVisibility(UITraitCollection* traitCollection,
assertWithMatcher:VisibleInPrimaryToolbar()];
[[EarlGrey selectElementWithMatcher:ShareButton()]
assertWithMatcher:VisibleInPrimaryToolbar()];
[[EarlGrey selectElementWithMatcher:BookmarkButton()]
[[EarlGrey selectElementWithMatcher:chrome_test_util::
ButtonWithAccessibilityLabelId(
IDS_IOS_ACCNAME_RELOAD)]
assertWithMatcher:VisibleInPrimaryToolbar()];
[[EarlGrey selectElementWithMatcher:chrome_test_util::
ButtonWithAccessibilityLabelId(
......@@ -257,10 +260,15 @@ void CheckToolbarButtonVisibility(UITraitCollection* traitCollection,
IDS_IOS_TOOLBAR_SHOW_TABS)]
assertWithMatcher:VisibleInPrimaryToolbar()];
} else {
// Unsplit in Regular x Regular, the reload/stop button is visible.
[[EarlGrey selectElementWithMatcher:chrome_test_util::
ButtonWithAccessibilityLabelId(
IDS_IOS_ACCNAME_RELOAD)]
// Unsplit in Regular x Regular, the bookmark button is visible, the stack
// view button is hidden.
[[EarlGrey
selectElementWithMatcher:
grey_allOf(chrome_test_util::ButtonWithAccessibilityLabelId(
IDS_IOS_TOOLBAR_SHOW_TABS),
VisibleInPrimaryToolbar(), nil)]
assertWithMatcher:grey_nil()];
[[EarlGrey selectElementWithMatcher:BookmarkButton()]
assertWithMatcher:VisibleInPrimaryToolbar()];
}
}
......@@ -321,10 +329,10 @@ void FocusOmnibox() {
// Tests that bookmarks button is spotlighted for the bookmarked pages.
- (void)testBookmarkButton {
if (!IsIPadIdiom()) {
// If this test is run on an iPhone, rotate it to have the unsplit toolbar.
[EarlGrey rotateDeviceToOrientation:UIDeviceOrientationLandscapeLeft
errorOrNil:nil];
if (!IsRegularXRegularSizeClass()) {
EARL_GREY_TEST_SKIPPED(
@"The bookmark button is only visible on Regular x Regular size "
@"classes.");
}
// Setup the bookmarks.
......@@ -363,12 +371,6 @@ void FocusOmnibox() {
// Clean the bookmarks
GREYAssert(chrome_test_util::ClearBookmarks(),
@"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.
......
......@@ -201,14 +201,12 @@
- (void)setUpLeadingStackView {
self.backButton = [self.buttonFactory backButton];
self.forwardButton = [self.buttonFactory forwardButton];
self.tabGridButton = [self.buttonFactory tabGridButton];
self.stopButton = [self.buttonFactory stopButton];
self.stopButton.hiddenInCurrentState = YES;
self.reloadButton = [self.buttonFactory reloadButton];
self.leadingStackViewButtons = @[
self.backButton, self.forwardButton, self.tabGridButton, self.stopButton,
self.reloadButton
self.backButton, self.forwardButton, self.stopButton, self.reloadButton
];
self.leadingStackView = [[UIStackView alloc]
initWithArrangedSubviews:self.leadingStackViewButtons];
......@@ -225,10 +223,13 @@
- (void)setUpTrailingStackView {
self.shareButton = [self.buttonFactory shareButton];
self.bookmarkButton = [self.buttonFactory bookmarkButton];
self.tabGridButton = [self.buttonFactory tabGridButton];
self.toolsMenuButton = [self.buttonFactory toolsMenuButton];
self.trailingStackViewButtons =
@[ self.shareButton, self.bookmarkButton, self.toolsMenuButton ];
self.trailingStackViewButtons = @[
self.shareButton, self.bookmarkButton, self.tabGridButton,
self.toolsMenuButton
];
self.trailingStackView = [[UIStackView alloc]
initWithArrangedSubviews:self.trailingStackViewButtons];
self.trailingStackView.translatesAutoresizingMaskIntoConstraints = NO;
......
......@@ -63,7 +63,7 @@
switch (self.type) {
case PRIMARY:
return ToolbarComponentVisibilityAlways &
~ToolbarComponentVisibilityCompactWidthRegularHeight;
~ToolbarComponentVisibilitySplit;
case SECONDARY:
return ToolbarComponentVisibilitySplit;
case LEGACY:
......@@ -86,7 +86,8 @@
- (ToolbarComponentVisibility)reloadButtonVisibility {
switch (self.type) {
case PRIMARY:
return ToolbarComponentVisibilityRegularWidthRegularHeight;
return ToolbarComponentVisibilityAlways &
~ToolbarComponentVisibilitySplit;
case SECONDARY:
return ToolbarComponentVisibilityNone;
case LEGACY:
......@@ -97,7 +98,8 @@
- (ToolbarComponentVisibility)stopButtonVisibility {
switch (self.type) {
case PRIMARY:
return ToolbarComponentVisibilityRegularWidthRegularHeight;
return ToolbarComponentVisibilityAlways &
~ToolbarComponentVisibilitySplit;
case SECONDARY:
return ToolbarComponentVisibilityNone;
case LEGACY:
......@@ -108,8 +110,7 @@
- (ToolbarComponentVisibility)bookmarkButtonVisibility {
switch (self.type) {
case PRIMARY:
return ToolbarComponentVisibilityAlways &
~ToolbarComponentVisibilityCompactWidthRegularHeight;
return ToolbarComponentVisibilityRegularWidthRegularHeight;
case SECONDARY:
return ToolbarComponentVisibilityNone;
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