Commit cabb24c1 authored by Kurt Horimoto's avatar Kurt Horimoto Committed by Commit Bot

[iOS] Update IsReadingListUIRebootEnabled() to use kUIRefreshPhase1.

This enables the table-based Reading List UI to be released with the
rest of the Phase 1 UI Refresh features.

This CL also updates Reading List EGTests to use a11y identifiers for
toolbar buttons rather than labels.  In the UI Refresh, the toolbar
buttons are based on UIBarButtonItems, which are rendered using
multiple views with the same a11y label.  Since EGTests couldn't find
matchers for the label, IDs are used instead.

Bug: 864378
Cq-Include-Trybots: luci.chromium.try:ios-simulator-full-configs;master.tryserver.chromium.mac:ios-simulator-cronet
Change-Id: I223469771314907b614120a6b98f9bb92ce40b25
Reviewed-on: https://chromium-review.googlesource.com/1139901
Commit-Queue: Kurt Horimoto <kkhorimoto@chromium.org>
Reviewed-by: default avatarRohit Rao <rohitrao@chromium.org>
Reviewed-by: default avatarGauthier Ambard <gambard@chromium.org>
Cr-Commit-Position: refs/heads/master@{#576156}
parent 87b3a36a
......@@ -135,7 +135,7 @@ bool IsBookmarksUIRebootEnabled() {
}
bool IsReadingListUIRebootEnabled() {
return base::FeatureList::IsEnabled(kCollectionsUIReboot);
return base::FeatureList::IsEnabled(kUIRefreshPhase1);
}
bool IsCollectionsUIRebootEnabled() {
......
......@@ -39,12 +39,14 @@ source_set("eg_tests") {
"//components/feature_engagement/public",
"//components/feature_engagement/test:test_support",
"//ios/chrome/app/strings",
"//ios/chrome/browser",
"//ios/chrome/browser/browser_state",
"//ios/chrome/browser/ui:ui_util",
"//ios/chrome/browser/ui/popup_menu:constants",
"//ios/chrome/browser/ui/tab_grid:egtest_support",
"//ios/chrome/browser/ui/tab_switcher:egtest_support",
"//ios/chrome/browser/ui/tab_switcher:modes",
"//ios/chrome/browser/ui/table_view",
"//ios/chrome/browser/ui/tools_menu/public",
"//ios/chrome/test/app:test_support",
"//ios/chrome/test/earl_grey:test_support",
......
......@@ -12,11 +12,13 @@
#include "components/feature_engagement/public/tracker.h"
#include "components/feature_engagement/test/test_tracker.h"
#include "ios/chrome/browser/browser_state/chrome_browser_state.h"
#include "ios/chrome/browser/experimental_flags.h"
#include "ios/chrome/browser/feature_engagement/tracker_factory.h"
#import "ios/chrome/browser/ui/popup_menu/popup_menu_constants.h"
#import "ios/chrome/browser/ui/tab_grid/tab_grid_egtest_util.h"
#import "ios/chrome/browser/ui/tab_switcher/tab_switcher_egtest_util.h"
#import "ios/chrome/browser/ui/tab_switcher/tab_switcher_mode.h"
#import "ios/chrome/browser/ui/table_view/table_view_navigation_controller_constants.h"
#include "ios/chrome/browser/ui/tools_menu/public/tools_menu_constants.h"
#include "ios/chrome/browser/ui/ui_util.h"
#include "ios/chrome/grit/ios_strings.h"
......@@ -248,8 +250,15 @@ void EnableNewTabTipTriggering(base::test::ScopedFeatureList& feature_list) {
}
[chrome_test_util::BrowserCommandDispatcherForMainBVC() showReadingList];
[[EarlGrey selectElementWithMatcher:grey_accessibilityLabel(@"Done")]
performAction:grey_tap()];
if (experimental_flags::IsReadingListUIRebootEnabled()) {
[[EarlGrey
selectElementWithMatcher:grey_accessibilityID(
kTableViewNavigationDismissButtonId)]
performAction:grey_tap()];
} else {
[[EarlGrey selectElementWithMatcher:grey_accessibilityLabel(@"Done")]
performAction:grey_tap()];
}
[ChromeEarlGreyUI openToolsMenu];
......
......@@ -100,6 +100,8 @@ source_set("reading_list_ui") {
"reading_list_table_view_controller.h",
"reading_list_table_view_controller.mm",
"reading_list_toolbar_button_commands.h",
"reading_list_toolbar_button_identifiers.h",
"reading_list_toolbar_button_identifiers.mm",
"reading_list_toolbar_button_manager.h",
"reading_list_toolbar_button_manager.mm",
"reading_list_ui_distillation_status.h",
......@@ -205,6 +207,7 @@ source_set("eg_tests") {
"//ios/chrome/browser/ui/popup_menu:constants",
"//ios/chrome/browser/ui/table_view",
"//ios/chrome/browser/ui/table_view:views",
"//ios/chrome/browser/ui/table_view/cells",
"//ios/chrome/browser/ui/tools_menu/public",
"//ios/chrome/test/app:test_support",
"//ios/chrome/test/earl_grey:test_support",
......
......@@ -6,6 +6,7 @@
#import "ios/chrome/browser/ui/alert_coordinator/action_sheet_coordinator.h"
#import "ios/chrome/browser/ui/reading_list/legacy_reading_list_toolbar_button.h"
#import "ios/chrome/browser/ui/reading_list/reading_list_toolbar_button_identifiers.h"
#import "ios/chrome/common/ui_util/constraints_ui_util.h"
#include "ios/chrome/grit/ios_strings.h"
#import "ios/third_party/material_components_ios/src/components/Typography/src/MaterialTypography.h"
......@@ -85,28 +86,34 @@ const CGFloat kHorizontalSpacing = 8.0f;
initWithText:l10n_util::GetNSString(IDS_IOS_READING_LIST_DELETE_BUTTON)
destructive:YES
position:Leading];
_deleteButton.accessibilityIdentifier = kReadingListToolbarDeleteButtonID;
_deleteAllButton = [[LegacyReadingListToolbarButton alloc]
initWithText:l10n_util::GetNSString(
IDS_IOS_READING_LIST_DELETE_ALL_READ_BUTTON)
destructive:YES
position:Leading];
_deleteAllButton.accessibilityIdentifier =
kReadingListToolbarDeleteAllReadButtonID;
_markButton = [[LegacyReadingListToolbarButton alloc]
initWithText:l10n_util::GetNSString(
IDS_IOS_READING_LIST_MARK_ALL_BUTTON)
destructive:NO
position:Centered];
_markButton.accessibilityIdentifier = kReadingListToolbarMarkButtonID;
_cancelButton = [[LegacyReadingListToolbarButton alloc]
initWithText:l10n_util::GetNSString(IDS_IOS_READING_LIST_CANCEL_BUTTON)
destructive:NO
position:Trailing];
_cancelButton.accessibilityIdentifier = kReadingListToolbarCancelButtonID;
_editButton = [[LegacyReadingListToolbarButton alloc]
initWithText:l10n_util::GetNSString(IDS_IOS_READING_LIST_EDIT_BUTTON)
destructive:NO
position:Trailing];
_editButton.accessibilityIdentifier = kReadingListToolbarEditButtonID;
[_editButton addTarget:nil
action:@selector(enterEditingModePressed)
......
......@@ -8,9 +8,12 @@
#include "base/metrics/user_metrics.h"
#include "base/metrics/user_metrics_action.h"
#include "base/strings/sys_string_conversions.h"
#include "components/feature_engagement/public/event_constants.h"
#include "components/feature_engagement/public/tracker.h"
#include "components/reading_list/core/reading_list_entry.h"
#include "ios/chrome/browser/chrome_url_constants.h"
#include "ios/chrome/browser/favicon/ios_chrome_large_icon_service_factory.h"
#include "ios/chrome/browser/feature_engagement/tracker_factory.h"
#import "ios/chrome/browser/metrics/new_tab_page_uma.h"
#include "ios/chrome/browser/reading_list/offline_url_utils.h"
#include "ios/chrome/browser/reading_list/reading_list_model_factory.h"
......@@ -135,6 +138,11 @@
animated:YES
completion:nil];
// Send the "Viewed Reading List" event to the feature_engagement::Tracker
// when the user opens their reading list.
feature_engagement::TrackerFactory::GetForBrowserState(self.browserState)
->NotifyEvent(feature_engagement::events::kViewedReadingList);
[super start];
self.started = YES;
}
......
......@@ -22,6 +22,10 @@
#import "ios/chrome/browser/ui/reading_list/reading_list_collection_view_cell.h"
#import "ios/chrome/browser/ui/reading_list/reading_list_collection_view_controller.h"
#import "ios/chrome/browser/ui/reading_list/reading_list_collection_view_item.h"
#import "ios/chrome/browser/ui/reading_list/reading_list_table_view_controller.h"
#import "ios/chrome/browser/ui/reading_list/reading_list_toolbar_button_identifiers.h"
#import "ios/chrome/browser/ui/table_view/cells/table_view_url_cell_favicon_badge_view.h"
#import "ios/chrome/browser/ui/table_view/cells/table_view_url_item.h"
#import "ios/chrome/browser/ui/table_view/table_view_empty_view.h"
#include "ios/chrome/browser/ui/tools_menu/public/tools_menu_constants.h"
#include "ios/chrome/browser/ui/ui_util.h"
......@@ -113,70 +117,109 @@ ReadingListModel* GetReadingListModel() {
return model;
}
// The ancestor class of toolbar buttons.
Class ToolbarButtonAncestorClass() {
return experimental_flags::IsReadingListUIRebootEnabled()
? [UIToolbar class]
: [LegacyReadingListToolbarButton class];
}
// The class displaying the reading list cells.
Class ReadingListCellClass() {
return experimental_flags::IsReadingListUIRebootEnabled()
? [TableViewURLCell class]
: [ReadingListCell class];
}
// The class displaying the reading list.
Class ReadingListViewControllerClass() {
return experimental_flags::IsReadingListUIRebootEnabled()
? [ReadingListTableViewController class]
: [ReadingListCollectionViewController class];
}
// Scroll to the top of the Reading List.
void ScrollToTop() {
NSError* error = nil;
[[EarlGrey selectElementWithMatcher:grey_accessibilityID(
[ReadingListCollectionViewController
[ReadingListViewControllerClass()
accessibilityIdentifier])]
performAction:grey_scrollToContentEdge(kGREYContentEdgeTop)
performAction:grey_scrollToContentEdgeWithStartPoint(kGREYContentEdgeTop,
0.5, 0.5)
error:&error];
[[GREYUIThreadExecutor sharedInstance] drainUntilIdle];
}
// Asserts the |button_id| button is not visible.
void AssertButtonNotVisibleWithID(int button_id) {
[[EarlGrey selectElementWithMatcher:
grey_allOf(chrome_test_util::ButtonWithAccessibilityLabelId(
button_id),
grey_ancestor(grey_kindOfClass(
[LegacyReadingListToolbarButton class])),
nil)] assertWithMatcher:grey_notVisible()];
// Asserts that the "mark" toolbar button is visible and has the a11y label of
// |a11y_label_id|.
void AssertToolbarMarkButtonText(int a11y_label_id) {
[[EarlGrey
selectElementWithMatcher:
grey_allOf(
grey_accessibilityID(kReadingListToolbarMarkButtonID),
grey_ancestor(grey_kindOfClass(ToolbarButtonAncestorClass())),
chrome_test_util::ButtonWithAccessibilityLabelId(a11y_label_id),
nil)] assertWithMatcher:grey_sufficientlyVisible()];
}
// Asserts the |button_id| toolbar button is not visible.
void AssertToolbarButtonNotVisibleWithID(NSString* button_id) {
[[EarlGrey
selectElementWithMatcher:grey_allOf(grey_accessibilityID(button_id),
grey_ancestor(grey_kindOfClass(
ToolbarButtonAncestorClass())),
nil)]
assertWithMatcher:grey_notVisible()];
}
// Assert the |button_id| toolbar button is visible.
void AssertToolbarButtonVisibleWithID(NSString* button_id) {
[[EarlGrey
selectElementWithMatcher:grey_allOf(grey_accessibilityID(button_id),
grey_ancestor(grey_kindOfClass(
ToolbarButtonAncestorClass())),
nil)]
assertWithMatcher:grey_sufficientlyVisible()];
}
// Assert the |button_id| button is visible.
void AssertButtonVisibleWithID(int button_id) {
[[EarlGrey selectElementWithMatcher:
grey_allOf(chrome_test_util::ButtonWithAccessibilityLabelId(
button_id),
grey_ancestor(grey_kindOfClass(
[LegacyReadingListToolbarButton class])),
nil)] assertWithMatcher:grey_sufficientlyVisible()];
// Taps the |button_id| toolbar button.
void TapToolbarButtonWithID(NSString* button_id) {
[[EarlGrey selectElementWithMatcher:grey_accessibilityID(button_id)]
performAction:grey_tap()];
}
// Taps the |button_id| button.
void TapButtonWithID(int button_id) {
// Taps the context menu button with the a11y label of |a11y_label_id|.
void TapContextMenuButtonWithA11yLabelID(int a11y_label_id) {
[[EarlGrey
selectElementWithMatcher:chrome_test_util::ButtonWithAccessibilityLabelId(
button_id)] performAction:grey_tap()];
a11y_label_id)] performAction:grey_tap()];
}
// Performs |action| on the entry with the title |entryTitle|. The view can be
// scrolled down to find the entry.
void performActionOnEntry(const std::string& entryTitle,
void PerformActionOnEntry(const std::string& entryTitle,
id<GREYAction> action) {
ScrollToTop();
id<GREYMatcher> matcher =
grey_allOf(chrome_test_util::StaticTextWithAccessibilityLabel(
base::SysUTF8ToNSString(entryTitle)),
grey_ancestor(grey_kindOfClass([ReadingListCell class])),
grey_ancestor(grey_kindOfClass(ReadingListCellClass())),
grey_sufficientlyVisible(), nil);
[[[EarlGrey selectElementWithMatcher:matcher]
usingSearchAction:grey_scrollInDirection(kGREYDirectionDown, 100)
onElementWithMatcher:grey_accessibilityID(
[ReadingListCollectionViewController
accessibilityIdentifier])]
ReadingListViewControllerClass())]
performAction:action];
}
// Taps the entry with the title |entryTitle|.
void TapEntry(const std::string& entryTitle) {
performActionOnEntry(entryTitle, grey_tap());
PerformActionOnEntry(entryTitle, grey_tap());
}
// Long-presses the entry with the title |entryTitle|.
void LongPressEntry(const std::string& entryTitle) {
performActionOnEntry(entryTitle,
PerformActionOnEntry(entryTitle,
grey_longPressWithDuration(kLongPressDuration));
}
......@@ -187,11 +230,11 @@ void AssertEntryVisible(const std::string& entryTitle) {
selectElementWithMatcher:
grey_allOf(chrome_test_util::StaticTextWithAccessibilityLabel(
base::SysUTF8ToNSString(entryTitle)),
grey_ancestor(grey_kindOfClass([ReadingListCell class])),
grey_ancestor(grey_kindOfClass(ReadingListCellClass())),
grey_sufficientlyVisible(), nil)]
usingSearchAction:grey_scrollInDirection(kGREYDirectionDown, 100)
onElementWithMatcher:grey_accessibilityID(
[ReadingListCollectionViewController
[ReadingListViewControllerClass()
accessibilityIdentifier])]
assertWithMatcher:grey_notNil()];
}
......@@ -220,11 +263,11 @@ void AssertEntryNotVisible(std::string title) {
selectElementWithMatcher:
grey_allOf(chrome_test_util::StaticTextWithAccessibilityLabel(
base::SysUTF8ToNSString(title)),
grey_ancestor(grey_kindOfClass([ReadingListCell class])),
grey_ancestor(grey_kindOfClass(ReadingListCellClass())),
grey_sufficientlyVisible(), nil)]
usingSearchAction:grey_scrollInDirection(kGREYDirectionDown, 100)
onElementWithMatcher:grey_accessibilityID(
[ReadingListCollectionViewController
[ReadingListViewControllerClass()
accessibilityIdentifier])]
assertWithMatcher:grey_notNil()
error:&error];
......@@ -233,6 +276,8 @@ void AssertEntryNotVisible(std::string title) {
// Asserts |header| is visible.
void AssertHeaderNotVisible(std::string header) {
[[GREYUIThreadExecutor sharedInstance] drainUntilIdle];
ScrollToTop();
[[EarlGrey selectElementWithMatcher:chrome_test_util::
StaticTextWithAccessibilityLabel(
base::SysUTF8ToNSString(header))]
......@@ -260,7 +305,7 @@ void AddEntriesAndEnterEdit() {
reading_list::ADDED_VIA_CURRENT_APP);
OpenReadingList();
TapButtonWithID(IDS_IOS_READING_LIST_EDIT_BUTTON);
TapToolbarButtonWithID(kReadingListToolbarEditButtonID);
}
// Computes the number of read entries in the model.
......@@ -303,7 +348,10 @@ void AddCurrentPageToReadingList() {
addToReadingList:command];
} else {
[ChromeEarlGreyUI openShareMenu];
TapButtonWithID(IDS_IOS_SHARE_MENU_READING_LIST_ACTION);
[[EarlGrey selectElementWithMatcher:
chrome_test_util::ButtonWithAccessibilityLabelId(
IDS_IOS_SHARE_MENU_READING_LIST_ACTION)]
performAction:grey_tap()];
}
// Wait for the snackbar to appear.
......@@ -340,11 +388,13 @@ void AddCurrentPageToReadingList() {
// Wait until one element is distilled.
void WaitForDistillation() {
NSString* a11y_id =
experimental_flags::IsReadingListUIRebootEnabled()
? [TableViewURLCellFaviconBadgeView accessibilityIdentifier]
: @"Reading List Item distillation date";
ConditionBlock wait_for_distillation_date = ^{
NSError* error = nil;
[[EarlGrey
selectElementWithMatcher:grey_accessibilityID(
@"Reading List Item distillation date")]
[[EarlGrey selectElementWithMatcher:grey_accessibilityID(a11y_id)]
assertWithMatcher:grey_notNil()
error:&error];
return error == nil;
......@@ -480,7 +530,7 @@ void AssertIsShowingDistillablePage(bool online) {
AddEntriesAndEnterEdit();
// In edit mode.
chrome_test_util::VerifyAccessibilityForCurrentScreen();
TapButtonWithID(IDS_IOS_READING_LIST_CANCEL_BUTTON);
TapToolbarButtonWithID(kReadingListToolbarCancelButtonID);
chrome_test_util::VerifyAccessibilityForCurrentScreen();
}
......@@ -521,7 +571,8 @@ void AssertIsShowingDistillablePage(bool online) {
// Long press the entry, and open it offline.
LongPressEntry(pageTitle);
TapButtonWithID(IDS_IOS_READING_LIST_CONTENT_CONTEXT_OFFLINE);
TapContextMenuButtonWithA11yLabelID(
IDS_IOS_READING_LIST_CONTENT_CONTEXT_OFFLINE);
AssertIsShowingDistillablePage(false);
// Tap the Omnibox' Info Bubble to open the Page Info.
......@@ -695,14 +746,11 @@ void AssertIsShowingDistillablePage(bool online) {
reading_list::ADDED_VIA_CURRENT_APP);
OpenReadingList();
AssertButtonNotVisibleWithID(IDS_IOS_READING_LIST_DELETE_BUTTON);
AssertButtonNotVisibleWithID(IDS_IOS_READING_LIST_DELETE_ALL_READ_BUTTON);
AssertButtonNotVisibleWithID(IDS_IOS_READING_LIST_MARK_READ_BUTTON);
AssertButtonNotVisibleWithID(IDS_IOS_READING_LIST_MARK_UNREAD_BUTTON);
AssertButtonNotVisibleWithID(IDS_IOS_READING_LIST_MARK_ALL_BUTTON);
AssertButtonNotVisibleWithID(IDS_IOS_READING_LIST_MARK_BUTTON);
AssertButtonNotVisibleWithID(IDS_IOS_READING_LIST_CANCEL_BUTTON);
AssertButtonVisibleWithID(IDS_IOS_READING_LIST_EDIT_BUTTON);
AssertToolbarButtonNotVisibleWithID(kReadingListToolbarDeleteButtonID);
AssertToolbarButtonNotVisibleWithID(kReadingListToolbarDeleteAllReadButtonID);
AssertToolbarButtonNotVisibleWithID(kReadingListToolbarMarkButtonID);
AssertToolbarButtonNotVisibleWithID(kReadingListToolbarCancelButtonID);
AssertToolbarButtonVisibleWithID(kReadingListToolbarEditButtonID);
}
// Tests that only the "Cancel", "Delete All Read" and "Mark All…" buttons are
......@@ -710,14 +758,11 @@ void AssertIsShowingDistillablePage(bool online) {
- (void)testVisibleButtonsEditingModeEmptySelection {
AddEntriesAndEnterEdit();
AssertButtonNotVisibleWithID(IDS_IOS_READING_LIST_DELETE_BUTTON);
AssertButtonNotVisibleWithID(IDS_IOS_READING_LIST_MARK_READ_BUTTON);
AssertButtonNotVisibleWithID(IDS_IOS_READING_LIST_MARK_UNREAD_BUTTON);
AssertButtonNotVisibleWithID(IDS_IOS_READING_LIST_MARK_BUTTON);
AssertButtonNotVisibleWithID(IDS_IOS_READING_LIST_EDIT_BUTTON);
AssertButtonVisibleWithID(IDS_IOS_READING_LIST_DELETE_ALL_READ_BUTTON);
AssertButtonVisibleWithID(IDS_IOS_READING_LIST_MARK_ALL_BUTTON);
AssertButtonVisibleWithID(IDS_IOS_READING_LIST_CANCEL_BUTTON);
AssertToolbarButtonNotVisibleWithID(kReadingListToolbarDeleteButtonID);
AssertToolbarButtonNotVisibleWithID(kReadingListToolbarEditButtonID);
AssertToolbarButtonVisibleWithID(kReadingListToolbarDeleteAllReadButtonID);
AssertToolbarButtonVisibleWithID(kReadingListToolbarCancelButtonID);
AssertToolbarMarkButtonText(IDS_IOS_READING_LIST_MARK_ALL_BUTTON);
}
// Tests that only the "Cancel", "Delete" and "Mark Unread" buttons are showing
......@@ -726,14 +771,11 @@ void AssertIsShowingDistillablePage(bool online) {
AddEntriesAndEnterEdit();
TapEntry(kReadTitle);
AssertButtonNotVisibleWithID(IDS_IOS_READING_LIST_DELETE_ALL_READ_BUTTON);
AssertButtonNotVisibleWithID(IDS_IOS_READING_LIST_MARK_READ_BUTTON);
AssertButtonNotVisibleWithID(IDS_IOS_READING_LIST_MARK_BUTTON);
AssertButtonNotVisibleWithID(IDS_IOS_READING_LIST_EDIT_BUTTON);
AssertButtonNotVisibleWithID(IDS_IOS_READING_LIST_MARK_ALL_BUTTON);
AssertButtonVisibleWithID(IDS_IOS_READING_LIST_MARK_UNREAD_BUTTON);
AssertButtonVisibleWithID(IDS_IOS_READING_LIST_DELETE_BUTTON);
AssertButtonVisibleWithID(IDS_IOS_READING_LIST_CANCEL_BUTTON);
AssertToolbarButtonNotVisibleWithID(kReadingListToolbarDeleteAllReadButtonID);
AssertToolbarButtonNotVisibleWithID(kReadingListToolbarEditButtonID);
AssertToolbarButtonVisibleWithID(kReadingListToolbarDeleteButtonID);
AssertToolbarButtonVisibleWithID(kReadingListToolbarCancelButtonID);
AssertToolbarMarkButtonText(IDS_IOS_READING_LIST_MARK_UNREAD_BUTTON);
}
// Tests that only the "Cancel", "Delete" and "Mark Read" buttons are showing
......@@ -742,14 +784,10 @@ void AssertIsShowingDistillablePage(bool online) {
AddEntriesAndEnterEdit();
TapEntry(kUnreadTitle);
AssertButtonNotVisibleWithID(IDS_IOS_READING_LIST_DELETE_ALL_READ_BUTTON);
AssertButtonNotVisibleWithID(IDS_IOS_READING_LIST_MARK_UNREAD_BUTTON);
AssertButtonNotVisibleWithID(IDS_IOS_READING_LIST_MARK_BUTTON);
AssertButtonNotVisibleWithID(IDS_IOS_READING_LIST_EDIT_BUTTON);
AssertButtonNotVisibleWithID(IDS_IOS_READING_LIST_MARK_ALL_BUTTON);
AssertButtonVisibleWithID(IDS_IOS_READING_LIST_MARK_READ_BUTTON);
AssertButtonVisibleWithID(IDS_IOS_READING_LIST_DELETE_BUTTON);
AssertButtonVisibleWithID(IDS_IOS_READING_LIST_CANCEL_BUTTON);
AssertToolbarButtonNotVisibleWithID(kReadingListToolbarDeleteAllReadButtonID);
AssertToolbarButtonVisibleWithID(kReadingListToolbarDeleteButtonID);
AssertToolbarButtonVisibleWithID(kReadingListToolbarCancelButtonID);
AssertToolbarMarkButtonText(IDS_IOS_READING_LIST_MARK_READ_BUTTON);
}
// Tests that only the "Cancel", "Delete" and "Mark…" buttons are showing when
......@@ -759,14 +797,11 @@ void AssertIsShowingDistillablePage(bool online) {
TapEntry(kReadTitle);
TapEntry(kUnreadTitle);
AssertButtonNotVisibleWithID(IDS_IOS_READING_LIST_DELETE_ALL_READ_BUTTON);
AssertButtonNotVisibleWithID(IDS_IOS_READING_LIST_MARK_UNREAD_BUTTON);
AssertButtonNotVisibleWithID(IDS_IOS_READING_LIST_MARK_READ_BUTTON);
AssertButtonNotVisibleWithID(IDS_IOS_READING_LIST_EDIT_BUTTON);
AssertButtonNotVisibleWithID(IDS_IOS_READING_LIST_MARK_ALL_BUTTON);
AssertButtonVisibleWithID(IDS_IOS_READING_LIST_MARK_BUTTON);
AssertButtonVisibleWithID(IDS_IOS_READING_LIST_DELETE_BUTTON);
AssertButtonVisibleWithID(IDS_IOS_READING_LIST_CANCEL_BUTTON);
AssertToolbarButtonNotVisibleWithID(kReadingListToolbarDeleteAllReadButtonID);
AssertToolbarButtonNotVisibleWithID(kReadingListToolbarEditButtonID);
AssertToolbarButtonVisibleWithID(kReadingListToolbarDeleteButtonID);
AssertToolbarButtonVisibleWithID(kReadingListToolbarCancelButtonID);
AssertToolbarMarkButtonText(IDS_IOS_READING_LIST_MARK_BUTTON);
}
// Tests the deletion of selected entries.
......@@ -775,7 +810,7 @@ void AssertIsShowingDistillablePage(bool online) {
TapEntry(kReadTitle2);
TapButtonWithID(IDS_IOS_READING_LIST_DELETE_BUTTON);
TapToolbarButtonWithID(kReadingListToolbarDeleteButtonID);
AssertEntryVisible(kReadTitle);
AssertEntryNotVisible(kReadTitle2);
......@@ -789,7 +824,7 @@ void AssertIsShowingDistillablePage(bool online) {
- (void)testDeleteAllReadEntries {
AddEntriesAndEnterEdit();
TapButtonWithID(IDS_IOS_READING_LIST_DELETE_ALL_READ_BUTTON);
TapToolbarButtonWithID(kReadingListToolbarDeleteAllReadButtonID);
AssertEntryNotVisible(kReadTitle);
AssertEntryNotVisible(kReadTitle2);
......@@ -804,12 +839,19 @@ void AssertIsShowingDistillablePage(bool online) {
- (void)testMarkAllRead {
AddEntriesAndEnterEdit();
TapButtonWithID(IDS_IOS_READING_LIST_MARK_ALL_BUTTON);
AssertToolbarMarkButtonText(IDS_IOS_READING_LIST_MARK_ALL_BUTTON);
TapToolbarButtonWithID(kReadingListToolbarMarkButtonID);
// Tap the action sheet.
TapButtonWithID(IDS_IOS_READING_LIST_MARK_ALL_READ_ACTION);
TapContextMenuButtonWithA11yLabelID(
IDS_IOS_READING_LIST_MARK_ALL_READ_ACTION);
if (@available(iOS 11, *)) {
// On iOS10, removing UITableView sections don't remove their header text
// from the hierarchy.
AssertHeaderNotVisible(kUnreadHeader);
}
AssertHeaderNotVisible(kUnreadHeader);
AssertAllEntriesVisible();
XCTAssertEqual(kNumberUnreadEntries + kNumberReadEntries,
ModelReadSize(GetReadingListModel()));
......@@ -820,10 +862,12 @@ void AssertIsShowingDistillablePage(bool online) {
- (void)testMarkAllUnread {
AddEntriesAndEnterEdit();
TapButtonWithID(IDS_IOS_READING_LIST_MARK_ALL_BUTTON);
AssertToolbarMarkButtonText(IDS_IOS_READING_LIST_MARK_ALL_BUTTON);
TapToolbarButtonWithID(kReadingListToolbarMarkButtonID);
// Tap the action sheet.
TapButtonWithID(IDS_IOS_READING_LIST_MARK_ALL_UNREAD_ACTION);
TapContextMenuButtonWithA11yLabelID(
IDS_IOS_READING_LIST_MARK_ALL_UNREAD_ACTION);
AssertHeaderNotVisible(kReadHeader);
AssertAllEntriesVisible();
......@@ -837,7 +881,8 @@ void AssertIsShowingDistillablePage(bool online) {
AddEntriesAndEnterEdit();
TapEntry(kUnreadTitle);
TapButtonWithID(IDS_IOS_READING_LIST_MARK_READ_BUTTON);
AssertToolbarMarkButtonText(IDS_IOS_READING_LIST_MARK_READ_BUTTON);
TapToolbarButtonWithID(kReadingListToolbarMarkButtonID);
AssertAllEntriesVisible();
XCTAssertEqual(kNumberReadEntries + 1, ModelReadSize(GetReadingListModel()));
......@@ -850,7 +895,8 @@ void AssertIsShowingDistillablePage(bool online) {
AddEntriesAndEnterEdit();
TapEntry(kReadTitle);
TapButtonWithID(IDS_IOS_READING_LIST_MARK_UNREAD_BUTTON);
AssertToolbarMarkButtonText(IDS_IOS_READING_LIST_MARK_UNREAD_BUTTON);
TapToolbarButtonWithID(kReadingListToolbarMarkButtonID);
AssertAllEntriesVisible();
XCTAssertEqual(kNumberReadEntries - 1, ModelReadSize(GetReadingListModel()));
......@@ -864,10 +910,11 @@ void AssertIsShowingDistillablePage(bool online) {
TapEntry(kReadTitle);
TapEntry(kUnreadTitle);
TapButtonWithID(IDS_IOS_READING_LIST_MARK_BUTTON);
AssertToolbarMarkButtonText(IDS_IOS_READING_LIST_MARK_BUTTON);
TapToolbarButtonWithID(kReadingListToolbarMarkButtonID);
// Tap the action sheet.
TapButtonWithID(IDS_IOS_READING_LIST_MARK_UNREAD_BUTTON);
TapContextMenuButtonWithA11yLabelID(IDS_IOS_READING_LIST_MARK_UNREAD_BUTTON);
AssertAllEntriesVisible();
XCTAssertEqual(kNumberReadEntries - 1, ModelReadSize(GetReadingListModel()));
......@@ -881,10 +928,11 @@ void AssertIsShowingDistillablePage(bool online) {
TapEntry(kReadTitle);
TapEntry(kUnreadTitle);
TapButtonWithID(IDS_IOS_READING_LIST_MARK_BUTTON);
AssertToolbarMarkButtonText(IDS_IOS_READING_LIST_MARK_BUTTON);
TapToolbarButtonWithID(kReadingListToolbarMarkButtonID);
// Tap the action sheet.
TapButtonWithID(IDS_IOS_READING_LIST_MARK_READ_BUTTON);
TapContextMenuButtonWithA11yLabelID(IDS_IOS_READING_LIST_MARK_READ_BUTTON);
AssertAllEntriesVisible();
XCTAssertEqual(kNumberReadEntries + 1, ModelReadSize(GetReadingListModel()));
......@@ -909,8 +957,8 @@ void AssertIsShowingDistillablePage(bool online) {
OpenReadingList();
[[EarlGrey selectElementWithMatcher:EmptyBackground()]
assertWithMatcher:grey_nil()];
TapButtonWithID(IDS_IOS_READING_LIST_EDIT_BUTTON);
TapButtonWithID(IDS_IOS_READING_LIST_DELETE_ALL_READ_BUTTON);
TapToolbarButtonWithID(kReadingListToolbarEditButtonID);
TapToolbarButtonWithID(kReadingListToolbarDeleteAllReadButtonID);
// Verify the background string is displayed.
[[EarlGrey selectElementWithMatcher:EmptyBackground()]
......
......@@ -649,6 +649,7 @@ ReadingListSelectionState GetSelectionStateForSelectedCounts(
[self batchEditDidFinish];
};
[self performBatchTableViewUpdates:updates completion:completion];
[self removeEmptySections];
}
// Moves the ListItem within self.tableViewModel at |modelIndex| and the
......
......@@ -11,6 +11,7 @@
#include "base/time/time.h"
#import "ios/chrome/browser/ui/reading_list/reading_list_list_item_custom_action_factory.h"
#import "ios/chrome/browser/ui/reading_list/reading_list_list_item_util.h"
#import "ios/chrome/browser/ui/table_view/cells/table_view_url_cell_favicon_badge_view.h"
#import "ios/chrome/browser/ui/table_view/cells/table_view_url_item.h"
#import "ios/chrome/browser/ui/table_view/chrome_table_view_styler.h"
#include "ios/chrome/browser/ui/ui_util.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.
#ifndef IOS_CHROME_BROWSER_UI_READING_LIST_READING_LIST_TOOLBAR_BUTTON_IDENTIFIERS_H_
#define IOS_CHROME_BROWSER_UI_READING_LIST_READING_LIST_TOOLBAR_BUTTON_IDENTIFIERS_H_
#import <Foundation/Foundation.h>
// Accessibility identifiers for reading list toolbar buttons.
extern NSString* const kReadingListToolbarEditButtonID;
extern NSString* const kReadingListToolbarDeleteButtonID;
extern NSString* const kReadingListToolbarDeleteAllReadButtonID;
extern NSString* const kReadingListToolbarCancelButtonID;
extern NSString* const kReadingListToolbarMarkButtonID;
#endif // IOS_CHROME_BROWSER_UI_READING_LIST_READING_LIST_TOOLBAR_BUTTON_IDENTIFIERS_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/reading_list/reading_list_toolbar_button_identifiers.h"
#if !defined(__has_feature) || !__has_feature(objc_arc)
#error "This file requires ARC support."
#endif
NSString* const kReadingListToolbarEditButtonID =
@"ReadingListToolbarEditButtonID";
NSString* const kReadingListToolbarDeleteButtonID =
@"ReadingListToolbarDeleteButtonID";
NSString* const kReadingListToolbarDeleteAllReadButtonID =
@"ReadingListToolbarDeleteAllReadButton";
NSString* const kReadingListToolbarCancelButtonID =
@"ReadingListToolbarCancelButton";
NSString* const kReadingListToolbarMarkButtonID =
@"ReadingListToolbarMarkButton";
;
......@@ -7,6 +7,7 @@
#include "base/logging.h"
#import "ios/chrome/browser/ui/alert_coordinator/action_sheet_coordinator.h"
#import "ios/chrome/browser/ui/reading_list/reading_list_toolbar_button_commands.h"
#import "ios/chrome/browser/ui/reading_list/reading_list_toolbar_button_identifiers.h"
#include "ios/chrome/grit/ios_strings.h"
#include "ui/base/l10n/l10n_util_mac.h"
......@@ -71,12 +72,14 @@ NSString* GetMarkButtonTitleForSelectionState(ReadingListSelectionState state) {
style:UIBarButtonItemStylePlain
target:nil
action:@selector(enterReadingListEditMode)];
_editButton.accessibilityIdentifier = kReadingListToolbarEditButtonID;
_deleteButton = [[UIBarButtonItem alloc]
initWithTitle:l10n_util::GetNSString(IDS_IOS_READING_LIST_DELETE_BUTTON)
style:UIBarButtonItemStylePlain
target:nil
action:@selector(deleteSelectedReadingListItems)];
_deleteButton.accessibilityIdentifier = kReadingListToolbarDeleteButtonID;
_deleteButton.tintColor = [UIColor redColor];
_deleteAllReadButton = [[UIBarButtonItem alloc]
......@@ -85,6 +88,8 @@ NSString* GetMarkButtonTitleForSelectionState(ReadingListSelectionState state) {
style:UIBarButtonItemStylePlain
target:nil
action:@selector(deleteAllReadReadingListItems)];
_deleteAllReadButton.accessibilityIdentifier =
kReadingListToolbarDeleteAllReadButtonID;
_deleteAllReadButton.tintColor = [UIColor redColor];
_cancelButton = [[UIBarButtonItem alloc]
......@@ -92,12 +97,14 @@ NSString* GetMarkButtonTitleForSelectionState(ReadingListSelectionState state) {
style:UIBarButtonItemStyleDone
target:nil
action:@selector(exitReadingListEditMode)];
_cancelButton.accessibilityIdentifier = kReadingListToolbarCancelButtonID;
_markButton = [[UIBarButtonItem alloc]
initWithTitle:GetMarkButtonTitleForSelectionState(self.selectionState)
style:UIBarButtonItemStylePlain
target:self
action:@selector(markButtonWasTapped)];
_markButton.accessibilityIdentifier = kReadingListToolbarMarkButtonID;
}
return self;
}
......
......@@ -26,6 +26,8 @@ source_set("cells") {
"table_view_text_item.mm",
"table_view_text_link_item.h",
"table_view_text_link_item.mm",
"table_view_url_cell_favicon_badge_view.h",
"table_view_url_cell_favicon_badge_view.mm",
"table_view_url_item.h",
"table_view_url_item.mm",
]
......
// 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_CELLS_TABLE_VIEW_URL_CELL_FAVICON_BADGE_VIEW_H_
#define IOS_CHROME_BROWSER_UI_TABLE_VIEW_CELLS_TABLE_VIEW_URL_CELL_FAVICON_BADGE_VIEW_H_
#import <UIKit/UIKit.h>
// View used to display the favicon badge image. This class automatically
// updates |hidden| to YES when its |image| is set to nil, rather than the
// default UIImageView behavior which applies a default highlight to the view
// for nil images.
@interface TableViewURLCellFaviconBadgeView : UIImageView
// The accessibility identifier of the badge view.
+ (NSString*)accessibilityIdentifier;
@end
#endif // IOS_CHROME_BROWSER_UI_TABLE_VIEW_CELLS_TABLE_VIEW_URL_CELL_FAVICON_BADGE_VIEW_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/cells/table_view_url_cell_favicon_badge_view.h"
#if !defined(__has_feature) || !__has_feature(objc_arc)
#error "This file requires ARC support."
#endif
@implementation TableViewURLCellFaviconBadgeView
- (instancetype)init {
if (self = [super init]) {
self.hidden = YES;
self.accessibilityIdentifier = [[self class] accessibilityIdentifier];
}
return self;
}
#pragma mark - Public
+ (NSString*)accessibilityIdentifier {
return @"TableViewURLCellFaviconBadgeView";
}
#pragma mark - UIImageView
- (void)setImage:(UIImage*)image {
[super setImage:image];
self.hidden = !image;
}
@end
......@@ -11,6 +11,7 @@
class GURL;
@class FaviconViewNew;
@class TableViewURLCellFaviconBadgeView;
// TableViewURLItem contains the model data for a TableViewURLCell.
@interface TableViewURLItem : TableViewItem
......@@ -45,7 +46,8 @@ class GURL;
@property(nonatomic, readonly, strong) UIImageView* faviconContainerView;
// The image view used to display the favicon badge.
@property(nonatomic, readonly, strong) UIImageView* faviconBadgeView;
@property(nonatomic, readonly, strong)
TableViewURLCellFaviconBadgeView* faviconBadgeView;
// The cell title.
@property(nonatomic, readonly, strong) UILabel* titleLabel;
......
......@@ -7,6 +7,7 @@
#include "base/mac/foundation_util.h"
#include "base/strings/sys_string_conversions.h"
#import "ios/chrome/browser/ui/table_view/cells/table_view_cells_constants.h"
#import "ios/chrome/browser/ui/table_view/cells/table_view_url_cell_favicon_badge_view.h"
#import "ios/chrome/browser/ui/table_view/chrome_table_view_styler.h"
#include "ios/chrome/browser/ui/ui_util.h"
#import "ios/chrome/browser/ui/uikit_ui_util.h"
......@@ -32,27 +33,6 @@ const char kDefaultSupplementalURLTextDelimiter[] = "•";
#pragma mark - TableViewURLCellFaviconBadgeView
// View used to display the favicon badge image. This class automatically
// updates |hidden| to YES when its |image| is set to nil, rather than the
// default UIImageView behavior which applies a default highlight to the view
// for nil images.
@interface TableViewURLCellFaviconBadgeView : UIImageView
@end
@implementation TableViewURLCellFaviconBadgeView
- (instancetype)init {
if (self = [super init])
self.hidden = YES;
return self;
}
- (void)setImage:(UIImage*)image {
[super setImage:image];
self.hidden = !image;
}
@end
#pragma mark - TableViewURLItem
......
......@@ -47,6 +47,7 @@ NSAttributedString* GetAttributedMessage(NSString* message) {
if (self = [super initWithFrame:frame]) {
_message = GetAttributedMessage(message);
_image = image;
self.accessibilityIdentifier = [[self class] accessibilityIdentifier];
}
return self;
}
......@@ -57,6 +58,7 @@ NSAttributedString* GetAttributedMessage(NSString* message) {
if (self = [super initWithFrame:frame]) {
_message = message;
_image = image;
self.accessibilityIdentifier = [[self class] accessibilityIdentifier];
}
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