Commit 1a168223 authored by David Jean's avatar David Jean Committed by Commit Bot

[ios] Fix bookmarks Edit button / Animation bugs

- Fixed Edit button to be disabled when seaching and no results.
- Fixed problem with background during search.
- Fixed clunky animation by closing search controller first.

Bug: 893559,893687,894031
Cq-Include-Trybots: luci.chromium.try:ios-simulator-cronet;luci.chromium.try:ios-simulator-full-configs
Change-Id: I6846006abf82d2e6ef1b6a9d783f6824d27df076
Reviewed-on: https://chromium-review.googlesource.com/c/1276646Reviewed-by: default avatarGauthier Ambard <gambard@chromium.org>
Reviewed-by: default avatarSergio Collazos <sczs@chromium.org>
Commit-Queue: David Jean <djean@chromium.org>
Cr-Commit-Position: refs/heads/master@{#599634}
parent 6eb8d7a9
......@@ -219,6 +219,8 @@ const int kMaxBookmarksSearchResults = 50;
toSectionWithIdentifier:BookmarkHomeSectionIdentifierMessages];
return;
}
[self updateTableViewBackground];
}
- (void)updateTableViewBackground {
......@@ -238,7 +240,8 @@ const int kMaxBookmarksSearchResults = 50;
return;
}
if (![self hasBookmarksOrFolders]) {
if (![self hasBookmarksOrFolders] &&
!self.sharedState.currentlyShowingSearchResults) {
[self.consumer
updateTableViewBackgroundStyle:BookmarkHomeBackgroundStyleEmpty];
} else {
......
......@@ -748,7 +748,13 @@ std::vector<GURL> GetUrlsToOpen(const std::vector<const BookmarkNode*>& nodes) {
}
[self navigateAway];
[self.navigationController setViewControllers:stack animated:YES];
auto completion = ^{
[self.navigationController setViewControllers:stack animated:YES];
};
[self.searchController dismissViewControllerAnimated:YES
completion:completion];
return;
}
BookmarkHomeViewController* controller =
......@@ -1231,8 +1237,24 @@ std::vector<GURL> GetUrlsToOpen(const std::vector<const BookmarkNode*>& nodes) {
}
- (BOOL)hasBookmarksOrFolders {
return self.sharedState.tableViewDisplayedRootNode &&
!self.sharedState.tableViewDisplayedRootNode->empty();
if (!self.sharedState.tableViewDisplayedRootNode)
return NO;
if (self.sharedState.currentlyShowingSearchResults) {
return [self
hasItemsInSectionIdentifier:BookmarkHomeSectionIdentifierBookmarks];
} else {
return !self.sharedState.tableViewDisplayedRootNode->empty();
}
}
- (BOOL)hasItemsInSectionIdentifier:(NSInteger)sectionIdentifier {
BOOL hasSection = [self.sharedState.tableViewModel
hasSectionForSectionIdentifier:sectionIdentifier];
if (!hasSection)
return NO;
NSInteger section = [self.sharedState.tableViewModel
sectionForSectionIdentifier:sectionIdentifier];
return [self.sharedState.tableViewModel numberOfItemsInSection:section] > 0;
}
- (std::vector<const bookmarks::BookmarkNode*>)getEditNodesInVector {
......@@ -1762,6 +1784,7 @@ std::vector<GURL> GetUrlsToOpen(const std::vector<const BookmarkNode*>& nodes) {
[self.mediator computeBookmarkTableViewDataMatching:text
orShowMessageWhenNoResults:noResults];
[self.sharedState.tableView reloadData];
[self setupContextBar];
}
}
......
......@@ -4152,12 +4152,19 @@ id<GREYMatcher> SearchIconButton() {
// Search 'zz'.
[[EarlGrey selectElementWithMatcher:SearchIconButton()]
performAction:grey_typeText(@"zz")];
performAction:grey_typeText(@"zz\n")];
// Verify that we have a 'No Results' label somewhere.
[[EarlGrey selectElementWithMatcher:grey_text(l10n_util::GetNSString(
IDS_HISTORY_NO_SEARCH_RESULTS))]
assertWithMatcher:grey_notNil()];
// Verify that Edit button is disabled.
[[EarlGrey
selectElementWithMatcher:ContextBarTrailingButtonWithLabel(
[BookmarksTestCase contextBarSelectString])]
assertWithMatcher:grey_accessibilityTrait(
UIAccessibilityTraitNotEnabled)];
}
// Tests that scrim is shown while search box is enabled with no queries.
......
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