Commit 2ad909df authored by eugenebut's avatar eugenebut Committed by Commit bot

[ios] Use +[ShellEarlGrey loadURL:] for page loading in EG tests.

Unlike web::shell_test_util::LoadUrl this new method waits until the
load is completed.

BUG=629116

Review-Url: https://codereview.chromium.org/2343453002
Cr-Commit-Position: refs/heads/master@{#419231}
parent be77cf13
......@@ -13,11 +13,11 @@
#import "ios/web/public/test/http_server.h"
#include "ios/web/public/test/http_server_util.h"
#import "ios/web/public/test/web_view_interaction_test_util.h"
#include "ios/web/shell/test/app/navigation_test_util.h"
#import "ios/web/shell/test/app/web_shell_test_util.h"
#include "ios/web/shell/test/app/web_view_interaction_test_util.h"
#import "ios/web/shell/test/earl_grey/shell_base_test_case.h"
#import "ios/web/shell/test/earl_grey/shell_actions.h"
#import "ios/web/shell/test/earl_grey/shell_earl_grey.h"
#import "ios/web/shell/test/earl_grey/shell_matchers.h"
#if !defined(__has_feature) || !__has_feature(objc_arc)
......@@ -49,7 +49,7 @@ using testing::elementToDismissContextMenu;
"</span></body>";
web::test::SetUpSimpleHttpServer(responses);
web::shell_test_util::LoadUrl(initialURL);
[ShellEarlGrey loadURL:initialURL];
[[EarlGrey selectElementWithMatcher:web::webView()]
performAction:web::longPressElementForContextMenu(
......@@ -86,7 +86,7 @@ using testing::elementToDismissContextMenu;
"</body>";
web::test::SetUpSimpleHttpServer(responses);
web::shell_test_util::LoadUrl(initialURL);
[ShellEarlGrey loadURL:initialURL];
[[EarlGrey selectElementWithMatcher:web::webView()]
performAction:web::longPressElementForContextMenu(
......@@ -117,7 +117,7 @@ using testing::elementToDismissContextMenu;
"</body>";
web::test::SetUpSimpleHttpServer(responses);
web::shell_test_util::LoadUrl(initialURL);
[ShellEarlGrey loadURL:initialURL];
[[EarlGrey selectElementWithMatcher:web::webView()]
performAction:web::longPressElementForContextMenu(
......@@ -149,7 +149,7 @@ using testing::elementToDismissContextMenu;
"</body>";
web::test::SetUpSimpleHttpServer(responses);
web::shell_test_util::LoadUrl(initialURL);
[ShellEarlGrey loadURL:initialURL];
[[EarlGrey selectElementWithMatcher:web::webView()]
performAction:web::longPressElementForContextMenu(
......
......@@ -8,8 +8,8 @@
#include "base/test/ios/wait_util.h"
#import "ios/web/public/test/http_server.h"
#include "ios/web/public/test/http_server_util.h"
#include "ios/web/shell/test/app/navigation_test_util.h"
#import "ios/web/shell/test/earl_grey/shell_base_test_case.h"
#import "ios/web/shell/test/earl_grey/shell_earl_grey.h"
#import "ios/web/shell/test/earl_grey/shell_matchers.h"
#if !defined(__has_feature) || !__has_feature(objc_arc)
......@@ -66,7 +66,7 @@ using web::webViewContainingText;
responses[destinationURL] = kDestinationPage;
web::test::SetUpSimpleHttpServer(responses);
web::shell_test_util::LoadUrl(originURL);
[ShellEarlGrey loadURL:originURL];
// Wait for redirect.
base::test::ios::SpinRunLoopWithMinDelay(
......
......@@ -11,9 +11,9 @@
#include "base/strings/sys_string_conversions.h"
#import "ios/web/public/test/http_server.h"
#include "ios/web/public/test/http_server_util.h"
#include "ios/web/shell/test/app/navigation_test_util.h"
#include "ios/web/shell/test/app/web_view_interaction_test_util.h"
#import "ios/web/shell/test/earl_grey/shell_base_test_case.h"
#import "ios/web/shell/test/earl_grey/shell_earl_grey.h"
#import "ios/web/shell/test/earl_grey/shell_matchers.h"
#if !defined(__has_feature) || !__has_feature(objc_arc)
......@@ -33,7 +33,7 @@
"http://ios/web/shell/test/http_server_files/basic_navigation_test.html");
web::test::SetUpFileBasedHttpServer();
web::shell_test_util::LoadUrl(URL);
[ShellEarlGrey loadURL:URL];
[[EarlGrey selectElementWithMatcher:web::addressFieldText(URL.spec())]
assertWithMatcher:grey_notNil()];
......@@ -58,13 +58,13 @@
web::test::SetUpSimpleHttpServer(responses);
web::shell_test_util::LoadUrl(URL1);
[ShellEarlGrey loadURL:URL1];
[[EarlGrey selectElementWithMatcher:web::addressFieldText(URL1.spec())]
assertWithMatcher:grey_notNil()];
[[EarlGrey selectElementWithMatcher:web::webViewContainingText(response1)]
assertWithMatcher:grey_notNil()];
web::shell_test_util::LoadUrl(URL2);
[ShellEarlGrey loadURL:URL2];
[[EarlGrey selectElementWithMatcher:web::addressFieldText(URL2.spec())]
assertWithMatcher:grey_notNil()];
[[EarlGrey selectElementWithMatcher:web::webViewContainingText(response2)]
......@@ -97,7 +97,7 @@
web::test::SetUpSimpleHttpServer(responses);
web::shell_test_util::LoadUrl(URL1);
[ShellEarlGrey loadURL:URL1];
[[EarlGrey selectElementWithMatcher:web::addressFieldText(URL1.spec())]
assertWithMatcher:grey_notNil()];
......@@ -135,7 +135,7 @@
web::test::SetUpSimpleHttpServer(responses);
web::shell_test_util::LoadUrl(URL);
[ShellEarlGrey loadURL:URL];
[[EarlGrey selectElementWithMatcher:web::addressFieldText(URL.spec())]
assertWithMatcher:grey_notNil()];
......@@ -167,7 +167,7 @@
web::test::SetUpSimpleHttpServer(responses);
web::shell_test_util::LoadUrl(URL);
[ShellEarlGrey loadURL:URL];
[[EarlGrey selectElementWithMatcher:web::addressFieldText(URL.spec())]
assertWithMatcher:grey_notNil()];
......
......@@ -9,8 +9,8 @@
#import "ios/web/public/test/http_server.h"
#include "ios/web/public/test/http_server_util.h"
#include "ios/web/shell/test/app/navigation_test_util.h"
#import "ios/web/shell/test/earl_grey/shell_base_test_case.h"
#import "ios/web/shell/test/earl_grey/shell_earl_grey.h"
#import "ios/web/shell/test/earl_grey/shell_matchers.h"
#if !defined(__has_feature) || !__has_feature(objc_arc)
......@@ -47,9 +47,7 @@ id<GREYMatcher> contentOffset(CGPoint offset) {
} // namespace
using web::shell_test_util::LoadUrl;
using web::test::HttpServer;
using web::webViewContainingText;
// Page state test cases for the web shell.
@interface PageStateTestCase : ShellBaseTestCase
......@@ -63,11 +61,7 @@ using web::webViewContainingText;
web::test::SetUpFileBasedHttpServer();
// Load first URL which is a long page.
LoadUrl(HttpServer::MakeUrl(kLongPage1));
// TODO(crbug.com/629116): Remove this once |LoadUrl| waits for the load
// completion.
[[EarlGrey selectElementWithMatcher:webViewContainingText("List of numbers")]
assertWithMatcher:grey_notNil()];
[ShellEarlGrey loadURL:HttpServer::MakeUrl(kLongPage1)];
// Scroll the first page and verify the offset.
[[EarlGrey selectElementWithMatcher:web::webViewScrollView()]
......@@ -76,14 +70,7 @@ using web::webViewContainingText;
assertWithMatcher:contentOffset(CGPointMake(0, kScrollOffset1))];
// Load second URL, which is also a long page.
GURL URL2 = HttpServer::MakeUrl(kLongPage2);
LoadUrl(URL2);
// TODO(crbug.com/629116): Remove these once |LoadUrl| waits for the load
// completion.
[[EarlGrey selectElementWithMatcher:web::addressFieldText(URL2.spec())]
assertWithMatcher:grey_notNil()];
[[EarlGrey selectElementWithMatcher:webViewContainingText("List of numbers")]
assertWithMatcher:grey_notNil()];
[ShellEarlGrey loadURL:HttpServer::MakeUrl(kLongPage2)];
// Scroll the second page and verify the offset.
[[EarlGrey selectElementWithMatcher:web::webViewScrollView()]
......
......@@ -9,9 +9,9 @@
#import "ios/web/public/test/earl_grey/web_view_matchers.h"
#import "ios/web/public/test/http_server.h"
#include "ios/web/public/test/http_server_util.h"
#include "ios/web/shell/test/app/navigation_test_util.h"
#import "ios/web/shell/test/app/web_shell_test_util.h"
#import "ios/web/shell/test/earl_grey/shell_base_test_case.h"
#import "ios/web/shell/test/earl_grey/shell_earl_grey.h"
#if !defined(__has_feature) || !__has_feature(objc_arc)
#error "This file requires ARC support."
......@@ -53,7 +53,6 @@ id<GREYMatcher> webViewWithPdf() {
} // namespace
using web::shell_test_util::LoadUrl;
using web::test::HttpServer;
// PDF test cases for the web shell.
......@@ -65,7 +64,7 @@ using web::test::HttpServer;
// Tests MIME type of the loaded PDF document.
- (void)testMIMEType {
web::test::SetUpFileBasedHttpServer();
LoadUrl(HttpServer::MakeUrl(kTestPDFURL));
[ShellEarlGrey loadURL:HttpServer::MakeUrl(kTestPDFURL)];
[[EarlGrey selectElementWithMatcher:webViewWithPdf()]
assertWithMatcher:grey_notNil()];
}
......
......@@ -11,8 +11,8 @@
#include "base/test/ios/wait_util.h"
#import "ios/web/public/test/http_server.h"
#include "ios/web/public/test/http_server_util.h"
#include "ios/web/shell/test/app/navigation_test_util.h"
#import "ios/web/shell/test/earl_grey/shell_base_test_case.h"
#import "ios/web/shell/test/earl_grey/shell_earl_grey.h"
#import "ios/web/shell/test/earl_grey/shell_matchers.h"
#include "url/gurl.h"
......@@ -30,7 +30,7 @@ void LoadPage(const std::string& page_content) {
const GURL url = web::test::HttpServer::MakeUrl("http://plugin");
std::map<GURL, std::string> responses{{url, page_content}};
web::test::SetUpSimpleHttpServer(responses);
web::shell_test_util::LoadUrl(url);
[ShellEarlGrey loadURL:url];
}
} // namespace
......
......@@ -8,8 +8,8 @@
#include "ios/web/public/test/http_server_util.h"
#include "ios/web/public/test/response_providers/html_response_provider.h"
#include "ios/web/public/test/response_providers/html_response_provider_impl.h"
#include "ios/web/shell/test/app/navigation_test_util.h"
#import "ios/web/shell/test/earl_grey/shell_base_test_case.h"
#import "ios/web/shell/test/earl_grey/shell_earl_grey.h"
#import "ios/web/shell/test/earl_grey/shell_matchers.h"
#include "net/http/http_status_code.h"
......@@ -50,7 +50,7 @@ using web::webViewContainingText;
web::test::SetUpHttpServer(std::move(provider));
// Load first URL and expect destination URL to load.
web::shell_test_util::LoadUrl(firstRedirectURL);
[ShellEarlGrey loadURL:firstRedirectURL];
[[EarlGrey selectElementWithMatcher:addressFieldText(destinationURL.spec())]
assertWithMatcher:grey_notNil()];
[[EarlGrey selectElementWithMatcher:webViewContainingText(kFinalPageContent)]
......@@ -74,7 +74,7 @@ using web::webViewContainingText;
web::test::SetUpHttpServer(std::move(provider));
// Load first URL and expect destination URL to load.
web::shell_test_util::LoadUrl(firstRedirectURL);
[ShellEarlGrey loadURL:firstRedirectURL];
[[EarlGrey selectElementWithMatcher:addressFieldText(destinationURL.spec())]
assertWithMatcher:grey_notNil()];
[[EarlGrey selectElementWithMatcher:webViewContainingText(kFinalPageContent)]
......@@ -98,7 +98,7 @@ using web::webViewContainingText;
web::test::SetUpHttpServer(std::move(provider));
// Load first URL and expect destination URL to load.
web::shell_test_util::LoadUrl(firstRedirectURL);
[ShellEarlGrey loadURL:firstRedirectURL];
[[EarlGrey selectElementWithMatcher:addressFieldText(destinationURL.spec())]
assertWithMatcher:grey_notNil()];
[[EarlGrey selectElementWithMatcher:webViewContainingText(kFinalPageContent)]
......
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