Commit 656db4d1 authored by Maksym Onufriienko's avatar Maksym Onufriienko Committed by Commit Bot

Converted Bookmark helper to compile under EG2.

Added testBookmarkHelpers in smoke_egtest.

Bug: 922813
Change-Id: I59b2348545e737c2b756abcc58eb77e07c491c79
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1626012
Commit-Queue: Maksym Onufriienko <monufriienko@chromium.org>
Reviewed-by: default avatarEugene But <eugenebut@chromium.org>
Cr-Commit-Position: refs/heads/master@{#662878}
parent 42284d42
......@@ -336,6 +336,7 @@ source_set("eg_app_support+eg2") {
deps = [
"//base",
"//base/test:test_support",
"//components/signin/core/browser",
"//components/strings",
"//components/unified_consent",
......@@ -360,7 +361,6 @@ source_set("eg_app_support+eg2") {
"//ios/chrome/test/app:test_support",
"//ios/testing:nserror_support",
"//ios/testing/earl_grey:eg_app_support+eg2",
"//ios/testing/earl_grey:eg_app_support+eg2",
"//ios/third_party/earl_grey2:app_framework+link",
"//ios/web:eg_app_support+eg2",
"//ios/web/public/test:element_selector",
......
......@@ -85,6 +85,9 @@ id ExecuteJavaScript(NSString* javascript, NSError* __autoreleasing* out_error);
// CHROME_EG_ASSERT_NO_ERROR is removed.
- (NSError*)openNewTab;
// Closes the current tab and waits for the UI to complete.
- (void)closeCurrentTab;
// Opens a new incognito tab and waits for the new tab animation to complete.
// TODO(crbug.com/963613): Change return type to void when
// CHROME_EG_ASSERT_NO_ERROR is removed.
......@@ -107,8 +110,15 @@ id ExecuteJavaScript(NSString* javascript, NSError* __autoreleasing* out_error);
// CHROME_EG_ASSERT_NO_ERROR is removed.
- (NSError*)waitForPageToFinishLoading;
// Closes the current tab and waits for the UI to complete.
- (void)closeCurrentTab;
#pragma mark - Bookmarks Utilities (EG2)
// Waits for the bookmark internal state to be done loading.
// If the condition is not met within a timeout a GREYAssert is induced.
- (NSError*)waitForBookmarksToFinishLoading;
// Clears bookmarks if any bookmark still presents. A GREYAssert is induced if
// bookmarks can not be cleared.
- (NSError*)clearBookmarks;
@end
......@@ -158,15 +168,6 @@ id ExecuteJavaScript(NSString* javascript, NSError* __autoreleasing* out_error);
// why the operation failed, otherwise nil.
- (NSError*)waitForIncognitoTabCount:(NSUInteger)count WARN_UNUSED_RESULT;
// Waits for the bookmark internal state to be done loading.
// If the condition is not met within a timeout returns an NSError indicating
// why the operation failed, otherwise nil.
- (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*)waitForSufficientlyVisibleElementWithMatcher:
(id<GREYMatcher>)matcher WARN_UNUSED_RESULT;
......
......@@ -21,7 +21,6 @@
#include "components/strings/grit/components_strings.h" // nogncheck
#import "ios/chrome/browser/ui/static_content/static_html_view_controller.h" // nogncheck
#import "ios/chrome/test/app/bookmarks_test_util.h" // nogncheck
#import "ios/chrome/test/app/chrome_test_util.h" // nogncheck
#import "ios/chrome/test/app/history_test_util.h" // nogncheck
#include "ios/chrome/test/app/navigation_test_util.h" // nogncheck
......@@ -97,6 +96,11 @@ GREY_STUB_CLASS_IN_APP_MAIN_QUEUE(ChromeEarlGreyAppInterface)
return nil;
}
- (void)closeCurrentTab {
[ChromeEarlGreyAppInterface closeCurrentTab];
[[GREYUIThreadExecutor sharedInstance] drainUntilIdle];
}
- (NSError*)openNewIncognitoTab {
[ChromeEarlGreyAppInterface openNewIncognitoTab];
[self waitForPageToFinishLoading];
......@@ -149,9 +153,19 @@ GREY_STUB_CLASS_IN_APP_MAIN_QUEUE(ChromeEarlGreyAppInterface)
return [self loadURL:URL waitForCompletion:YES];
}
- (void)closeCurrentTab {
[ChromeEarlGreyAppInterface closeCurrentTab];
[[GREYUIThreadExecutor sharedInstance] drainUntilIdle];
#pragma mark - Bookmarks Utilities (EG2)
- (NSError*)waitForBookmarksToFinishLoading {
EG_TEST_HELPER_ASSERT_TRUE(
[ChromeEarlGreyAppInterface waitForBookmarksToFinishinLoading],
@"Bookmark model did not load");
return nil;
}
- (NSError*)clearBookmarks {
EG_TEST_HELPER_ASSERT_TRUE([ChromeEarlGreyAppInterface clearBookmarks],
@"Not all bookmarks were removed.");
return nil;
}
@end
......@@ -292,28 +306,6 @@ id ExecuteJavaScript(NSString* javascript,
return nil;
}
- (NSError*)waitForBookmarksToFinishLoading {
bool success = WaitUntilConditionOrTimeout(kWaitForUIElementTimeout, ^{
return chrome_test_util::BookmarksLoaded();
});
if (!success) {
return testing::NSErrorWithLocalizedDescription(
@"Bookmark model did not load");
}
return nil;
}
- (NSError*)clearBookmarks {
bool success = chrome_test_util::ClearBookmarks();
if (!success) {
return testing::NSErrorWithLocalizedDescription(
@"Not all bookmarks were removed.");
}
return nil;
}
- (NSError*)waitForSufficientlyVisibleElementWithMatcher:
(id<GREYMatcher>)matcher {
bool success = WaitUntilConditionOrTimeout(kWaitForUIElementTimeout, ^bool {
......
......@@ -35,6 +35,9 @@
// Opens a new tab, and does not wait for animations to complete.
+ (void)openNewTab;
// Closes current tab.
+ (void)closeCurrentTab;
// Opens a new incognito tab, and does not wait for animations to complete.
+ (void)openNewIncognitoTab;
......@@ -52,8 +55,14 @@
// Navigates forward to the next page without waiting for the page to load.
+ (void)startGoingForward;
// Closes current tab.
+ (void)closeCurrentTab;
#pragma mark - Bookmarks Utilities (EG2)
// Waits for the bookmark internal state to be done loading.
// Return YES on success.
+ (BOOL)waitForBookmarksToFinishinLoading;
// Clears bookmarks. Returns YES on success.
+ (BOOL)clearBookmarks;
@end
......
......@@ -3,8 +3,10 @@
// found in the LICENSE file.
#import "ios/chrome/test/earl_grey/chrome_earl_grey_app_interface.h"
#import "base/test/ios/wait_util.h"
#include "base/strings/sys_string_conversions.h"
#import "ios/chrome/test/app/bookmarks_test_util.h"
#import "ios/chrome/test/app/chrome_test_util.h"
#import "ios/chrome/test/app/history_test_util.h"
#include "ios/chrome/test/app/navigation_test_util.h"
......@@ -16,6 +18,8 @@
#error "This file requires ARC support."
#endif
using base::test::ios::kWaitForActionTimeout;
using base::test::ios::WaitUntilConditionOrTimeout;
using chrome_test_util::BrowserCommandDispatcherForMainBVC;
@implementation ChromeEarlGreyAppInterface
......@@ -55,6 +59,10 @@ using chrome_test_util::BrowserCommandDispatcherForMainBVC;
chrome_test_util::OpenNewTab();
}
+ (void)closeCurrentTab {
chrome_test_util::CloseCurrentTab();
}
+ (void)openNewIncognitoTab {
chrome_test_util::OpenNewIncognitoTab();
}
......@@ -75,8 +83,16 @@ using chrome_test_util::BrowserCommandDispatcherForMainBVC;
[BrowserCommandDispatcherForMainBVC() goForward];
}
+ (void)closeCurrentTab {
chrome_test_util::CloseCurrentTab();
#pragma mark - Bookmarks Utilities (EG2)
+ (BOOL)waitForBookmarksToFinishinLoading {
return WaitUntilConditionOrTimeout(kWaitForActionTimeout, ^{
return chrome_test_util::BookmarksLoaded();
});
}
+ (BOOL)clearBookmarks {
return chrome_test_util::ClearBookmarks();
}
@end
......@@ -129,4 +129,10 @@
[ChromeEarlGrey openNewTab];
}
// Tests bookmark converted helpers in chrome_earl_grey.h.
- (void)testBookmarkHelpers {
[ChromeEarlGrey waitForBookmarksToFinishLoading];
[ChromeEarlGrey clearBookmarks];
}
@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