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