Commit b4573545 authored by Justin Cohen's avatar Justin Cohen Committed by Commit Bot

[ios] Wait for new tab page load and animations to complete in tests.

Non CRWNativeContent NTP pages do not load instantly, and instead
load similarly to web view page loads.  Add logic to wait for the
webState to finish loading and the NTP animation to complete.

Bug: 783192
Change-Id: If3d47e7467c2831697ae8baf9fd8f6755aa535af
Reviewed-on: https://chromium-review.googlesource.com/c/1324229Reviewed-by: default avatarPeter Lee <pkl@chromium.org>
Reviewed-by: default avatarEugene But <eugenebut@chromium.org>
Commit-Queue: Justin Cohen <justincohen@chromium.org>
Cr-Commit-Position: refs/heads/master@{#607338}
parent 7a07736b
...@@ -71,7 +71,7 @@ void AssertHandoffURL(const GURL& gurl) { ...@@ -71,7 +71,7 @@ void AssertHandoffURL(const GURL& gurl) {
// Tests Handoff URL for a new tab. // Tests Handoff URL for a new tab.
- (void)testTypicalURLInNewTab { - (void)testTypicalURLInNewTab {
chrome_test_util::OpenNewTab(); [ChromeEarlGrey openNewTab];
const GURL destinationUrl = web::test::HttpServer::MakeUrl( const GURL destinationUrl = web::test::HttpServer::MakeUrl(
"http://ios/testing/data/http_server_files/pony.html"); "http://ios/testing/data/http_server_files/pony.html");
[ChromeEarlGrey loadURL:destinationUrl]; [ChromeEarlGrey loadURL:destinationUrl];
...@@ -81,7 +81,7 @@ void AssertHandoffURL(const GURL& gurl) { ...@@ -81,7 +81,7 @@ void AssertHandoffURL(const GURL& gurl) {
// Tests that Handoff URL should never be set for an incognito tab. // Tests that Handoff URL should never be set for an incognito tab.
- (void)testTypicalURLInNewIncognitoTab { - (void)testTypicalURLInNewIncognitoTab {
// Opens an incognito tab and loads a web page. Check that Handoff URL is nil. // Opens an incognito tab and loads a web page. Check that Handoff URL is nil.
chrome_test_util::OpenNewIncognitoTab(); [ChromeEarlGrey openNewIncognitoTab];
const GURL destinationUrl = web::test::HttpServer::MakeUrl( const GURL destinationUrl = web::test::HttpServer::MakeUrl(
"http://ios/testing/data/http_server_files/destination.html"); "http://ios/testing/data/http_server_files/destination.html");
[ChromeEarlGrey loadURL:destinationUrl]; [ChromeEarlGrey loadURL:destinationUrl];
...@@ -107,9 +107,9 @@ void AssertHandoffURL(const GURL& gurl) { ...@@ -107,9 +107,9 @@ void AssertHandoffURL(const GURL& gurl) {
// Sets up the state for 3 tabs. // Sets up the state for 3 tabs.
[ChromeEarlGrey loadURL:tab1URL]; [ChromeEarlGrey loadURL:tab1URL];
chrome_test_util::OpenNewTab(); [ChromeEarlGrey openNewTab];
[ChromeEarlGrey loadURL:tab2URL]; [ChromeEarlGrey loadURL:tab2URL];
chrome_test_util::OpenNewTab(); [ChromeEarlGrey openNewTab];
[ChromeEarlGrey loadURL:tab3URL]; [ChromeEarlGrey loadURL:tab3URL];
// When tab 3 is closed, tab 2 is front and Handoff URL should be the URL for // When tab 3 is closed, tab 2 is front and Handoff URL should be the URL for
...@@ -135,13 +135,13 @@ void AssertHandoffURL(const GURL& gurl) { ...@@ -135,13 +135,13 @@ void AssertHandoffURL(const GURL& gurl) {
// Loads one page. // Loads one page.
[ChromeEarlGrey loadURL:tab1URL]; [ChromeEarlGrey loadURL:tab1URL];
// Loads page two in incognito and verifies that Handoff URL is nil. // Loads page two in incognito and verifies that Handoff URL is nil.
chrome_test_util::OpenNewIncognitoTab(); [ChromeEarlGrey openNewIncognitoTab];
[ChromeEarlGrey loadURL:tab2URL]; [ChromeEarlGrey loadURL:tab2URL];
AssertHandoffURL(GURL()); AssertHandoffURL(GURL());
// Loads page three in a new normal tab and verify that Handoff URL is not // Loads page three in a new normal tab and verify that Handoff URL is not
// nil. // nil.
chrome_test_util::OpenNewTab(); [ChromeEarlGrey openNewTab];
[ChromeEarlGrey loadURL:tab3URL]; [ChromeEarlGrey loadURL:tab3URL];
AssertHandoffURL(tab3URL); AssertHandoffURL(tab3URL);
} }
......
...@@ -144,7 +144,7 @@ void ClearBrowsingData() { ...@@ -144,7 +144,7 @@ void ClearBrowsingData() {
void OpenNewIncognitoTab() { void OpenNewIncognitoTab() {
NSUInteger incognito_tab_count = GetIncognitoTabCount(); NSUInteger incognito_tab_count = GetIncognitoTabCount();
chrome_test_util::OpenNewIncognitoTab(); [ChromeEarlGrey openNewIncognitoTab];
[ChromeEarlGrey waitForIncognitoTabCount:(incognito_tab_count + 1)]; [ChromeEarlGrey waitForIncognitoTabCount:(incognito_tab_count + 1)];
GREYAssert(IsIncognitoMode(), @"Failed to switch to incognito mode."); GREYAssert(IsIncognitoMode(), @"Failed to switch to incognito mode.");
} }
...@@ -171,7 +171,7 @@ void CloseAllIncognitoTabs() { ...@@ -171,7 +171,7 @@ void CloseAllIncognitoTabs() {
void OpenNewRegularTab() { void OpenNewRegularTab() {
NSUInteger tab_count = chrome_test_util::GetMainTabCount(); NSUInteger tab_count = chrome_test_util::GetMainTabCount();
chrome_test_util::OpenNewTab(); [ChromeEarlGrey openNewTab];
[ChromeEarlGrey waitForMainTabCount:(tab_count + 1)]; [ChromeEarlGrey waitForMainTabCount:(tab_count + 1)];
} }
......
...@@ -111,7 +111,7 @@ NSString* const kIncognitoCookieValue = @"rainbow"; ...@@ -111,7 +111,7 @@ NSString* const kIncognitoCookieValue = @"rainbow";
// Opens an incognito tab, loads the dummy page, and sets incognito test // Opens an incognito tab, loads the dummy page, and sets incognito test
// cookie. // cookie.
chrome_test_util::OpenNewIncognitoTab(); [ChromeEarlGrey openNewIncognitoTab];
[ChromeEarlGrey [ChromeEarlGrey
loadURL:web::test::HttpServer::MakeUrl(kTestUrlIncognitoSetCookie)]; loadURL:web::test::HttpServer::MakeUrl(kTestUrlIncognitoSetCookie)];
cookies = [ChromeEarlGrey cookies]; cookies = [ChromeEarlGrey cookies];
...@@ -122,7 +122,7 @@ NSString* const kIncognitoCookieValue = @"rainbow"; ...@@ -122,7 +122,7 @@ NSString* const kIncognitoCookieValue = @"rainbow";
// Switches back to normal profile by opening up a new tab. Test cookie // Switches back to normal profile by opening up a new tab. Test cookie
// should not be found. // should not be found.
chrome_test_util::OpenNewTab(); [ChromeEarlGrey openNewTab];
[ChromeEarlGrey [ChromeEarlGrey
loadURL:web::test::HttpServer::MakeUrl(kTestUrlNormalBrowsing)]; loadURL:web::test::HttpServer::MakeUrl(kTestUrlNormalBrowsing)];
cookies = [ChromeEarlGrey cookies]; cookies = [ChromeEarlGrey cookies];
...@@ -138,7 +138,7 @@ NSString* const kIncognitoCookieValue = @"rainbow"; ...@@ -138,7 +138,7 @@ NSString* const kIncognitoCookieValue = @"rainbow";
// incognito tabs and synchronize with the UI. // incognito tabs and synchronize with the UI.
[[GREYUIThreadExecutor sharedInstance] drainUntilIdle]; [[GREYUIThreadExecutor sharedInstance] drainUntilIdle];
chrome_test_util::OpenNewTab(); [ChromeEarlGrey openNewTab];
[ChromeEarlGrey [ChromeEarlGrey
loadURL:web::test::HttpServer::MakeUrl(kTestUrlIncognitoBrowsing)]; loadURL:web::test::HttpServer::MakeUrl(kTestUrlIncognitoBrowsing)];
cookies = [ChromeEarlGrey cookies]; cookies = [ChromeEarlGrey cookies];
...@@ -155,7 +155,7 @@ NSString* const kIncognitoCookieValue = @"rainbow"; ...@@ -155,7 +155,7 @@ NSString* const kIncognitoCookieValue = @"rainbow";
loadURL:web::test::HttpServer::MakeUrl(kTestUrlNormalBrowsing)]; loadURL:web::test::HttpServer::MakeUrl(kTestUrlNormalBrowsing)];
// Opens an incognito tab, loads a page, and sets an incognito cookie. // Opens an incognito tab, loads a page, and sets an incognito cookie.
chrome_test_util::OpenNewIncognitoTab(); [ChromeEarlGrey openNewIncognitoTab];
[ChromeEarlGrey [ChromeEarlGrey
loadURL:web::test::HttpServer::MakeUrl(kTestUrlIncognitoSetCookie)]; loadURL:web::test::HttpServer::MakeUrl(kTestUrlIncognitoSetCookie)];
NSDictionary* cookies = [ChromeEarlGrey cookies]; NSDictionary* cookies = [ChromeEarlGrey cookies];
...@@ -170,13 +170,13 @@ NSString* const kIncognitoCookieValue = @"rainbow"; ...@@ -170,13 +170,13 @@ NSString* const kIncognitoCookieValue = @"rainbow";
// incognito tabs and synchronize with the UI. // incognito tabs and synchronize with the UI.
[[GREYUIThreadExecutor sharedInstance] drainUntilIdle]; [[GREYUIThreadExecutor sharedInstance] drainUntilIdle];
chrome_test_util::OpenNewTab(); [ChromeEarlGrey openNewTab];
[ChromeEarlGrey [ChromeEarlGrey
loadURL:web::test::HttpServer::MakeUrl(kTestUrlNormalBrowsing)]; loadURL:web::test::HttpServer::MakeUrl(kTestUrlNormalBrowsing)];
// Opens a new incognito tab and verify that the previously set cookie // Opens a new incognito tab and verify that the previously set cookie
// is no longer there. // is no longer there.
chrome_test_util::OpenNewIncognitoTab(); [ChromeEarlGrey openNewIncognitoTab];
[ChromeEarlGrey [ChromeEarlGrey
loadURL:web::test::HttpServer::MakeUrl(kTestUrlIncognitoBrowsing)]; loadURL:web::test::HttpServer::MakeUrl(kTestUrlIncognitoBrowsing)];
cookies = [ChromeEarlGrey cookies]; cookies = [ChromeEarlGrey cookies];
...@@ -205,7 +205,7 @@ NSString* const kIncognitoCookieValue = @"rainbow"; ...@@ -205,7 +205,7 @@ NSString* const kIncognitoCookieValue = @"rainbow";
@"Only one cookie should be found in normal mode."); @"Only one cookie should be found in normal mode.");
// Switches to a new incognito tab and verifies that cookie is not there. // Switches to a new incognito tab and verifies that cookie is not there.
chrome_test_util::OpenNewIncognitoTab(); [ChromeEarlGrey openNewIncognitoTab];
[ChromeEarlGrey [ChromeEarlGrey
loadURL:web::test::HttpServer::MakeUrl(kTestUrlIncognitoBrowsing)]; loadURL:web::test::HttpServer::MakeUrl(kTestUrlIncognitoBrowsing)];
cookies = [ChromeEarlGrey cookies]; cookies = [ChromeEarlGrey cookies];
...@@ -219,7 +219,7 @@ NSString* const kIncognitoCookieValue = @"rainbow"; ...@@ -219,7 +219,7 @@ NSString* const kIncognitoCookieValue = @"rainbow";
// incognito tabs and synchronize with the UI. // incognito tabs and synchronize with the UI.
[[GREYUIThreadExecutor sharedInstance] drainUntilIdle]; [[GREYUIThreadExecutor sharedInstance] drainUntilIdle];
chrome_test_util::OpenNewTab(); [ChromeEarlGrey openNewTab];
[ChromeEarlGrey [ChromeEarlGrey
loadURL:web::test::HttpServer::MakeUrl(kTestUrlNormalBrowsing)]; loadURL:web::test::HttpServer::MakeUrl(kTestUrlNormalBrowsing)];
cookies = [ChromeEarlGrey cookies]; cookies = [ChromeEarlGrey cookies];
...@@ -237,7 +237,7 @@ NSString* const kIncognitoCookieValue = @"rainbow"; ...@@ -237,7 +237,7 @@ NSString* const kIncognitoCookieValue = @"rainbow";
// cookie in incognito tab. // cookie in incognito tab.
[ChromeEarlGrey [ChromeEarlGrey
loadURL:web::test::HttpServer::MakeUrl(kTestUrlNormalBrowsing)]; loadURL:web::test::HttpServer::MakeUrl(kTestUrlNormalBrowsing)];
chrome_test_util::OpenNewIncognitoTab(); [ChromeEarlGrey openNewIncognitoTab];
[ChromeEarlGrey [ChromeEarlGrey
loadURL:web::test::HttpServer::MakeUrl(kTestUrlIncognitoSetCookie)]; loadURL:web::test::HttpServer::MakeUrl(kTestUrlIncognitoSetCookie)];
NSDictionary* cookies = [ChromeEarlGrey cookies]; NSDictionary* cookies = [ChromeEarlGrey cookies];
...@@ -248,7 +248,7 @@ NSString* const kIncognitoCookieValue = @"rainbow"; ...@@ -248,7 +248,7 @@ NSString* const kIncognitoCookieValue = @"rainbow";
// Switches back to a normal tab and verifies that cookie set in incognito tab // Switches back to a normal tab and verifies that cookie set in incognito tab
// is not available. // is not available.
chrome_test_util::OpenNewTab(); [ChromeEarlGrey openNewTab];
[ChromeEarlGrey [ChromeEarlGrey
loadURL:web::test::HttpServer::MakeUrl(kTestUrlNormalBrowsing)]; loadURL:web::test::HttpServer::MakeUrl(kTestUrlNormalBrowsing)];
cookies = [ChromeEarlGrey cookies]; cookies = [ChromeEarlGrey cookies];
...@@ -256,7 +256,7 @@ NSString* const kIncognitoCookieValue = @"rainbow"; ...@@ -256,7 +256,7 @@ NSString* const kIncognitoCookieValue = @"rainbow";
@"Incognito cookie should not be found in normal mode."); @"Incognito cookie should not be found in normal mode.");
// Returns back to Incognito tab and cookie is still there. // Returns back to Incognito tab and cookie is still there.
chrome_test_util::OpenNewIncognitoTab(); [ChromeEarlGrey openNewIncognitoTab];
[ChromeEarlGrey [ChromeEarlGrey
loadURL:web::test::HttpServer::MakeUrl(kTestUrlIncognitoBrowsing)]; loadURL:web::test::HttpServer::MakeUrl(kTestUrlIncognitoBrowsing)];
cookies = [ChromeEarlGrey cookies]; cookies = [ChromeEarlGrey cookies];
...@@ -279,7 +279,7 @@ NSString* const kIncognitoCookieValue = @"rainbow"; ...@@ -279,7 +279,7 @@ NSString* const kIncognitoCookieValue = @"rainbow";
@"Only one cookie should be found in normal mode."); @"Only one cookie should be found in normal mode.");
// Creates another normal tab and verifies that the cookie is also there. // Creates another normal tab and verifies that the cookie is also there.
chrome_test_util::OpenNewTab(); [ChromeEarlGrey openNewTab];
[ChromeEarlGrey [ChromeEarlGrey
loadURL:web::test::HttpServer::MakeUrl(kTestUrlNormalBrowsing)]; loadURL:web::test::HttpServer::MakeUrl(kTestUrlNormalBrowsing)];
cookies = [ChromeEarlGrey cookies]; cookies = [ChromeEarlGrey cookies];
......
...@@ -47,7 +47,7 @@ using web::test::HttpServer; ...@@ -47,7 +47,7 @@ using web::test::HttpServer;
GREYAssertTrue(chrome_test_util::ClearBrowsingHistory(), GREYAssertTrue(chrome_test_util::ClearBrowsingHistory(),
@"Clearing Browsing History timed out"); @"Clearing Browsing History timed out");
[[GREYUIThreadExecutor sharedInstance] drainUntilIdle]; [[GREYUIThreadExecutor sharedInstance] drainUntilIdle];
chrome_test_util::OpenNewTab(); [ChromeEarlGrey openNewTab];
[[EarlGrey selectElementWithMatcher: [[EarlGrey selectElementWithMatcher:
chrome_test_util::StaticTextWithAccessibilityLabel(@"title1")] chrome_test_util::StaticTextWithAccessibilityLabel(@"title1")]
...@@ -59,9 +59,7 @@ using web::test::HttpServer; ...@@ -59,9 +59,7 @@ using web::test::HttpServer;
// with the icon present. // with the icon present.
[ChromeEarlGrey goBack]; [ChromeEarlGrey goBack];
chrome_test_util::OpenNewTab(); [ChromeEarlGrey openNewTab];
// New tab page is not loaded within a single tick so wait before assert.
[ChromeEarlGrey waitForPageToFinishLoading];
[[EarlGrey selectElementWithMatcher: [[EarlGrey selectElementWithMatcher:
chrome_test_util::StaticTextWithAccessibilityLabel(@"title1")] chrome_test_util::StaticTextWithAccessibilityLabel(@"title1")]
...@@ -95,7 +93,7 @@ using web::test::HttpServer; ...@@ -95,7 +93,7 @@ using web::test::HttpServer;
GREYAssertTrue(chrome_test_util::ClearBrowsingHistory(), GREYAssertTrue(chrome_test_util::ClearBrowsingHistory(),
@"Clearing Browsing History timed out"); @"Clearing Browsing History timed out");
[[GREYUIThreadExecutor sharedInstance] drainUntilIdle]; [[GREYUIThreadExecutor sharedInstance] drainUntilIdle];
chrome_test_util::OpenNewTab(); [ChromeEarlGrey openNewTab];
[[EarlGrey selectElementWithMatcher: [[EarlGrey selectElementWithMatcher:
chrome_test_util::StaticTextWithAccessibilityLabel(@"title2")] chrome_test_util::StaticTextWithAccessibilityLabel(@"title2")]
assertWithMatcher:grey_nil()]; assertWithMatcher:grey_nil()];
...@@ -107,7 +105,7 @@ using web::test::HttpServer; ...@@ -107,7 +105,7 @@ using web::test::HttpServer;
// After loading URL, need to do another action before opening a new tab // After loading URL, need to do another action before opening a new tab
// with the icon present. // with the icon present.
[ChromeEarlGrey goBack]; [ChromeEarlGrey goBack];
chrome_test_util::OpenNewTab(); [ChromeEarlGrey openNewTab];
// Which of the two tiles that is displayed is an implementation detail, and // Which of the two tiles that is displayed is an implementation detail, and
// this test helps document it. The purpose of the test is to verify that only // this test helps document it. The purpose of the test is to verify that only
......
...@@ -76,8 +76,7 @@ std::unique_ptr<net::test_server::HttpResponse> StandardResponse( ...@@ -76,8 +76,7 @@ std::unique_ptr<net::test_server::HttpResponse> StandardResponse(
[ChromeEarlGrey loadURL:pageURL]; [ChromeEarlGrey loadURL:pageURL];
[ChromeEarlGrey goBack]; [ChromeEarlGrey goBack];
[[self class] closeAllTabs]; [[self class] closeAllTabs];
chrome_test_util::OpenNewTab(); [ChromeEarlGrey openNewTab];
[[GREYUIThreadExecutor sharedInstance] drainUntilIdle];
[[EarlGrey [[EarlGrey
selectElementWithMatcher:grey_accessibilityID( selectElementWithMatcher:grey_accessibilityID(
...@@ -89,8 +88,7 @@ std::unique_ptr<net::test_server::HttpResponse> StandardResponse( ...@@ -89,8 +88,7 @@ std::unique_ptr<net::test_server::HttpResponse> StandardResponse(
performAction:grey_typeText([pageString stringByAppendingString:@"\n"])]; performAction:grey_typeText([pageString stringByAppendingString:@"\n"])];
[ChromeEarlGrey waitForPageToFinishLoading]; [ChromeEarlGrey waitForPageToFinishLoading];
[[self class] closeAllTabs]; [[self class] closeAllTabs];
chrome_test_util::OpenNewTab(); [ChromeEarlGrey openNewTab];
[[GREYUIThreadExecutor sharedInstance] drainUntilIdle];
// Type the begining of the address to have the autocomplete suggestion. // Type the begining of the address to have the autocomplete suggestion.
[[EarlGrey [[EarlGrey
......
...@@ -739,7 +739,7 @@ using translate::LanguageDetectionController; ...@@ -739,7 +739,7 @@ using translate::LanguageDetectionController;
} }
// Do a translation in incognito // Do a translation in incognito
chrome_test_util::OpenNewIncognitoTab(); [ChromeEarlGrey openNewIncognitoTab];
[ChromeEarlGrey loadURL:URL]; [ChromeEarlGrey loadURL:URL];
[self simulateTranslationFromSpanishToEnglish]; [self simulateTranslationFromSpanishToEnglish];
// Check that the infobar does not contain the "Always Translate" switch. // Check that the infobar does not contain the "Always Translate" switch.
......
...@@ -278,7 +278,7 @@ id<GREYMatcher> SearchIconButton() { ...@@ -278,7 +278,7 @@ id<GREYMatcher> SearchIconButton() {
const GURL secondURL = web::test::HttpServer::MakeUrl( const GURL secondURL = web::test::HttpServer::MakeUrl(
"http://ios/testing/data/http_server_files/destination.html"); "http://ios/testing/data/http_server_files/destination.html");
[ChromeEarlGrey loadURL:firstURL]; [ChromeEarlGrey loadURL:firstURL];
chrome_test_util::OpenNewTab(); [ChromeEarlGrey openNewTab];
[ChromeEarlGrey loadURL:secondURL]; [ChromeEarlGrey loadURL:secondURL];
[BookmarksTestCase bookmarkCurrentTabWithTitle:@"my bookmark"]; [BookmarksTestCase bookmarkCurrentTabWithTitle:@"my bookmark"];
...@@ -2115,7 +2115,7 @@ id<GREYMatcher> SearchIconButton() { ...@@ -2115,7 +2115,7 @@ id<GREYMatcher> SearchIconButton() {
[BookmarksTestCase verifyOrderOfTabsWithCurrentTabIndex:0]; [BookmarksTestCase verifyOrderOfTabsWithCurrentTabIndex:0];
// Switch to Incognito mode by adding a new incognito tab. // Switch to Incognito mode by adding a new incognito tab.
chrome_test_util::OpenNewIncognitoTab(); [ChromeEarlGrey openNewIncognitoTab];
[BookmarksTestCase openBookmarks]; [BookmarksTestCase openBookmarks];
......
...@@ -503,10 +503,7 @@ GREYElementInteraction* CellWithMatcher(id<GREYMatcher> matcher) { ...@@ -503,10 +503,7 @@ GREYElementInteraction* CellWithMatcher(id<GREYMatcher> matcher) {
[ChromeEarlGrey goBack]; [ChromeEarlGrey goBack];
[[self class] closeAllTabs]; [[self class] closeAllTabs];
chrome_test_util::OpenNewTab(); [ChromeEarlGrey openNewTab];
// TODO(crbug.com/783192): ChromeEarlGrey should have a method to open a new
// tab and synchronize with the UI.
[[GREYUIThreadExecutor sharedInstance] drainUntilIdle];
[[EarlGrey selectElementWithMatcher: [[EarlGrey selectElementWithMatcher:
chrome_test_util::StaticTextWithAccessibilityLabel(pageTitle)] chrome_test_util::StaticTextWithAccessibilityLabel(pageTitle)]
......
...@@ -577,7 +577,7 @@ std::unique_ptr<net::test_server::HttpResponse> StandardResponse( ...@@ -577,7 +577,7 @@ std::unique_ptr<net::test_server::HttpResponse> StandardResponse(
// with the icon present. // with the icon present.
[ChromeEarlGrey goBack]; [ChromeEarlGrey goBack];
[[self class] closeAllTabs]; [[self class] closeAllTabs];
chrome_test_util::OpenNewTab(); [ChromeEarlGrey openNewTab];
} }
@end @end
...@@ -114,9 +114,7 @@ bool WaitForDownloadButton() { ...@@ -114,9 +114,7 @@ bool WaitForDownloadButton() {
// presented. EarlGrey does not allow testing "Open in..." dialog, because it // presented. EarlGrey does not allow testing "Open in..." dialog, because it
// is run in a separate process. Performs download in Incognito. // is run in a separate process. Performs download in Incognito.
- (void)testSucessfullDownloadInIncognito { - (void)testSucessfullDownloadInIncognito {
chrome_test_util::OpenNewIncognitoTab(); [ChromeEarlGrey openNewIncognitoTab];
[[GREYUIThreadExecutor sharedInstance] drainUntilIdle];
[ChromeEarlGrey loadURL:self.testServer->GetURL("/")]; [ChromeEarlGrey loadURL:self.testServer->GetURL("/")];
[ChromeEarlGrey waitForWebViewContainingText:"Download"]; [ChromeEarlGrey waitForWebViewContainingText:"Download"];
[ChromeEarlGrey tapWebViewElementWithID:@"download"]; [ChromeEarlGrey tapWebViewElementWithID:@"download"];
...@@ -164,8 +162,7 @@ bool WaitForDownloadButton() { ...@@ -164,8 +162,7 @@ bool WaitForDownloadButton() {
// does not wait until the download progress bar becomes idle (which will // does not wait until the download progress bar becomes idle (which will
// not happen until the download is complete). // not happen until the download is complete).
ScopedSynchronizationDisabler disabler; ScopedSynchronizationDisabler disabler;
chrome_test_util::OpenNewTab(); [ChromeEarlGrey openNewTab];
[[GREYUIThreadExecutor sharedInstance] drainUntilIdle];
} }
// Load a URL in a separate Tab and close that tab. // Load a URL in a separate Tab and close that tab.
......
...@@ -133,7 +133,7 @@ void VerifyNumberOfInfobarsInManager(size_t number_of_infobars) { ...@@ -133,7 +133,7 @@ void VerifyNumberOfInfobarsInManager(size_t number_of_infobars) {
NSString* infoBarMessage = @"TestInfoBar"; NSString* infoBarMessage = @"TestInfoBar";
// Create the second tab, navigate to the test page, and add the test infobar. // Create the second tab, navigate to the test page, and add the test infobar.
chrome_test_util::OpenNewTab(); [ChromeEarlGrey openNewTab];
[ChromeEarlGrey loadURL:ponyURL]; [ChromeEarlGrey loadURL:ponyURL];
[ChromeEarlGrey waitForMainTabCount:2]; [ChromeEarlGrey waitForMainTabCount:2];
VerifyTestInfoBarVisibleForCurrentTab(false, infoBarMessage); VerifyTestInfoBarVisibleForCurrentTab(false, infoBarMessage);
......
...@@ -18,6 +18,7 @@ ...@@ -18,6 +18,7 @@
#import "ios/chrome/test/app/chrome_test_util.h" #import "ios/chrome/test/app/chrome_test_util.h"
#import "ios/chrome/test/app/tab_test_util.h" #import "ios/chrome/test/app/tab_test_util.h"
#import "ios/chrome/test/earl_grey/accessibility_util.h" #import "ios/chrome/test/earl_grey/accessibility_util.h"
#import "ios/chrome/test/earl_grey/chrome_earl_grey.h"
#import "ios/chrome/test/earl_grey/chrome_matchers.h" #import "ios/chrome/test/earl_grey/chrome_matchers.h"
#import "ios/chrome/test/earl_grey/chrome_test_case.h" #import "ios/chrome/test/earl_grey/chrome_test_case.h"
#include "ui/base/l10n/l10n_util.h" #include "ui/base/l10n/l10n_util.h"
...@@ -61,7 +62,7 @@ void WaitForHistoryToDisappear() { ...@@ -61,7 +62,7 @@ void WaitForHistoryToDisappear() {
// Tests that all items are accessible on the incognito page. // Tests that all items are accessible on the incognito page.
- (void)testAccessibilityOnIncognitoTab { - (void)testAccessibilityOnIncognitoTab {
chrome_test_util::OpenNewIncognitoTab(); [ChromeEarlGrey openNewIncognitoTab];
WaitForHistoryToDisappear(); WaitForHistoryToDisappear();
chrome_test_util::VerifyAccessibilityForCurrentScreen(); chrome_test_util::VerifyAccessibilityForCurrentScreen();
GREYAssert(chrome_test_util::CloseAllIncognitoTabs(), @"Tabs did not close"); GREYAssert(chrome_test_util::CloseAllIncognitoTabs(), @"Tabs did not close");
......
...@@ -44,7 +44,7 @@ NSString* const kTitleOfTestPage = @"TestPageTitle"; ...@@ -44,7 +44,7 @@ NSString* const kTitleOfTestPage = @"TestPageTitle";
void OpenRecentTabsPanel() { void OpenRecentTabsPanel() {
// At least one tab is needed to be able to open the recent tabs panel. // At least one tab is needed to be able to open the recent tabs panel.
if (chrome_test_util::GetMainTabCount() == 0) if (chrome_test_util::GetMainTabCount() == 0)
chrome_test_util::OpenNewTab(); [ChromeEarlGrey openNewTab];
[ChromeEarlGreyUI openToolsMenu]; [ChromeEarlGreyUI openToolsMenu];
[ChromeEarlGreyUI tapToolsMenuButton:RecentTabsMenuButton()]; [ChromeEarlGreyUI tapToolsMenuButton:RecentTabsMenuButton()];
......
...@@ -607,8 +607,7 @@ bool IsCertificateCleared() { ...@@ -607,8 +607,7 @@ bool IsCertificateCleared() {
// Verifies that Settings opens when signed-out and in Incognito mode. // Verifies that Settings opens when signed-out and in Incognito mode.
// This tests that crbug.com/607335 has not regressed. // This tests that crbug.com/607335 has not regressed.
- (void)testSettingsSignedOutIncognito { - (void)testSettingsSignedOutIncognito {
chrome_test_util::OpenNewIncognitoTab(); [ChromeEarlGrey openNewIncognitoTab];
[ChromeEarlGreyUI openSettingsMenu]; [ChromeEarlGreyUI openSettingsMenu];
[[EarlGrey selectElementWithMatcher:SettingsCollectionView()] [[EarlGrey selectElementWithMatcher:SettingsCollectionView()]
assertWithMatcher:grey_notNil()]; assertWithMatcher:grey_notNil()];
......
...@@ -373,7 +373,7 @@ void AssertNumberOfEntitiesWithName(int entity_count, ...@@ -373,7 +373,7 @@ void AssertNumberOfEntitiesWithName(int entity_count,
// Load both URLs in separate tabs. // Load both URLs in separate tabs.
[ChromeEarlGrey loadURL:URL1]; [ChromeEarlGrey loadURL:URL1];
chrome_test_util::OpenNewTab(); [ChromeEarlGrey openNewTab];
[ChromeEarlGrey loadURL:URL2]; [ChromeEarlGrey loadURL:URL2];
// Sign in to sync, after opening two tabs. // Sign in to sync, after opening two tabs.
......
...@@ -765,7 +765,7 @@ void FocusOmnibox() { ...@@ -765,7 +765,7 @@ void FocusOmnibox() {
[[GREYUIThreadExecutor sharedInstance] drainUntilIdleWithTimeout:2]; [[GREYUIThreadExecutor sharedInstance] drainUntilIdleWithTimeout:2];
[[self class] closeAllTabs]; [[self class] closeAllTabs];
chrome_test_util::OpenNewTab(); [ChromeEarlGrey openNewTab];
// Check that the bottom toolbar is visible. // Check that the bottom toolbar is visible.
[[EarlGrey selectElementWithMatcher:SearchButton()] [[EarlGrey selectElementWithMatcher:SearchButton()]
......
...@@ -124,7 +124,7 @@ const char kLinksTestURL2Text[] = "arrived"; ...@@ -124,7 +124,7 @@ const char kLinksTestURL2Text[] = "arrived";
// Add a non-owned tab. It should be added at the end and marked as the // Add a non-owned tab. It should be added at the end and marked as the
// current tab. Next tab should wrap back to index 0, the original parent tab. // current tab. Next tab should wrap back to index 0, the original parent tab.
chrome_test_util::OpenNewTab(); [ChromeEarlGrey openNewTab];
[ChromeEarlGrey waitForMainTabCount:6U]; [ChromeEarlGrey waitForMainTabCount:6U];
GREYAssertEqual(parentTab, chrome_test_util::GetNextTab(), GREYAssertEqual(parentTab, chrome_test_util::GetNextTab(),
@"Unexpected next tab"); @"Unexpected next tab");
......
...@@ -139,7 +139,7 @@ id<GREYMatcher> PopupBlocker() { ...@@ -139,7 +139,7 @@ id<GREYMatcher> PopupBlocker() {
[[EarlGrey selectElementWithMatcher:test_page_matcher] [[EarlGrey selectElementWithMatcher:test_page_matcher]
performAction:link_tap]; performAction:link_tap];
[ChromeEarlGrey waitForMainTabCount:2]; [ChromeEarlGrey waitForMainTabCount:2];
chrome_test_util::OpenNewTab(); [ChromeEarlGrey openNewTab];
[ChromeEarlGrey waitForMainTabCount:3]; [ChromeEarlGrey waitForMainTabCount:3];
chrome_test_util::SelectTabAtIndexInCurrentMode(0); chrome_test_util::SelectTabAtIndexInCurrentMode(0);
[[EarlGrey selectElementWithMatcher:test_page_matcher] [[EarlGrey selectElementWithMatcher:test_page_matcher]
......
...@@ -61,6 +61,9 @@ id ExecuteJavaScript(NSString* javascript, NSError* __autoreleasing* out_error); ...@@ -61,6 +61,9 @@ id ExecuteJavaScript(NSString* javascript, NSError* __autoreleasing* out_error);
// Opens a new tab and waits for the new tab animation to complete. // Opens a new tab and waits for the new tab animation to complete.
+ (void)openNewTab; + (void)openNewTab;
// Opens a new incognito tab and waits for the new tab animation to complete.
+ (void)openNewIncognitoTab;
// Waits for the page to finish loading within a timeout, or a GREYAssert is // Waits for the page to finish loading within a timeout, or a GREYAssert is
// induced. // induced.
+ (void)waitForPageToFinishLoading; + (void)waitForPageToFinishLoading;
......
...@@ -133,6 +133,13 @@ id ExecuteJavaScript(NSString* javascript, ...@@ -133,6 +133,13 @@ id ExecuteJavaScript(NSString* javascript,
+ (void)openNewTab { + (void)openNewTab {
chrome_test_util::OpenNewTab(); chrome_test_util::OpenNewTab();
[ChromeEarlGrey waitForPageToFinishLoading];
[[GREYUIThreadExecutor sharedInstance] drainUntilIdle];
}
+ (void)openNewIncognitoTab {
chrome_test_util::OpenNewIncognitoTab();
[ChromeEarlGrey waitForPageToFinishLoading];
[[GREYUIThreadExecutor sharedInstance] drainUntilIdle]; [[GREYUIThreadExecutor sharedInstance] drainUntilIdle];
} }
......
...@@ -19,6 +19,7 @@ ...@@ -19,6 +19,7 @@
#include "ios/chrome/test/app/signin_test_util.h" #include "ios/chrome/test/app/signin_test_util.h"
#import "ios/chrome/test/app/sync_test_util.h" #import "ios/chrome/test/app/sync_test_util.h"
#import "ios/chrome/test/app/tab_test_util.h" #import "ios/chrome/test/app/tab_test_util.h"
#import "ios/chrome/test/earl_grey/chrome_earl_grey.h"
#import "ios/web/public/test/http_server/http_server.h" #import "ios/web/public/test/http_server/http_server.h"
#include "testing/coverage_util_ios.h" #include "testing/coverage_util_ios.h"
...@@ -194,8 +195,7 @@ const CFTimeInterval kDrainTimeout = 5; ...@@ -194,8 +195,7 @@ const CFTimeInterval kDrainTimeout = 5;
chrome_test_util::ResetSigninPromoPreferences(); chrome_test_util::ResetSigninPromoPreferences();
chrome_test_util::ResetMockAuthentication(); chrome_test_util::ResetMockAuthentication();
chrome_test_util::OpenNewTab(); [ChromeEarlGrey openNewTab];
[[GREYUIThreadExecutor sharedInstance] drainUntilIdle];
} }
// Tear down called once per test, to close all tabs and menus, and clear the // Tear down called once per test, to close all tabs and menus, and clear the
......
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