Commit 5367e5e7 authored by Justin Cohen's avatar Justin Cohen Committed by Commit Bot

[ios] Stop the NTP on web usage toggle.

This happens when clearing browser data, and forces the NTP
to be recreated (and not show previous NTP tiles).

Bug: 905735
Change-Id: If818e02703c7324f0a660bf6b115603db3682b74
Reviewed-on: https://chromium-review.googlesource.com/c/1339340Reviewed-by: default avatarKurt Horimoto <kkhorimoto@chromium.org>
Reviewed-by: default avatarRohit Rao <rohitrao@chromium.org>
Commit-Queue: Justin Cohen <justincohen@chromium.org>
Cr-Commit-Position: refs/heads/master@{#608947}
parent 9f069147
......@@ -8,6 +8,7 @@
#import "ios/chrome/test/app/history_test_util.h"
#import "ios/chrome/test/app/tab_test_util.h"
#import "ios/chrome/test/earl_grey/chrome_earl_grey.h"
#import "ios/chrome/test/earl_grey/chrome_earl_grey_ui.h"
#import "ios/chrome/test/earl_grey/chrome_matchers.h"
#import "ios/chrome/test/earl_grey/chrome_test_case.h"
#import "ios/web/public/test/http_server/html_response_provider.h"
......@@ -19,6 +20,11 @@
#error "This file requires ARC support."
#endif
using chrome_test_util::ClearBrowsingDataCell;
using chrome_test_util::ClearBrowsingDataButton;
using chrome_test_util::ConfirmClearBrowsingDataButton;
using chrome_test_util::SettingsDoneButton;
using chrome_test_util::SettingsMenuPrivacyButton;
using web::test::HttpServer;
// Test case for NTP tiles.
......@@ -116,6 +122,20 @@ using web::test::HttpServer;
[[EarlGrey selectElementWithMatcher:
chrome_test_util::StaticTextWithAccessibilityLabel(@"title1")]
assertWithMatcher:grey_nil()];
// Clear history and verify that the tile does not exist.
[ChromeEarlGreyUI openSettingsMenu];
[ChromeEarlGreyUI tapSettingsMenuButton:SettingsMenuPrivacyButton()];
[ChromeEarlGreyUI tapPrivacyMenuButton:ClearBrowsingDataCell()];
[ChromeEarlGreyUI tapClearBrowsingDataMenuButton:ClearBrowsingDataButton()];
[[EarlGrey selectElementWithMatcher:ConfirmClearBrowsingDataButton()]
performAction:grey_tap()];
[[EarlGrey selectElementWithMatcher:SettingsDoneButton()]
performAction:grey_tap()];
[[EarlGrey selectElementWithMatcher:
chrome_test_util::StaticTextWithAccessibilityLabel(@"title2")]
assertWithMatcher:grey_nil()];
}
@end
......@@ -1050,6 +1050,15 @@ applicationCommandEndpoint:(id<ApplicationCommands>)applicationCommandEndpoint
[self updateDialogPresenterActiveState];
[self updateBroadcastState];
// Stop the NTP on web usage toggle. This happens when clearing browser
// data, and forces the NTP to be recreated in -displayTab below.
// TODO(crbug.com/906199): Move this to the NewTabPageTabHelper when
// WebStateObserver has a webUsage callback.
if (!active) {
for (const auto& element : _ntpCoordinatorsForWebStates)
[element.second stop];
}
if (active) {
// Make sure the tab (if any; it's possible to get here without a current
// tab if the caller is about to create one) ends up on screen completely.
......
......@@ -134,6 +134,13 @@ id<GREYMatcher> AddAccountButton();
// Returns matcher for the sign out accounts button.
id<GREYMatcher> SignOutAccountsButton();
// Returns matcher for the Clear Browsing Data cell on the Privacy screen.
id<GREYMatcher> ClearBrowsingDataCell();
// Returns matcher for the clear browsing data button on the clear browsing data
// panel.
id<GREYMatcher> ClearBrowsingDataButton();
// Returns matcher for the clear browsing data collection view.
id<GREYMatcher> ClearBrowsingDataCollectionView();
......
......@@ -343,6 +343,14 @@ id<GREYMatcher> SignOutAccountsButton() {
return grey_accessibilityID(kSettingsAccountsSignoutCellId);
}
id<GREYMatcher> ClearBrowsingDataCell() {
return ButtonWithAccessibilityLabelId(IDS_IOS_CLEAR_BROWSING_DATA_TITLE);
}
id<GREYMatcher> ClearBrowsingDataButton() {
return ButtonWithAccessibilityLabelId(IDS_IOS_CLEAR_BUTTON);
}
id<GREYMatcher> ClearBrowsingDataCollectionView() {
return grey_accessibilityID(
kClearBrowsingDataCollectionViewAccessibilityIdentifier);
......
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