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

[ios] Fixes Recent Tabs Eg Tests for UIRefresh

testClosedTabAppearsInRecentTabsPanel, testOpenHistory and testRecentTabSigninPromoReloaded
were failing because of missing A11y info and because we weren't updating the mediator correctly
on start.
testRecentTabSigninPromoReloadedWhileHidden was failing because RecentTabsTableVC implementation
wasn't updating the SignInPromoItem configuraton when the section was collapsed.

Cq-Include-Trybots: master.tryserver.chromium.mac:ios-simulator-cronet;master.tryserver.chromium.mac:ios-simulator-full-configs
Change-Id: I9d89501a0285914bc15897d0bdaf48d080f0455b
Reviewed-on: https://chromium-review.googlesource.com/990588
Commit-Queue: Sergio Collazos <sczs@chromium.org>
Reviewed-by: default avatarRohit Rao <rohitrao@chromium.org>
Cr-Commit-Position: refs/heads/master@{#547722}
parent 1233e9a6
......@@ -99,6 +99,7 @@ source_set("eg_tests") {
"//ios/chrome/browser/ui",
"//ios/chrome/browser/ui/authentication:eg_test_support",
"//ios/chrome/browser/ui/ntp/recent_tabs",
"//ios/chrome/browser/ui/table_view",
"//ios/chrome/test/app:test_support",
"//ios/chrome/test/earl_grey:test_support",
"//ios/public/provider/chrome/browser/signin:test_support",
......
......@@ -12,6 +12,7 @@
#include "components/strings/grit/components_strings.h"
#import "ios/chrome/browser/ui/authentication/signin_earlgrey_utils.h"
#import "ios/chrome/browser/ui/ntp/recent_tabs/recent_tabs_constants.h"
#import "ios/chrome/browser/ui/table_view/table_container_constants.h"
#include "ios/chrome/browser/ui/ui_util.h"
#include "ios/chrome/grit/ios_strings.h"
#import "ios/chrome/test/app/tab_test_util.h"
......@@ -76,9 +77,10 @@ id<GREYMatcher> TitleOfTestPage() {
// Closes the recent tabs panel.
- (void)closeRecentTabs {
id<GREYMatcher> exit_button_matcher = grey_accessibilityID(@"Exit");
[[EarlGrey selectElementWithMatcher:exit_button_matcher]
performAction:grey_tap()];
NSString* exitID =
IsUIRefreshPhase1Enabled() ? kTableContainerDismissButtonId : @"Exit";
id<GREYMatcher> exitMatcher = grey_accessibilityID(exitID);
[[EarlGrey selectElementWithMatcher:exitMatcher] performAction:grey_tap()];
// Wait until the recent tabs panel is dismissed.
[[GREYUIThreadExecutor sharedInstance] drainUntilIdle];
}
......@@ -125,16 +127,23 @@ id<GREYMatcher> TitleOfTestPage() {
OpenRecentTabsPanel();
// Tap "Show Full History"
[[EarlGrey
selectElementWithMatcher:chrome_test_util::ButtonWithAccessibilityLabel(
l10n_util::GetNSString(
IDS_HISTORY_SHOWFULLHISTORY_LINK))]
id<GREYMatcher> showHistoryMatcher =
IsUIRefreshPhase1Enabled()
? chrome_test_util::StaticTextWithAccessibilityLabelId(
IDS_HISTORY_SHOWFULLHISTORY_LINK)
: chrome_test_util::ButtonWithAccessibilityLabelId(
IDS_HISTORY_SHOWFULLHISTORY_LINK);
[[EarlGrey selectElementWithMatcher:showHistoryMatcher]
performAction:grey_tap()];
// Make sure history is opened.
[[EarlGrey
selectElementWithMatcher:grey_accessibilityLabel(
l10n_util::GetNSString(IDS_HISTORY_TITLE))]
selectElementWithMatcher:grey_allOf(grey_accessibilityLabel(
l10n_util::GetNSString(
IDS_HISTORY_TITLE)),
grey_accessibilityTrait(
UIAccessibilityTraitHeader),
nil)]
assertWithMatcher:grey_sufficientlyVisible()];
// Close History.
......
......@@ -65,10 +65,10 @@
// longer than its associated VC.
if (!self.mediator) {
self.mediator = [[RecentTabsMediator alloc] init];
self.mediator.browserState = self.browserState;
self.mediator.consumer = recentTabsTableViewController;
[self.mediator initObservers];
}
self.mediator.browserState = self.browserState;
self.mediator.consumer = recentTabsTableViewController;
[self.mediator reloadSessions];
// Initialize and configure RecentTabsViewController.
......
......@@ -953,23 +953,26 @@ const int kRelativeTimeMaxHours = 4;
(SigninPromoViewConfigurator*)configurator
identityChanged:(BOOL)identityChanged {
DCHECK(self.signinPromoViewMediator);
if ([self.tableViewModel sectionIsCollapsed:SectionIdentifierOtherDevices])
return;
// Update the TableViewSigninPromoItem configurator. It will be used by the
// item to configure the cell once |self.tableView| requests a cell on
// cellForRowAtIndexPath.
NSIndexPath* indexPath =
[self.tableViewModel indexPathForItemType:ItemTypeOtherDevicesSigninPromo
sectionIdentifier:SectionIdentifierOtherDevices];
TableViewItem* item = [self.tableViewModel itemAtIndexPath:indexPath];
TableViewSigninPromoItem* signInItem =
base::mac::ObjCCastStrict<TableViewSigninPromoItem>(item);
signInItem.configurator = configurator;
// If section is collapsed no tableView update is needed.
if ([self.tableViewModel sectionIsCollapsed:SectionIdentifierOtherDevices]) {
return;
}
// If the section is not collapsed and the identity has changed, reload the
// Cell.
if (identityChanged) {
[self.tableView reloadRowsAtIndexPaths:@[ indexPath ]
withRowAnimation:UITableViewRowAnimationNone];
return;
}
UITableViewCell* cell = [self.tableView cellForRowAtIndexPath:indexPath];
NSArray<UIView*>* contentViews = cell.contentView.subviews;
DCHECK(contentViews.count == 1);
UIView* subview = contentViews[0];
DCHECK([subview isKindOfClass:[SigninPromoView class]]);
SigninPromoView* signinPromoView = (SigninPromoView*)subview;
[configurator configureSigninPromoView:signinPromoView];
}
- (void)signinDidFinish {
......
......@@ -9,6 +9,8 @@ source_set("table_view") {
"chrome_table_view_controller.mm",
"table_container_bottom_toolbar.h",
"table_container_bottom_toolbar.mm",
"table_container_constants.h",
"table_container_constants.mm",
"table_container_view_controller.h",
"table_container_view_controller.mm",
"table_view_model.h",
......
......@@ -16,7 +16,7 @@
// TableViewItem for SignIn Promo Cell.
@interface TableViewSigninPromoItem : TableViewItem
// SigninPromoViewConfigurator used to configure the SigninPromoView.
@property(nonatomic, weak) SigninPromoViewConfigurator* configurator;
@property(nonatomic, strong) SigninPromoViewConfigurator* configurator;
// SigninPromoViewDelegate to perform SigninPromoView actions.
@property(nonatomic, weak) id<SigninPromoViewDelegate> delegate;
// Text being displayed.
......
......@@ -27,6 +27,8 @@ const CGFloat kVerticalSpacing = 2.0;
self = [super initWithType:type];
if (self) {
self.cellClass = [TableViewTextHeaderFooterView class];
self.accessibilityTraits |=
UIAccessibilityTraitButton | UIAccessibilityTraitHeader;
}
return self;
}
......@@ -42,6 +44,7 @@ const CGFloat kVerticalSpacing = 2.0;
base::mac::ObjCCastStrict<TableViewTextHeaderFooterView>(headerFooter);
header.textLabel.text = self.text;
header.subtitleLabel.text = self.subtitleText;
header.accessibilityLabel = self.text;
}
@end
......
// Copyright 2018 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_TABLE_VIEW_TABLE_CONTAINER_CONSTANTS_H_
#define IOS_CHROME_BROWSER_UI_TABLE_VIEW_TABLE_CONTAINER_CONSTANTS_H_
#import <Foundation/Foundation.h>
// Accessibility ID for the "Done" button on TableContainer navigation bar.
extern NSString* const kTableContainerDismissButtonId;
#endif // IOS_CHROME_BROWSER_UI_TABLE_VIEW_TABLE_CONTAINER_CONSTANTS_H_
// Copyright 2018 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/table_view/table_container_constants.h"
#if !defined(__has_feature) || !__has_feature(objc_arc)
#error "This file requires ARC support."
#endif
NSString* const kTableContainerDismissButtonId =
@"kTableContainerDismissButtonId";
......@@ -5,6 +5,7 @@
#import "ios/chrome/browser/ui/table_view/table_container_view_controller.h"
#import "ios/chrome/browser/ui/table_view/chrome_table_view_controller.h"
#import "ios/chrome/browser/ui/table_view/table_container_constants.h"
#include "ios/chrome/grit/ios_strings.h"
#include "ui/base/l10n/l10n_util.h"
......@@ -33,6 +34,7 @@
_dismissButton.style = UIBarButtonItemStylePlain;
_dismissButton.title =
l10n_util::GetNSString(IDS_IOS_NAVIGATION_BAR_DONE_BUTTON);
[_dismissButton setAccessibilityIdentifier:kTableContainerDismissButtonId];
}
return self;
}
......
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