Commit 8285be72 authored by Yi Su's avatar Yi Su Committed by Commit Bot

Remove ios_web_shell_egtests.NavigationTestCase.

ios_web_shell_egtests.NavigationTestCase can be removed now since it's
covered by ios/web/navigation/history_state_operations_inttest.mm.

Bug: 930859
Change-Id: Ib14239b206799d1429070800ad7ee259faaaee69
Reviewed-on: https://chromium-review.googlesource.com/c/1486338
Commit-Queue: Yi Su <mrsuyi@chromium.org>
Auto-Submit: Yi Su <mrsuyi@chromium.org>
Reviewed-by: default avatarEugene But <eugenebut@chromium.org>
Cr-Commit-Position: refs/heads/master@{#635220}
parent e194b7e0
...@@ -20,7 +20,6 @@ ios_eg_test("ios_web_shell_egtests") { ...@@ -20,7 +20,6 @@ ios_eg_test("ios_web_shell_egtests") {
sources = [ sources = [
"context_menu_egtest.mm", "context_menu_egtest.mm",
"meta_tags_egtest.mm", "meta_tags_egtest.mm",
"navigation_egtest.mm",
"page_state_egtest.mm", "page_state_egtest.mm",
"plugin_placeholder_egtest.mm", "plugin_placeholder_egtest.mm",
"redirect_egtest.mm", "redirect_egtest.mm",
...@@ -98,7 +97,6 @@ source_set("earl_grey_test_support") { ...@@ -98,7 +97,6 @@ source_set("earl_grey_test_support") {
bundle_data("bundle") { bundle_data("bundle") {
visibility = [ ":*" ] visibility = [ ":*" ]
sources = [ sources = [
"http_server_files/basic_navigation_test.html",
"http_server_files/tall_page.html", "http_server_files/tall_page.html",
] ]
outputs = [ outputs = [
......
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8"/>
<title>Browsing tests</title>
</head>
<body>
<table>
<tr>
<th>Code</th>
<th>Expected result</th>
</tr>
<tr id="link-to-about-blank">
<td>
<a href="about:blank"
id="basic-link-navigation-to-about-blank"
name="basic-link-navigation-to-about-blank">
BasicLinkNavigationToAboutBlank
</a>
</td>
<td>about:blank opened in this tab</td>
</tr>
</table>
</body>
</html>
// Copyright 2016 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#import <UIKit/UIKit.h>
#import <WebKit/WebKit.h>
#import <XCTest/XCTest.h>
#import <EarlGrey/EarlGrey.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/shell/test/app/web_view_interaction_test_util.h"
#import "ios/web/shell/test/earl_grey/shell_earl_grey.h"
#import "ios/web/shell/test/earl_grey/shell_matchers.h"
#import "ios/web/shell/test/earl_grey/web_shell_test_case.h"
#if !defined(__has_feature) || !__has_feature(objc_arc)
#error "This file requires ARC support."
#endif
// Navigation test cases for the web shell. These are Earl Grey integration
// tests, which are based on XCTest.
@interface NavigationTestCase : WebShellTestCase
@end
@implementation NavigationTestCase
// Tests clicking a link to about:blank.
- (void)testNavigationLinkToAboutBlank {
const GURL URL = web::test::HttpServer::MakeUrl(
"http://ios/web/shell/test/http_server_files/basic_navigation_test.html");
web::test::SetUpFileBasedHttpServer();
[ShellEarlGrey loadURL:URL];
[[EarlGrey selectElementWithMatcher:web::AddressFieldText(URL.spec())]
assertWithMatcher:grey_notNil()];
web::shell_test_util::TapWebViewElementWithId(
"basic-link-navigation-to-about-blank");
[[EarlGrey selectElementWithMatcher:web::AddressFieldText("about:blank")]
assertWithMatcher:grey_notNil()];
}
// Tests the back and forward button after entering two URLs.
- (void)testNavigationBackAndForward {
// Create map of canned responses and set up the test HTML server.
std::map<GURL, std::string> responses;
const GURL URL1 = web::test::HttpServer::MakeUrl("http://firstURL");
const char response1[] = "Test Page 1";
responses[URL1] = response1;
const GURL URL2 = web::test::HttpServer::MakeUrl("http://secondURL");
const char response2[] = "Test Page 2";
responses[URL2] = response2;
web::test::SetUpSimpleHttpServer(responses);
[ShellEarlGrey loadURL:URL1];
[[EarlGrey selectElementWithMatcher:web::AddressFieldText(URL1.spec())]
assertWithMatcher:grey_notNil()];
[ShellEarlGrey waitForWebViewContainingText:response1];
[ShellEarlGrey loadURL:URL2];
[[EarlGrey selectElementWithMatcher:web::AddressFieldText(URL2.spec())]
assertWithMatcher:grey_notNil()];
[ShellEarlGrey waitForWebViewContainingText:response2];
[[EarlGrey selectElementWithMatcher:web::BackButton()]
performAction:grey_tap()];
[[EarlGrey selectElementWithMatcher:web::AddressFieldText(URL1.spec())]
assertWithMatcher:grey_notNil()];
[ShellEarlGrey waitForWebViewContainingText:response1];
[[EarlGrey selectElementWithMatcher:web::ForwardButton()]
performAction:grey_tap()];
[[EarlGrey selectElementWithMatcher:web::AddressFieldText(URL2.spec())]
assertWithMatcher:grey_notNil()];
[ShellEarlGrey waitForWebViewContainingText:response2];
}
// Tests back and forward navigation where a fragment link is tapped.
- (void)testNavigationBackAndForwardAfterFragmentLink {
// Create map of canned responses and set up the test HTML server.
std::map<GURL, std::string> responses;
const GURL URL1 = web::test::HttpServer::MakeUrl("http://fragmentLink");
const std::string response = "<a href='#hash' id='link'>link</a>";
responses[URL1] = response;
const GURL URL2 = web::test::HttpServer::MakeUrl("http://fragmentLink/#hash");
web::test::SetUpSimpleHttpServer(responses);
[ShellEarlGrey loadURL:URL1];
[[EarlGrey selectElementWithMatcher:web::AddressFieldText(URL1.spec())]
assertWithMatcher:grey_notNil()];
web::shell_test_util::TapWebViewElementWithId("link");
[[EarlGrey selectElementWithMatcher:web::AddressFieldText(URL2.spec())]
assertWithMatcher:grey_notNil()];
[[EarlGrey selectElementWithMatcher:web::BackButton()]
performAction:grey_tap()];
[[EarlGrey selectElementWithMatcher:web::AddressFieldText(URL1.spec())]
assertWithMatcher:grey_notNil()];
[[EarlGrey selectElementWithMatcher:web::ForwardButton()]
performAction:grey_tap()];
[[EarlGrey selectElementWithMatcher:web::AddressFieldText(URL2.spec())]
assertWithMatcher:grey_notNil()];
}
// Tests tapping a link with onclick="event.preventDefault()" and verifies that
// the URL didn't change..
- (void)testNavigationLinkPreventDefaultOverridesHref {
// Create map of canned responses and set up the test HTML server.
std::map<GURL, std::string> responses;
const GURL URL = web::test::HttpServer::MakeUrl("http://overridesHrefLink");
const char pageHTML[] =
"<script>"
" function printMsg() {"
" document.body.appendChild(document.createTextNode('Default "
"prevented!'));"
" }"
"</script>"
"<a href='#hash' id='overrides-href' onclick='event.preventDefault(); "
"printMsg();'>redirectLink</a>";
responses[URL] = pageHTML;
web::test::SetUpSimpleHttpServer(responses);
[ShellEarlGrey loadURL:URL];
[[EarlGrey selectElementWithMatcher:web::AddressFieldText(URL.spec())]
assertWithMatcher:grey_notNil()];
web::shell_test_util::TapWebViewElementWithId("overrides-href");
[[EarlGrey selectElementWithMatcher:web::AddressFieldText(URL.spec())]
assertWithMatcher:grey_notNil()];
[ShellEarlGrey waitForWebViewContainingText:"Default prevented!"];
}
// Tests tapping on a link with unsupported URL scheme.
- (void)testNavigationUnsupportedSchema {
// Create map of canned responses and set up the test HTML server.
std::map<GURL, std::string> responses;
const GURL URL =
web::test::HttpServer::MakeUrl("http://urlWithUnsupportedSchemeLink");
const char pageHTML[] =
"<script>"
" function printMsg() {"
" document.body.appendChild(document.createTextNode("
" 'No navigation!'));"
" }"
"</script>"
"<a href='aaa://unsupported' id='link' "
"onclick='printMsg();'>unsupportedScheme</a>";
responses[URL] = pageHTML;
web::test::SetUpSimpleHttpServer(responses);
[ShellEarlGrey loadURL:URL];
[[EarlGrey selectElementWithMatcher:web::AddressFieldText(URL.spec())]
assertWithMatcher:grey_notNil()];
web::shell_test_util::TapWebViewElementWithId("link");
[[EarlGrey selectElementWithMatcher:web::AddressFieldText(URL.spec())]
assertWithMatcher:grey_notNil()];
[ShellEarlGrey waitForWebViewContainingText:"No navigation!"];
}
@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