Commit ad5dfc6b authored by sczs's avatar sczs Committed by Commit Bot

[ios] Makes BookmarksFoldersEGTest EG2 compatible.

- Adds verifyFolderExists to BookmarkEarlGrey and its AppInterface.

- Adds ScrollToTop to ChromeActions to be used on Bookmark Folder test.

- Deletes BookmarkEarlGreyUtils since its no longer used.

Change-Id: Ia1eeb07bcfa80f03e263c49d4f89b2592c338903
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1976490
Commit-Queue: Sergio Collazos <sczs@chromium.org>
Reviewed-by: default avatarEugene But <eugenebut@chromium.org>
Cr-Commit-Position: refs/heads/master@{#726604}
parent bc2e4b15
...@@ -172,12 +172,8 @@ source_set("eg_tests") { ...@@ -172,12 +172,8 @@ source_set("eg_tests") {
":eg_test_support", ":eg_test_support",
"//base", "//base",
"//base/test:test_support", "//base/test:test_support",
"//components/prefs",
"//components/strings", "//components/strings",
"//ios/chrome/app/strings", "//ios/chrome/app/strings",
"//ios/chrome/browser",
"//ios/chrome/browser/bookmarks:bookmarks_utils",
"//ios/chrome/browser/browser_state",
"//ios/chrome/browser/ui/authentication:eg_test_support", "//ios/chrome/browser/ui/authentication:eg_test_support",
"//ios/chrome/browser/ui/popup_menu:constants", "//ios/chrome/browser/ui/popup_menu:constants",
"//ios/chrome/browser/ui/table_view:feature_flags", "//ios/chrome/browser/ui/table_view:feature_flags",
...@@ -203,8 +199,6 @@ source_set("eg_test_support") { ...@@ -203,8 +199,6 @@ source_set("eg_test_support") {
"bookmark_earl_grey_app_interface.mm", "bookmark_earl_grey_app_interface.mm",
"bookmark_earl_grey_ui.h", "bookmark_earl_grey_ui.h",
"bookmark_earl_grey_ui.mm", "bookmark_earl_grey_ui.mm",
"bookmark_earl_grey_utils.h",
"bookmark_earl_grey_utils.mm",
] ]
deps = [ deps = [
":bookmarks", ":bookmarks",
...@@ -246,6 +240,7 @@ source_set("eg2_tests") { ...@@ -246,6 +240,7 @@ source_set("eg2_tests") {
"bookmarks_accessibility_egtest.mm", "bookmarks_accessibility_egtest.mm",
"bookmarks_egtest.mm", "bookmarks_egtest.mm",
"bookmarks_entries_egtest.mm", "bookmarks_entries_egtest.mm",
"bookmarks_folders_egtest.mm",
"bookmarks_promo_egtest.mm", "bookmarks_promo_egtest.mm",
"bookmarks_search_egtest.mm", "bookmarks_search_egtest.mm",
] ]
......
...@@ -72,6 +72,10 @@ const GURL GetFrenchUrl(); ...@@ -72,6 +72,10 @@ const GURL GetFrenchUrl();
// bookmarks does exist. // bookmarks does exist.
- (void)verifyAbsenceOfBookmarkWithURL:(NSString*)URL; - (void)verifyAbsenceOfBookmarkWithURL:(NSString*)URL;
// Verifies that a folder called |title| exists. GREYAssert is induced if the
// folder doesn't exist.
- (void)verifyExistenceOfFolderWithTitle:(NSString*)title;
#pragma mark - Promo #pragma mark - Promo
// Checks that the promo has already been seen or not. GREYAssert is induced if // Checks that the promo has already been seen or not. GREYAssert is induced if
......
...@@ -111,6 +111,11 @@ const GURL GetFrenchUrl() { ...@@ -111,6 +111,11 @@ const GURL GetFrenchUrl() {
[BookmarkEarlGreyAppInterface verifyAbsenceOfBookmarkWithURL:URL]); [BookmarkEarlGreyAppInterface verifyAbsenceOfBookmarkWithURL:URL]);
} }
- (void)verifyExistenceOfFolderWithTitle:(NSString*)title {
EG_TEST_HELPER_ASSERT_NO_ERROR(
[BookmarkEarlGreyAppInterface verifyExistenceOfFolderWithTitle:title]);
}
#pragma mark - Promo #pragma mark - Promo
- (void)verifyPromoAlreadySeen:(BOOL)seen { - (void)verifyPromoAlreadySeen:(BOOL)seen {
......
...@@ -51,6 +51,9 @@ ...@@ -51,6 +51,9 @@
// Verifies the absence of a Bookmark with |URL|. // Verifies the absence of a Bookmark with |URL|.
+ (NSError*)verifyAbsenceOfBookmarkWithURL:(NSString*)URL; + (NSError*)verifyAbsenceOfBookmarkWithURL:(NSString*)URL;
// Verifies that a folder called |title| exists.
+ (NSError*)verifyExistenceOfFolderWithTitle:(NSString*)title;
// Checks that the promo has already been seen or not. // Checks that the promo has already been seen or not.
+ (NSError*)verifyPromoAlreadySeen:(BOOL)seen; + (NSError*)verifyPromoAlreadySeen:(BOOL)seen;
......
...@@ -257,6 +257,31 @@ ...@@ -257,6 +257,31 @@
return nil; return nil;
} }
+ (NSError*)verifyExistenceOfFolderWithTitle:(NSString*)title {
base::string16 folderTitle16(base::SysNSStringToUTF16(title));
ui::TreeNodeIterator<const bookmarks::BookmarkNode> iterator(
[self bookmarkModel] -> root_node());
BOOL folderExists = NO;
while (iterator.has_next()) {
const bookmarks::BookmarkNode* bookmark = iterator.Next();
if (bookmark->is_url())
continue;
// This is a folder.
if (bookmark->GetTitle() == folderTitle16) {
// Folder exists, return.
return nil;
}
}
if (!folderExists)
return testing::NSErrorWithLocalizedDescription(
[NSString stringWithFormat:@"Folder %@ doesn't exist", title]);
return nil;
}
+ (NSError*)verifyPromoAlreadySeen:(BOOL)seen { + (NSError*)verifyPromoAlreadySeen:(BOOL)seen {
ios::ChromeBrowserState* browserState = ios::ChromeBrowserState* browserState =
chrome_test_util::GetOriginalBrowserState(); chrome_test_util::GetOriginalBrowserState();
......
// Copyright 2019 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef IOS_CHROME_BROWSER_UI_BOOKMARKS_BOOKMARK_EARL_GREY_UTILS_H_
#define IOS_CHROME_BROWSER_UI_BOOKMARKS_BOOKMARK_EARL_GREY_UTILS_H_
#import <Foundation/Foundation.h>
// Methods used for the EarlGrey tests.
@interface BookmarkEarlGreyUtils : NSObject
// Clear Bookmarks top most row position cache.
+ (void)clearBookmarksPositionCache;
// Loads a set of default bookmarks in the model for the tests to use.
+ (void)setupStandardBookmarks;
// Loads a large set of bookmarks in the model which is longer than the screen
// height.
+ (void)setupBookmarksWhichExceedsScreenHeight;
// Asserts that |expectedCount| bookmarks exist with the corresponding |title|
// using the BookmarkModel.
+ (void)assertBookmarksWithTitle:(NSString*)title
expectedCount:(NSUInteger)expectedCount;
// Asserts that a folder called |title| exists.
+ (void)assertFolderExists:(NSString*)title;
// Verifies that there is |count| children on the bookmark folder with |name|.
+ (void)assertChildCount:(size_t)count ofFolderWithName:(NSString*)name;
// Removes programmatically the first bookmark with the given title.
+ (void)removeBookmarkWithTitle:(NSString*)title;
+ (void)moveBookmarkWithTitle:(NSString*)bookmarkTitle
toFolderWithTitle:(NSString*)newFolder;
@end
#endif // IOS_CHROME_BROWSER_UI_BOOKMARKS_BOOKMARK_EARL_GREY_UTILS_H_
...@@ -48,6 +48,12 @@ id<GREYAction> TapWebElementWithId(const std::string& element_id); ...@@ -48,6 +48,12 @@ id<GREYAction> TapWebElementWithId(const std::string& element_id);
id<GREYAction> TapWebElementWithIdInFrame(const std::string& element_id, id<GREYAction> TapWebElementWithIdInFrame(const std::string& element_id,
const int frame_index); const int frame_index);
// Action to scroll to top of a UIScrollView.
// On iOS 13 the settings menu appears as a card that can be dismissed with a
// downward swipe, for this reason we need to swipe up programmatically to
// avoid dismissing the VC.
id<GREYAction> ScrollToTop();
} // namespace chrome_test_util } // namespace chrome_test_util
#endif // IOS_CHROME_TEST_EARL_GREY_CHROME_ACTIONS_H_ #endif // IOS_CHROME_TEST_EARL_GREY_CHROME_ACTIONS_H_
...@@ -53,4 +53,8 @@ id<GREYAction> TapWebElementWithIdInFrame(const std::string& element_id, ...@@ -53,4 +53,8 @@ id<GREYAction> TapWebElementWithIdInFrame(const std::string& element_id,
inFrameWithIndex:frame_index]]; inFrameWithIndex:frame_index]];
} }
id<GREYAction> ScrollToTop() {
return [ChromeActionsAppInterface scrollToTop];
}
} // namespace chrome_test_util } // namespace chrome_test_util
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