Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #import <UIKit/UIKit.h> | 5 #import <UIKit/UIKit.h> |
| 6 #import <WebKit/WebKit.h> | 6 #import <WebKit/WebKit.h> |
| 7 #import <XCTest/XCTest.h> | 7 #import <XCTest/XCTest.h> |
| 8 | 8 |
| 9 #import <EarlGrey/EarlGrey.h> | 9 #import <EarlGrey/EarlGrey.h> |
| 10 | 10 |
| 11 #include "base/strings/stringprintf.h" | |
| 11 #include "base/strings/sys_string_conversions.h" | 12 #include "base/strings/sys_string_conversions.h" |
| 12 #import "ios/web/public/test/http_server.h" | 13 #import "ios/web/public/test/http_server.h" |
| 13 #include "ios/web/public/test/http_server_util.h" | 14 #include "ios/web/public/test/http_server_util.h" |
| 14 #include "ios/web/shell/test/app/navigation_test_util.h" | 15 #include "ios/web/shell/test/app/navigation_test_util.h" |
| 15 #include "ios/web/shell/test/app/web_view_interaction_test_util.h" | 16 #include "ios/web/shell/test/app/web_view_interaction_test_util.h" |
|
Eugene But (OOO till 7-30)
2016/06/24 00:41:25
Sorry, missed this: s/include/import
| |
| 16 #import "ios/web/shell/test/earl_grey/shell_matchers.h" | 17 #import "ios/web/shell/test/earl_grey/shell_matchers.h" |
| 17 | 18 |
| 18 // Navigation test cases for the web shell. These are Earl Grey integration | 19 // Navigation test cases for the web shell. These are Earl Grey integration |
| 19 // tests, which are based on XCTest. | 20 // tests, which are based on XCTest. |
| 20 @interface CRWWebShellNavigationTest : XCTestCase | 21 @interface CRWWebShellNavigationTest : XCTestCase |
| 21 | 22 |
| 22 @end | 23 @end |
| 23 | 24 |
| 24 @implementation CRWWebShellNavigationTest | 25 @implementation CRWWebShellNavigationTest |
| 25 | 26 |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 132 performAction:grey_tap()]; | 133 performAction:grey_tap()]; |
| 133 [[EarlGrey selectElementWithMatcher:web::addressFieldText(URL1.spec())] | 134 [[EarlGrey selectElementWithMatcher:web::addressFieldText(URL1.spec())] |
| 134 assertWithMatcher:grey_notNil()]; | 135 assertWithMatcher:grey_notNil()]; |
| 135 | 136 |
| 136 [[EarlGrey selectElementWithMatcher:web::forwardButton()] | 137 [[EarlGrey selectElementWithMatcher:web::forwardButton()] |
| 137 performAction:grey_tap()]; | 138 performAction:grey_tap()]; |
| 138 [[EarlGrey selectElementWithMatcher:web::addressFieldText(URL2.spec())] | 139 [[EarlGrey selectElementWithMatcher:web::addressFieldText(URL2.spec())] |
| 139 assertWithMatcher:grey_notNil()]; | 140 assertWithMatcher:grey_notNil()]; |
| 140 } | 141 } |
| 141 | 142 |
| 143 // Tests tapping a link with onclick="event.preventDefault()" and verifies that | |
| 144 // the URL didn't change.. | |
| 145 - (void)testNavigationLinkPreventDefaultOverridesHref { | |
| 146 // Create map of canned responses and set up the test HTML server. | |
| 147 std::map<GURL, std::string> responses; | |
| 148 const GURL URL = web::test::HttpServer::MakeUrl("http://overridesHrefLink"); | |
| 149 const GURL destURL = web::test::HttpServer::MakeUrl("http://destination"); | |
| 150 | |
| 151 const std::string response = base::StringPrintf( | |
| 152 "<a href='%s' id='overrides-href' " | |
| 153 "onclick='event.preventDefault()'>redirectLink</a>", | |
| 154 destURL.spec().c_str()); | |
| 155 responses[URL] = response; | |
| 156 std::string destResponse = "You're here!"; | |
| 157 responses[destURL] = destResponse; | |
| 158 | |
| 159 web::test::SetUpSimpleHttpServer(responses); | |
| 160 web::shell_test_util::LoadUrl(URL); | |
| 161 [[EarlGrey selectElementWithMatcher:web::addressFieldText(URL.spec())] | |
| 162 assertWithMatcher:grey_notNil()]; | |
| 163 | |
| 164 web::shell_test_util::TapWebViewElementWithId("overrides-href"); | |
| 165 | |
| 166 [[EarlGrey selectElementWithMatcher:web::addressFieldText(URL.spec())] | |
| 167 assertWithMatcher:grey_notNil()]; | |
| 168 [[EarlGrey selectElementWithMatcher:web::webViewContainingText(destResponse)] | |
| 169 assertWithMatcher:grey_nil()]; | |
| 170 } | |
| 171 | |
| 142 @end | 172 @end |
| OLD | NEW |