Commit 2def78be authored by sczs@chromium.org's avatar sczs@chromium.org Committed by Commit Bot

[ios] Fixes Bookmarks crash when deleting a cell being edited.

When a new Folder is created, the folder cell is created on edit mode. If we try to delete the cell
at this point (by swiping the cell to the left) a crash occurs (both on legacy and UIRefresh).

This Cl prevent this crash by returning NO on canEditRowAtIndexPath for the editingFolderCell.

Cq-Include-Trybots: luci.chromium.try:ios-simulator-full-configs;master.tryserver.chromium.mac:ios-simulator-cronet
Change-Id: Iaca9d4d7001d89d795d2ce2c82db46a092086ec9
Reviewed-on: https://chromium-review.googlesource.com/1098230
Commit-Queue: Sergio Collazos <sczs@chromium.org>
Reviewed-by: default avatarRohit Rao <rohitrao@chromium.org>
Cr-Commit-Position: refs/heads/master@{#566705}
parent 0f26a581
......@@ -1744,6 +1744,13 @@ const CGFloat kShadowRadius = 12.0f;
return NO;
}
// If the cell at |indexPath| is being edited (which happens when creating a
// new Folder) return NO.
if (self.sharedState.editingFolderCell ==
[self.tableView cellForRowAtIndexPath:indexPath]) {
return NO;
}
// Enable the swipe-to-delete gesture and reordering control for nodes of
// type URL or Folder, but not the permanent ones.
BookmarkHomeNodeItem* nodeItem =
......
......@@ -2977,6 +2977,27 @@ id<GREYMatcher> TappableBookmarkNodeWithLabel(NSString* label) {
[BookmarksTestCase verifyBookmarkFolderIsSeen:@"Folder 2"];
}
- (void)testCantDeleteCellBeingEdited {
[BookmarksTestCase setupStandardBookmarks];
[BookmarksTestCase openBookmarks];
[BookmarksTestCase openMobileBookmarks];
// Create a new folder and type "New Folder 1" without pressing return.
NSString* newFolderTitle = @"New Folder";
[BookmarksTestCase createNewBookmarkFolderWithFolderTitle:newFolderTitle
pressReturn:NO];
// Swipe action to try to delete the newly created folder while its name its
// being edited.
[[EarlGrey
selectElementWithMatcher:TappableBookmarkNodeWithLabel(@"New Folder")]
performAction:grey_swipeFastInDirection(kGREYDirectionLeft)];
// Verify the delete confirmation button doesn't show up.
[[EarlGrey selectElementWithMatcher:BookmarksDeleteSwipeButton()]
assertWithMatcher:grey_nil()];
}
// Tests that all elements on the bookmarks landing page are accessible.
- (void)testAccessibilityOnBookmarksLandingPage {
[BookmarksTestCase setupStandardBookmarks];
......
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