Commit 9ea7417b authored by Gauthier Ambard's avatar Gauthier Ambard Committed by Commit Bot

[iOS] Don't reconfigure cells if they are nil

When reconfiguring a "nil" cell, there is a DCHECK in the item.
This CL makes sure that we don't reconfigure if we the cell is nil.

Bug: 1013708
Change-Id: I1082a59a74fc50b0b0243a4ff9255606a3218c6b
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1862675
Auto-Submit: Gauthier Ambard <gambard@chromium.org>
Commit-Queue: Olivier Robin <olivierrobin@chromium.org>
Reviewed-by: default avatarOlivier Robin <olivierrobin@chromium.org>
Cr-Commit-Position: refs/heads/master@{#705912}
parent 788aa532
...@@ -12,6 +12,7 @@ ...@@ -12,6 +12,7 @@
#include "base/bind.h" #include "base/bind.h"
#include "base/ios/ios_util.h" #include "base/ios/ios_util.h"
#include "base/mac/foundation_util.h" #include "base/mac/foundation_util.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/sys_string_conversions.h" #include "base/strings/sys_string_conversions.h"
#include "base/strings/utf_string_conversions.h" #include "base/strings/utf_string_conversions.h"
#import "base/test/ios/wait_util.h" #import "base/test/ios/wait_util.h"
...@@ -274,6 +275,28 @@ void OpenReadingList() { ...@@ -274,6 +275,28 @@ void OpenReadingList() {
[chrome_test_util::BrowserCommandDispatcherForMainBVC() showReadingList]; [chrome_test_util::BrowserCommandDispatcherForMainBVC() showReadingList];
} }
// Adds 20 read and 20 unread entries to the model, opens the reading list menu
// and enter edit mode.
void AddLotOfEntriesAndEnterEdit() {
ReadingListModel* model = GetReadingListModel();
for (NSInteger index = 0; index < 10; index++) {
GURL url_to_be_added =
GURL(kReadURL + std::string("/") + base::NumberToString(index));
model->AddEntry(url_to_be_added, std::string(kReadTitle),
reading_list::ADDED_VIA_CURRENT_APP);
model->SetReadStatus(url_to_be_added, true);
}
for (NSInteger index = 0; index < 10; index++) {
GURL url_to_be_added =
GURL(kUnreadURL + std::string("/") + base::NumberToString(index));
model->AddEntry(url_to_be_added, std::string(kReadTitle),
reading_list::ADDED_VIA_CURRENT_APP);
}
OpenReadingList();
TapToolbarButtonWithID(kReadingListToolbarEditButtonID);
}
// Adds a read and an unread entry to the model, opens the reading list menu and // Adds a read and an unread entry to the model, opens the reading list menu and
// enter edit mode. // enter edit mode.
void AddEntriesAndEnterEdit() { void AddEntriesAndEnterEdit() {
...@@ -872,6 +895,21 @@ void AssertIsShowingDistillablePage(bool online, const GURL& distillable_url) { ...@@ -872,6 +895,21 @@ void AssertIsShowingDistillablePage(bool online, const GURL& distillable_url) {
XCTAssertEqual((size_t)0, ModelReadSize(GetReadingListModel())); XCTAssertEqual((size_t)0, ModelReadSize(GetReadingListModel()));
} }
// Marks all read entries as unread, when there is a lot of entries. This is to
// prevent crbug.com/1013708 from regressing.
- (void)testMarkAllUnreadLotOfEntry {
AddLotOfEntriesAndEnterEdit();
AssertToolbarMarkButtonText(IDS_IOS_READING_LIST_MARK_ALL_BUTTON);
TapToolbarButtonWithID(kReadingListToolbarMarkButtonID);
// Tap the action sheet.
TapContextMenuButtonWithA11yLabelID(
IDS_IOS_READING_LIST_MARK_ALL_UNREAD_ACTION);
AssertHeaderNotVisible(kReadHeader);
}
// Selects an unread entry and mark it as read. // Selects an unread entry and mark it as read.
- (void)testMarkEntriesRead { - (void)testMarkEntriesRead {
AddEntriesAndEnterEdit(); AddEntriesAndEnterEdit();
......
...@@ -667,6 +667,9 @@ ReadingListSelectionState GetSelectionStateForSelectedCounts( ...@@ -667,6 +667,9 @@ ReadingListSelectionState GetSelectionStateForSelectedCounts(
toSection:(SectionIdentifier)toSection { toSection:(SectionIdentifier)toSection {
// Reconfigure cells, allowing the custom actions to be updated. // Reconfigure cells, allowing the custom actions to be updated.
for (NSIndexPath* indexPath in sortedIndexPaths) { for (NSIndexPath* indexPath in sortedIndexPaths) {
if (![self.tableView cellForRowAtIndexPath:indexPath])
continue;
[[self.tableViewModel itemAtIndexPath:indexPath] [[self.tableViewModel itemAtIndexPath:indexPath]
configureCell:[self.tableView cellForRowAtIndexPath:indexPath] configureCell:[self.tableView cellForRowAtIndexPath:indexPath]
withStyler:self.styler]; withStyler:self.styler];
......
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