Commit a401f865 authored by Marti Wong's avatar Marti Wong Committed by Commit Bot

Bookmarks starts at root when cached path is permanent node & empty(iOS)

This CL makes Bookmarks ignore the cached path (and starts at root node)
when cached path of Bookmarks is a permanent node (Mobile Bookmarks,
Bookmarks Bar or Other Bookmarks) and is empty.  Egtest is modified
accordingly.

Bug: 571878
Change-Id: I68773b63e3f12a1ce1e1cf0842c2888dae92d568
Reviewed-on: https://chromium-review.googlesource.com/810185
Commit-Queue: Marti Wong <martiw@chromium.org>
Reviewed-by: default avatarLouis Romero <lpromero@chromium.org>
Cr-Commit-Position: refs/heads/master@{#522415}
parent d0976380
......@@ -1067,19 +1067,20 @@ std::vector<GURL> GetUrlsToOpen(const std::vector<const BookmarkNode*>& nodes) {
const BookmarkNode* node = bookmark_utils_ios::FindFolderById(
self.bookmarks, [[mutablePath firstObject] longLongValue]);
DCHECK(node);
if (node) {
BookmarkHomeViewController* controller =
[self createControllerWithRootFolder:node];
// We only scroll to the last viewing position for the leaf
// node.
if (mutablePath.count == 1 && pathCache.position) {
[controller
setCachedContentPosition:[NSNumber
numberWithFloat:pathCache.position]];
}
controller.isReconstructingFromCache = YES;
[self.navigationController pushViewController:controller animated:NO];
// if node is an empty permanent node, return.
if (node->empty() && IsPrimaryPermanentNode(node, self.bookmarks)) {
return;
}
BookmarkHomeViewController* controller =
[self createControllerWithRootFolder:node];
// Only scroll to the last viewing position for the leaf node.
if (mutablePath.count == 1 && pathCache.position) {
[controller
setCachedContentPosition:[NSNumber numberWithFloat:pathCache.position]];
}
controller.isReconstructingFromCache = YES;
[self.navigationController pushViewController:controller animated:NO];
}
// Set up context bar for the new UI.
......
......@@ -2355,7 +2355,8 @@ id<GREYMatcher> TappableBookmarkNodeWithLabel(NSString* label) {
assertWithMatcher:grey_sufficientlyVisible()];
}
- (void)testCachePositionIsRecreatedWhenNodeIsDeleted {
// Verify root node is opened when cache position is deleted.
- (void)testCachePositionIsResetWhenNodeIsDeleted {
base::test::ScopedFeatureList scoped_feature_list;
scoped_feature_list.InitAndEnableFeature(kBookmarkNewGeneration);
......@@ -2371,7 +2372,7 @@ id<GREYMatcher> TappableBookmarkNodeWithLabel(NSString* label) {
[[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"Folder 2")]
performAction:grey_tap()];
// Close bookmarks
// Close bookmarks, it will store Folder 2 as the cache position.
[[EarlGrey selectElementWithMatcher:BookmarksDoneButton()]
performAction:grey_tap()];
......@@ -2381,7 +2382,37 @@ id<GREYMatcher> TappableBookmarkNodeWithLabel(NSString* label) {
// Reopen bookmarks.
[BookmarksNewGenTestCase openBookmarks];
// Ensure the root node is opened, by verifying folders at this level.
// Ensure the root node is opened, by verifying Mobile Bookmarks is seen in a
// table cell.
[BookmarksNewGenTestCase verifyBookmarkFolderIsSeen:@"Mobile Bookmarks"];
}
// Verify root node is opened when cache position is a permanent node and is
// empty.
- (void)testCachePositionIsResetWhenNodeIsPermanentAndEmpty {
base::test::ScopedFeatureList scoped_feature_list;
scoped_feature_list.InitAndEnableFeature(kBookmarkNewGeneration);
[BookmarksNewGenTestCase setupStandardBookmarks];
[BookmarksNewGenTestCase openBookmarks];
[BookmarksNewGenTestCase openMobileBookmarks];
// Close bookmarks, it will store Mobile Bookmarks as the cache position.
[[EarlGrey selectElementWithMatcher:BookmarksDoneButton()]
performAction:grey_tap()];
// Delete all bookmarks and folders under Mobile Bookmarks.
[BookmarksNewGenTestCase removeBookmarkWithTitle:@"Folder 1.1"];
[BookmarksNewGenTestCase removeBookmarkWithTitle:@"Folder 1"];
[BookmarksNewGenTestCase removeBookmarkWithTitle:@"French URL"];
[BookmarksNewGenTestCase removeBookmarkWithTitle:@"Second URL"];
[BookmarksNewGenTestCase removeBookmarkWithTitle:@"First URL"];
// Reopen bookmarks.
[BookmarksNewGenTestCase openBookmarks];
// Ensure the root node is opened, by verifying Mobile Bookmarks is seen in a
// table cell.
[BookmarksNewGenTestCase verifyBookmarkFolderIsSeen:@"Mobile Bookmarks"];
}
......
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