Commit c52143f5 authored by sczs's avatar sczs Committed by Commit Bot

[ios] Deletes BookmarkContextBar and uses UIToolbar instead

- Deletes BookmarkContextBar files and usage from BookmarkHomeVC.
- Uses BookmarkHomeVC navigationController UIToolbar instead.
- Creates accessibilityIdentifiers for toolbar buttons.
- Changes the BookmarkTableCell margins since these were giving the effect of shrinking row height.

Screenshots
Old: https://drive.google.com/open?id=1v3GQRiiPiIzJNZ7Lxd-pgpaaqP15b0PR
New: https://drive.google.com/open?id=1z5mOT3p1NBj62EaMKfR2P5WSD2irQmyX

Bug: 839435
Cq-Include-Trybots: master.tryserver.chromium.mac:ios-simulator-cronet;master.tryserver.chromium.mac:ios-simulator-full-configs
Change-Id: I155365b6f9520010153ce97187ef1f6a2a8514f7
Reviewed-on: https://chromium-review.googlesource.com/1054123
Commit-Queue: Sergio Collazos <sczs@chromium.org>
Reviewed-by: default avatarRohit Rao <rohitrao@chromium.org>
Cr-Commit-Position: refs/heads/master@{#558114}
parent a242af07
...@@ -95,7 +95,6 @@ source_set("bookmarks") { ...@@ -95,7 +95,6 @@ source_set("bookmarks") {
"//ios/chrome/browser/ui/alert_coordinator", "//ios/chrome/browser/ui/alert_coordinator",
"//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/bookmarks/bars",
"//ios/chrome/browser/ui/bookmarks/cells", "//ios/chrome/browser/ui/bookmarks/cells",
"//ios/chrome/browser/ui/colors", "//ios/chrome/browser/ui/colors",
"//ios/chrome/browser/ui/commands", "//ios/chrome/browser/ui/commands",
...@@ -120,10 +119,7 @@ source_set("bookmarks") { ...@@ -120,10 +119,7 @@ source_set("bookmarks") {
"//ui/gfx", "//ui/gfx",
"//url", "//url",
] ]
allow_circular_includes_from = [ allow_circular_includes_from = [ "//ios/chrome/browser/ui/bookmarks/cells" ]
"//ios/chrome/browser/ui/bookmarks/bars",
"//ios/chrome/browser/ui/bookmarks/cells",
]
libs = [ libs = [
"CoreGraphics.framework", "CoreGraphics.framework",
"QuartzCore.framework", "QuartzCore.framework",
......
# Copyright 2016 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
source_set("bars") {
configs += [ "//build/config/compiler:enable_arc" ]
sources = [
"bookmark_context_bar.h",
"bookmark_context_bar.mm",
]
deps = [
"//base",
"//ios/chrome/app/strings",
"//ios/chrome/browser/ui",
"//ios/chrome/browser/ui/colors",
"//ios/third_party/material_components_ios",
"//ui/base",
]
libs = [ "UIKit.framework" ]
}
// Copyright 2017 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef IOS_CHROME_BROWSER_UI_BOOKMARKS_BARS_BOOKMARK_CONTEXT_BAR_H_
#define IOS_CHROME_BROWSER_UI_BOOKMARKS_BARS_BOOKMARK_CONTEXT_BAR_H_
#import <UIKit/UIKit.h>
// Delegate for BookmarkContextBar. Used to pass on button actions.
@protocol ContextBarDelegate<NSObject>
// Called when the leading button is clicked.
- (void)leadingButtonClicked;
// Called when the center button is clicked.
- (void)centerButtonClicked;
// Called when the trailing button is clicked.
- (void)trailingButtonClicked;
@end
typedef NS_ENUM(NSInteger, ContextBarButton) {
ContextBarLeadingButton,
ContextBarCenterButton,
ContextBarTrailingButton
};
typedef NS_ENUM(NSInteger, ContextBarButtonStyle) {
ContextBarButtonStyleDefault,
ContextBarButtonStyleDelete,
};
// View with 3 customizable buttons in a row.
@interface BookmarkContextBar : UIView
@property(nonatomic, weak) id<ContextBarDelegate> delegate;
// Methods for setting button's title, style and visibility.
- (void)setButtonTitle:(NSString*)title forButton:(ContextBarButton)button;
- (void)setButtonStyle:(ContextBarButtonStyle)style
forButton:(ContextBarButton)button;
- (void)setButtonVisibility:(BOOL)visible forButton:(ContextBarButton)button;
- (void)setButtonEnabled:(BOOL)enabled forButton:(ContextBarButton)button;
- (void)updateHeight;
@end
#endif // IOS_CHROME_BROWSER_UI_BOOKMARKS_BARS_BOOKMARK_CONTEXT_BAR_H_
// Copyright 2017 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#import "ios/chrome/browser/ui/bookmarks/bars/bookmark_context_bar.h"
#include "base/logging.h"
#import "ios/chrome/browser/ui/colors/MDCPalette+CrAdditions.h"
#include "ios/chrome/browser/ui/rtl_geometry.h"
#import "ios/chrome/browser/ui/uikit_ui_util.h"
#import "ios/chrome/browser/ui/util/constraints_ui_util.h"
#import "ios/third_party/material_components_ios/src/components/Buttons/src/MaterialButtons.h"
#import "ios/third_party/material_components_ios/src/components/Palettes/src/MaterialPalettes.h"
#import "ios/third_party/material_components_ios/src/components/Typography/src/MaterialTypography.h"
#include "ui/base/l10n/l10n_util_mac.h"
#import "ui/gfx/ios/NSString+CrStringDrawing.h"
#if !defined(__has_feature) || !__has_feature(objc_arc)
#error "This file requires ARC support."
#endif
namespace {
// Shadow opacity for the BookmarkContextBar.
const CGFloat kShadowOpacity = 0.12f;
// Shadow radius for the BookmarkContextBar.
const CGFloat kShadowRadius = 12.0f;
// Horizontal margin for the contents of BookmarkContextBar.
const CGFloat kHorizontalMargin = 16.0f;
// Vertical margin for the contents of BookmarkContextBar.
const CGFloat kVerticalMargin = 8.0f;
// Horizontal spacing between the buttons inside BookmarkContextBar.
const CGFloat kHorizontalSpacing = 8.0f;
// Height of the toolbar in normal state.
const CGFloat kToolbarNormalHeight = 48.0f;
// Height of the expanded toolbar (buttons on multiple lines).
const CGFloat kToolbarExpandedHeight = 58.0f;
} // namespace
@interface BookmarkContextBar ()
// Button at the leading position.
@property(nonatomic, strong) UIButton* leadingButton;
@property(nonatomic, strong) UIView* leadingButtonContainer;
// Button at the center position.
@property(nonatomic, strong) UIButton* centerButton;
@property(nonatomic, strong) UIView* centerButtonContainer;
// Button at the trailing position.
@property(nonatomic, strong) UIButton* trailingButton;
@property(nonatomic, strong) UIView* trailingButtonContainer;
// Stack view for arranging the buttons.
@property(nonatomic, strong) UIStackView* stackView;
// Height constraint for the stack view containing the buttons.
@property(nonatomic, strong) NSLayoutConstraint* heightConstraint;
@end
@implementation BookmarkContextBar
@synthesize delegate = _delegate;
@synthesize leadingButton = _leadingButton;
@synthesize leadingButtonContainer = _leadingButtonContainer;
@synthesize centerButton = _centerButton;
@synthesize centerButtonContainer = _centerButtonContainer;
@synthesize trailingButton = _trailingButton;
@synthesize trailingButtonContainer = _trailingButtonContainer;
@synthesize stackView = _stackView;
@synthesize heightConstraint = _heightConstraint;
#pragma mark - Private Methods
- (UIButton*)getButton:(ContextBarButton)contextBarButton {
switch (contextBarButton) {
case ContextBarLeadingButton: {
return _leadingButton;
break;
}
case ContextBarCenterButton: {
return _centerButton;
break;
}
case ContextBarTrailingButton: {
return _trailingButton;
break;
}
default: { NOTREACHED(); }
}
}
- (void)setButtonStyle:(ContextBarButtonStyle)style
forUIButton:(UIButton*)button {
UIColor* textColor = style == ContextBarButtonStyleDelete
? [[MDCPalette cr_redPalette] tint500]
: [[MDCPalette cr_bluePalette] tint500];
UIColor* disabledColor = style == ContextBarButtonStyleDelete
? [[MDCPalette cr_redPalette] tint200]
: [[MDCPalette cr_bluePalette] tint200];
[button setTitleColor:textColor forState:UIControlStateNormal];
[button setTitleColor:disabledColor forState:UIControlStateDisabled];
}
- (void)configureStyleForButton:(ContextBarButton)contextBarButton {
UIButton* button = [self getButton:contextBarButton];
[button setBackgroundColor:[UIColor whiteColor]];
[button setTitleColor:[[MDCPalette cr_bluePalette] tint500]
forState:UIControlStateNormal];
[[button titleLabel] setFont:[MDCTypography subheadFont]];
[self setButtonStyle:ContextBarButtonStyleDefault forUIButton:button];
[button setTranslatesAutoresizingMaskIntoConstraints:NO];
button.titleLabel.numberOfLines = 2;
button.titleLabel.adjustsFontSizeToFitWidth = YES;
switch (contextBarButton) {
case ContextBarLeadingButton: {
if (UseRTLLayout()) {
button.titleLabel.textAlignment = NSTextAlignmentRight;
button.contentHorizontalAlignment =
UIControlContentHorizontalAlignmentRight;
} else {
button.titleLabel.textAlignment = NSTextAlignmentLeft;
button.contentHorizontalAlignment =
UIControlContentHorizontalAlignmentLeft;
}
break;
}
case ContextBarCenterButton: {
button.titleLabel.textAlignment = NSTextAlignmentCenter;
button.contentHorizontalAlignment =
UIControlContentHorizontalAlignmentCenter;
break;
}
case ContextBarTrailingButton: {
if (UseRTLLayout()) {
button.titleLabel.textAlignment = NSTextAlignmentLeft;
button.contentHorizontalAlignment =
UIControlContentHorizontalAlignmentLeft;
} else {
button.titleLabel.textAlignment = NSTextAlignmentRight;
button.contentHorizontalAlignment =
UIControlContentHorizontalAlignmentRight;
}
break;
}
default: { NOTREACHED(); }
}
}
#pragma mark - Public Methods
- (instancetype)initWithFrame:(CGRect)frame {
self = [super initWithFrame:frame];
if (self) {
NSDictionary* views = nil;
NSArray* constraints = nil;
self.accessibilityIdentifier = @"context_bar";
_leadingButton = [UIButton buttonWithType:UIButtonTypeCustom];
[self configureStyleForButton:ContextBarLeadingButton];
[_leadingButton addTarget:self
action:@selector(leadingButtonClicked:)
forControlEvents:UIControlEventTouchUpInside];
_leadingButton.accessibilityIdentifier = @"context_bar_leading_button";
_leadingButtonContainer = [[UIView alloc] init];
_leadingButtonContainer.hidden = YES;
[_leadingButtonContainer addSubview:_leadingButton];
views = @{@"button" : _leadingButton};
constraints = @[ @"V:|[button]|", @"H:|[button]" ];
ApplyVisualConstraints(constraints, views);
[_leadingButton.trailingAnchor
constraintLessThanOrEqualToAnchor:_leadingButtonContainer
.trailingAnchor]
.active = YES;
_centerButton = [UIButton buttonWithType:UIButtonTypeCustom];
[self configureStyleForButton:ContextBarCenterButton];
[_centerButton addTarget:self
action:@selector(centerButtonClicked:)
forControlEvents:UIControlEventTouchUpInside];
_centerButton.accessibilityIdentifier = @"context_bar_center_button";
_centerButtonContainer = [[UIView alloc] init];
_centerButtonContainer.hidden = YES;
[_centerButtonContainer addSubview:_centerButton];
views = @{@"button" : _centerButton};
constraints = @[ @"V:|[button]|" ];
ApplyVisualConstraints(constraints, views);
[_centerButton.centerXAnchor
constraintEqualToAnchor:_centerButtonContainer.centerXAnchor]
.active = YES;
[_centerButton.trailingAnchor
constraintLessThanOrEqualToAnchor:_centerButtonContainer.trailingAnchor]
.active = YES;
[_centerButton.leadingAnchor
constraintGreaterThanOrEqualToAnchor:_centerButtonContainer
.leadingAnchor]
.active = YES;
_trailingButton = [UIButton buttonWithType:UIButtonTypeCustom];
[self configureStyleForButton:ContextBarTrailingButton];
[_trailingButton addTarget:self
action:@selector(trailingButtonClicked:)
forControlEvents:UIControlEventTouchUpInside];
_trailingButton.accessibilityIdentifier = @"context_bar_trailing_button";
_trailingButtonContainer = [[UIView alloc] init];
_trailingButtonContainer.hidden = YES;
[_trailingButtonContainer addSubview:_trailingButton];
views = @{@"button" : _trailingButton};
constraints = @[ @"V:|[button]|", @"H:[button]|" ];
ApplyVisualConstraints(constraints, views);
[_trailingButton.leadingAnchor
constraintGreaterThanOrEqualToAnchor:_trailingButtonContainer
.leadingAnchor]
.active = YES;
_stackView = [[UIStackView alloc] initWithArrangedSubviews:@[
_leadingButtonContainer, _centerButtonContainer, _trailingButtonContainer
]];
_stackView.alignment = UIStackViewAlignmentCenter;
_stackView.distribution = UIStackViewDistributionFillEqually;
_stackView.axis = UILayoutConstraintAxisHorizontal;
[self addSubview:_stackView];
_stackView.translatesAutoresizingMaskIntoConstraints = NO;
_stackView.layoutMarginsRelativeArrangement = YES;
PinToSafeArea(_stackView, self);
_heightConstraint = [_stackView.heightAnchor
constraintEqualToConstant:kToolbarNormalHeight];
_heightConstraint.active = YES;
_stackView.layoutMargins = UIEdgeInsetsMake(
kVerticalMargin, kHorizontalMargin, kVerticalMargin, kHorizontalMargin);
_stackView.spacing = kHorizontalSpacing;
[self setBackgroundColor:[UIColor whiteColor]];
[[self layer] setShadowOpacity:kShadowOpacity];
[[self layer] setShadowRadius:kShadowRadius];
}
return self;
}
- (void)setButtonTitle:(NSString*)title forButton:(ContextBarButton)button {
[[self getButton:button] setTitle:title forState:UIControlStateNormal];
}
- (void)setButtonStyle:(ContextBarButtonStyle)style
forButton:(ContextBarButton)button {
[self setButtonStyle:style forUIButton:[self getButton:button]];
}
- (void)setButtonVisibility:(BOOL)visible forButton:(ContextBarButton)button {
// Set the visiblity of the button container.
[self getButton:button].superview.hidden = !visible;
}
- (void)setButtonEnabled:(BOOL)enabled forButton:(ContextBarButton)button {
[[self getButton:button] setEnabled:enabled];
}
- (void)leadingButtonClicked:(UIButton*)button {
if (!self.delegate) {
NOTREACHED();
}
[self.delegate leadingButtonClicked];
}
- (void)centerButtonClicked:(UIButton*)button {
if (!self.delegate) {
NOTREACHED();
}
[self.delegate centerButtonClicked];
}
- (void)trailingButtonClicked:(UIButton*)button {
if (!self.delegate) {
NOTREACHED();
}
[self.delegate trailingButtonClicked];
}
- (void)updateHeight {
NSArray* buttons = @[ _leadingButton, _centerButton, _trailingButton ];
CGFloat availableWidth = self.frame.size.width - kHorizontalMargin * 2;
NSUInteger visibleCount = 0;
// Count the number of visible buttons and deduct the button spacings from
// availableWidth.
for (UIButton* button in buttons) {
if (!button.superview.hidden) {
visibleCount++;
if (visibleCount > 1) {
availableWidth -= kHorizontalSpacing;
}
}
}
// Expand toolbar height in case word wrapping happens.
for (UIButton* button in buttons) {
if (!button.superview.hidden) {
CGFloat rect = [button.titleLabel.text
cr_pixelAlignedSizeWithFont:button.titleLabel.font]
.width;
if (rect > availableWidth / visibleCount) {
self.heightConstraint.constant = kToolbarExpandedHeight;
return;
}
}
}
// Use the normal height when there is no word wrapping.
self.heightConstraint.constant = kToolbarNormalHeight;
}
@end
...@@ -90,9 +90,6 @@ class BookmarkNode; ...@@ -90,9 +90,6 @@ class BookmarkNode;
// The app bar for the bookmarks. // The app bar for the bookmarks.
@property(nonatomic, readonly) MDCAppBar* appBar; @property(nonatomic, readonly) MDCAppBar* appBar;
// The context bar at the bottom of the bookmarks.
@property(nonatomic, readonly) BookmarkContextBar* contextBar;
// This view is created and used if the model is not fully loaded yet by the // This view is created and used if the model is not fully loaded yet by the
// time this controller starts. // time this controller starts.
@property(nonatomic, readonly) BookmarkHomeWaitingView* waitForModelView; @property(nonatomic, readonly) BookmarkHomeWaitingView* waitForModelView;
......
...@@ -20,7 +20,6 @@ ...@@ -20,7 +20,6 @@
#include "ios/chrome/browser/favicon/ios_chrome_large_icon_service_factory.h" #include "ios/chrome/browser/favicon/ios_chrome_large_icon_service_factory.h"
#import "ios/chrome/browser/metrics/new_tab_page_uma.h" #import "ios/chrome/browser/metrics/new_tab_page_uma.h"
#import "ios/chrome/browser/ui/authentication/signin_promo_view_configurator.h" #import "ios/chrome/browser/ui/authentication/signin_promo_view_configurator.h"
#import "ios/chrome/browser/ui/bookmarks/bars/bookmark_context_bar.h"
#import "ios/chrome/browser/ui/bookmarks/bookmark_edit_view_controller.h" #import "ios/chrome/browser/ui/bookmarks/bookmark_edit_view_controller.h"
#import "ios/chrome/browser/ui/bookmarks/bookmark_folder_editor_view_controller.h" #import "ios/chrome/browser/ui/bookmarks/bookmark_folder_editor_view_controller.h"
#import "ios/chrome/browser/ui/bookmarks/bookmark_folder_view_controller.h" #import "ios/chrome/browser/ui/bookmarks/bookmark_folder_view_controller.h"
...@@ -32,6 +31,7 @@ ...@@ -32,6 +31,7 @@
#import "ios/chrome/browser/ui/bookmarks/bookmark_navigation_controller.h" #import "ios/chrome/browser/ui/bookmarks/bookmark_navigation_controller.h"
#import "ios/chrome/browser/ui/bookmarks/bookmark_path_cache.h" #import "ios/chrome/browser/ui/bookmarks/bookmark_path_cache.h"
#import "ios/chrome/browser/ui/bookmarks/bookmark_table_view.h" #import "ios/chrome/browser/ui/bookmarks/bookmark_table_view.h"
#import "ios/chrome/browser/ui/bookmarks/bookmark_ui_constants.h"
#import "ios/chrome/browser/ui/bookmarks/bookmark_utils_ios.h" #import "ios/chrome/browser/ui/bookmarks/bookmark_utils_ios.h"
#import "ios/chrome/browser/ui/bookmarks/cells/bookmark_home_node_item.h" #import "ios/chrome/browser/ui/bookmarks/cells/bookmark_home_node_item.h"
#import "ios/chrome/browser/ui/bookmarks/cells/bookmark_table_cell.h" #import "ios/chrome/browser/ui/bookmarks/cells/bookmark_table_cell.h"
...@@ -106,6 +106,11 @@ std::vector<GURL> GetUrlsToOpen(const std::vector<const BookmarkNode*>& nodes) { ...@@ -106,6 +106,11 @@ std::vector<GURL> GetUrlsToOpen(const std::vector<const BookmarkNode*>& nodes) {
} }
return urls; return urls;
} }
// Shadow opacity for the NavigationController Toolbar.
const CGFloat kShadowOpacity = 0.12f;
// Shadow radius for the NavigationController Toolbar.
const CGFloat kShadowRadius = 12.0f;
} // namespace } // namespace
@interface BookmarkHomeViewController ()< @interface BookmarkHomeViewController ()<
...@@ -117,7 +122,6 @@ std::vector<GURL> GetUrlsToOpen(const std::vector<const BookmarkNode*>& nodes) { ...@@ -117,7 +122,6 @@ std::vector<GURL> GetUrlsToOpen(const std::vector<const BookmarkNode*>& nodes) {
BookmarkModelBridgeObserver, BookmarkModelBridgeObserver,
BookmarkTableCellTitleEditDelegate, BookmarkTableCellTitleEditDelegate,
BookmarkTableViewDelegate, BookmarkTableViewDelegate,
ContextBarDelegate,
UIGestureRecognizerDelegate, UIGestureRecognizerDelegate,
UITableViewDataSource, UITableViewDataSource,
UITableViewDelegate> { UITableViewDelegate> {
...@@ -167,9 +171,6 @@ std::vector<GURL> GetUrlsToOpen(const std::vector<const BookmarkNode*>& nodes) { ...@@ -167,9 +171,6 @@ std::vector<GURL> GetUrlsToOpen(const std::vector<const BookmarkNode*>& nodes) {
// The app bar for the bookmarks. // The app bar for the bookmarks.
@property(nonatomic, strong) MDCAppBar* appBar; @property(nonatomic, strong) MDCAppBar* appBar;
// The context bar at the bottom of the bookmarks.
@property(nonatomic, strong) BookmarkContextBar* contextBar;
// This view is created and used if the model is not fully loaded yet by the // This view is created and used if the model is not fully loaded yet by the
// time this controller starts. // time this controller starts.
@property(nonatomic, strong) BookmarkHomeWaitingView* waitForModelView; @property(nonatomic, strong) BookmarkHomeWaitingView* waitForModelView;
...@@ -190,6 +191,12 @@ std::vector<GURL> GetUrlsToOpen(const std::vector<const BookmarkNode*>& nodes) { ...@@ -190,6 +191,12 @@ std::vector<GURL> GetUrlsToOpen(const std::vector<const BookmarkNode*>& nodes) {
// Dispatcher for sending commands. // Dispatcher for sending commands.
@property(nonatomic, readonly, weak) id<ApplicationCommands> dispatcher; @property(nonatomic, readonly, weak) id<ApplicationCommands> dispatcher;
// Navigation UIToolbar Delete button.
@property(nonatomic, strong) UIBarButtonItem* deleteButton;
// Navigation UIToolbar More button.
@property(nonatomic, strong) UIBarButtonItem* moreButton;
@end @end
@implementation BookmarkHomeViewController @implementation BookmarkHomeViewController
...@@ -204,7 +211,6 @@ std::vector<GURL> GetUrlsToOpen(const std::vector<const BookmarkNode*>& nodes) { ...@@ -204,7 +211,6 @@ std::vector<GURL> GetUrlsToOpen(const std::vector<const BookmarkNode*>& nodes) {
@synthesize waitForModelView = _waitForModelView; @synthesize waitForModelView = _waitForModelView;
@synthesize homeDelegate = _homeDelegate; @synthesize homeDelegate = _homeDelegate;
@synthesize bookmarksTableView = _bookmarksTableView; @synthesize bookmarksTableView = _bookmarksTableView;
@synthesize contextBar = _contextBar;
@synthesize contextBarState = _contextBarState; @synthesize contextBarState = _contextBarState;
@synthesize dispatcher = _dispatcher; @synthesize dispatcher = _dispatcher;
@synthesize cachedContentPosition = _cachedContentPosition; @synthesize cachedContentPosition = _cachedContentPosition;
...@@ -212,6 +218,8 @@ std::vector<GURL> GetUrlsToOpen(const std::vector<const BookmarkNode*>& nodes) { ...@@ -212,6 +218,8 @@ std::vector<GURL> GetUrlsToOpen(const std::vector<const BookmarkNode*>& nodes) {
@synthesize sharedState = _sharedState; @synthesize sharedState = _sharedState;
@synthesize mediator = _mediator; @synthesize mediator = _mediator;
@synthesize tableViewStyler = _tableViewStyler; @synthesize tableViewStyler = _tableViewStyler;
@synthesize deleteButton = _deleteButton;
@synthesize moreButton = _moreButton;
#if !defined(__has_feature) || !__has_feature(objc_arc) #if !defined(__has_feature) || !__has_feature(objc_arc)
#error "This file requires ARC support." #error "This file requires ARC support."
...@@ -253,6 +261,14 @@ std::vector<GURL> GetUrlsToOpen(const std::vector<const BookmarkNode*>& nodes) { ...@@ -253,6 +261,14 @@ std::vector<GURL> GetUrlsToOpen(const std::vector<const BookmarkNode*>& nodes) {
- (void)viewDidLoad { - (void)viewDidLoad {
[super viewDidLoad]; [super viewDidLoad];
// Set Toolbar Appeareance.
self.navigationController.toolbar.translucent = NO;
self.navigationController.toolbar.barTintColor = [UIColor whiteColor];
self.navigationController.toolbar.accessibilityIdentifier =
kBookmarkHomeUIToolbarIdentifier;
self.navigationController.toolbar.layer.shadowRadius = kShadowRadius;
self.navigationController.toolbar.layer.shadowOpacity = kShadowOpacity;
if (self.bookmarks->loaded()) { if (self.bookmarks->loaded()) {
[self loadBookmarkViews]; [self loadBookmarkViews];
} else { } else {
...@@ -266,6 +282,13 @@ std::vector<GURL> GetUrlsToOpen(const std::vector<const BookmarkNode*>& nodes) { ...@@ -266,6 +282,13 @@ std::vector<GURL> GetUrlsToOpen(const std::vector<const BookmarkNode*>& nodes) {
// ViewController hierarchy (as each view controller is setting itself as // ViewController hierarchy (as each view controller is setting itself as
// delegate). // delegate).
self.navigationController.interactivePopGestureRecognizer.delegate = self; self.navigationController.interactivePopGestureRecognizer.delegate = self;
// Hide the toolbar if we're displaying the root node.
if (_rootNode == self.bookmarks->root_node()) {
self.navigationController.toolbarHidden = YES;
} else {
self.navigationController.toolbarHidden = NO;
}
} }
- (void)viewDidLayoutSubviews { - (void)viewDidLayoutSubviews {
...@@ -276,9 +299,6 @@ std::vector<GURL> GetUrlsToOpen(const std::vector<const BookmarkNode*>& nodes) { ...@@ -276,9 +299,6 @@ std::vector<GURL> GetUrlsToOpen(const std::vector<const BookmarkNode*>& nodes) {
[self setContentPosition:self.cachedContentPosition.floatValue]; [self setContentPosition:self.cachedContentPosition.floatValue];
self.cachedContentPosition = nil; self.cachedContentPosition = nil;
} }
// The height of contextBar might change due to word wrapping of buttons
// after titleLabel or orientation changed.
[self.contextBar updateHeight];
} }
- (BOOL)prefersStatusBarHidden { - (BOOL)prefersStatusBarHidden {
...@@ -323,7 +343,6 @@ std::vector<GURL> GetUrlsToOpen(const std::vector<const BookmarkNode*>& nodes) { ...@@ -323,7 +343,6 @@ std::vector<GURL> GetUrlsToOpen(const std::vector<const BookmarkNode*>& nodes) {
[self.bookmarksTableView [self.bookmarksTableView
setAutoresizingMask:UIViewAutoresizingFlexibleWidth | setAutoresizingMask:UIViewAutoresizingFlexibleWidth |
UIViewAutoresizingFlexibleHeight]; UIViewAutoresizingFlexibleHeight];
[self.bookmarksTableView setTranslatesAutoresizingMaskIntoConstraints:NO];
[self.view addSubview:self.bookmarksTableView]; [self.view addSubview:self.bookmarksTableView];
// Configure the table view. // Configure the table view.
...@@ -360,9 +379,8 @@ std::vector<GURL> GetUrlsToOpen(const std::vector<const BookmarkNode*>& nodes) { ...@@ -360,9 +379,8 @@ std::vector<GURL> GetUrlsToOpen(const std::vector<const BookmarkNode*>& nodes) {
// After the table view has been added. // After the table view has been added.
[self setupNavigationBar]; [self setupNavigationBar];
if (_rootNode != self.bookmarks->root_node()) { [self setupContextBar];
[self setupContextBar];
}
if (self.isReconstructingFromCache) { if (self.isReconstructingFromCache) {
[self setupUIStackCacheIfApplicable]; [self setupUIStackCacheIfApplicable];
} }
...@@ -944,12 +962,12 @@ std::vector<GURL> GetUrlsToOpen(const std::vector<const BookmarkNode*>& nodes) { ...@@ -944,12 +962,12 @@ std::vector<GURL> GetUrlsToOpen(const std::vector<const BookmarkNode*>& nodes) {
// Set up context bar for the new UI. // Set up context bar for the new UI.
- (void)setupContextBar { - (void)setupContextBar {
self.contextBar = [[BookmarkContextBar alloc] initWithFrame:CGRectZero]; if (_rootNode != self.bookmarks->root_node()) {
self.contextBar.delegate = self; self.navigationController.toolbarHidden = NO;
[self.contextBar setTranslatesAutoresizingMaskIntoConstraints:NO]; [self setContextBarState:BookmarksContextBarDefault];
} else {
[self setContextBarState:BookmarksContextBarDefault]; self.navigationController.toolbarHidden = YES;
[self.view addSubview:self.contextBar]; }
} }
// Set up navigation bar for the new UI. // Set up navigation bar for the new UI.
...@@ -1037,34 +1055,6 @@ std::vector<GURL> GetUrlsToOpen(const std::vector<const BookmarkNode*>& nodes) { ...@@ -1037,34 +1055,6 @@ std::vector<GURL> GetUrlsToOpen(const std::vector<const BookmarkNode*>& nodes) {
rendererInitiated:NO]; rendererInitiated:NO];
} }
- (void)updateViewConstraints {
if (!_addedConstraints) {
if (self.contextBar && self.bookmarksTableView) {
NSDictionary* views = @{
@"tableView" : self.bookmarksTableView,
@"contextBar" : self.contextBar,
};
NSArray* constraints = @[
@"V:|[tableView][contextBar]|",
@"H:|[tableView]|",
@"H:|[contextBar]|",
];
ApplyVisualConstraints(constraints, views);
} else if (self.bookmarksTableView) {
NSDictionary* views = @{
@"tableView" : self.bookmarksTableView,
};
NSArray* constraints = @[
@"V:|[tableView]|",
@"H:|[tableView]|",
];
ApplyVisualConstraints(constraints, views);
}
_addedConstraints = YES;
}
[super updateViewConstraints];
}
- (void)addNewFolder { - (void)addNewFolder {
[self.sharedState.editingFolderCell stopEdit]; [self.sharedState.editingFolderCell stopEdit];
if (!self.sharedState.tableViewDisplayedRootNode) { if (!self.sharedState.tableViewDisplayedRootNode) {
...@@ -1346,8 +1336,8 @@ std::vector<GURL> GetUrlsToOpen(const std::vector<const BookmarkNode*>& nodes) { ...@@ -1346,8 +1336,8 @@ std::vector<GURL> GetUrlsToOpen(const std::vector<const BookmarkNode*>& nodes) {
case BookmarksContextBarSingleFolderSelection: case BookmarksContextBarSingleFolderSelection:
// Reset to start state, and then override with customizations that apply. // Reset to start state, and then override with customizations that apply.
[self setBookmarksContextBarSelectionStartState]; [self setBookmarksContextBarSelectionStartState];
[self.contextBar setButtonEnabled:YES forButton:ContextBarCenterButton]; self.moreButton.enabled = YES;
[self.contextBar setButtonEnabled:YES forButton:ContextBarLeadingButton]; self.deleteButton.enabled = YES;
break; break;
case BookmarksContextBarNone: case BookmarksContextBarNone:
default: default:
...@@ -1357,49 +1347,80 @@ std::vector<GURL> GetUrlsToOpen(const std::vector<const BookmarkNode*>& nodes) { ...@@ -1357,49 +1347,80 @@ std::vector<GURL> GetUrlsToOpen(const std::vector<const BookmarkNode*>& nodes) {
- (void)setBookmarksContextBarButtonsDefaultState { - (void)setBookmarksContextBarButtonsDefaultState {
// Set New Folder button // Set New Folder button
[self.contextBar setButtonTitle:l10n_util::GetNSString( NSString* titleString =
IDS_IOS_BOOKMARK_CONTEXT_BAR_NEW_FOLDER) l10n_util::GetNSString(IDS_IOS_BOOKMARK_CONTEXT_BAR_NEW_FOLDER);
forButton:ContextBarLeadingButton]; UIBarButtonItem* newFolderButton =
[self.contextBar setButtonVisibility:YES forButton:ContextBarLeadingButton]; [[UIBarButtonItem alloc] initWithTitle:titleString
[self.contextBar setButtonEnabled:[self allowsNewFolder] style:UIBarButtonItemStylePlain
forButton:ContextBarLeadingButton]; target:self
[self.contextBar setButtonStyle:ContextBarButtonStyleDefault action:@selector(leadingButtonClicked)];
forButton:ContextBarLeadingButton]; newFolderButton.accessibilityIdentifier =
kBookmarkHomeLeadingButtonIdentifier;
// Set Center button to invisible. newFolderButton.enabled = [self allowsNewFolder];
[self.contextBar setButtonVisibility:NO forButton:ContextBarCenterButton];
// Spacer button.
UIBarButtonItem* spaceButton = [[UIBarButtonItem alloc]
initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace
target:nil
action:nil];
// Set Select button. // Set Select button.
[self.contextBar titleString = l10n_util::GetNSString(IDS_IOS_BOOKMARK_CONTEXT_BAR_SELECT);
setButtonTitle:l10n_util::GetNSString(IDS_IOS_BOOKMARK_CONTEXT_BAR_SELECT) UIBarButtonItem* selectButton =
forButton:ContextBarTrailingButton]; [[UIBarButtonItem alloc] initWithTitle:titleString
[self.contextBar setButtonVisibility:YES forButton:ContextBarTrailingButton]; style:UIBarButtonItemStylePlain
[self.contextBar setButtonEnabled:[self hasBookmarksOrFolders] target:self
forButton:ContextBarTrailingButton]; action:@selector(trailingButtonClicked)];
selectButton.accessibilityIdentifier = kBookmarkHomeTrailingButtonIdentifier;
selectButton.enabled = [self hasBookmarksOrFolders];
[self setToolbarItems:@[ newFolderButton, spaceButton, selectButton ]
animated:NO];
} }
- (void)setBookmarksContextBarSelectionStartState { - (void)setBookmarksContextBarSelectionStartState {
// Disabled Delete button. // Disabled Delete button.
[self.contextBar NSString* titleString =
setButtonTitle:l10n_util::GetNSString(IDS_IOS_BOOKMARK_CONTEXT_BAR_DELETE) l10n_util::GetNSString(IDS_IOS_BOOKMARK_CONTEXT_BAR_DELETE);
forButton:ContextBarLeadingButton]; self.deleteButton =
[self.contextBar setButtonVisibility:YES forButton:ContextBarLeadingButton]; [[UIBarButtonItem alloc] initWithTitle:titleString
[self.contextBar setButtonEnabled:NO forButton:ContextBarLeadingButton]; style:UIBarButtonItemStylePlain
[self.contextBar setButtonStyle:ContextBarButtonStyleDelete target:self
forButton:ContextBarLeadingButton]; action:@selector(leadingButtonClicked)];
self.deleteButton.tintColor = [UIColor redColor];
self.deleteButton.enabled = NO;
self.deleteButton.accessibilityIdentifier =
kBookmarkHomeLeadingButtonIdentifier;
// Disabled More button. // Disabled More button.
[self.contextBar titleString = l10n_util::GetNSString(IDS_IOS_BOOKMARK_CONTEXT_BAR_MORE);
setButtonTitle:l10n_util::GetNSString(IDS_IOS_BOOKMARK_CONTEXT_BAR_MORE) self.moreButton =
forButton:ContextBarCenterButton]; [[UIBarButtonItem alloc] initWithTitle:titleString
[self.contextBar setButtonVisibility:YES forButton:ContextBarCenterButton]; style:UIBarButtonItemStylePlain
[self.contextBar setButtonEnabled:NO forButton:ContextBarCenterButton]; target:self
action:@selector(centerButtonClicked)];
self.moreButton.enabled = NO;
self.moreButton.accessibilityIdentifier = kBookmarkHomeCenterButtonIdentifier;
// Enabled Cancel button. // Enabled Cancel button.
[self.contextBar setButtonTitle:l10n_util::GetNSString(IDS_CANCEL) titleString = l10n_util::GetNSString(IDS_CANCEL);
forButton:ContextBarTrailingButton]; UIBarButtonItem* cancelButton =
[self.contextBar setButtonVisibility:YES forButton:ContextBarTrailingButton]; [[UIBarButtonItem alloc] initWithTitle:titleString
[self.contextBar setButtonEnabled:YES forButton:ContextBarTrailingButton]; style:UIBarButtonItemStylePlain
target:self
action:@selector(trailingButtonClicked)];
cancelButton.accessibilityIdentifier = kBookmarkHomeTrailingButtonIdentifier;
// Spacer button.
UIBarButtonItem* spaceButton = [[UIBarButtonItem alloc]
initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace
target:nil
action:nil];
[self setToolbarItems:@[
self.deleteButton, spaceButton, self.moreButton, spaceButton, cancelButton
]
animated:NO];
} }
#pragma mark - Context Menu #pragma mark - Context Menu
......
...@@ -25,7 +25,6 @@ TEST_F(BookmarkHomeViewControllerTest, LoadBookmarks) { ...@@ -25,7 +25,6 @@ TEST_F(BookmarkHomeViewControllerTest, LoadBookmarks) {
dispatcher:nil]; dispatcher:nil];
EXPECT_EQ(nil, controller.appBar); EXPECT_EQ(nil, controller.appBar);
EXPECT_EQ(nil, controller.contextBar);
EXPECT_EQ(nil, controller.bookmarksTableView); EXPECT_EQ(nil, controller.bookmarksTableView);
[controller setRootNode:_bookmarkModel->mobile_node()]; [controller setRootNode:_bookmarkModel->mobile_node()];
...@@ -34,7 +33,6 @@ TEST_F(BookmarkHomeViewControllerTest, LoadBookmarks) { ...@@ -34,7 +33,6 @@ TEST_F(BookmarkHomeViewControllerTest, LoadBookmarks) {
EXPECT_NE(nil, controller); EXPECT_NE(nil, controller);
EXPECT_NE(nil, controller.appBar); EXPECT_NE(nil, controller.appBar);
EXPECT_NE(nil, controller.contextBar);
EXPECT_NE(nil, controller.bookmarksTableView); EXPECT_NE(nil, controller.bookmarksTableView);
} }
} }
......
...@@ -11,5 +11,13 @@ ...@@ -11,5 +11,13 @@
extern NSString* const kBookmarkEditDeleteButtonIdentifier; extern NSString* const kBookmarkEditDeleteButtonIdentifier;
// Accessibility identifier of the BookmarkFolderEditorVC toolbar delete button. // Accessibility identifier of the BookmarkFolderEditorVC toolbar delete button.
extern NSString* const kBookmarkFolderEditorDeleteButtonIdentifier; extern NSString* const kBookmarkFolderEditorDeleteButtonIdentifier;
// Accessibility identifier of the BookmarkHomeVC leading button.
extern NSString* const kBookmarkHomeLeadingButtonIdentifier;
// Accessibility identifier of the BookmarkHomeVC center button.
extern NSString* const kBookmarkHomeCenterButtonIdentifier;
// Accessibility identifier of the BookmarkHomeVC trailing button.
extern NSString* const kBookmarkHomeTrailingButtonIdentifier;
// Accessibility identifier of the BookmarkHomeVC UIToolbar.
extern NSString* const kBookmarkHomeUIToolbarIdentifier;
#endif // IOS_CHROME_BROWSER_UI_BOOKMARKS_BOOKMARK_UI_CONSTANTS_H_ #endif // IOS_CHROME_BROWSER_UI_BOOKMARKS_BOOKMARK_UI_CONSTANTS_H_
...@@ -12,3 +12,11 @@ NSString* const kBookmarkEditDeleteButtonIdentifier = ...@@ -12,3 +12,11 @@ NSString* const kBookmarkEditDeleteButtonIdentifier =
@"kBookmarkEditDeleteButtonIdentifier"; @"kBookmarkEditDeleteButtonIdentifier";
NSString* const kBookmarkFolderEditorDeleteButtonIdentifier = NSString* const kBookmarkFolderEditorDeleteButtonIdentifier =
@"kBookmarkFolderEditorDeleteButtonIdentifier"; @"kBookmarkFolderEditorDeleteButtonIdentifier";
NSString* const kBookmarkHomeLeadingButtonIdentifier =
@"kBookmarkHomeLeadingButtonIdentifier";
NSString* const kBookmarkHomeCenterButtonIdentifier =
@"kBookmarkHomeCenterButtonIdentifier";
NSString* const kBookmarkHomeTrailingButtonIdentifier =
@"kBookmarkHomeTrailingButtonIdentifier";
NSString* const kBookmarkHomeUIToolbarIdentifier =
@"kBookmarkHomeUIToolbarIdentifier";
...@@ -116,7 +116,7 @@ id<GREYMatcher> BookmarksDoneButton() { ...@@ -116,7 +116,7 @@ id<GREYMatcher> BookmarksDoneButton() {
// Matcher for context bar leading button. // Matcher for context bar leading button.
id<GREYMatcher> ContextBarLeadingButtonWithLabel(NSString* label) { id<GREYMatcher> ContextBarLeadingButtonWithLabel(NSString* label) {
return grey_allOf(grey_accessibilityID(@"context_bar_leading_button"), return grey_allOf(grey_accessibilityID(kBookmarkHomeLeadingButtonIdentifier),
grey_accessibilityLabel(label), grey_accessibilityLabel(label),
grey_accessibilityTrait(UIAccessibilityTraitButton), grey_accessibilityTrait(UIAccessibilityTraitButton),
grey_sufficientlyVisible(), nil); grey_sufficientlyVisible(), nil);
...@@ -124,7 +124,7 @@ id<GREYMatcher> ContextBarLeadingButtonWithLabel(NSString* label) { ...@@ -124,7 +124,7 @@ id<GREYMatcher> ContextBarLeadingButtonWithLabel(NSString* label) {
// Matcher for context bar center button. // Matcher for context bar center button.
id<GREYMatcher> ContextBarCenterButtonWithLabel(NSString* label) { id<GREYMatcher> ContextBarCenterButtonWithLabel(NSString* label) {
return grey_allOf(grey_accessibilityID(@"context_bar_center_button"), return grey_allOf(grey_accessibilityID(kBookmarkHomeCenterButtonIdentifier),
grey_accessibilityLabel(label), grey_accessibilityLabel(label),
grey_accessibilityTrait(UIAccessibilityTraitButton), grey_accessibilityTrait(UIAccessibilityTraitButton),
grey_sufficientlyVisible(), nil); grey_sufficientlyVisible(), nil);
...@@ -132,7 +132,7 @@ id<GREYMatcher> ContextBarCenterButtonWithLabel(NSString* label) { ...@@ -132,7 +132,7 @@ id<GREYMatcher> ContextBarCenterButtonWithLabel(NSString* label) {
// Matcher for context bar trailing button. // Matcher for context bar trailing button.
id<GREYMatcher> ContextBarTrailingButtonWithLabel(NSString* label) { id<GREYMatcher> ContextBarTrailingButtonWithLabel(NSString* label) {
return grey_allOf(grey_accessibilityID(@"context_bar_trailing_button"), return grey_allOf(grey_accessibilityID(kBookmarkHomeTrailingButtonIdentifier),
grey_accessibilityLabel(label), grey_accessibilityLabel(label),
grey_accessibilityTrait(UIAccessibilityTraitButton), grey_accessibilityTrait(UIAccessibilityTraitButton),
grey_sufficientlyVisible(), nil); grey_sufficientlyVisible(), nil);
...@@ -438,8 +438,9 @@ id<GREYMatcher> CloseToolsMenuButton() { ...@@ -438,8 +438,9 @@ id<GREYMatcher> CloseToolsMenuButton() {
[BookmarksTestCase openMobileBookmarks]; [BookmarksTestCase openMobileBookmarks];
// Change to edit mode // Change to edit mode
[[EarlGrey selectElementWithMatcher:grey_accessibilityID( [[EarlGrey
@"context_bar_trailing_button")] selectElementWithMatcher:grey_accessibilityID(
kBookmarkHomeTrailingButtonIdentifier)]
performAction:grey_tap()]; performAction:grey_tap()];
// Select URLs. // Select URLs.
...@@ -658,8 +659,9 @@ id<GREYMatcher> CloseToolsMenuButton() { ...@@ -658,8 +659,9 @@ id<GREYMatcher> CloseToolsMenuButton() {
assertWithMatcher:grey_notNil()]; assertWithMatcher:grey_notNil()];
// Change to edit mode // Change to edit mode
[[EarlGrey selectElementWithMatcher:grey_accessibilityID( [[EarlGrey
@"context_bar_trailing_button")] selectElementWithMatcher:grey_accessibilityID(
kBookmarkHomeTrailingButtonIdentifier)]
performAction:grey_tap()]; performAction:grey_tap()];
// Verify the delete confirmation button is gone after entering edit mode. // Verify the delete confirmation button is gone after entering edit mode.
...@@ -700,15 +702,17 @@ id<GREYMatcher> CloseToolsMenuButton() { ...@@ -700,15 +702,17 @@ id<GREYMatcher> CloseToolsMenuButton() {
[BookmarksTestCase openMobileBookmarks]; [BookmarksTestCase openMobileBookmarks];
// Verify the context bar is shown. // Verify the context bar is shown.
[[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"context_bar")] [[EarlGrey selectElementWithMatcher:grey_accessibilityID(
kBookmarkHomeUIToolbarIdentifier)]
assertWithMatcher:grey_notNil()]; assertWithMatcher:grey_notNil()];
// Verify the context bar's leading and trailing buttons are shown. // Verify the context bar's leading and trailing buttons are shown.
[[EarlGrey selectElementWithMatcher:grey_accessibilityID( [[EarlGrey selectElementWithMatcher:grey_accessibilityID(
@"context_bar_leading_button")] kBookmarkHomeLeadingButtonIdentifier)]
assertWithMatcher:grey_notNil()]; assertWithMatcher:grey_notNil()];
[[EarlGrey selectElementWithMatcher:grey_accessibilityID( [[EarlGrey
@"context_bar_trailing_button")] selectElementWithMatcher:grey_accessibilityID(
kBookmarkHomeTrailingButtonIdentifier)]
assertWithMatcher:grey_notNil()]; assertWithMatcher:grey_notNil()];
} }
...@@ -718,12 +722,14 @@ id<GREYMatcher> CloseToolsMenuButton() { ...@@ -718,12 +722,14 @@ id<GREYMatcher> CloseToolsMenuButton() {
[BookmarksTestCase openMobileBookmarks]; [BookmarksTestCase openMobileBookmarks];
// Verify the context bar is shown. // Verify the context bar is shown.
[[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"context_bar")] [[EarlGrey selectElementWithMatcher:grey_accessibilityID(
kBookmarkHomeUIToolbarIdentifier)]
assertWithMatcher:grey_notNil()]; assertWithMatcher:grey_notNil()];
// Change to edit mode // Change to edit mode
[[EarlGrey selectElementWithMatcher:grey_accessibilityID( [[EarlGrey
@"context_bar_trailing_button")] selectElementWithMatcher:grey_accessibilityID(
kBookmarkHomeTrailingButtonIdentifier)]
performAction:grey_tap()]; performAction:grey_tap()];
// Verify context bar shows disabled "Delete" disabled "More" enabled // Verify context bar shows disabled "Delete" disabled "More" enabled
...@@ -941,8 +947,9 @@ id<GREYMatcher> CloseToolsMenuButton() { ...@@ -941,8 +947,9 @@ id<GREYMatcher> CloseToolsMenuButton() {
[BookmarksTestCase openMobileBookmarks]; [BookmarksTestCase openMobileBookmarks];
// Change to edit mode // Change to edit mode
[[EarlGrey selectElementWithMatcher:grey_accessibilityID( [[EarlGrey
@"context_bar_trailing_button")] selectElementWithMatcher:grey_accessibilityID(
kBookmarkHomeTrailingButtonIdentifier)]
performAction:grey_tap()]; performAction:grey_tap()];
// Select URL. // Select URL.
...@@ -968,8 +975,9 @@ id<GREYMatcher> CloseToolsMenuButton() { ...@@ -968,8 +975,9 @@ id<GREYMatcher> CloseToolsMenuButton() {
// 1. Edit the bookmark title at edit page. // 1. Edit the bookmark title at edit page.
// Change to edit mode // Change to edit mode
[[EarlGrey selectElementWithMatcher:grey_accessibilityID( [[EarlGrey
@"context_bar_trailing_button")] selectElementWithMatcher:grey_accessibilityID(
kBookmarkHomeTrailingButtonIdentifier)]
performAction:grey_tap()]; performAction:grey_tap()];
// Select URL. // Select URL.
...@@ -1000,8 +1008,9 @@ id<GREYMatcher> CloseToolsMenuButton() { ...@@ -1000,8 +1008,9 @@ id<GREYMatcher> CloseToolsMenuButton() {
// 2. Edit the bookmark url at edit page. // 2. Edit the bookmark url at edit page.
// Change to edit mode // Change to edit mode
[[EarlGrey selectElementWithMatcher:grey_accessibilityID( [[EarlGrey
@"context_bar_trailing_button")] selectElementWithMatcher:grey_accessibilityID(
kBookmarkHomeTrailingButtonIdentifier)]
performAction:grey_tap()]; performAction:grey_tap()];
// Select URL. // Select URL.
...@@ -1031,8 +1040,9 @@ id<GREYMatcher> CloseToolsMenuButton() { ...@@ -1031,8 +1040,9 @@ id<GREYMatcher> CloseToolsMenuButton() {
// 3. Move a single url at edit page. // 3. Move a single url at edit page.
// Change to edit mode // Change to edit mode
[[EarlGrey selectElementWithMatcher:grey_accessibilityID( [[EarlGrey
@"context_bar_trailing_button")] selectElementWithMatcher:grey_accessibilityID(
kBookmarkHomeTrailingButtonIdentifier)]
performAction:grey_tap()]; performAction:grey_tap()];
// Select single url. // Select single url.
...@@ -1066,8 +1076,9 @@ id<GREYMatcher> CloseToolsMenuButton() { ...@@ -1066,8 +1076,9 @@ id<GREYMatcher> CloseToolsMenuButton() {
performAction:grey_tap()]; performAction:grey_tap()];
// Change to edit mode // Change to edit mode
[[EarlGrey selectElementWithMatcher:grey_accessibilityID( [[EarlGrey
@"context_bar_trailing_button")] selectElementWithMatcher:grey_accessibilityID(
kBookmarkHomeTrailingButtonIdentifier)]
performAction:grey_tap()]; performAction:grey_tap()];
// Select URL. // Select URL.
...@@ -1095,8 +1106,9 @@ id<GREYMatcher> CloseToolsMenuButton() { ...@@ -1095,8 +1106,9 @@ id<GREYMatcher> CloseToolsMenuButton() {
[BookmarksTestCase openMobileBookmarks]; [BookmarksTestCase openMobileBookmarks];
// Change to edit mode // Change to edit mode
[[EarlGrey selectElementWithMatcher:grey_accessibilityID( [[EarlGrey
@"context_bar_trailing_button")] selectElementWithMatcher:grey_accessibilityID(
kBookmarkHomeTrailingButtonIdentifier)]
performAction:grey_tap()]; performAction:grey_tap()];
// Select URL. // Select URL.
...@@ -1132,8 +1144,9 @@ id<GREYMatcher> CloseToolsMenuButton() { ...@@ -1132,8 +1144,9 @@ id<GREYMatcher> CloseToolsMenuButton() {
[BookmarksTestCase openMobileBookmarks]; [BookmarksTestCase openMobileBookmarks];
// Change to edit mode // Change to edit mode
[[EarlGrey selectElementWithMatcher:grey_accessibilityID( [[EarlGrey
@"context_bar_trailing_button")] selectElementWithMatcher:grey_accessibilityID(
kBookmarkHomeTrailingButtonIdentifier)]
performAction:grey_tap()]; performAction:grey_tap()];
// Select URLs. // Select URLs.
...@@ -1406,8 +1419,9 @@ id<GREYMatcher> CloseToolsMenuButton() { ...@@ -1406,8 +1419,9 @@ id<GREYMatcher> CloseToolsMenuButton() {
[BookmarksTestCase openMobileBookmarks]; [BookmarksTestCase openMobileBookmarks];
// Change to edit mode // Change to edit mode
[[EarlGrey selectElementWithMatcher:grey_accessibilityID( [[EarlGrey
@"context_bar_trailing_button")] selectElementWithMatcher:grey_accessibilityID(
kBookmarkHomeTrailingButtonIdentifier)]
performAction:grey_tap()]; performAction:grey_tap()];
// Select Folder. // Select Folder.
...@@ -1438,8 +1452,9 @@ id<GREYMatcher> CloseToolsMenuButton() { ...@@ -1438,8 +1452,9 @@ id<GREYMatcher> CloseToolsMenuButton() {
[BookmarksTestCase openMobileBookmarks]; [BookmarksTestCase openMobileBookmarks];
// Change to edit mode // Change to edit mode
[[EarlGrey selectElementWithMatcher:grey_accessibilityID( [[EarlGrey
@"context_bar_trailing_button")] selectElementWithMatcher:grey_accessibilityID(
kBookmarkHomeTrailingButtonIdentifier)]
performAction:grey_tap()]; performAction:grey_tap()];
// Select Folders. // Select Folders.
...@@ -1465,8 +1480,9 @@ id<GREYMatcher> CloseToolsMenuButton() { ...@@ -1465,8 +1480,9 @@ id<GREYMatcher> CloseToolsMenuButton() {
[BookmarksTestCase openMobileBookmarks]; [BookmarksTestCase openMobileBookmarks];
// Change to edit mode // Change to edit mode
[[EarlGrey selectElementWithMatcher:grey_accessibilityID( [[EarlGrey
@"context_bar_trailing_button")] selectElementWithMatcher:grey_accessibilityID(
kBookmarkHomeTrailingButtonIdentifier)]
performAction:grey_tap()]; performAction:grey_tap()];
// Select URL and folder. // Select URL and folder.
...@@ -1584,8 +1600,9 @@ id<GREYMatcher> CloseToolsMenuButton() { ...@@ -1584,8 +1600,9 @@ id<GREYMatcher> CloseToolsMenuButton() {
// 2. Move a single folder at edit page. // 2. Move a single folder at edit page.
// Change to edit mode // Change to edit mode
[[EarlGrey selectElementWithMatcher:grey_accessibilityID( [[EarlGrey
@"context_bar_trailing_button")] selectElementWithMatcher:grey_accessibilityID(
kBookmarkHomeTrailingButtonIdentifier)]
performAction:grey_tap()]; performAction:grey_tap()];
// Select single folder. // Select single folder.
...@@ -1616,8 +1633,9 @@ id<GREYMatcher> CloseToolsMenuButton() { ...@@ -1616,8 +1633,9 @@ id<GREYMatcher> CloseToolsMenuButton() {
// 3. Test the cancel button at edit page. // 3. Test the cancel button at edit page.
// Change to edit mode // Change to edit mode
[[EarlGrey selectElementWithMatcher:grey_accessibilityID( [[EarlGrey
@"context_bar_trailing_button")] selectElementWithMatcher:grey_accessibilityID(
kBookmarkHomeTrailingButtonIdentifier)]
performAction:grey_tap()]; performAction:grey_tap()];
// Select single folder. // Select single folder.
...@@ -1780,8 +1798,9 @@ id<GREYMatcher> CloseToolsMenuButton() { ...@@ -1780,8 +1798,9 @@ id<GREYMatcher> CloseToolsMenuButton() {
[BookmarksTestCase openMobileBookmarks]; [BookmarksTestCase openMobileBookmarks];
// Change to edit mode, using context menu. // Change to edit mode, using context menu.
[[EarlGrey selectElementWithMatcher:grey_accessibilityID( [[EarlGrey
@"context_bar_trailing_button")] selectElementWithMatcher:grey_accessibilityID(
kBookmarkHomeTrailingButtonIdentifier)]
performAction:grey_tap()]; performAction:grey_tap()];
// Select multiple folders. // Select multiple folders.
...@@ -1856,8 +1875,9 @@ id<GREYMatcher> CloseToolsMenuButton() { ...@@ -1856,8 +1875,9 @@ id<GREYMatcher> CloseToolsMenuButton() {
[BookmarksTestCase openMobileBookmarks]; [BookmarksTestCase openMobileBookmarks];
// Change to edit mode, using context menu. // Change to edit mode, using context menu.
[[EarlGrey selectElementWithMatcher:grey_accessibilityID( [[EarlGrey
@"context_bar_trailing_button")] selectElementWithMatcher:grey_accessibilityID(
kBookmarkHomeTrailingButtonIdentifier)]
performAction:grey_tap()]; performAction:grey_tap()];
// Select URL and folder. // Select URL and folder.
...@@ -1946,8 +1966,9 @@ id<GREYMatcher> CloseToolsMenuButton() { ...@@ -1946,8 +1966,9 @@ id<GREYMatcher> CloseToolsMenuButton() {
[BookmarksTestCase openMobileBookmarks]; [BookmarksTestCase openMobileBookmarks];
// Change to edit mode, using context menu. // Change to edit mode, using context menu.
[[EarlGrey selectElementWithMatcher:grey_accessibilityID( [[EarlGrey
@"context_bar_trailing_button")] selectElementWithMatcher:grey_accessibilityID(
kBookmarkHomeTrailingButtonIdentifier)]
performAction:grey_tap()]; performAction:grey_tap()];
// Select URL and folder. // Select URL and folder.
...@@ -2006,8 +2027,9 @@ id<GREYMatcher> CloseToolsMenuButton() { ...@@ -2006,8 +2027,9 @@ id<GREYMatcher> CloseToolsMenuButton() {
[BookmarksTestCase openMobileBookmarks]; [BookmarksTestCase openMobileBookmarks];
// Change to edit mode, using context menu. // Change to edit mode, using context menu.
[[EarlGrey selectElementWithMatcher:grey_accessibilityID( [[EarlGrey
@"context_bar_trailing_button")] selectElementWithMatcher:grey_accessibilityID(
kBookmarkHomeTrailingButtonIdentifier)]
performAction:grey_tap()]; performAction:grey_tap()];
// Select URL and folder. // Select URL and folder.
...@@ -2050,8 +2072,9 @@ id<GREYMatcher> CloseToolsMenuButton() { ...@@ -2050,8 +2072,9 @@ id<GREYMatcher> CloseToolsMenuButton() {
[BookmarksTestCase openMobileBookmarks]; [BookmarksTestCase openMobileBookmarks];
// Change to edit mode // Change to edit mode
[[EarlGrey selectElementWithMatcher:grey_accessibilityID( [[EarlGrey
@"context_bar_trailing_button")] selectElementWithMatcher:grey_accessibilityID(
kBookmarkHomeTrailingButtonIdentifier)]
performAction:grey_tap()]; performAction:grey_tap()];
// Select Folder. // Select Folder.
...@@ -2113,8 +2136,9 @@ id<GREYMatcher> CloseToolsMenuButton() { ...@@ -2113,8 +2136,9 @@ id<GREYMatcher> CloseToolsMenuButton() {
[BookmarksTestCase openMobileBookmarks]; [BookmarksTestCase openMobileBookmarks];
// Change to edit mode // Change to edit mode
[[EarlGrey selectElementWithMatcher:grey_accessibilityID( [[EarlGrey
@"context_bar_trailing_button")] selectElementWithMatcher:grey_accessibilityID(
kBookmarkHomeTrailingButtonIdentifier)]
performAction:grey_tap()]; performAction:grey_tap()];
// Select single URL. // Select single URL.
...@@ -2150,8 +2174,9 @@ id<GREYMatcher> CloseToolsMenuButton() { ...@@ -2150,8 +2174,9 @@ id<GREYMatcher> CloseToolsMenuButton() {
[BookmarksTestCase openMobileBookmarks]; [BookmarksTestCase openMobileBookmarks];
// Change to edit mode // Change to edit mode
[[EarlGrey selectElementWithMatcher:grey_accessibilityID( [[EarlGrey
@"context_bar_trailing_button")] selectElementWithMatcher:grey_accessibilityID(
kBookmarkHomeTrailingButtonIdentifier)]
performAction:grey_tap()]; performAction:grey_tap()];
// Select single URL. // Select single URL.
...@@ -2187,8 +2212,9 @@ id<GREYMatcher> CloseToolsMenuButton() { ...@@ -2187,8 +2212,9 @@ id<GREYMatcher> CloseToolsMenuButton() {
[BookmarksTestCase openMobileBookmarks]; [BookmarksTestCase openMobileBookmarks];
// Change to edit mode // Change to edit mode
[[EarlGrey selectElementWithMatcher:grey_accessibilityID( [[EarlGrey
@"context_bar_trailing_button")] selectElementWithMatcher:grey_accessibilityID(
kBookmarkHomeTrailingButtonIdentifier)]
performAction:grey_tap()]; performAction:grey_tap()];
// Select Folder and URL. // Select Folder and URL.
...@@ -2571,8 +2597,9 @@ id<GREYMatcher> CloseToolsMenuButton() { ...@@ -2571,8 +2597,9 @@ id<GREYMatcher> CloseToolsMenuButton() {
performAction:grey_tap()]; performAction:grey_tap()];
// Change to edit mode, using context menu. // Change to edit mode, using context menu.
[[EarlGrey selectElementWithMatcher:grey_accessibilityID( [[EarlGrey
@"context_bar_trailing_button")] selectElementWithMatcher:grey_accessibilityID(
kBookmarkHomeTrailingButtonIdentifier)]
performAction:grey_tap()]; performAction:grey_tap()];
// Select every URL and folder. // Select every URL and folder.
...@@ -2621,8 +2648,9 @@ id<GREYMatcher> CloseToolsMenuButton() { ...@@ -2621,8 +2648,9 @@ id<GREYMatcher> CloseToolsMenuButton() {
performAction:grey_tap()]; performAction:grey_tap()];
// Change to edit mode, using context menu. // Change to edit mode, using context menu.
[[EarlGrey selectElementWithMatcher:grey_accessibilityID( [[EarlGrey
@"context_bar_trailing_button")] selectElementWithMatcher:grey_accessibilityID(
kBookmarkHomeTrailingButtonIdentifier)]
performAction:grey_tap()]; performAction:grey_tap()];
// Delete the Folder 1 and Folder 2 programmatically in background. // Delete the Folder 1 and Folder 2 programmatically in background.
...@@ -2883,8 +2911,9 @@ id<GREYMatcher> CloseToolsMenuButton() { ...@@ -2883,8 +2911,9 @@ id<GREYMatcher> CloseToolsMenuButton() {
[BookmarksTestCase openMobileBookmarks]; [BookmarksTestCase openMobileBookmarks];
// Change to edit mode // Change to edit mode
[[EarlGrey selectElementWithMatcher:grey_accessibilityID( [[EarlGrey
@"context_bar_trailing_button")] selectElementWithMatcher:grey_accessibilityID(
kBookmarkHomeTrailingButtonIdentifier)]
performAction:grey_tap()]; performAction:grey_tap()];
// Select single URL. // Select single URL.
...@@ -2911,8 +2940,9 @@ id<GREYMatcher> CloseToolsMenuButton() { ...@@ -2911,8 +2940,9 @@ id<GREYMatcher> CloseToolsMenuButton() {
[BookmarksTestCase openMobileBookmarks]; [BookmarksTestCase openMobileBookmarks];
// Change to edit mode // Change to edit mode
[[EarlGrey selectElementWithMatcher:grey_accessibilityID( [[EarlGrey
@"context_bar_trailing_button")] selectElementWithMatcher:grey_accessibilityID(
kBookmarkHomeTrailingButtonIdentifier)]
performAction:grey_tap()]; performAction:grey_tap()];
chrome_test_util::VerifyAccessibilityForCurrentScreen(); chrome_test_util::VerifyAccessibilityForCurrentScreen();
...@@ -3258,8 +3288,9 @@ id<GREYMatcher> CloseToolsMenuButton() { ...@@ -3258,8 +3288,9 @@ id<GREYMatcher> CloseToolsMenuButton() {
// Select urls from Mobile Bookmarks and tap on a specified context bar button. // Select urls from Mobile Bookmarks and tap on a specified context bar button.
+ (void)selectUrlsAndTapOnContextBarButtonWithLabelId:(int)buttonLabelId { + (void)selectUrlsAndTapOnContextBarButtonWithLabelId:(int)buttonLabelId {
// Change to edit mode // Change to edit mode
[[EarlGrey selectElementWithMatcher:grey_accessibilityID( [[EarlGrey
@"context_bar_trailing_button")] selectElementWithMatcher:grey_accessibilityID(
kBookmarkHomeTrailingButtonIdentifier)]
performAction:grey_tap()]; performAction:grey_tap()];
// Select URLs. // Select URLs.
...@@ -3370,7 +3401,8 @@ id<GREYMatcher> CloseToolsMenuButton() { ...@@ -3370,7 +3401,8 @@ id<GREYMatcher> CloseToolsMenuButton() {
- (void)verifyContextBarInDefaultStateWithSelectEnabled:(BOOL)selectEnabled - (void)verifyContextBarInDefaultStateWithSelectEnabled:(BOOL)selectEnabled
newFolderEnabled:(BOOL)newFolderEnabled { newFolderEnabled:(BOOL)newFolderEnabled {
// Verify the context bar is shown. // Verify the context bar is shown.
[[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"context_bar")] [[EarlGrey selectElementWithMatcher:grey_accessibilityID(
kBookmarkHomeUIToolbarIdentifier)]
assertWithMatcher:grey_notNil()]; assertWithMatcher:grey_notNil()];
// Verify context bar shows enabled "New Folder" and enabled "Select". // Verify context bar shows enabled "New Folder" and enabled "Select".
...@@ -3400,7 +3432,8 @@ id<GREYMatcher> CloseToolsMenuButton() { ...@@ -3400,7 +3432,8 @@ id<GREYMatcher> CloseToolsMenuButton() {
- (void)verifyContextBarInEditMode { - (void)verifyContextBarInEditMode {
// Verify the context bar is shown. // Verify the context bar is shown.
[[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"context_bar")] [[EarlGrey selectElementWithMatcher:grey_accessibilityID(
kBookmarkHomeUIToolbarIdentifier)]
assertWithMatcher:grey_notNil()]; assertWithMatcher:grey_notNil()];
[[EarlGrey [[EarlGrey
...@@ -3625,7 +3658,7 @@ id<GREYMatcher> CloseToolsMenuButton() { ...@@ -3625,7 +3658,7 @@ id<GREYMatcher> CloseToolsMenuButton() {
pressReturn:(BOOL)pressReturn { pressReturn:(BOOL)pressReturn {
// Click on "New Folder". // Click on "New Folder".
[[EarlGrey selectElementWithMatcher:grey_accessibilityID( [[EarlGrey selectElementWithMatcher:grey_accessibilityID(
@"context_bar_leading_button")] kBookmarkHomeLeadingButtonIdentifier)]
performAction:grey_tap()]; performAction:grey_tap()];
NSString* titleIdentifier = @"bookmark_editing_text"; NSString* titleIdentifier = @"bookmark_editing_text";
......
...@@ -87,18 +87,12 @@ const CGFloat kBookmarkTableCellImagePadding = 16.0; ...@@ -87,18 +87,12 @@ const CGFloat kBookmarkTableCellImagePadding = 16.0;
constraintEqualToConstant:kBookmarkTableCellImageSize] constraintEqualToConstant:kBookmarkTableCellImageSize]
.active = YES; .active = YES;
// Create stack view. // Create and configure StackView.
UIStackView* contentStack = [[UIStackView alloc] UIStackView* contentStack = [[UIStackView alloc]
initWithArrangedSubviews:@[ _iconView, _placeholderLabel, _titleText ]]; initWithArrangedSubviews:@[ _iconView, _placeholderLabel, _titleText ]];
[self.contentView addSubview:contentStack]; [self.contentView addSubview:contentStack];
contentStack.layoutMargins = UIEdgeInsetsMake(
0, kBookmarkTableCellImagePadding, 0, kBookmarkTableCellImagePadding);
contentStack.layoutMarginsRelativeArrangement = YES;
contentStack.spacing = kBookmarkTableCellImagePadding; contentStack.spacing = kBookmarkTableCellImagePadding;
contentStack.alignment = UIStackViewAlignmentCenter; contentStack.alignment = UIStackViewAlignmentCenter;
// Configure stack view layout.
contentStack.translatesAutoresizingMaskIntoConstraints = NO; contentStack.translatesAutoresizingMaskIntoConstraints = NO;
[NSLayoutConstraint activateConstraints:@[ [NSLayoutConstraint activateConstraints:@[
[contentStack.topAnchor [contentStack.topAnchor
...@@ -106,9 +100,11 @@ const CGFloat kBookmarkTableCellImagePadding = 16.0; ...@@ -106,9 +100,11 @@ const CGFloat kBookmarkTableCellImagePadding = 16.0;
[contentStack.bottomAnchor [contentStack.bottomAnchor
constraintEqualToAnchor:self.contentView.bottomAnchor], constraintEqualToAnchor:self.contentView.bottomAnchor],
[contentStack.leadingAnchor [contentStack.leadingAnchor
constraintEqualToAnchor:self.contentView.leadingAnchor], constraintEqualToAnchor:self.contentView.leadingAnchor
constant:kBookmarkTableCellImagePadding],
[contentStack.trailingAnchor [contentStack.trailingAnchor
constraintEqualToAnchor:self.contentView.trailingAnchor] constraintEqualToAnchor:self.contentView.trailingAnchor
constant:-kBookmarkTableCellImagePadding]
]]; ]];
// Add separator view. // Add separator view.
......
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