Commit 911726ec authored by Maksym Onufriienko's avatar Maksym Onufriienko Committed by Commit Bot

Used navigation_test_util#LoadUrl and #IsLoading in ChromeEarlGrey only.

Not called navigation_test_util methods directly from EG tests,
instead use [ChromeEarlGrey loadUrl],
[ChromeEarlGrey loadUrlWithoutWaitingForContent]
and [ChromeEarlGrey isLoading].
Also removed unused "ios/chrome/test/app/navigation_test_util.h" imports
through EG-tests.

This is part of EG1 to EG2 migration, which involves moving EarlGrey code from
app-side helpers into test code. For GREYAsserts, the policy is to take assert-
containing-helpers, modify them to return NSError* with localizedDescription
containing the assert failure (in the event of a failure), and then assert
on the result of the helper on the test side.

Note.
There is a usage of navigation_test_util in ios_internal
https://chrome-internal-review.googlesource.com/c/chrome/ios_internal/+/1240877
will submit it after this cl

Bug: 922813
Change-Id: Iafad97e8c0f7904e34a2af3292fbc03dfb505130
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1590707
Commit-Queue: Maksym Onufriienko <monufriienko@chromium.org>
Reviewed-by: default avatarEugene But <eugenebut@chromium.org>
Cr-Commit-Position: refs/heads/master@{#660882}
parent 0a2e826a
...@@ -20,7 +20,6 @@ ...@@ -20,7 +20,6 @@
#import "ios/chrome/browser/ui/util/uikit_ui_util.h" #import "ios/chrome/browser/ui/util/uikit_ui_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/histogram_test_util.h" #import "ios/chrome/test/app/histogram_test_util.h"
#include "ios/chrome/test/app/navigation_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/app/web_view_interaction_test_util.h" #import "ios/chrome/test/app/web_view_interaction_test_util.h"
#import "ios/chrome/test/earl_grey/chrome_actions.h" #import "ios/chrome/test/earl_grey/chrome_actions.h"
...@@ -396,7 +395,8 @@ void CloseTabAtIndexAndSync(NSUInteger i) { ...@@ -396,7 +395,8 @@ void CloseTabAtIndexAndSync(NSUInteger i) {
// A blank tab needed to switch to it after reloading. // A blank tab needed to switch to it after reloading.
CHROME_EG_ASSERT_NO_ERROR([ChromeEarlGrey openNewTab]); CHROME_EG_ASSERT_NO_ERROR([ChromeEarlGrey openNewTab]);
CHROME_EG_ASSERT_NO_ERROR([ChromeEarlGrey openNewTab]); CHROME_EG_ASSERT_NO_ERROR([ChromeEarlGrey openNewTab]);
chrome_test_util::LoadUrl(slowURL); CHROME_EG_ASSERT_NO_ERROR([ChromeEarlGrey loadURL:slowURL
waitForCompletion:NO]);
CHROME_EG_ASSERT_NO_ERROR(OpenNewIncognitoTabUsingUIAndEvictMainTabs()); CHROME_EG_ASSERT_NO_ERROR(OpenNewIncognitoTabUsingUIAndEvictMainTabs());
web::test::SetUpHttpServer(std::make_unique<web::DelayedResponseProvider>( web::test::SetUpHttpServer(std::make_unique<web::DelayedResponseProvider>(
...@@ -416,7 +416,7 @@ void CloseTabAtIndexAndSync(NSUInteger i) { ...@@ -416,7 +416,7 @@ void CloseTabAtIndexAndSync(NSUInteger i) {
GREYAssert( GREYAssert(
[[GREYCondition conditionWithName:@"Wait for tab to restart loading." [[GREYCondition conditionWithName:@"Wait for tab to restart loading."
block:^BOOL() { block:^BOOL() {
return chrome_test_util::IsLoading(); return [ChromeEarlGrey isLoading];
}] waitWithTimeout:kWaitElementTimeout], }] waitWithTimeout:kWaitElementTimeout],
@"Tab did not start loading."); @"Tab did not start loading.");
[[GREYConfiguration sharedInstance] [[GREYConfiguration sharedInstance]
...@@ -528,8 +528,8 @@ void CloseTabAtIndexAndSync(NSUInteger i) { ...@@ -528,8 +528,8 @@ void CloseTabAtIndexAndSync(NSUInteger i) {
chrome_test_util::HistogramTester histogramTester; chrome_test_util::HistogramTester histogramTester;
CHROME_EG_ASSERT_NO_ERROR([ChromeEarlGrey openNewTab]); CHROME_EG_ASSERT_NO_ERROR([ChromeEarlGrey openNewTab]);
chrome_test_util::LoadUrl(slowURL); CHROME_EG_ASSERT_NO_ERROR([ChromeEarlGrey loadURL:slowURL
waitForCompletion:NO]);
CHROME_EG_ASSERT_NO_ERROR(OpenNewIncognitoTabUsingUIAndEvictMainTabs()); CHROME_EG_ASSERT_NO_ERROR(OpenNewIncognitoTabUsingUIAndEvictMainTabs());
web::test::SetUpHttpServer(std::make_unique<web::DelayedResponseProvider>( web::test::SetUpHttpServer(std::make_unique<web::DelayedResponseProvider>(
...@@ -585,7 +585,8 @@ void CloseTabAtIndexAndSync(NSUInteger i) { ...@@ -585,7 +585,8 @@ void CloseTabAtIndexAndSync(NSUInteger i) {
[[GREYConfiguration sharedInstance] [[GREYConfiguration sharedInstance]
setValue:@(NO) setValue:@(NO)
forConfigKey:kGREYConfigKeySynchronizationEnabled]; forConfigKey:kGREYConfigKeySynchronizationEnabled];
chrome_test_util::LoadUrl(slowURL); CHROME_EG_ASSERT_NO_ERROR([ChromeEarlGrey loadURL:slowURL
waitForCompletion:NO]);
// Ensure loading starts but is not finished. // Ensure loading starts but is not finished.
base::test::ios::SpinRunLoopWithMaxDelay(base::TimeDelta::FromSeconds(1)); base::test::ios::SpinRunLoopWithMaxDelay(base::TimeDelta::FromSeconds(1));
......
...@@ -27,7 +27,6 @@ ...@@ -27,7 +27,6 @@
#include "ios/chrome/browser/translate/chrome_ios_translate_client.h" #include "ios/chrome/browser/translate/chrome_ios_translate_client.h"
#include "ios/chrome/browser/ui/translate/language_selection_view_controller.h" #include "ios/chrome/browser/ui/translate/language_selection_view_controller.h"
#import "ios/chrome/test/app/chrome_test_util.h" #import "ios/chrome/test/app/chrome_test_util.h"
#include "ios/chrome/test/app/navigation_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/app/web_view_interaction_test_util.h" #import "ios/chrome/test/app/web_view_interaction_test_util.h"
#import "ios/chrome/test/earl_grey/chrome_earl_grey.h" #import "ios/chrome/test/earl_grey/chrome_earl_grey.h"
......
...@@ -10,7 +10,6 @@ ...@@ -10,7 +10,6 @@
#import "ios/chrome/browser/ui/util/uikit_ui_util.h" #import "ios/chrome/browser/ui/util/uikit_ui_util.h"
#include "ios/chrome/grit/ios_strings.h" #include "ios/chrome/grit/ios_strings.h"
#import "ios/chrome/test/app/chrome_test_util.h" #import "ios/chrome/test/app/chrome_test_util.h"
#include "ios/chrome/test/app/navigation_test_util.h"
#import "ios/chrome/test/earl_grey/chrome_earl_grey.h" #import "ios/chrome/test/earl_grey/chrome_earl_grey.h"
#import "ios/chrome/test/earl_grey/chrome_earl_grey_ui.h" #import "ios/chrome/test/earl_grey/chrome_earl_grey_ui.h"
#import "ios/chrome/test/earl_grey/chrome_error_util.h" #import "ios/chrome/test/earl_grey/chrome_error_util.h"
...@@ -58,7 +57,7 @@ const char kHTMLURL[] = "http://test"; ...@@ -58,7 +57,7 @@ const char kHTMLURL[] = "http://test";
responses[url] = response; responses[url] = response;
web::test::SetUpSimpleHttpServer(responses); web::test::SetUpSimpleHttpServer(responses);
chrome_test_util::LoadUrl(url); CHROME_EG_ASSERT_NO_ERROR([ChromeEarlGrey loadURL:url]);
CHROME_EG_ASSERT_NO_ERROR( CHROME_EG_ASSERT_NO_ERROR(
[ChromeEarlGrey waitForWebViewContainingText:response]); [ChromeEarlGrey waitForWebViewContainingText:response]);
...@@ -72,7 +71,7 @@ const char kHTMLURL[] = "http://test"; ...@@ -72,7 +71,7 @@ const char kHTMLURL[] = "http://test";
web::test::SetUpFileBasedHttpServer(); web::test::SetUpFileBasedHttpServer();
GURL url = web::test::HttpServer::MakeUrl(kPDFURL); GURL url = web::test::HttpServer::MakeUrl(kPDFURL);
chrome_test_util::LoadUrl(url); CHROME_EG_ASSERT_NO_ERROR([ChromeEarlGrey loadURL:url waitForCompletion:NO]);
[self printCurrentPage]; [self printCurrentPage];
} }
......
...@@ -28,7 +28,6 @@ ...@@ -28,7 +28,6 @@
#include "ios/chrome/grit/ios_strings.h" #include "ios/chrome/grit/ios_strings.h"
#include "ios/chrome/grit/ios_theme_resources.h" #include "ios/chrome/grit/ios_theme_resources.h"
#import "ios/chrome/test/app/chrome_test_util.h" #import "ios/chrome/test/app/chrome_test_util.h"
#include "ios/chrome/test/app/navigation_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_earl_grey.h"
......
...@@ -8,7 +8,6 @@ ...@@ -8,7 +8,6 @@
#include "components/strings/grit/components_strings.h" #include "components/strings/grit/components_strings.h"
#import "ios/chrome/browser/ui/popup_menu/popup_menu_constants.h" #import "ios/chrome/browser/ui/popup_menu/popup_menu_constants.h"
#import "ios/chrome/test/app/chrome_test_util.h" #import "ios/chrome/test/app/chrome_test_util.h"
#import "ios/chrome/test/app/navigation_test_util.h"
#import "ios/chrome/test/earl_grey/chrome_earl_grey.h" #import "ios/chrome/test/earl_grey/chrome_earl_grey.h"
#import "ios/chrome/test/earl_grey/chrome_earl_grey_ui.h" #import "ios/chrome/test/earl_grey/chrome_earl_grey_ui.h"
#import "ios/chrome/test/earl_grey/chrome_error_util.h" #import "ios/chrome/test/earl_grey/chrome_error_util.h"
...@@ -105,10 +104,9 @@ id<GREYMatcher> incognitoHelpContainsText() { ...@@ -105,10 +104,9 @@ id<GREYMatcher> incognitoHelpContainsText() {
loadAndCheckSimpleURL(); loadAndCheckSimpleURL();
// Navigate to the chrome://crash URL which should show the Sad Tab. // Navigate to the chrome://crash URL which should show the Sad Tab.
// Use chrome_test_util::LoadURL() directly to avoid ChomeEarlGrey helper
// methods which expect to wait for web content.
const GURL crash_URL = GURL("chrome://crash"); const GURL crash_URL = GURL("chrome://crash");
chrome_test_util::LoadUrl(crash_URL); CHROME_EG_ASSERT_NO_ERROR([ChromeEarlGrey loadURL:crash_URL
waitForCompletion:NO]);
[[EarlGrey selectElementWithMatcher:reloadSadTabTitleText()] [[EarlGrey selectElementWithMatcher:reloadSadTabTitleText()]
assertWithMatcher:grey_notNil()]; assertWithMatcher:grey_notNil()];
...@@ -119,7 +117,8 @@ id<GREYMatcher> incognitoHelpContainsText() { ...@@ -119,7 +117,8 @@ id<GREYMatcher> incognitoHelpContainsText() {
// A second visit to the crashing URL should show a feedback message. // A second visit to the crashing URL should show a feedback message.
// It should also show help messages including an invitation to use // It should also show help messages including an invitation to use
// Incognito Mode. // Incognito Mode.
chrome_test_util::LoadUrl(crash_URL); CHROME_EG_ASSERT_NO_ERROR([ChromeEarlGrey loadURL:crash_URL
waitForCompletion:NO]);
[[EarlGrey selectElementWithMatcher:feedbackSadTabTitleContainsText()] [[EarlGrey selectElementWithMatcher:feedbackSadTabTitleContainsText()]
assertWithMatcher:grey_notNil()]; assertWithMatcher:grey_notNil()];
[[EarlGrey selectElementWithMatcher:incognitoHelpContainsText()] [[EarlGrey selectElementWithMatcher:incognitoHelpContainsText()]
...@@ -141,10 +140,12 @@ id<GREYMatcher> incognitoHelpContainsText() { ...@@ -141,10 +140,12 @@ id<GREYMatcher> incognitoHelpContainsText() {
// Test an initial crash, and then a second crash in Incognito mode, as above. // Test an initial crash, and then a second crash in Incognito mode, as above.
// Incognito mode should not be suggested if already in Incognito mode. // Incognito mode should not be suggested if already in Incognito mode.
chrome_test_util::LoadUrl(crash_URL); CHROME_EG_ASSERT_NO_ERROR([ChromeEarlGrey loadURL:crash_URL
waitForCompletion:NO]);
[[EarlGrey selectElementWithMatcher:reloadSadTabTitleText()] [[EarlGrey selectElementWithMatcher:reloadSadTabTitleText()]
assertWithMatcher:grey_notNil()]; assertWithMatcher:grey_notNil()];
chrome_test_util::LoadUrl(crash_URL); CHROME_EG_ASSERT_NO_ERROR([ChromeEarlGrey loadURL:crash_URL
waitForCompletion:NO]);
[[EarlGrey selectElementWithMatcher:feedbackSadTabTitleContainsText()] [[EarlGrey selectElementWithMatcher:feedbackSadTabTitleContainsText()]
assertWithMatcher:grey_notNil()]; assertWithMatcher:grey_notNil()];
[[EarlGrey selectElementWithMatcher:incognitoHelpContainsText()] [[EarlGrey selectElementWithMatcher:incognitoHelpContainsText()]
......
...@@ -12,7 +12,6 @@ ...@@ -12,7 +12,6 @@
#include "ios/chrome/browser/content_settings/host_content_settings_map_factory.h" #include "ios/chrome/browser/content_settings/host_content_settings_map_factory.h"
#include "ios/chrome/grit/ios_strings.h" #include "ios/chrome/grit/ios_strings.h"
#import "ios/chrome/test/app/chrome_test_util.h" #import "ios/chrome/test/app/chrome_test_util.h"
#include "ios/chrome/test/app/navigation_test_util.h"
#import "ios/chrome/test/app/web_view_interaction_test_util.h" #import "ios/chrome/test/app/web_view_interaction_test_util.h"
#include "ios/chrome/test/earl_grey/accessibility_util.h" #include "ios/chrome/test/earl_grey/accessibility_util.h"
#import "ios/chrome/test/earl_grey/chrome_actions.h" #import "ios/chrome/test/earl_grey/chrome_actions.h"
......
...@@ -27,7 +27,6 @@ ...@@ -27,7 +27,6 @@
#include "ios/chrome/grit/ios_strings.h" #include "ios/chrome/grit/ios_strings.h"
#include "ios/chrome/grit/ios_theme_resources.h" #include "ios/chrome/grit/ios_theme_resources.h"
#import "ios/chrome/test/app/chrome_test_util.h" #import "ios/chrome/test/app/chrome_test_util.h"
#include "ios/chrome/test/app/navigation_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/app/web_view_interaction_test_util.h" #import "ios/chrome/test/app/web_view_interaction_test_util.h"
#include "ios/chrome/test/earl_grey/accessibility_util.h" #include "ios/chrome/test/earl_grey/accessibility_util.h"
......
...@@ -13,7 +13,6 @@ ...@@ -13,7 +13,6 @@
#include "ios/chrome/browser/chrome_url_constants.h" #include "ios/chrome/browser/chrome_url_constants.h"
#include "ios/chrome/browser/system_flags.h" #include "ios/chrome/browser/system_flags.h"
#import "ios/chrome/browser/ui/omnibox/omnibox_text_field_ios.h" #import "ios/chrome/browser/ui/omnibox/omnibox_text_field_ios.h"
#include "ios/chrome/test/app/navigation_test_util.h"
#import "ios/chrome/test/app/web_view_interaction_test_util.h" #import "ios/chrome/test/app/web_view_interaction_test_util.h"
#import "ios/chrome/test/earl_grey/chrome_earl_grey.h" #import "ios/chrome/test/earl_grey/chrome_earl_grey.h"
#import "ios/chrome/test/earl_grey/chrome_earl_grey_ui.h" #import "ios/chrome/test/earl_grey/chrome_earl_grey_ui.h"
...@@ -198,7 +197,7 @@ id<GREYMatcher> WaitForOmniboxText(std::string text) { ...@@ -198,7 +197,7 @@ id<GREYMatcher> WaitForOmniboxText(std::string text) {
- (void)testChromeURLInvalid { - (void)testChromeURLInvalid {
// Navigate to the native error page chrome://invalidchromeurl. // Navigate to the native error page chrome://invalidchromeurl.
const std::string kChromeInvalidURL = "chrome://invalidchromeurl"; const std::string kChromeInvalidURL = "chrome://invalidchromeurl";
chrome_test_util::LoadUrl(GURL(kChromeInvalidURL)); CHROME_EG_ASSERT_NO_ERROR([ChromeEarlGrey loadURL:GURL(kChromeInvalidURL)]);
// Verify that the resulting page is an error page. // Verify that the resulting page is an error page.
[[EarlGrey selectElementWithMatcher:WaitForOmniboxText(kChromeInvalidURL)] [[EarlGrey selectElementWithMatcher:WaitForOmniboxText(kChromeInvalidURL)]
......
...@@ -345,6 +345,7 @@ source_set("eg_tests") { ...@@ -345,6 +345,7 @@ source_set("eg_tests") {
"//ios/chrome/browser/ui/commands", "//ios/chrome/browser/ui/commands",
"//ios/chrome/browser/ui/popup_menu:constants", "//ios/chrome/browser/ui/popup_menu:constants",
"//ios/chrome/browser/ui/util", "//ios/chrome/browser/ui/util",
"//ios/chrome/test:eg_test_support",
"//ios/chrome/test:test_support", "//ios/chrome/test:test_support",
"//ios/chrome/test/app:test_support", "//ios/chrome/test/app:test_support",
"//ios/chrome/test/earl_grey:test_support", "//ios/chrome/test/earl_grey:test_support",
......
...@@ -10,7 +10,6 @@ ...@@ -10,7 +10,6 @@
#include "base/strings/stringprintf.h" #include "base/strings/stringprintf.h"
#include "ios/chrome/browser/ui/util/ui_util.h" #include "ios/chrome/browser/ui/util/ui_util.h"
#import "ios/chrome/test/app/chrome_test_util.h" #import "ios/chrome/test/app/chrome_test_util.h"
#include "ios/chrome/test/app/navigation_test_util.h"
#import "ios/chrome/test/app/web_view_interaction_test_util.h" #import "ios/chrome/test/app/web_view_interaction_test_util.h"
#import "ios/chrome/test/earl_grey/chrome_earl_grey.h" #import "ios/chrome/test/earl_grey/chrome_earl_grey.h"
#import "ios/chrome/test/earl_grey/chrome_earl_grey_ui.h" #import "ios/chrome/test/earl_grey/chrome_earl_grey_ui.h"
......
...@@ -14,7 +14,6 @@ ...@@ -14,7 +14,6 @@
#import "ios/chrome/browser/ui/popup_menu/popup_menu_constants.h" #import "ios/chrome/browser/ui/popup_menu/popup_menu_constants.h"
#include "ios/chrome/browser/ui/util/ui_util.h" #include "ios/chrome/browser/ui/util/ui_util.h"
#import "ios/chrome/test/app/chrome_test_util.h" #import "ios/chrome/test/app/chrome_test_util.h"
#include "ios/chrome/test/app/navigation_test_util.h"
#import "ios/chrome/test/app/web_view_interaction_test_util.h" #import "ios/chrome/test/app/web_view_interaction_test_util.h"
#import "ios/chrome/test/earl_grey/chrome_earl_grey.h" #import "ios/chrome/test/earl_grey/chrome_earl_grey.h"
#import "ios/chrome/test/earl_grey/chrome_earl_grey_ui.h" #import "ios/chrome/test/earl_grey/chrome_earl_grey_ui.h"
......
...@@ -11,7 +11,6 @@ ...@@ -11,7 +11,6 @@
#include "components/strings/grit/components_strings.h" #include "components/strings/grit/components_strings.h"
#include "ios/chrome/browser/ui/util/ui_util.h" #include "ios/chrome/browser/ui/util/ui_util.h"
#include "ios/chrome/grit/ios_strings.h" #include "ios/chrome/grit/ios_strings.h"
#include "ios/chrome/test/app/navigation_test_util.h"
#import "ios/chrome/test/earl_grey/chrome_earl_grey.h" #import "ios/chrome/test/earl_grey/chrome_earl_grey.h"
#import "ios/chrome/test/earl_grey/chrome_error_util.h" #import "ios/chrome/test/earl_grey/chrome_error_util.h"
#import "ios/chrome/test/earl_grey/chrome_matchers.h" #import "ios/chrome/test/earl_grey/chrome_matchers.h"
...@@ -87,7 +86,7 @@ void WaitForHttpAuthDialog() { ...@@ -87,7 +86,7 @@ void WaitForHttpAuthDialog() {
GURL URL = web::test::HttpServer::MakeUrl("http://good-auth"); GURL URL = web::test::HttpServer::MakeUrl("http://good-auth");
web::test::SetUpHttpServer(std::make_unique<web::HttpAuthResponseProvider>( web::test::SetUpHttpServer(std::make_unique<web::HttpAuthResponseProvider>(
URL, "GoodRealm", "gooduser", "goodpass")); URL, "GoodRealm", "gooduser", "goodpass"));
chrome_test_util::LoadUrl(URL); CHROME_EG_ASSERT_NO_ERROR([ChromeEarlGrey loadURL:URL waitForCompletion:NO]);
WaitForHttpAuthDialog(); WaitForHttpAuthDialog();
// Enter valid username and password. // Enter valid username and password.
...@@ -114,7 +113,7 @@ void WaitForHttpAuthDialog() { ...@@ -114,7 +113,7 @@ void WaitForHttpAuthDialog() {
GURL URL = web::test::HttpServer::MakeUrl("http://bad-auth"); GURL URL = web::test::HttpServer::MakeUrl("http://bad-auth");
web::test::SetUpHttpServer(std::make_unique<web::HttpAuthResponseProvider>( web::test::SetUpHttpServer(std::make_unique<web::HttpAuthResponseProvider>(
URL, "BadRealm", "baduser", "badpass")); URL, "BadRealm", "baduser", "badpass"));
chrome_test_util::LoadUrl(URL); CHROME_EG_ASSERT_NO_ERROR([ChromeEarlGrey loadURL:URL waitForCompletion:NO]);
WaitForHttpAuthDialog(); WaitForHttpAuthDialog();
// Enter invalid username and password. // Enter invalid username and password.
...@@ -140,7 +139,7 @@ void WaitForHttpAuthDialog() { ...@@ -140,7 +139,7 @@ void WaitForHttpAuthDialog() {
GURL URL = web::test::HttpServer::MakeUrl("http://cancel-auth"); GURL URL = web::test::HttpServer::MakeUrl("http://cancel-auth");
web::test::SetUpHttpServer(std::make_unique<web::HttpAuthResponseProvider>( web::test::SetUpHttpServer(std::make_unique<web::HttpAuthResponseProvider>(
URL, "CancellingRealm", "", "")); URL, "CancellingRealm", "", ""));
chrome_test_util::LoadUrl(URL); CHROME_EG_ASSERT_NO_ERROR([ChromeEarlGrey loadURL:URL waitForCompletion:NO]);
WaitForHttpAuthDialog(); WaitForHttpAuthDialog();
[[EarlGrey selectElementWithMatcher:chrome_test_util::CancelButton()] [[EarlGrey selectElementWithMatcher:chrome_test_util::CancelButton()]
......
...@@ -15,7 +15,6 @@ ...@@ -15,7 +15,6 @@
#include "base/threading/thread_restrictions.h" #include "base/threading/thread_restrictions.h"
#include "base/time/time.h" #include "base/time/time.h"
#include "ios/chrome/browser/ui/util/ui_util.h" #include "ios/chrome/browser/ui/util/ui_util.h"
#include "ios/chrome/test/app/navigation_test_util.h"
#import "ios/chrome/test/app/web_view_interaction_test_util.h" #import "ios/chrome/test/app/web_view_interaction_test_util.h"
#import "ios/chrome/test/earl_grey/chrome_earl_grey.h" #import "ios/chrome/test/earl_grey/chrome_earl_grey.h"
#import "ios/chrome/test/earl_grey/chrome_earl_grey_ui.h" #import "ios/chrome/test/earl_grey/chrome_earl_grey_ui.h"
...@@ -188,7 +187,8 @@ class InfinitePendingResponseProvider : public HtmlResponseProvider { ...@@ -188,7 +187,8 @@ class InfinitePendingResponseProvider : public HtmlResponseProvider {
web::test::SetUpHttpServer(std::move(uniqueInfinitePendingProvider)); web::test::SetUpHttpServer(std::move(uniqueInfinitePendingProvider));
// The page being loaded never completes, so call the LoadUrl helper that // The page being loaded never completes, so call the LoadUrl helper that
// does not wait for the page to complete loading. // does not wait for the page to complete loading.
chrome_test_util::LoadUrl(infinitePendingURL); CHROME_EG_ASSERT_NO_ERROR([ChromeEarlGrey loadURL:infinitePendingURL
waitForCompletion:NO]);
// Wait until the page is half loaded. // Wait until the page is half loaded.
CHROME_EG_ASSERT_NO_ERROR( CHROME_EG_ASSERT_NO_ERROR(
......
...@@ -9,12 +9,12 @@ ...@@ -9,12 +9,12 @@
#include "base/strings/stringprintf.h" #include "base/strings/stringprintf.h"
#include "base/time/time.h" #include "base/time/time.h"
#include "ios/chrome/browser/ui/util/ui_util.h" #include "ios/chrome/browser/ui/util/ui_util.h"
#include "ios/chrome/test/app/navigation_test_util.h"
#import "ios/chrome/test/earl_grey/chrome_earl_grey.h" #import "ios/chrome/test/earl_grey/chrome_earl_grey.h"
#import "ios/chrome/test/earl_grey/chrome_earl_grey_ui.h" #import "ios/chrome/test/earl_grey/chrome_earl_grey_ui.h"
#import "ios/chrome/test/earl_grey/chrome_error_util.h" #import "ios/chrome/test/earl_grey/chrome_error_util.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"
#import "ios/chrome/test/scoped_eg_synchronization_disabler.h"
#include "ios/web/public/test/http_server/html_response_provider.h" #include "ios/web/public/test/http_server/html_response_provider.h"
#import "ios/web/public/test/http_server/http_server.h" #import "ios/web/public/test/http_server/http_server.h"
#include "ios/web/public/test/http_server/http_server_util.h" #include "ios/web/public/test/http_server/http_server_util.h"
...@@ -95,9 +95,16 @@ class InfinitePendingResponseProvider : public HtmlResponseProvider { ...@@ -95,9 +95,16 @@ class InfinitePendingResponseProvider : public HtmlResponseProvider {
web::test::SetUpHttpServer( web::test::SetUpHttpServer(
std::make_unique<InfinitePendingResponseProvider>(infinitePendingURL)); std::make_unique<InfinitePendingResponseProvider>(infinitePendingURL));
// The page being loaded never completes, so call the LoadUrl helper that if (IsIPadIdiom()) {
// does not wait for the page to complete loading. // TODO(crbug.com/960508): Investigate why test fails on iPad if
chrome_test_util::LoadUrl(infinitePendingURL); // synchronization is enabled.
ScopedSynchronizationDisabler disabler;
CHROME_EG_ASSERT_NO_ERROR([ChromeEarlGrey loadURL:infinitePendingURL
waitForCompletion:NO]);
} else {
CHROME_EG_ASSERT_NO_ERROR([ChromeEarlGrey loadURL:infinitePendingURL
waitForCompletion:NO]);
}
if (IsIPadIdiom()) { if (IsIPadIdiom()) {
// Disable EG synchronization so the framework does not wait until the tab // Disable EG synchronization so the framework does not wait until the tab
...@@ -127,8 +134,8 @@ class InfinitePendingResponseProvider : public HtmlResponseProvider { ...@@ -127,8 +134,8 @@ class InfinitePendingResponseProvider : public HtmlResponseProvider {
[[EarlGrey selectElementWithMatcher:chrome_test_util::StopButton()] [[EarlGrey selectElementWithMatcher:chrome_test_util::StopButton()]
performAction:grey_tap()]; performAction:grey_tap()];
// Enable synchronization back. The spinner should become idle and test should // Enable synchronization back. The spinner should become idle and test
// wait for it. // should wait for it.
[[GREYConfiguration sharedInstance] [[GREYConfiguration sharedInstance]
setValue:@YES setValue:@YES
forConfigKey:kGREYConfigKeySynchronizationEnabled]; forConfigKey:kGREYConfigKeySynchronizationEnabled];
......
...@@ -14,7 +14,6 @@ ...@@ -14,7 +14,6 @@
#include "ios/chrome/browser/chrome_url_constants.h" #include "ios/chrome/browser/chrome_url_constants.h"
#include "ios/chrome/browser/ui/util/ui_util.h" #include "ios/chrome/browser/ui/util/ui_util.h"
#import "ios/chrome/test/app/chrome_test_util.h" #import "ios/chrome/test/app/chrome_test_util.h"
#include "ios/chrome/test/app/navigation_test_util.h"
#import "ios/chrome/test/earl_grey/chrome_earl_grey.h" #import "ios/chrome/test/earl_grey/chrome_earl_grey.h"
#import "ios/chrome/test/earl_grey/chrome_earl_grey_ui.h" #import "ios/chrome/test/earl_grey/chrome_earl_grey_ui.h"
#import "ios/chrome/test/earl_grey/chrome_error_util.h" #import "ios/chrome/test/earl_grey/chrome_error_util.h"
......
...@@ -60,15 +60,27 @@ id ExecuteJavaScript(NSString* javascript, NSError* __autoreleasing* out_error); ...@@ -60,15 +60,27 @@ id ExecuteJavaScript(NSString* javascript, NSError* __autoreleasing* out_error);
#pragma mark - Navigation Utilities #pragma mark - Navigation Utilities
// Loads |URL| in the current WebState with transition type
// ui::PAGE_TRANSITION_TYPED, and if waitForCompletion is YES
// waits for the loading to complete within a timeout.
// Returns nil on success, or else an NSError indicating why the operation
// failed.
- (NSError*)loadURL:(const GURL&)URL waitForCompletion:(BOOL)wait;
// Loads |URL| in the current WebState with transition type // Loads |URL| in the current WebState with transition type
// ui::PAGE_TRANSITION_TYPED, and waits for the loading to complete within a // ui::PAGE_TRANSITION_TYPED, and waits for the loading to complete within a
// timeout, or a GREYAssert is induced. // timeout. Returns nil on success, or else an NSError indicating why the
// operation failed.
// TODO(crbug.com/963613): Change return type to avoid when // TODO(crbug.com/963613): Change return type to avoid when
// CHROME_EG_ASSERT_NO_ERROR is removed. // CHROME_EG_ASSERT_NO_ERROR is removed.
- (NSError*)loadURL:(const GURL&)URL; - (NSError*)loadURL:(const GURL&)URL;
// Reloads the page and waits for the loading to complete within a timeout, or a // Checks whether current WebState is loading.
// GREYAssert is induced. - (BOOL)isLoading WARN_UNUSED_RESULT;
// Reloads the page and waits for the loading to complete within a timeout.
// If the condition is not met within a timeout returns an NSError indicating
// why the operation failed, otherwise nil.
- (NSError*)reload WARN_UNUSED_RESULT; - (NSError*)reload WARN_UNUSED_RESULT;
// Navigates back to the previous page and waits for the loading to complete // Navigates back to the previous page and waits for the loading to complete
......
...@@ -130,8 +130,12 @@ id ExecuteJavaScript(NSString* javascript, ...@@ -130,8 +130,12 @@ id ExecuteJavaScript(NSString* javascript,
#pragma mark - Navigation Utilities #pragma mark - Navigation Utilities
- (NSError*)loadURL:(const GURL&)URL { - (NSError*)loadURL:(const GURL&)URL waitForCompletion:(BOOL)wait {
chrome_test_util::LoadUrl(URL); chrome_test_util::LoadUrl(URL);
if (!wait) {
return nil;
}
bool pageLoaded = chrome_test_util::WaitForPageToFinishLoading(); bool pageLoaded = chrome_test_util::WaitForPageToFinishLoading();
EG_TEST_HELPER_ASSERT_TRUE(pageLoaded, @"Page did not complete loading"); EG_TEST_HELPER_ASSERT_TRUE(pageLoaded, @"Page did not complete loading");
...@@ -144,6 +148,14 @@ id ExecuteJavaScript(NSString* javascript, ...@@ -144,6 +148,14 @@ id ExecuteJavaScript(NSString* javascript,
return nil; return nil;
} }
- (NSError*)loadURL:(const GURL&)URL {
return [ChromeEarlGrey loadURL:URL waitForCompletion:YES];
}
- (BOOL)isLoading {
return chrome_test_util::IsLoading();
}
- (NSError*)reload { - (NSError*)reload {
[chrome_test_util::BrowserCommandDispatcherForMainBVC() reload]; [chrome_test_util::BrowserCommandDispatcherForMainBVC() reload];
return [ChromeEarlGrey waitForPageToFinishLoading]; return [ChromeEarlGrey waitForPageToFinishLoading];
......
...@@ -18,7 +18,6 @@ ...@@ -18,7 +18,6 @@
#import "ios/chrome/browser/ui/util/uikit_ui_util.h" #import "ios/chrome/browser/ui/util/uikit_ui_util.h"
#include "ios/chrome/grit/ios_strings.h" #include "ios/chrome/grit/ios_strings.h"
#import "ios/chrome/test/app/chrome_test_util.h" #import "ios/chrome/test/app/chrome_test_util.h"
#include "ios/chrome/test/app/navigation_test_util.h"
#import "ios/chrome/test/earl_grey/chrome_matchers.h" #import "ios/chrome/test/earl_grey/chrome_matchers.h"
#import "ios/testing/nserror_util.h" #import "ios/testing/nserror_util.h"
#import "ios/web/public/test/earl_grey/js_test_util.h" #import "ios/web/public/test/earl_grey/js_test_util.h"
......
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