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") { ...@@ -336,6 +336,7 @@ source_set("eg_app_support+eg2") {
deps = [ deps = [
"//base", "//base",
"//base/test:test_support",
"//components/signin/core/browser", "//components/signin/core/browser",
"//components/strings", "//components/strings",
"//components/unified_consent", "//components/unified_consent",
...@@ -360,7 +361,6 @@ source_set("eg_app_support+eg2") { ...@@ -360,7 +361,6 @@ source_set("eg_app_support+eg2") {
"//ios/chrome/test/app:test_support", "//ios/chrome/test/app:test_support",
"//ios/testing:nserror_support", "//ios/testing:nserror_support",
"//ios/testing/earl_grey:eg_app_support+eg2", "//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/third_party/earl_grey2:app_framework+link",
"//ios/web:eg_app_support+eg2", "//ios/web:eg_app_support+eg2",
"//ios/web/public/test:element_selector", "//ios/web/public/test:element_selector",
......
...@@ -85,6 +85,9 @@ id ExecuteJavaScript(NSString* javascript, NSError* __autoreleasing* out_error); ...@@ -85,6 +85,9 @@ id ExecuteJavaScript(NSString* javascript, NSError* __autoreleasing* out_error);
// CHROME_EG_ASSERT_NO_ERROR is removed. // CHROME_EG_ASSERT_NO_ERROR is removed.
- (NSError*)openNewTab; - (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. // Opens a new incognito tab and waits for the new tab animation to complete.
// TODO(crbug.com/963613): Change return type to void when // TODO(crbug.com/963613): Change return type to void when
// CHROME_EG_ASSERT_NO_ERROR is removed. // CHROME_EG_ASSERT_NO_ERROR is removed.
...@@ -107,8 +110,15 @@ id ExecuteJavaScript(NSString* javascript, NSError* __autoreleasing* out_error); ...@@ -107,8 +110,15 @@ id ExecuteJavaScript(NSString* javascript, NSError* __autoreleasing* out_error);
// CHROME_EG_ASSERT_NO_ERROR is removed. // CHROME_EG_ASSERT_NO_ERROR is removed.
- (NSError*)waitForPageToFinishLoading; - (NSError*)waitForPageToFinishLoading;
// Closes the current tab and waits for the UI to complete. #pragma mark - Bookmarks Utilities (EG2)
- (void)closeCurrentTab;
// 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 @end
...@@ -158,15 +168,6 @@ id ExecuteJavaScript(NSString* javascript, NSError* __autoreleasing* out_error); ...@@ -158,15 +168,6 @@ id ExecuteJavaScript(NSString* javascript, NSError* __autoreleasing* out_error);
// why the operation failed, otherwise nil. // why the operation failed, otherwise nil.
- (NSError*)waitForIncognitoTabCount:(NSUInteger)count WARN_UNUSED_RESULT; - (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. // Waits for the matcher to return an element that is sufficiently visible.
- (NSError*)waitForSufficientlyVisibleElementWithMatcher: - (NSError*)waitForSufficientlyVisibleElementWithMatcher:
(id<GREYMatcher>)matcher WARN_UNUSED_RESULT; (id<GREYMatcher>)matcher WARN_UNUSED_RESULT;
......
...@@ -21,7 +21,6 @@ ...@@ -21,7 +21,6 @@
#include "components/strings/grit/components_strings.h" // nogncheck #include "components/strings/grit/components_strings.h" // nogncheck
#import "ios/chrome/browser/ui/static_content/static_html_view_controller.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/chrome_test_util.h" // nogncheck
#import "ios/chrome/test/app/history_test_util.h" // nogncheck #import "ios/chrome/test/app/history_test_util.h" // nogncheck
#include "ios/chrome/test/app/navigation_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) ...@@ -97,6 +96,11 @@ GREY_STUB_CLASS_IN_APP_MAIN_QUEUE(ChromeEarlGreyAppInterface)
return nil; return nil;
} }
- (void)closeCurrentTab {
[ChromeEarlGreyAppInterface closeCurrentTab];
[[GREYUIThreadExecutor sharedInstance] drainUntilIdle];
}
- (NSError*)openNewIncognitoTab { - (NSError*)openNewIncognitoTab {
[ChromeEarlGreyAppInterface openNewIncognitoTab]; [ChromeEarlGreyAppInterface openNewIncognitoTab];
[self waitForPageToFinishLoading]; [self waitForPageToFinishLoading];
...@@ -149,9 +153,19 @@ GREY_STUB_CLASS_IN_APP_MAIN_QUEUE(ChromeEarlGreyAppInterface) ...@@ -149,9 +153,19 @@ GREY_STUB_CLASS_IN_APP_MAIN_QUEUE(ChromeEarlGreyAppInterface)
return [self loadURL:URL waitForCompletion:YES]; return [self loadURL:URL waitForCompletion:YES];
} }
- (void)closeCurrentTab { #pragma mark - Bookmarks Utilities (EG2)
[ChromeEarlGreyAppInterface closeCurrentTab];
[[GREYUIThreadExecutor sharedInstance] drainUntilIdle]; - (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 @end
...@@ -292,28 +306,6 @@ id ExecuteJavaScript(NSString* javascript, ...@@ -292,28 +306,6 @@ id ExecuteJavaScript(NSString* javascript,
return nil; 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: - (NSError*)waitForSufficientlyVisibleElementWithMatcher:
(id<GREYMatcher>)matcher { (id<GREYMatcher>)matcher {
bool success = WaitUntilConditionOrTimeout(kWaitForUIElementTimeout, ^bool { bool success = WaitUntilConditionOrTimeout(kWaitForUIElementTimeout, ^bool {
......
...@@ -35,6 +35,9 @@ ...@@ -35,6 +35,9 @@
// Opens a new tab, and does not wait for animations to complete. // Opens a new tab, and does not wait for animations to complete.
+ (void)openNewTab; + (void)openNewTab;
// Closes current tab.
+ (void)closeCurrentTab;
// Opens a new incognito tab, and does not wait for animations to complete. // Opens a new incognito tab, and does not wait for animations to complete.
+ (void)openNewIncognitoTab; + (void)openNewIncognitoTab;
...@@ -52,8 +55,14 @@ ...@@ -52,8 +55,14 @@
// Navigates forward to the next page without waiting for the page to load. // Navigates forward to the next page without waiting for the page to load.
+ (void)startGoingForward; + (void)startGoingForward;
// Closes current tab. #pragma mark - Bookmarks Utilities (EG2)
+ (void)closeCurrentTab;
// 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 @end
......
...@@ -3,8 +3,10 @@ ...@@ -3,8 +3,10 @@
// found in the LICENSE file. // found in the LICENSE file.
#import "ios/chrome/test/earl_grey/chrome_earl_grey_app_interface.h" #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" #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/chrome_test_util.h"
#import "ios/chrome/test/app/history_test_util.h" #import "ios/chrome/test/app/history_test_util.h"
#include "ios/chrome/test/app/navigation_test_util.h" #include "ios/chrome/test/app/navigation_test_util.h"
...@@ -16,6 +18,8 @@ ...@@ -16,6 +18,8 @@
#error "This file requires ARC support." #error "This file requires ARC support."
#endif #endif
using base::test::ios::kWaitForActionTimeout;
using base::test::ios::WaitUntilConditionOrTimeout;
using chrome_test_util::BrowserCommandDispatcherForMainBVC; using chrome_test_util::BrowserCommandDispatcherForMainBVC;
@implementation ChromeEarlGreyAppInterface @implementation ChromeEarlGreyAppInterface
...@@ -55,6 +59,10 @@ using chrome_test_util::BrowserCommandDispatcherForMainBVC; ...@@ -55,6 +59,10 @@ using chrome_test_util::BrowserCommandDispatcherForMainBVC;
chrome_test_util::OpenNewTab(); chrome_test_util::OpenNewTab();
} }
+ (void)closeCurrentTab {
chrome_test_util::CloseCurrentTab();
}
+ (void)openNewIncognitoTab { + (void)openNewIncognitoTab {
chrome_test_util::OpenNewIncognitoTab(); chrome_test_util::OpenNewIncognitoTab();
} }
...@@ -75,8 +83,16 @@ using chrome_test_util::BrowserCommandDispatcherForMainBVC; ...@@ -75,8 +83,16 @@ using chrome_test_util::BrowserCommandDispatcherForMainBVC;
[BrowserCommandDispatcherForMainBVC() goForward]; [BrowserCommandDispatcherForMainBVC() goForward];
} }
+ (void)closeCurrentTab { #pragma mark - Bookmarks Utilities (EG2)
chrome_test_util::CloseCurrentTab();
+ (BOOL)waitForBookmarksToFinishinLoading {
return WaitUntilConditionOrTimeout(kWaitForActionTimeout, ^{
return chrome_test_util::BookmarksLoaded();
});
}
+ (BOOL)clearBookmarks {
return chrome_test_util::ClearBookmarks();
} }
@end @end
...@@ -129,4 +129,10 @@ ...@@ -129,4 +129,10 @@
[ChromeEarlGrey openNewTab]; [ChromeEarlGrey openNewTab];
} }
// Tests bookmark converted helpers in chrome_earl_grey.h.
- (void)testBookmarkHelpers {
[ChromeEarlGrey waitForBookmarksToFinishLoading];
[ChromeEarlGrey clearBookmarks];
}
@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