Commit b08e7aba authored by Maksym Onufriienko's avatar Maksym Onufriienko Committed by Commit Bot

EG2 conversion of tab_util methods + isLoading.

Bug: 922813
Change-Id: I8d2abc2c56678eee4f7060e5169a0ed535cf08c8
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1632915
Commit-Queue: Maksym Onufriienko <monufriienko@chromium.org>
Reviewed-by: default avatarEugene But <eugenebut@chromium.org>
Cr-Commit-Position: refs/heads/master@{#664403}
parent a91a682e
...@@ -61,6 +61,9 @@ id ExecuteJavaScript(NSString* javascript, NSError* __autoreleasing* out_error); ...@@ -61,6 +61,9 @@ id ExecuteJavaScript(NSString* javascript, NSError* __autoreleasing* out_error);
// CHROME_EG_ASSERT_NO_ERROR is removed. // CHROME_EG_ASSERT_NO_ERROR is removed.
- (NSError*)loadURL:(const GURL&)URL; - (NSError*)loadURL:(const GURL&)URL;
// Returns YES if the current WebState is loading.
- (BOOL)isLoading WARN_UNUSED_RESULT;
// Reloads the page and waits for the loading to complete within a timeout, or a // Reloads the page and waits for the loading to complete within a timeout, or a
// GREYAssert is induced. // GREYAssert is induced.
// TODO(crbug.com/963613): Change return type to void when // TODO(crbug.com/963613): Change return type to void when
...@@ -143,7 +146,7 @@ id ExecuteJavaScript(NSString* javascript, NSError* __autoreleasing* out_error); ...@@ -143,7 +146,7 @@ id ExecuteJavaScript(NSString* javascript, NSError* __autoreleasing* out_error);
// the real one. // the real one.
- (void)tearDownFakeSyncServer; - (void)tearDownFakeSyncServer;
#pragma mark - Tab Utilities #pragma mark - Tab Utilities (EG2)
// Opens a new tab and waits for the new tab animation to complete within a // Opens a new tab and waits for the new tab animation to complete within a
// timeout, or a GREYAssert is induced. // timeout, or a GREYAssert is induced.
...@@ -175,6 +178,41 @@ id ExecuteJavaScript(NSString* javascript, NSError* __autoreleasing* out_error); ...@@ -175,6 +178,41 @@ id ExecuteJavaScript(NSString* javascript, NSError* __autoreleasing* out_error);
// be switched to main (non-incognito) after closing the incognito tabs. // be switched to main (non-incognito) after closing the incognito tabs.
- (void)closeAllTabs; - (void)closeAllTabs;
// Selects tab with given index in current mode (incognito or main
// (non-incognito)).
- (void)selectTabAtIndex:(NSUInteger)index;
// Closes tab with the given index in current mode (incognito or main
// (non-incognito)).
- (void)closeTabAtIndex:(NSUInteger)index;
// Returns YES if the browser is in incognito mode, and NO otherwise.
- (BOOL)isIncognitoMode WARN_UNUSED_RESULT;
// Returns the number of main (non-incognito) tabs.
- (NSUInteger)mainTabCount WARN_UNUSED_RESULT;
// Returns the number of incognito tabs.
- (NSUInteger)incognitoTabCount WARN_UNUSED_RESULT;
// Simulates a backgrounding and raises an EarlGrey exception if simulation not
// succeeded.
- (void)simulateTabsBackgrounding;
// Returns the number of main (non-incognito) tabs currently evicted.
- (NSUInteger)evictedMainTabCount WARN_UNUSED_RESULT;
// Evicts the tabs associated with the non-current browser mode.
- (void)evictOtherTabModelTabs;
// Sets the normal tabs as 'cold start' tabs and raises an EarlGrey exception if
// operation not succeeded.
- (void)setCurrentTabsToBeColdStartTabs;
// Resets the tab usage recorder on current mode and raises an EarlGrey
// exception if operation not succeeded.
- (void)resetTabUsageRecorder;
#pragma mark - SignIn Utilities #pragma mark - SignIn Utilities
// Signs the user out, clears the known accounts entirely and checks whether the // Signs the user out, clears the known accounts entirely and checks whether the
...@@ -245,9 +283,6 @@ id ExecuteJavaScript(NSString* javascript, NSError* __autoreleasing* out_error); ...@@ -245,9 +283,6 @@ id ExecuteJavaScript(NSString* javascript, NSError* __autoreleasing* out_error);
#pragma mark - Navigation Utilities #pragma mark - Navigation Utilities
// Checks whether current WebState is loading.
- (BOOL)isLoading WARN_UNUSED_RESULT;
// Waits for a static html view containing |text|. If the condition is not met // Waits for a static html view containing |text|. If the condition is not met
// within a timeout, a GREYAssert is induced. // within a timeout, a GREYAssert is induced.
// TODO(crbug.com/963613): Change return type to void when // TODO(crbug.com/963613): Change return type to void when
...@@ -346,43 +381,6 @@ id ExecuteJavaScript(NSString* javascript, NSError* __autoreleasing* out_error); ...@@ -346,43 +381,6 @@ id ExecuteJavaScript(NSString* javascript, NSError* __autoreleasing* out_error);
- (NSError*)verifySyncServerURLs:(const std::multiset<std::string>&)URLs - (NSError*)verifySyncServerURLs:(const std::multiset<std::string>&)URLs
WARN_UNUSED_RESULT; WARN_UNUSED_RESULT;
#pragma mark - Tab Utilities
// Selects tab with given index in current mode (incognito or main
// (non-incognito)).
- (void)selectTabAtIndex:(NSUInteger)index;
// Closes tab with the given index in current mode (incognito or main
// (non-incognito)).
- (void)closeTabAtIndex:(NSUInteger)index;
// Returns YES if the browser is in incognito mode, and NO otherwise.
- (BOOL)isIncognitoMode WARN_UNUSED_RESULT;
// Returns the number of main (non-incognito) tabs.
- (NSUInteger)mainTabCount WARN_UNUSED_RESULT;
// Returns the number of incognito tabs.
- (NSUInteger)incognitoTabCount WARN_UNUSED_RESULT;
// Simulates a backgrounding and raises an EarlGrey exception if simulation not
// succeeded.
- (void)simulateTabsBackgrounding;
// Returns the number of main (non-incognito) tabs currently evicted.
- (NSUInteger)evictedMainTabCount WARN_UNUSED_RESULT;
// Evicts the tabs associated with the non-current browser mode.
- (void)evictOtherTabModelTabs;
// Sets the normal tabs as 'cold start' tabs and raises an EarlGrey exception if
// operation not succeeded.
- (void)setCurrentTabsToBeColdStartTabs;
// Resets the tab usage recorder on current mode and raises an EarlGrey
// exception if operation not succeeded.
- (void)resetTabUsageRecorder;
@end @end
#endif // IOS_CHROME_TEST_EARL_GREY_CHROME_EARL_GREY_H_ #endif // IOS_CHROME_TEST_EARL_GREY_CHROME_EARL_GREY_H_
...@@ -86,6 +86,51 @@ GREY_STUB_CLASS_IN_APP_MAIN_QUEUE(ChromeEarlGreyAppInterface) ...@@ -86,6 +86,51 @@ GREY_STUB_CLASS_IN_APP_MAIN_QUEUE(ChromeEarlGreyAppInterface)
return nil; return nil;
} }
#pragma mark - Tab Utilities
- (void)selectTabAtIndex:(NSUInteger)index {
[ChromeEarlGreyAppInterface selectTabAtIndex:index];
}
- (BOOL)isIncognitoMode {
return [ChromeEarlGreyAppInterface isIncognitoMode];
}
- (void)closeTabAtIndex:(NSUInteger)index {
[ChromeEarlGreyAppInterface closeTabAtIndex:index];
}
- (NSUInteger)mainTabCount {
return [ChromeEarlGreyAppInterface mainTabCount];
}
- (NSUInteger)incognitoTabCount {
return [ChromeEarlGreyAppInterface incognitoTabCount];
}
- (NSUInteger)evictedMainTabCount {
return [ChromeEarlGreyAppInterface evictedMainTabCount];
}
- (void)evictOtherTabModelTabs {
[ChromeEarlGreyAppInterface evictOtherTabModelTabs];
}
- (void)simulateTabsBackgrounding {
EG_TEST_HELPER_ASSERT_NO_ERROR(
[ChromeEarlGreyAppInterface simulateTabsBackgrounding]);
}
- (void)setCurrentTabsToBeColdStartTabs {
EG_TEST_HELPER_ASSERT_NO_ERROR(
[ChromeEarlGreyAppInterface setCurrentTabsToBeColdStartTabs]);
}
- (void)resetTabUsageRecorder {
EG_TEST_HELPER_ASSERT_NO_ERROR(
[ChromeEarlGreyAppInterface resetTabUsageRecorder]);
}
- (NSError*)openNewTab { - (NSError*)openNewTab {
[ChromeEarlGreyAppInterface openNewTab]; [ChromeEarlGreyAppInterface openNewTab];
[self waitForPageToFinishLoading]; [self waitForPageToFinishLoading];
...@@ -154,6 +199,11 @@ GREY_STUB_CLASS_IN_APP_MAIN_QUEUE(ChromeEarlGreyAppInterface) ...@@ -154,6 +199,11 @@ GREY_STUB_CLASS_IN_APP_MAIN_QUEUE(ChromeEarlGreyAppInterface)
- (NSError*)loadURL:(const GURL&)URL { - (NSError*)loadURL:(const GURL&)URL {
return [self loadURL:URL waitForCompletion:YES]; return [self loadURL:URL waitForCompletion:YES];
} }
- (BOOL)isLoading {
return [ChromeEarlGreyAppInterface isLoading];
}
- (NSError*)waitForSufficientlyVisibleElementWithMatcher: - (NSError*)waitForSufficientlyVisibleElementWithMatcher:
(id<GREYMatcher>)matcher { (id<GREYMatcher>)matcher {
NSString* errorDescription = [NSString NSString* errorDescription = [NSString
...@@ -392,10 +442,6 @@ id ExecuteJavaScript(NSString* javascript, ...@@ -392,10 +442,6 @@ id ExecuteJavaScript(NSString* javascript,
#pragma mark - Navigation Utilities #pragma mark - Navigation Utilities
- (BOOL)isLoading {
return chrome_test_util::IsLoading();
}
- (NSError*)waitForErrorPage { - (NSError*)waitForErrorPage {
NSString* const kErrorPageText = NSString* const kErrorPageText =
l10n_util::GetNSString(IDS_ERRORPAGES_HEADING_NOT_AVAILABLE); l10n_util::GetNSString(IDS_ERRORPAGES_HEADING_NOT_AVAILABLE);
...@@ -612,52 +658,6 @@ id ExecuteJavaScript(NSString* javascript, ...@@ -612,52 +658,6 @@ id ExecuteJavaScript(NSString* javascript,
return nil; return nil;
} }
#pragma mark - Tab Utilities
- (void)selectTabAtIndex:(NSUInteger)index {
chrome_test_util::SelectTabAtIndexInCurrentMode(index);
}
- (BOOL)isIncognitoMode {
return chrome_test_util::IsIncognitoMode();
}
- (void)closeTabAtIndex:(NSUInteger)index {
chrome_test_util::CloseTabAtIndex(index);
}
- (NSUInteger)mainTabCount {
return chrome_test_util::GetMainTabCount();
}
- (NSUInteger)incognitoTabCount {
return chrome_test_util::GetIncognitoTabCount();
}
- (NSUInteger)evictedMainTabCount {
return chrome_test_util::GetEvictedMainTabCount();
}
- (void)evictOtherTabModelTabs {
chrome_test_util::EvictOtherTabModelTabs();
}
- (void)simulateTabsBackgrounding {
EG_TEST_HELPER_ASSERT_TRUE(chrome_test_util::SimulateTabsBackgrounding(),
@"Fail to simulate tab backgrounding.");
}
- (void)setCurrentTabsToBeColdStartTabs {
EG_TEST_HELPER_ASSERT_TRUE(
chrome_test_util::SetCurrentTabsToBeColdStartTabs(),
@"Fail to state tabs as cold start tabs");
}
- (void)resetTabUsageRecorder {
EG_TEST_HELPER_ASSERT_TRUE(chrome_test_util::ResetTabUsageRecorder(),
@"Fail to reset the TabUsageRecorder");
}
@end @end
#endif // defined(CHROME_EARL_GREY_1) #endif // defined(CHROME_EARL_GREY_1)
...@@ -36,6 +36,46 @@ ...@@ -36,6 +36,46 @@
// Reloads the page without waiting for the page to load. // Reloads the page without waiting for the page to load.
+ (void)startReloading; + (void)startReloading;
#pragma mark - Tab Utilities
// Selects tab with given index in current mode (incognito or main
// (non-incognito)).
+ (void)selectTabAtIndex:(NSUInteger)index;
// Closes tab with the given index in current mode (incognito or main
// (non-incognito)).
+ (void)closeTabAtIndex:(NSUInteger)index;
// Returns YES if the browser is in incognito mode, and NO otherwise.
+ (BOOL)isIncognitoMode WARN_UNUSED_RESULT;
// Returns the number of open non-incognito tabs.
+ (NSUInteger)mainTabCount WARN_UNUSED_RESULT;
// Returns the number of open incognito tabs.
+ (NSUInteger)incognitoTabCount WARN_UNUSED_RESULT;
// Simulates a backgrounding.
// If not succeed returns an NSError indicating why the
// operation failed, otherwise nil.
+ (NSError*)simulateTabsBackgrounding;
// Returns the number of main (non-incognito) tabs currently evicted.
+ (NSUInteger)evictedMainTabCount WARN_UNUSED_RESULT;
// Evicts the tabs associated with the non-current browser mode.
+ (void)evictOtherTabModelTabs;
// Sets the normal tabs as 'cold start' tabs
// If not succeed returns an NSError indicating why the
// operation failed, otherwise nil.
+ (NSError*)setCurrentTabsToBeColdStartTabs;
// Resets the tab usage recorder on current mode.
// If not succeed returns an NSError indicating why the
// operation failed, otherwise nil.
+ (NSError*)resetTabUsageRecorder;
// 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;
...@@ -76,12 +116,6 @@ ...@@ -76,12 +116,6 @@
// otherwise nil. // otherwise nil.
+ (NSError*)waitForWebStateNotContainingText:(NSString*)text; + (NSError*)waitForWebStateNotContainingText:(NSString*)text;
// Returns the number of open non-incognito tabs.
+ (NSUInteger)mainTabCount;
// Returns the number of open incognito tabs.
+ (NSUInteger)incognitoTabCount;
// Sets value for content setting. // Sets value for content setting.
+ (void)setContentSettings:(ContentSetting)setting; + (void)setContentSettings:(ContentSetting)setting;
......
...@@ -63,6 +63,60 @@ using chrome_test_util::BrowserCommandDispatcherForMainBVC; ...@@ -63,6 +63,60 @@ using chrome_test_util::BrowserCommandDispatcherForMainBVC;
[BrowserCommandDispatcherForMainBVC() reload]; [BrowserCommandDispatcherForMainBVC() reload];
} }
#pragma mark - Tab Utilities
+ (void)selectTabAtIndex:(NSUInteger)index {
chrome_test_util::SelectTabAtIndexInCurrentMode(index);
}
+ (BOOL)isIncognitoMode {
return chrome_test_util::IsIncognitoMode();
}
+ (void)closeTabAtIndex:(NSUInteger)index {
chrome_test_util::CloseTabAtIndex(index);
}
+ (NSUInteger)mainTabCount {
return chrome_test_util::GetMainTabCount();
}
+ (NSUInteger)incognitoTabCount {
return chrome_test_util::GetIncognitoTabCount();
}
+ (NSUInteger)evictedMainTabCount {
return chrome_test_util::GetEvictedMainTabCount();
}
+ (void)evictOtherTabModelTabs {
chrome_test_util::EvictOtherTabModelTabs();
}
+ (NSError*)simulateTabsBackgrounding {
if (!chrome_test_util::SimulateTabsBackgrounding()) {
return testing::NSErrorWithLocalizedDescription(
@"Fail to simulate tab backgrounding.");
}
return nil;
}
+ (NSError*)setCurrentTabsToBeColdStartTabs {
if (!chrome_test_util::SetCurrentTabsToBeColdStartTabs()) {
return testing::NSErrorWithLocalizedDescription(
@"Fail to state tabs as cold start tabs");
}
return nil;
}
+ (NSError*)resetTabUsageRecorder {
if (!chrome_test_util::ResetTabUsageRecorder()) {
return testing::NSErrorWithLocalizedDescription(
@"Fail to reset the TabUsageRecorder");
}
return nil;
}
+ (void)openNewTab { + (void)openNewTab {
chrome_test_util::OpenNewTab(); chrome_test_util::OpenNewTab();
} }
...@@ -125,14 +179,6 @@ using chrome_test_util::BrowserCommandDispatcherForMainBVC; ...@@ -125,14 +179,6 @@ using chrome_test_util::BrowserCommandDispatcherForMainBVC;
return nil; return nil;
} }
+ (NSUInteger)mainTabCount {
return chrome_test_util::GetMainTabCount();
}
+ (NSUInteger)incognitoTabCount {
return chrome_test_util::GetIncognitoTabCount();
}
+ (void)setContentSettings:(ContentSetting)setting { + (void)setContentSettings:(ContentSetting)setting {
chrome_test_util::SetContentSettingsBlockPopups(setting); chrome_test_util::SetContentSettingsBlockPopups(setting);
} }
......
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