Moved usage of bookmarks_test_util#ClearBookmarks to ChromeEarlGrey only.
Replace GREYAsserts in EG2 tests to CHROME_EG_ASSERT_NO_ERROR tests and use [ChromeEarlGrey clearBookmarks] instead of chrome_test_util::ClearBookmarks(). This is part of EG1 to EG2 migration, which involves moving EarlGrey code from app-side helpers into test code. For GREYAsserts, the policy is to take assert- containing-helpers, modify them to return NSError* with localizedDescription containing the assert failure (in the event of a failure), and then assert on the result of the helper on the test side. Bug: 922813 Change-Id: If5cecef09463564027f4a236533ae76f8da788dc Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1588748 Commit-Queue: Maksym Onufriienko <monufriienko@chromium.org> Reviewed-by: Eugene But <eugenebut@chromium.org> Cr-Commit-Position: refs/heads/master@{#655063}
This commit is contained in:

committed by
Commit Bot

parent
2653e143ff
commit
7eb6bbd707
ios/chrome
browser
ui
bookmarks
keyboard
settings
sync
toolbar
test
@ -173,15 +173,13 @@ id<GREYMatcher> SearchIconButton() {
|
||||
[super setUp];
|
||||
|
||||
CHROME_EG_ASSERT_NO_ERROR([ChromeEarlGrey waitForBookmarksToFinishLoading]);
|
||||
GREYAssert(chrome_test_util::ClearBookmarks(),
|
||||
@"Not all bookmarks were removed.");
|
||||
CHROME_EG_ASSERT_NO_ERROR([ChromeEarlGrey clearBookmarks]);
|
||||
}
|
||||
|
||||
// Tear down called once per test.
|
||||
- (void)tearDown {
|
||||
[super tearDown];
|
||||
GREYAssert(chrome_test_util::ClearBookmarks(),
|
||||
@"Not all bookmarks were removed.");
|
||||
CHROME_EG_ASSERT_NO_ERROR([ChromeEarlGrey clearBookmarks]);
|
||||
// Clear position cache so that Bookmarks starts at the root folder in next
|
||||
// test.
|
||||
ios::ChromeBrowserState* browser_state =
|
||||
@ -1723,15 +1721,13 @@ id<GREYMatcher> SearchIconButton() {
|
||||
[super setUp];
|
||||
|
||||
CHROME_EG_ASSERT_NO_ERROR([ChromeEarlGrey waitForBookmarksToFinishLoading]);
|
||||
GREYAssert(chrome_test_util::ClearBookmarks(),
|
||||
@"Not all bookmarks were removed.");
|
||||
CHROME_EG_ASSERT_NO_ERROR([ChromeEarlGrey clearBookmarks]);
|
||||
}
|
||||
|
||||
// Tear down called once per test.
|
||||
- (void)tearDown {
|
||||
[super tearDown];
|
||||
GREYAssert(chrome_test_util::ClearBookmarks(),
|
||||
@"Not all bookmarks were removed.");
|
||||
CHROME_EG_ASSERT_NO_ERROR([ChromeEarlGrey clearBookmarks]);
|
||||
// Clear position cache so that Bookmarks starts at the root folder in next
|
||||
// test.
|
||||
ios::ChromeBrowserState* browser_state =
|
||||
@ -2716,15 +2712,13 @@ id<GREYMatcher> SearchIconButton() {
|
||||
[super setUp];
|
||||
|
||||
CHROME_EG_ASSERT_NO_ERROR([ChromeEarlGrey waitForBookmarksToFinishLoading]);
|
||||
GREYAssert(chrome_test_util::ClearBookmarks(),
|
||||
@"Not all bookmarks were removed.");
|
||||
CHROME_EG_ASSERT_NO_ERROR([ChromeEarlGrey clearBookmarks]);
|
||||
}
|
||||
|
||||
// Tear down called once per test.
|
||||
- (void)tearDown {
|
||||
[super tearDown];
|
||||
GREYAssert(chrome_test_util::ClearBookmarks(),
|
||||
@"Not all bookmarks were removed.");
|
||||
CHROME_EG_ASSERT_NO_ERROR([ChromeEarlGrey clearBookmarks]);
|
||||
// Clear position cache so that Bookmarks starts at the root folder in next
|
||||
// test.
|
||||
ios::ChromeBrowserState* browser_state =
|
||||
@ -2930,15 +2924,13 @@ id<GREYMatcher> SearchIconButton() {
|
||||
[super setUp];
|
||||
|
||||
CHROME_EG_ASSERT_NO_ERROR([ChromeEarlGrey waitForBookmarksToFinishLoading]);
|
||||
GREYAssert(chrome_test_util::ClearBookmarks(),
|
||||
@"Not all bookmarks were removed.");
|
||||
CHROME_EG_ASSERT_NO_ERROR([ChromeEarlGrey clearBookmarks]);
|
||||
}
|
||||
|
||||
// Tear down called once per test.
|
||||
- (void)tearDown {
|
||||
[super tearDown];
|
||||
GREYAssert(chrome_test_util::ClearBookmarks(),
|
||||
@"Not all bookmarks were removed.");
|
||||
CHROME_EG_ASSERT_NO_ERROR([ChromeEarlGrey clearBookmarks]);
|
||||
|
||||
// Clear position cache so that Bookmarks starts at the root folder in next
|
||||
// test.
|
||||
@ -3107,15 +3099,13 @@ id<GREYMatcher> SearchIconButton() {
|
||||
[super setUp];
|
||||
|
||||
CHROME_EG_ASSERT_NO_ERROR([ChromeEarlGrey waitForBookmarksToFinishLoading]);
|
||||
GREYAssert(chrome_test_util::ClearBookmarks(),
|
||||
@"Not all bookmarks were removed.");
|
||||
CHROME_EG_ASSERT_NO_ERROR([ChromeEarlGrey clearBookmarks]);
|
||||
}
|
||||
|
||||
// Tear down called once per test.
|
||||
- (void)tearDown {
|
||||
[super tearDown];
|
||||
GREYAssert(chrome_test_util::ClearBookmarks(),
|
||||
@"Not all bookmarks were removed.");
|
||||
CHROME_EG_ASSERT_NO_ERROR([ChromeEarlGrey clearBookmarks]);
|
||||
// Clear position cache so that Bookmarks starts at the root folder in next
|
||||
// test.
|
||||
ios::ChromeBrowserState* browser_state =
|
||||
@ -4048,15 +4038,13 @@ id<GREYMatcher> SearchIconButton() {
|
||||
[super setUp];
|
||||
|
||||
CHROME_EG_ASSERT_NO_ERROR([ChromeEarlGrey waitForBookmarksToFinishLoading]);
|
||||
GREYAssert(chrome_test_util::ClearBookmarks(),
|
||||
@"Not all bookmarks were removed.");
|
||||
CHROME_EG_ASSERT_NO_ERROR([ChromeEarlGrey clearBookmarks]);
|
||||
}
|
||||
|
||||
// Tear down called once per test.
|
||||
- (void)tearDown {
|
||||
[super tearDown];
|
||||
GREYAssert(chrome_test_util::ClearBookmarks(),
|
||||
@"Not all bookmarks were removed.");
|
||||
CHROME_EG_ASSERT_NO_ERROR([ChromeEarlGrey clearBookmarks]);
|
||||
// Clear position cache so that Bookmarks starts at the root folder in next
|
||||
// test.
|
||||
ios::ChromeBrowserState* browser_state =
|
||||
|
@ -117,8 +117,7 @@ using chrome_test_util::SettingsDoneButton;
|
||||
// shown.
|
||||
- (void)testKeyboardCommandsNotRegistered_AddBookmarkPresented {
|
||||
CHROME_EG_ASSERT_NO_ERROR([ChromeEarlGrey waitForBookmarksToFinishLoading]);
|
||||
BOOL success = chrome_test_util::ClearBookmarks();
|
||||
GREYAssert(success, @"Not all bookmarks were removed.");
|
||||
CHROME_EG_ASSERT_NO_ERROR([ChromeEarlGrey clearBookmarks]);
|
||||
|
||||
// Load a webpage because the NTP is not always bookmarkable.
|
||||
web::test::SetUpFileBasedHttpServer();
|
||||
|
@ -99,8 +99,7 @@ void AssertNumberOfEntitiesWithName(int entity_count,
|
||||
|
||||
- (void)tearDown {
|
||||
CHROME_EG_ASSERT_NO_ERROR([ChromeEarlGrey waitForBookmarksToFinishLoading]);
|
||||
chrome_test_util::ClearBookmarks();
|
||||
AssertNumberOfEntities(0, syncer::BOOKMARKS);
|
||||
CHROME_EG_ASSERT_NO_ERROR([ChromeEarlGrey clearBookmarks]);
|
||||
|
||||
chrome_test_util::ClearSyncServerData();
|
||||
AssertNumberOfEntities(0, syncer::AUTOFILL_PROFILE);
|
||||
|
@ -409,8 +409,7 @@ void FocusOmnibox() {
|
||||
|
||||
// Setup the bookmarks.
|
||||
CHROME_EG_ASSERT_NO_ERROR([ChromeEarlGrey waitForBookmarksToFinishLoading]);
|
||||
GREYAssert(chrome_test_util::ClearBookmarks(),
|
||||
@"Not all bookmarks were removed.");
|
||||
CHROME_EG_ASSERT_NO_ERROR([ChromeEarlGrey clearBookmarks]);
|
||||
|
||||
// Setup the server.
|
||||
self.testServer->RegisterRequestHandler(
|
||||
@ -444,8 +443,7 @@ void FocusOmnibox() {
|
||||
assertWithMatcher:Spotlighted()];
|
||||
|
||||
// Clean the bookmarks
|
||||
GREYAssert(chrome_test_util::ClearBookmarks(),
|
||||
@"Not all bookmarks were removed.");
|
||||
CHROME_EG_ASSERT_NO_ERROR([ChromeEarlGrey clearBookmarks]);
|
||||
}
|
||||
|
||||
// Tests that tapping a button cancels the focus on the omnibox.
|
||||
|
@ -137,6 +137,10 @@ id ExecuteJavaScript(NSString* javascript, NSError* __autoreleasing* out_error);
|
||||
// happen within a timeout, a GREYAssert is induced.
|
||||
+ (NSError*)waitForBookmarksToFinishLoading WARN_UNUSED_RESULT;
|
||||
|
||||
// Clears bookmarks and if any bookmark still presents. Returns nil on success,
|
||||
// or else an NSError indicating why the operation failed.
|
||||
+ (NSError*)clearBookmarks;
|
||||
|
||||
// Waits for the matcher to return an element that is sufficiently visible.
|
||||
+ (NSError*)waitForElementWithMatcherSufficientlyVisible:
|
||||
(id<GREYMatcher>)matcher WARN_UNUSED_RESULT;
|
||||
|
@ -372,6 +372,15 @@ id ExecuteJavaScript(NSString* javascript,
|
||||
return nil;
|
||||
}
|
||||
|
||||
+ (NSError*)clearBookmarks {
|
||||
bool success = chrome_test_util::ClearBookmarks();
|
||||
if (!success) {
|
||||
return testing::NSErrorWithLocalizedDescription(
|
||||
@"Not all bookmarks were removed.");
|
||||
}
|
||||
return nil;
|
||||
}
|
||||
|
||||
+ (NSError*)waitForElementWithMatcherSufficientlyVisible:
|
||||
(id<GREYMatcher>)matcher {
|
||||
bool success = WaitUntilConditionOrTimeout(kWaitForUIElementTimeout, ^bool {
|
||||
|
Reference in New Issue
Block a user