Commit 71fadc89 authored by Mark Cogan's avatar Mark Cogan Committed by Commit Bot

[iOS showcase] Remove dependencies on clean/ from showcase.

This CL removes clean/ view controllers from Showcase.

Bug: 785925, 710662, 772186
Cq-Include-Trybots: master.tryserver.chromium.mac:ios-simulator-cronet;master.tryserver.chromium.mac:ios-simulator-full-configs
Change-Id: Iebce9f69b7776aa2755e46ec379d7245075a55a7
Reviewed-on: https://chromium-review.googlesource.com/774465
Commit-Queue: Mark Cogan <marq@chromium.org>
Reviewed-by: default avatarLouis Romero <lpromero@chromium.org>
Cr-Commit-Position: refs/heads/master@{#517135}
parent 4935983c
......@@ -25,18 +25,11 @@ ios_app_bundle("showcase") {
group("features") {
deps = [
"//ios/clean/chrome/browser/ui/tools:tools_ui",
"//ios/showcase/bubble",
"//ios/showcase/content_suggestions",
"//ios/showcase/ntp",
"//ios/showcase/payments",
"//ios/showcase/root",
"//ios/showcase/settings",
"//ios/showcase/tab",
"//ios/showcase/tab_grid",
"//ios/showcase/text_badge_view",
"//ios/showcase/toolbar",
"//ios/showcase/tools_menu",
"//ios/showcase/uikit_table_view_cell",
"//ios/showcase/widget",
]
......@@ -61,11 +54,7 @@ ios_eg_test("ios_showcase_egtests") {
"//ios/showcase/content_suggestions:eg_tests",
"//ios/showcase/core:eg_tests",
"//ios/showcase/payments:eg_tests",
"//ios/showcase/root:eg_tests",
"//ios/showcase/tab:eg_tests",
"//ios/showcase/tab_grid:eg_tests",
"//ios/showcase/text_badge_view:eg_tests",
"//ios/showcase/toolbar:eg_tests",
# All shared libraries must have the sanitizer deps to properly link in
# asan mode (this target will be empty in other cases).
......
include_rules = [
"+components/strings",
"+ios/chrome",
"+ios/clean",
"+ios/third_party/material_components_ios",
"+ios/third_party/material_roboto_font_loader_ios",
"+ui/base",
......
......@@ -21,16 +21,6 @@
showcase::kClassForInstantiationKey : @"SCContentSuggestionsCoordinator",
showcase::kUseCaseKey : @"Content Suggestions UI",
},
@{
showcase::kClassForDisplayKey : @"MenuViewController",
showcase::kClassForInstantiationKey : @"SCToolsCoordinator",
showcase::kUseCaseKey : @"Tools menu",
},
@{
showcase::kClassForDisplayKey : @"NTPViewController",
showcase::kClassForInstantiationKey : @"SCNTPCoordinator",
showcase::kUseCaseKey : @"NTP",
},
@{
showcase::kClassForDisplayKey : @"PaymentRequestEditViewController",
showcase::kClassForInstantiationKey : @"SCPaymentsEditorCoordinator",
......@@ -46,36 +36,11 @@
showcase::kClassForInstantiationKey : @"SCPaymentsSelectorCoordinator",
showcase::kUseCaseKey : @"Payment request selector view",
},
@{
showcase::kClassForDisplayKey : @"RootContainerViewController",
showcase::kClassForInstantiationKey : @"SCRootCoordinator",
showcase::kUseCaseKey : @"Root container",
},
@{
showcase::kClassForDisplayKey : @"SettingsViewController",
showcase::kClassForInstantiationKey : @"SCSettingsCoordinator",
showcase::kUseCaseKey : @"Main settings screen",
},
@{
showcase::kClassForDisplayKey : @"TabGridViewController",
showcase::kClassForInstantiationKey : @"SCTabGridCoordinator",
showcase::kUseCaseKey : @"Tab grid",
},
@{
showcase::kClassForDisplayKey : @"TopToolbarTabViewController",
showcase::kClassForInstantiationKey : @"SCTopToolbarTabCoordinator",
showcase::kUseCaseKey : @"Top toolbar tab",
},
@{
showcase::kClassForDisplayKey : @"BottomToolbarTabViewController",
showcase::kClassForInstantiationKey : @"SCBottomToolbarTabCoordinator",
showcase::kUseCaseKey : @"Bottom toolbar tab",
},
@{
showcase::kClassForDisplayKey : @"ToolbarViewController",
showcase::kClassForInstantiationKey : @"SCToolbarCoordinator",
showcase::kUseCaseKey : @"Toolbar",
},
@{
showcase::kClassForDisplayKey : @"UITableViewCell",
showcase::kClassForInstantiationKey : @"UIKitTableViewCellViewController",
......
# 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.
source_set("ntp") {
sources = [
"sc_ntp_coordinator.h",
"sc_ntp_coordinator.mm",
]
deps = [
"//ios/chrome/browser/ui/content_suggestions:content_suggestions_constant",
"//ios/chrome/browser/ui/ntp:ntp_internal",
"//ios/clean/chrome/browser/ui/commands",
"//ios/clean/chrome/browser/ui/ntp:ntp_ui",
"//ios/showcase/common",
]
libs = [ "UIKit.framework" ]
configs += [ "//build/config/compiler:enable_arc" ]
}
// 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_SHOWCASE_NTP_SC_NTP_COORDINATOR_H_
#define IOS_SHOWCASE_NTP_SC_NTP_COORDINATOR_H_
#import <UIKit/UIKit.h>
#import "ios/showcase/common/navigation_coordinator.h"
@interface SCNTPCoordinator : NSObject<NavigationCoordinator>
@end
#endif // IOS_SHOWCASE_NTP_SC_NTP_COORDINATOR_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/showcase/ntp/sc_ntp_coordinator.h"
#import "ios/chrome/browser/ui/content_suggestions/ntp_home_constant.h"
#import "ios/chrome/browser/ui/ntp/new_tab_page_bar_item.h"
#import "ios/clean/chrome/browser/ui/commands/ntp_commands.h"
#import "ios/clean/chrome/browser/ui/ntp/ntp_view_controller.h"
#import "ios/showcase/common/protocol_alerter.h"
#if !defined(__has_feature) || !__has_feature(objc_arc)
#error "This file requires ARC support."
#endif
@interface SCNTPCoordinator ()
@property(nonatomic, strong) ProtocolAlerter* alerter;
@end
@implementation SCNTPCoordinator
@synthesize baseViewController;
@synthesize alerter = _alerter;
- (void)start {
NTPViewController* ntp = [[NTPViewController alloc] init];
self.alerter =
[[ProtocolAlerter alloc] initWithProtocols:@[ @protocol(NTPCommands) ]];
self.alerter.baseViewController = self.baseViewController;
ntp.dispatcher = static_cast<id<NTPCommands>>(self.alerter);
NewTabPageBarItem* item1 = [NewTabPageBarItem
newTabPageBarItemWithTitle:@"Item 1"
identifier:ntp_home::HOME_PANEL
image:[UIImage imageNamed:@"ntp_mv_search"]];
NewTabPageBarItem* item2 = [NewTabPageBarItem
newTabPageBarItemWithTitle:@"Item 2"
identifier:ntp_home::BOOKMARKS_PANEL
image:[UIImage imageNamed:@"ntp_bookmarks"]];
[ntp setBarItems:@[ item1, item2 ]];
[self.baseViewController pushViewController:ntp animated:YES];
}
@end
# 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.
source_set("root") {
sources = [
"sc_root_coordinator.h",
"sc_root_coordinator.mm",
]
deps = [
"//base",
"//ios/clean/chrome/browser/ui/root:root_ui",
"//ios/showcase/common",
]
libs = [ "UIKit.framework" ]
configs += [ "//build/config/compiler:enable_arc" ]
}
source_set("eg_tests") {
testonly = true
sources = [
"sc_root_egtest.mm",
]
deps = [
"//ios/showcase/test",
"//ios/third_party/earl_grey:earl_grey+link",
]
libs = [ "XCTest.framework" ]
configs += [ "//build/config/compiler:enable_arc" ]
}
// 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_SHOWCASE_ROOT_SC_ROOT_COORDINATOR_H_
#define IOS_SHOWCASE_ROOT_SC_ROOT_COORDINATOR_H_
#import <Foundation/Foundation.h>
#import "ios/showcase/common/navigation_coordinator.h"
@interface SCRootCoordinator : NSObject<NavigationCoordinator>
@end
#endif // IOS_SHOWCASE_ROOT_SC_ROOT_COORDINATOR_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/showcase/root/sc_root_coordinator.h"
#import "ios/clean/chrome/browser/ui/root/root_container_view_controller.h"
#if !defined(__has_feature) || !__has_feature(objc_arc)
#error "This file requires ARC support."
#endif
@implementation SCRootCoordinator
@synthesize baseViewController;
- (void)start {
RootContainerViewController* viewController =
[[RootContainerViewController alloc] init];
UIViewController* contentViewController = [[UIViewController alloc] init];
contentViewController.view.backgroundColor = [UIColor greenColor];
viewController.contentViewController = contentViewController;
viewController.title = @"Root container";
[self.baseViewController pushViewController:viewController animated:YES];
}
@end
// 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 <EarlGrey/EarlGrey.h>
#import "ios/showcase/test/showcase_eg_utils.h"
#import "ios/showcase/test/showcase_test_case.h"
#if !defined(__has_feature) || !__has_feature(objc_arc)
#error "This file requires ARC support."
#endif
// Tests for the root container view controller.
@interface SCRootTestCase : ShowcaseTestCase
@end
@implementation SCRootTestCase
// Tests launching RootContainerViewController.
- (void)testLaunch {
showcase_utils::Open(@"RootContainerViewController");
showcase_utils::Close();
}
@end
# 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.
source_set("tab") {
sources = [
"sc_bottom_toolbar_tab_coordinator.h",
"sc_bottom_toolbar_tab_coordinator.mm",
"sc_top_toolbar_tab_coordinator.h",
"sc_top_toolbar_tab_coordinator.mm",
]
deps = [
"//base",
"//ios/clean/chrome/browser/ui/commands",
"//ios/clean/chrome/browser/ui/tab:tab_ui",
"//ios/showcase/common",
]
libs = [ "UIKit.framework" ]
configs += [ "//build/config/compiler:enable_arc" ]
}
source_set("eg_tests") {
testonly = true
sources = [
"sc_tab_egtest.mm",
]
deps = [
"//ios/showcase/test",
"//ios/third_party/earl_grey:earl_grey+link",
]
libs = [ "XCTest.framework" ]
configs += [ "//build/config/compiler:enable_arc" ]
}
// 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_SHOWCASE_TAB_SC_BOTTOM_TOOLBAR_TAB_COORDINATOR_H_
#define IOS_SHOWCASE_TAB_SC_BOTTOM_TOOLBAR_TAB_COORDINATOR_H_
#import <UIKit/UIKit.h>
#import "ios/showcase/common/navigation_coordinator.h"
@interface SCBottomToolbarTabCoordinator : NSObject<NavigationCoordinator>
@end
#endif // IOS_SHOWCASE_TAB_SC_BOTTOM_TOOLBAR_TAB_COORDINATOR_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/showcase/tab/sc_bottom_toolbar_tab_coordinator.h"
#import "ios/clean/chrome/browser/ui/tab/tab_container_view_controller.h"
#if !defined(__has_feature) || !__has_feature(objc_arc)
#error "This file requires ARC support."
#endif
@implementation SCBottomToolbarTabCoordinator
@synthesize baseViewController;
- (void)start {
TabContainerViewController* bottomToolbarTabViewController =
[[TabContainerViewController alloc] init];
bottomToolbarTabViewController.usesBottomToolbar = YES;
bottomToolbarTabViewController.title = @"Bottom toolbar tab";
UIViewController* toolbar = [[UIViewController alloc] init];
toolbar.view.backgroundColor = [UIColor greenColor];
bottomToolbarTabViewController.toolbarViewController = toolbar;
UIViewController* content = [[UIViewController alloc] init];
content.view.backgroundColor = [UIColor whiteColor];
bottomToolbarTabViewController.contentViewController = content;
[self.baseViewController pushViewController:bottomToolbarTabViewController
animated:YES];
}
@end
// 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 <EarlGrey/EarlGrey.h>
#import "ios/showcase/test/showcase_eg_utils.h"
#import "ios/showcase/test/showcase_test_case.h"
#if !defined(__has_feature) || !__has_feature(objc_arc)
#error "This file requires ARC support."
#endif
// Tests for the tab container view controller.
@interface SCTabTestCase : ShowcaseTestCase
@end
@implementation SCTabTestCase
// Tests launching TopToolbarTabViewController.
// TODO(crbug.com/710662): re-enable this test.
- (void)FLAKY_testLaunchWithTopToolbar {
showcase_utils::Open(@"TopToolbarTabViewController");
showcase_utils::Close();
}
// Tests launching BottomToolbarTabViewController.
// TODO(crbug.com/710662): re-enable this test.
- (void)FLAKY_testLaunchWithBottomToolbar {
showcase_utils::Open(@"BottomToolbarTabViewController");
showcase_utils::Close();
}
@end
// 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_SHOWCASE_TAB_SC_TOP_TOOLBAR_TAB_COORDINATOR_H_
#define IOS_SHOWCASE_TAB_SC_TOP_TOOLBAR_TAB_COORDINATOR_H_
#import <UIKit/UIKit.h>
#import "ios/showcase/common/navigation_coordinator.h"
@interface SCTopToolbarTabCoordinator : NSObject<NavigationCoordinator>
@end
#endif // IOS_SHOWCASE_TAB_SC_TOP_TOOLBAR_TAB_COORDINATOR_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/showcase/tab/sc_top_toolbar_tab_coordinator.h"
#import "ios/clean/chrome/browser/ui/tab/tab_container_view_controller.h"
#if !defined(__has_feature) || !__has_feature(objc_arc)
#error "This file requires ARC support."
#endif
@implementation SCTopToolbarTabCoordinator
@synthesize baseViewController;
- (void)start {
TabContainerViewController* topToolbarTabViewController =
[[TabContainerViewController alloc] init];
topToolbarTabViewController.title = @"Top toolbar tab";
UIViewController* toolbar = [[UIViewController alloc] init];
toolbar.view.backgroundColor = [UIColor greenColor];
topToolbarTabViewController.toolbarViewController = toolbar;
UIViewController* content = [[UIViewController alloc] init];
content.view.backgroundColor = [UIColor whiteColor];
topToolbarTabViewController.contentViewController = content;
[self.baseViewController pushViewController:topToolbarTabViewController
animated:YES];
}
@end
# 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("tab_grid") {
sources = [
"sc_tab_grid_coordinator.h",
"sc_tab_grid_coordinator.mm",
]
deps = [
"//base",
"//ios/clean/chrome/browser/ui/commands",
"//ios/clean/chrome/browser/ui/tab_collection:tab_collection_ui",
"//ios/clean/chrome/browser/ui/tab_grid:tab_grid_ui",
"//ios/showcase/common",
]
libs = [ "UIKit.framework" ]
configs += [ "//build/config/compiler:enable_arc" ]
}
source_set("eg_tests") {
testonly = true
sources = [
"sc_tab_grid_egtest.mm",
]
deps = [
"//ios/showcase/test",
"//ios/third_party/earl_grey:earl_grey+link",
]
configs += [ "//build/config/compiler:enable_arc" ]
}
// 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.
#ifndef IOS_SHOWCASE_TAB_GRID_SC_TAB_GRID_COORDINATOR_H_
#define IOS_SHOWCASE_TAB_GRID_SC_TAB_GRID_COORDINATOR_H_
#import <UIKit/UIKit.h>
#import "ios/showcase/common/navigation_coordinator.h"
@interface SCTabGridCoordinator : NSObject<NavigationCoordinator>
@end
#endif // IOS_SHOWCASE_TAB_GRID_SC_TAB_GRID_COORDINATOR_H_
// 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.
#import "ios/showcase/tab_grid/sc_tab_grid_coordinator.h"
#import "base/format_macros.h"
#import "ios/clean/chrome/browser/ui/commands/settings_commands.h"
#import "ios/clean/chrome/browser/ui/commands/tab_grid_commands.h"
#import "ios/clean/chrome/browser/ui/commands/tools_menu_commands.h"
#import "ios/clean/chrome/browser/ui/tab_collection/tab_collection_consumer.h"
#import "ios/clean/chrome/browser/ui/tab_collection/tab_collection_item.h"
#import "ios/clean/chrome/browser/ui/tab_grid/tab_grid_view_controller.h"
#import "ios/showcase/common/protocol_alerter.h"
#if !defined(__has_feature) || !__has_feature(objc_arc)
#error "This file requires ARC support."
#endif
@interface SCTabGridCoordinator ()
@property(nonatomic, strong) TabGridViewController* viewController;
@property(nonatomic, strong) ProtocolAlerter* alerter;
@end
@implementation SCTabGridCoordinator
@synthesize baseViewController = _baseViewController;
@synthesize viewController = _viewController;
@synthesize alerter = _alerter;
- (void)start {
self.alerter = [[ProtocolAlerter alloc] initWithProtocols:@[
@protocol(SettingsCommands), @protocol(TabGridCommands),
@protocol(ToolsMenuCommands)
]];
self.alerter.baseViewController = self.baseViewController;
self.viewController = [[TabGridViewController alloc] init];
self.viewController.title = @"Tab Grid";
self.viewController.dispatcher =
static_cast<id<SettingsCommands, TabGridCommands, ToolsMenuCommands>>(
self.alerter);
TabCollectionItem* item0 = [[TabCollectionItem alloc] init];
item0.title = @"Tab 0";
[self.viewController populateItems:@[ item0 ] selectedIndex:0];
[self.baseViewController setHidesBarsOnSwipe:YES];
[self.baseViewController pushViewController:self.viewController animated:YES];
}
@end
// 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.
#import <EarlGrey/EarlGrey.h>
#import "ios/showcase/test/showcase_eg_utils.h"
#import "ios/showcase/test/showcase_test_case.h"
#if !defined(__has_feature) || !__has_feature(objc_arc)
#error "This file requires ARC support."
#endif
// Tests for the tab grid view controller.
@interface SCTabGridTestCase : ShowcaseTestCase
@end
@implementation SCTabGridTestCase
// Tests launching TabGridViewController and tapping a cell.
// TODO(crbug.com/710662): re-enable this test.
- (void)FLAKY_testLaunchAndTappingCell {
showcase_utils::Open(@"TabGridViewController");
[[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"Tab 0_button")]
performAction:grey_tap()];
[[EarlGrey selectElementWithMatcher:grey_text(@"TabGridCommands")]
assertWithMatcher:grey_notNil()];
[[EarlGrey selectElementWithMatcher:grey_accessibilityLabel(
@"protocol_alerter_done")]
performAction:grey_tap()];
showcase_utils::Close();
}
@end
# 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.
source_set("toolbar") {
sources = [
"sc_toolbar_coordinator.h",
"sc_toolbar_coordinator.mm",
]
deps = [
"//ios/clean/chrome/browser/ui/commands",
"//ios/clean/chrome/browser/ui/toolbar:toolbar_components_ui",
"//ios/clean/chrome/browser/ui/toolbar:toolbar_ui",
"//ios/showcase/common",
]
libs = [ "UIKit.framework" ]
configs += [ "//build/config/compiler:enable_arc" ]
}
source_set("eg_tests") {
testonly = true
sources = [
"sc_toolbar_egtest.mm",
]
deps = [
"//components/strings",
"//ios/chrome/app/strings",
"//ios/chrome/browser/ui",
"//ios/chrome/test/earl_grey:test_support",
"//ios/showcase/test",
"//ios/third_party/earl_grey:earl_grey+link",
"//ui/base",
]
configs += [ "//build/config/compiler:enable_arc" ]
}
// 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_SHOWCASE_TOOLBAR_SC_TOOLBAR_COORDINATOR_H_
#define IOS_SHOWCASE_TOOLBAR_SC_TOOLBAR_COORDINATOR_H_
#import <UIKit/UIKit.h>
#import "ios/showcase/common/navigation_coordinator.h"
@interface SCToolbarCoordinator : NSObject<NavigationCoordinator>
@end
#endif // IOS_SHOWCASE_TOOLBAR_SC_TOOLBAR_COORDINATOR_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/showcase/toolbar/sc_toolbar_coordinator.h"
#import "ios/clean/chrome/browser/ui/commands/navigation_commands.h"
#import "ios/clean/chrome/browser/ui/commands/tab_grid_commands.h"
#import "ios/clean/chrome/browser/ui/commands/tab_strip_commands.h"
#import "ios/clean/chrome/browser/ui/commands/tools_menu_commands.h"
#import "ios/clean/chrome/browser/ui/toolbar/toolbar_button_factory.h"
#import "ios/clean/chrome/browser/ui/toolbar/toolbar_view_controller.h"
#import "ios/showcase/common/protocol_alerter.h"
#if !defined(__has_feature) || !__has_feature(objc_arc)
#error "This file requires ARC support."
#endif
namespace {
// Toolbar height.
CGFloat kToolbarHeight = 50.0f;
} // namespace
@interface SCToolbarCoordinator ()
@property(nonatomic, strong) ProtocolAlerter* alerter;
@end
@implementation SCToolbarCoordinator
@synthesize baseViewController = _baseViewController;
@synthesize alerter = _alerter;
- (void)start {
self.alerter = [[ProtocolAlerter alloc] initWithProtocols:@[
@protocol(NavigationCommands), @protocol(TabGridCommands),
@protocol(TabStripCommands), @protocol(ToolsMenuCommands)
]];
self.alerter.baseViewController = self.baseViewController;
UIViewController* containerViewController = [[UIViewController alloc] init];
containerViewController.view.backgroundColor = [UIColor whiteColor];
containerViewController.title = @"Toolbar";
UIView* containerView = [[UIView alloc] init];
[containerViewController.view addSubview:containerView];
containerView.backgroundColor = [UIColor redColor];
containerView.translatesAutoresizingMaskIntoConstraints = NO;
id dispatcher =
static_cast<id<NavigationCommands, TabGridCommands, TabStripCommands,
ToolsMenuCommands>>(self.alerter);
CleanToolbarViewController* toolbarViewController =
[[CleanToolbarViewController alloc]
initWithDispatcher:dispatcher
buttonFactory:[[CleanToolbarButtonFactory alloc]
initWithStyle:NORMAL]];
toolbarViewController.usesTabStrip = YES;
[containerViewController addChildViewController:toolbarViewController];
toolbarViewController.view.frame = containerView.frame;
[containerView addSubview:toolbarViewController.view];
[toolbarViewController didMoveToParentViewController:containerViewController];
[NSLayoutConstraint activateConstraints:@[
[containerView.heightAnchor constraintEqualToConstant:kToolbarHeight],
[containerView.leadingAnchor
constraintEqualToAnchor:containerViewController.view.leadingAnchor],
[containerView.trailingAnchor
constraintEqualToAnchor:containerViewController.view.trailingAnchor],
[containerView.centerYAnchor
constraintEqualToAnchor:containerViewController.view.centerYAnchor],
]];
[self.baseViewController pushViewController:containerViewController
animated:YES];
}
@end
// 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 <EarlGrey/EarlGrey.h>
#include "components/strings/grit/components_strings.h"
#import "ios/chrome/browser/ui/uikit_ui_util.h"
#include "ios/chrome/grit/ios_strings.h"
#import "ios/chrome/test/earl_grey/accessibility_util.h"
#import "ios/showcase/test/showcase_eg_utils.h"
#import "ios/showcase/test/showcase_test_case.h"
#include "ui/base/l10n/l10n_util.h"
#if !defined(__has_feature) || !__has_feature(objc_arc)
#error "This file requires ARC support."
#endif
namespace {
using ::showcase_utils::Open;
using ::showcase_utils::Close;
}
// Tests for the toolbar view controller.
@interface SCToolbarTestCase : ShowcaseTestCase
@end
@implementation SCToolbarTestCase
- (void)setUp {
[super setUp];
Open(@"ToolbarViewController");
}
- (void)tearDown {
Close();
if ([UIDevice currentDevice].orientation != UIDeviceOrientationPortrait) {
[EarlGrey rotateDeviceToOrientation:UIDeviceOrientationPortrait
errorOrNil:nil];
}
[super tearDown];
}
// TODO(crbug.com/772186): Fails on iOS 10 devices.
#if TARGET_IPHONE_SIMULATOR
#define MAYBE_testVerifyToolbarButtonsLabelAndAction \
testVerifyToolbarButtonsLabelAndAction
#else
#define MAYBE_testVerifyToolbarButtonsLabelAndAction \
DISABLED_testVerifyToolbarButtonsLabelAndAction
#endif
// Tests if the Toolbar buttons have the right accessibility labels and
// commands.
- (void)MAYBE_testVerifyToolbarButtonsLabelAndAction {
// Buttons displayed in both Regular and Compact SizeClasses.
// Back Button.
[[EarlGrey
selectElementWithMatcher:grey_accessibilityLabel(
l10n_util::GetNSString(IDS_ACCNAME_BACK))]
performAction:grey_tap()];
[[EarlGrey selectElementWithMatcher:grey_accessibilityLabel(@"goBack")]
assertWithMatcher:grey_notNil()];
[[EarlGrey selectElementWithMatcher:grey_accessibilityLabel(
@"protocol_alerter_done")]
performAction:grey_tap()];
// Forward Button.
[[EarlGrey
selectElementWithMatcher:grey_accessibilityLabel(
l10n_util::GetNSString(IDS_ACCNAME_FORWARD))]
performAction:grey_tap()];
[[EarlGrey selectElementWithMatcher:grey_accessibilityLabel(@"goForward")]
assertWithMatcher:grey_notNil()];
[[EarlGrey selectElementWithMatcher:grey_accessibilityLabel(
@"protocol_alerter_done")]
performAction:grey_tap()];
// ShowTabStrip Button.
[[EarlGrey
selectElementWithMatcher:grey_accessibilityLabel(l10n_util::GetNSString(
IDS_IOS_TOOLBAR_SHOW_TABS))]
performAction:grey_tap()];
[[EarlGrey selectElementWithMatcher:grey_accessibilityLabel(@"showTabStrip")]
assertWithMatcher:grey_notNil()];
[[EarlGrey selectElementWithMatcher:grey_accessibilityLabel(
@"protocol_alerter_done")]
performAction:grey_tap()];
// Menu Button.
[[EarlGrey
selectElementWithMatcher:grey_accessibilityLabel(l10n_util::GetNSString(
IDS_IOS_TOOLBAR_SETTINGS))]
performAction:grey_tap()];
[[EarlGrey selectElementWithMatcher:grey_accessibilityLabel(@"showToolsMenu")]
assertWithMatcher:grey_notNil()];
[[EarlGrey selectElementWithMatcher:grey_accessibilityLabel(
@"protocol_alerter_done")]
performAction:grey_tap()];
// Buttons displayed only in Regular SizeClass.
if (!IsCompact()) {
// Share Button.
[[EarlGrey
selectElementWithMatcher:grey_accessibilityLabel(l10n_util::GetNSString(
IDS_IOS_TOOLS_MENU_SHARE))]
assertWithMatcher:grey_notNil()];
// Reload Button.
[[EarlGrey
selectElementWithMatcher:grey_accessibilityLabel(l10n_util::GetNSString(
IDS_IOS_ACCNAME_RELOAD))]
performAction:grey_tap()];
[[EarlGrey selectElementWithMatcher:grey_accessibilityLabel(@"reloadPage")]
assertWithMatcher:grey_notNil()];
[[EarlGrey selectElementWithMatcher:grey_accessibilityLabel(
@"protocol_alerter_done")]
performAction:grey_tap()];
// Stop Button.
[[EarlGrey
selectElementWithMatcher:grey_accessibilityLabel(l10n_util::GetNSString(
IDS_IOS_ACCNAME_STOP))]
performAction:grey_tap()];
[[EarlGrey
selectElementWithMatcher:grey_accessibilityLabel(@"stopLoadingPage")]
assertWithMatcher:grey_notNil()];
[[EarlGrey selectElementWithMatcher:grey_accessibilityLabel(
@"protocol_alerter_done")]
performAction:grey_tap()];
}
}
// Tests that the Menu will be closed on rotation from portrait to landscape and
// viceversa.
- (void)testRotation {
// TODO(crbug.com/652464): Enable the test for iPad when rotation bug is
// fixed.
if (IsIPadIdiom()) {
EARL_GREY_TEST_DISABLED(@"Disabled for iPad due to device rotation bug.");
}
// Rotate from portrait to landscape.
if ([EarlGrey rotateDeviceToOrientation:UIDeviceOrientationLandscapeRight
errorOrNil:nil]) {
[[EarlGrey
selectElementWithMatcher:grey_accessibilityLabel(@"closeToolsMenu")]
assertWithMatcher:grey_notNil()];
[[EarlGrey selectElementWithMatcher:grey_accessibilityLabel(
@"protocol_alerter_done")]
performAction:grey_tap()];
// If successful rotate back from landscape to portrait.
if ([EarlGrey rotateDeviceToOrientation:UIDeviceOrientationPortrait
errorOrNil:nil]) {
[[EarlGrey
selectElementWithMatcher:grey_accessibilityLabel(@"closeToolsMenu")]
assertWithMatcher:grey_notNil()];
[[EarlGrey selectElementWithMatcher:grey_accessibilityLabel(
@"protocol_alerter_done")]
performAction:grey_tap()];
}
}
}
// Tests that the Regular SizeClass buttons appear when a rotation causes a
// SizeClass change from Compact to Regular. E.g. iPhone Plus rotation from
// portrait to landscape and viceversa.
- (void)testRotationSizeClassChange {
// TODO(crbug.com/652464): Enable the test for iPad when rotation bug is
// fixed.
if (IsIPadIdiom()) {
EARL_GREY_TEST_DISABLED(@"Disabled for iPad due to device rotation bug.");
}
// If currently on compact rotate to check if SizeClass changes to regular.
if (IsCompact()) {
if ([EarlGrey rotateDeviceToOrientation:UIDeviceOrientationLandscapeRight
errorOrNil:nil]) {
[[EarlGrey selectElementWithMatcher:grey_accessibilityLabel(
@"protocol_alerter_done")]
performAction:grey_tap()];
// If SizeClass is not compact after rotation, confirm that some
// ToolbarButtons are now visible.
if (!IsCompact()) {
[[EarlGrey selectElementWithMatcher:grey_accessibilityLabel(
l10n_util::GetNSString(
IDS_IOS_TOOLS_MENU_SHARE))]
assertWithMatcher:grey_notNil()];
[[EarlGrey selectElementWithMatcher:grey_accessibilityLabel(
l10n_util::GetNSString(
IDS_IOS_ACCNAME_RELOAD))]
assertWithMatcher:grey_notNil()];
[[EarlGrey selectElementWithMatcher:grey_accessibilityLabel(
l10n_util::GetNSString(
IDS_IOS_ACCNAME_STOP))]
assertWithMatcher:grey_notNil()];
// Going back to Compact Width.
if ([EarlGrey rotateDeviceToOrientation:UIDeviceOrientationPortrait
errorOrNil:nil]) {
[[EarlGrey selectElementWithMatcher:grey_accessibilityLabel(
@"protocol_alerter_done")]
performAction:grey_tap()];
[[EarlGrey
selectElementWithMatcher:grey_accessibilityLabel(
l10n_util::GetNSString(
IDS_IOS_TOOLS_MENU_SHARE))]
assertWithMatcher:grey_nil()];
[[EarlGrey selectElementWithMatcher:grey_accessibilityLabel(
l10n_util::GetNSString(
IDS_IOS_ACCNAME_RELOAD))]
assertWithMatcher:grey_nil()];
[[EarlGrey selectElementWithMatcher:grey_accessibilityLabel(
l10n_util::GetNSString(
IDS_IOS_ACCNAME_STOP))]
assertWithMatcher:grey_nil()];
}
}
}
}
}
@end
# 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.
source_set("tools_menu") {
sources = [
"sc_tools_coordinator.h",
"sc_tools_coordinator.mm",
]
deps = [
"//base",
"//ios/clean/chrome/browser/ui/commands",
"//ios/clean/chrome/browser/ui/tools:tools_ui",
"//ios/showcase/common",
"//ui/base",
]
libs = [ "UIKit.framework" ]
configs += [ "//build/config/compiler:enable_arc" ]
}
// 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_SHOWCASE_TOOLS_MENU_SC_TOOLS_COORDINATOR_H_
#define IOS_SHOWCASE_TOOLS_MENU_SC_TOOLS_COORDINATOR_H_
#import <UIKit/UIKit.h>
#import "ios/showcase/common/navigation_coordinator.h"
@interface SCToolsCoordinator : NSObject<NavigationCoordinator>
@end
#endif // IOS_SHOWCASE_TOOLS_MENU_SC_TOOLS_COORDINATOR_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/showcase/tools_menu/sc_tools_coordinator.h"
#include "base/macros.h"
#import "ios/clean/chrome/browser/ui/commands/find_in_page_visibility_commands.h"
#import "ios/clean/chrome/browser/ui/commands/navigation_commands.h"
#import "ios/clean/chrome/browser/ui/commands/settings_commands.h"
#import "ios/clean/chrome/browser/ui/commands/tools_menu_commands.h"
#import "ios/clean/chrome/browser/ui/tools/menu_view_controller.h"
#import "ios/clean/chrome/browser/ui/tools/tools_menu_item.h"
#import "ios/clean/chrome/browser/ui/tools/tools_menu_model.h"
#import "ios/showcase/common/protocol_alerter.h"
#include "ui/base/l10n/l10n_util.h"
#if !defined(__has_feature) || !__has_feature(objc_arc)
#error "This file requires ARC support."
#endif
@interface SCToolsCoordinator ()
@property(nonatomic, strong) ProtocolAlerter* alerter;
@end
@implementation SCToolsCoordinator
@synthesize baseViewController = _baseViewController;
@synthesize alerter = _alerter;
#pragma mark - BrowserCoordinator
- (void)start {
self.alerter = [[ProtocolAlerter alloc] initWithProtocols:@[
@protocol(FindInPageVisibilityCommands), @protocol(NavigationCommands),
@protocol(ToolsMenuCommands), @protocol(SettingsCommands)
]];
self.alerter.baseViewController = self.baseViewController;
MenuViewController* viewController = [[MenuViewController alloc] init];
viewController.modalPresentationStyle = UIModalPresentationCustom;
viewController.dispatcher =
static_cast<id<FindInPageVisibilityCommands, NavigationCommands,
ToolsMenuCommands, SettingsCommands>>(self.alerter);
NSMutableArray* menuItems = [NSMutableArray array];
// Load the full model into the VC.
for (size_t i = 0; i < arraysize(itemsModelList); ++i) {
const MenuModelItem& modelItem = itemsModelList[i];
ToolsMenuItem* menuItem = [[ToolsMenuItem alloc] init];
menuItem.title = l10n_util::GetNSStringWithFixup(modelItem.title_id);
menuItem.action = NSSelectorFromString(modelItem.selector);
[menuItems addObject:menuItem];
}
[viewController setToolsMenuItems:menuItems];
// The Overflow controls will only be displayed on CompactWidth SizeClasses.
[viewController setDisplayOverflowControls:YES];
[self.baseViewController pushViewController:viewController animated:YES];
}
@end
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