Commit 4bc5e237 authored by Rohit Rao's avatar Rohit Rao Committed by Commit Bot

[ios] Updates [ChromeEarlGrey clearBrowsingHistory] to assert on error.

Rather than having each caller assert that the clear browsing history operation
succeeded, we can have the helper itself assert on failure.

BUG=963613

Change-Id: I5f754eec1a53185d39bbadc7b238a97c056f2e07
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1614744
Commit-Queue: Eugene But <eugenebut@chromium.org>
Reviewed-by: default avatarEugene But <eugenebut@chromium.org>
Cr-Commit-Position: refs/heads/master@{#660471}
parent cc97161a
......@@ -35,7 +35,7 @@ using web::test::HttpServer;
@implementation NTPTilesTest
- (void)tearDown {
CHROME_EG_ASSERT_NO_ERROR([ChromeEarlGrey clearBrowsingHistory]);
[ChromeEarlGrey clearBrowsingHistory];
[super tearDown];
}
......@@ -49,7 +49,7 @@ using web::test::HttpServer;
web::test::SetUpSimpleHttpServer(responses);
// Clear history and verify that the tile does not exist.
CHROME_EG_ASSERT_NO_ERROR([ChromeEarlGrey clearBrowsingHistory]);
[ChromeEarlGrey clearBrowsingHistory];
CHROME_EG_ASSERT_NO_ERROR([ChromeEarlGrey openNewTab]);
[[EarlGrey selectElementWithMatcher:
......@@ -93,7 +93,7 @@ using web::test::HttpServer;
web::test::SetUpHttpServer(std::move(provider));
// Clear history and verify that the tile does not exist.
CHROME_EG_ASSERT_NO_ERROR([ChromeEarlGrey clearBrowsingHistory]);
[ChromeEarlGrey clearBrowsingHistory];
CHROME_EG_ASSERT_NO_ERROR([ChromeEarlGrey openNewTab]);
[[EarlGrey selectElementWithMatcher:
chrome_test_util::StaticTextWithAccessibilityLabel(@"title2")]
......
......@@ -61,7 +61,7 @@ std::unique_ptr<net::test_server::HttpResponse> StandardResponse(
@"Disabled for iPad due to alternate letters educational screen.");
}
CHROME_EG_ASSERT_NO_ERROR([ChromeEarlGrey clearBrowsingHistory]);
[ChromeEarlGrey clearBrowsingHistory];
// Set server up.
self.testServer->RegisterRequestHandler(
base::BindRepeating(&StandardResponse));
......
......@@ -184,7 +184,7 @@ GREYElementInteraction* CellWithMatcher(id<GREYMatcher> matcher) {
- (void)tearDown {
self.provider->FireCategoryStatusChanged(
self.category, CategoryStatus::ALL_SUGGESTIONS_EXPLICITLY_DISABLED);
CHROME_EG_ASSERT_NO_ERROR([ChromeEarlGrey clearBrowsingHistory]);
[ChromeEarlGrey clearBrowsingHistory];
[super tearDown];
}
......@@ -490,7 +490,7 @@ GREYElementInteraction* CellWithMatcher(id<GREYMatcher> matcher) {
NSString* pageTitle = base::SysUTF8ToNSString(kPageTitle);
// Clear history and verify that the tile does not exist.
CHROME_EG_ASSERT_NO_ERROR([ChromeEarlGrey clearBrowsingHistory]);
[ChromeEarlGrey clearBrowsingHistory];
CHROME_EG_ASSERT_NO_ERROR([ChromeEarlGrey loadURL:pageURL]);
CHROME_EG_ASSERT_NO_ERROR(
[ChromeEarlGrey waitForWebViewContainingText:kPageLoadedString]);
......
......@@ -722,7 +722,7 @@ std::unique_ptr<net::test_server::HttpResponse> StandardResponse(
const GURL pageURL = self.testServer->GetURL(kPageURL);
// Clear history to ensure the tile will be shown.
CHROME_EG_ASSERT_NO_ERROR([ChromeEarlGrey clearBrowsingHistory]);
[ChromeEarlGrey clearBrowsingHistory];
CHROME_EG_ASSERT_NO_ERROR([ChromeEarlGrey loadURL:pageURL]);
CHROME_EG_ASSERT_NO_ERROR(
[ChromeEarlGrey waitForWebViewContainingText:kPageLoadedString]);
......
......@@ -149,7 +149,7 @@ id<GREYMatcher> OpenInNewIncognitoTabButton() {
_URL1 = web::test::HttpServer::MakeUrl(kURL1);
_URL2 = web::test::HttpServer::MakeUrl(kURL2);
_URL3 = web::test::HttpServer::MakeUrl(kURL3);
CHROME_EG_ASSERT_NO_ERROR([ChromeEarlGrey clearBrowsingHistory]);
[ChromeEarlGrey clearBrowsingHistory];
// Some tests rely on a clean state for the "Clear Browsing Data" settings
// screen.
[self resetBrowsingDataPrefs];
......
......@@ -104,7 +104,7 @@ std::unique_ptr<net::test_server::HttpResponse> StandardResponse(
base::BindRepeating(&StandardResponse));
GREYAssertTrue(self.testServer->Start(), @"Test server failed to start.");
CHROME_EG_ASSERT_NO_ERROR([ChromeEarlGrey clearBrowsingHistory]);
[ChromeEarlGrey clearBrowsingHistory];
}
// Tests that tapping the switch to open tab button, switch to the open tab,
......
......@@ -83,7 +83,7 @@ std::unique_ptr<net::test_server::HttpResponse> StandardResponse(
base::BindRepeating(&StandardResponse));
GREYAssertTrue(self.testServer->Start(), @"Test server failed to start.");
CHROME_EG_ASSERT_NO_ERROR([ChromeEarlGrey clearBrowsingHistory]);
[ChromeEarlGrey clearBrowsingHistory];
[self prepareMostVisitedTiles];
// Clear pasteboard
[[UIPasteboard generalPasteboard] setItems:@[]];
......
......@@ -84,7 +84,7 @@ id<GREYMatcher> TitleOfTestPage() {
@implementation RecentTabsTestCase
- (void)setUp {
CHROME_EG_ASSERT_NO_ERROR([ChromeEarlGrey clearBrowsingHistory]);
[ChromeEarlGrey clearBrowsingHistory];
[super setUp];
web::test::SetUpSimpleHttpServer(std::map<GURL, std::string>{{
web::test::HttpServer::MakeUrl(kURLOfTestPage),
......
......@@ -386,9 +386,9 @@ void AssertNumberOfEntitiesWithName(int entity_count,
- (void)testSyncTypedURLUpload {
const GURL mockURL("http://not-a-real-site/");
CHROME_EG_ASSERT_NO_ERROR([ChromeEarlGrey clearBrowsingHistory]);
[ChromeEarlGrey clearBrowsingHistory];
[self setTearDownHandler:^{
CHROME_EG_ASSERT_NO_ERROR([ChromeEarlGrey clearBrowsingHistory]);
[ChromeEarlGrey clearBrowsingHistory];
}];
chrome_test_util::AddTypedURLOnClient(mockURL);
......@@ -422,9 +422,9 @@ void AssertNumberOfEntitiesWithName(int entity_count,
- (void)testSyncTypedUrlDownload {
const GURL mockURL("http://not-a-real-site/");
CHROME_EG_ASSERT_NO_ERROR([ChromeEarlGrey clearBrowsingHistory]);
[ChromeEarlGrey clearBrowsingHistory];
[self setTearDownHandler:^{
CHROME_EG_ASSERT_NO_ERROR([ChromeEarlGrey clearBrowsingHistory]);
[ChromeEarlGrey clearBrowsingHistory];
}];
// Inject typed url on server.
......@@ -457,9 +457,9 @@ void AssertNumberOfEntitiesWithName(int entity_count,
- (void)testSyncTypedURLDeleteFromClient {
const GURL mockURL("http://not-a-real-site/");
CHROME_EG_ASSERT_NO_ERROR([ChromeEarlGrey clearBrowsingHistory]);
[ChromeEarlGrey clearBrowsingHistory];
[self setTearDownHandler:^{
CHROME_EG_ASSERT_NO_ERROR([ChromeEarlGrey clearBrowsingHistory]);
[ChromeEarlGrey clearBrowsingHistory];
}];
// Inject typed url on server.
......@@ -502,9 +502,9 @@ void AssertNumberOfEntitiesWithName(int entity_count,
- (void)testSyncTypedURLDeleteFromServer {
const GURL mockURL("http://not-a-real-site/");
CHROME_EG_ASSERT_NO_ERROR([ChromeEarlGrey clearBrowsingHistory]);
[ChromeEarlGrey clearBrowsingHistory];
[self setTearDownHandler:^{
CHROME_EG_ASSERT_NO_ERROR([ChromeEarlGrey clearBrowsingHistory]);
[ChromeEarlGrey clearBrowsingHistory];
}];
chrome_test_util::AddTypedURLOnClient(mockURL);
......
......@@ -209,7 +209,7 @@ class CacheTestResponseProvider : public web::DataResponseProvider {
web::test::SetUpHttpServer(std::make_unique<CacheTestResponseProvider>());
// Clear the history to ensure expected omnibox autocomplete results.
CHROME_EG_ASSERT_NO_ERROR([ChromeEarlGrey clearBrowsingHistory]);
[ChromeEarlGrey clearBrowsingHistory];
const GURL cacheTestFirstPageURL =
HttpServer::MakeUrl(kCacheTestFirstPageURL);
......
......@@ -38,8 +38,9 @@ id ExecuteJavaScript(NSString* javascript, NSError* __autoreleasing* out_error);
@interface ChromeEarlGreyImpl : BaseEGTestHelperImpl
#pragma mark - History Utilities
// Clears browsing history.
- (NSError*)clearBrowsingHistory WARN_UNUSED_RESULT;
// Clears browsing history. Raises an EarlGrey exception if history is not
// cleared within a timeout.
- (void)clearBrowsingHistory;
@end
......
......@@ -53,13 +53,13 @@ GREY_STUB_CLASS_IN_APP_MAIN_QUEUE(ChromeEarlGreyAppInterface)
#pragma mark - History Utilities
- (NSError*)clearBrowsingHistory {
NSError* error = [ChromeEarlGreyAppInterface clearBrowsingHistory];
- (void)clearBrowsingHistory {
EG_TEST_HELPER_ASSERT_NO_ERROR(
[ChromeEarlGreyAppInterface clearBrowsingHistory]);
// After clearing browsing history via code, wait for the UI to be done
// with any updates. This includes icons from the new tab page being removed.
[[GREYUIThreadExecutor sharedInstance] drainUntilIdle];
return error;
}
@end
......
......@@ -82,7 +82,7 @@
// Tests that helpers from chrome_earl_grey.h are available for use in tests.
- (void)testClearBrowsingHistory {
CHROME_EG_ASSERT_NO_ERROR([ChromeEarlGrey clearBrowsingHistory]);
[ChromeEarlGrey clearBrowsingHistory];
}
@end
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