| 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/sys_string_conversions.h" | 11 #include "base/strings/sys_string_conversions.h" |
| 12 #import "ios/web/public/test/http_server.h" | 12 #import "ios/web/public/test/http_server.h" |
| 13 #include "ios/web/public/test/http_server_util.h" | 13 #include "ios/web/public/test/http_server_util.h" |
| 14 #include "ios/web/shell/test/app/navigation_test_util.h" | 14 #include "ios/web/shell/test/app/navigation_test_util.h" |
| 15 #include "ios/web/shell/test/app/web_view_interaction_test_util.h" | 15 #include "ios/web/shell/test/app/web_view_interaction_test_util.h" |
| 16 #import "ios/web/shell/test/earl_grey/shell_base_test_case.h" |
| 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 : ShellBaseTestCase |
| 21 | 22 |
| 22 @end | 23 @end |
| 23 | 24 |
| 24 @implementation CRWWebShellNavigationTest | 25 @implementation CRWWebShellNavigationTest |
| 25 | 26 |
| 26 // Set up called once for the class. | |
| 27 + (void)setUp { | |
| 28 [super setUp]; | |
| 29 [[EarlGrey selectElementWithMatcher:web::webViewContainingText("Chromium")] | |
| 30 assertWithMatcher:grey_notNil()]; | |
| 31 web::test::HttpServer& server = web::test::HttpServer::GetSharedInstance(); | |
| 32 server.StartOrDie(); | |
| 33 DCHECK(server.IsRunning()); | |
| 34 } | |
| 35 | |
| 36 // Tear down called once for the class. | |
| 37 + (void)tearDown { | |
| 38 [super tearDown]; | |
| 39 web::test::HttpServer& server = web::test::HttpServer::GetSharedInstance(); | |
| 40 server.Stop(); | |
| 41 DCHECK(!server.IsRunning()); | |
| 42 } | |
| 43 | |
| 44 // Tear down called after each test. | |
| 45 - (void)tearDown { | |
| 46 [super tearDown]; | |
| 47 web::test::HttpServer& server = web::test::HttpServer::GetSharedInstance(); | |
| 48 server.RemoveAllResponseProviders(); | |
| 49 } | |
| 50 | |
| 51 // Tests clicking a link to about:blank. | 27 // Tests clicking a link to about:blank. |
| 52 - (void)testNavigationLinkToAboutBlank { | 28 - (void)testNavigationLinkToAboutBlank { |
| 53 const GURL URL = web::test::HttpServer::MakeUrl( | 29 const GURL URL = web::test::HttpServer::MakeUrl( |
| 54 "http://ios/web/shell/test/http_server_files/basic_navigation_test.html"); | 30 "http://ios/web/shell/test/http_server_files/basic_navigation_test.html"); |
| 55 web::test::SetUpFileBasedHttpServer(); | 31 web::test::SetUpFileBasedHttpServer(); |
| 56 | 32 |
| 57 // TODO(crbug.com/611515): Create web shell utility that only requires URL, | |
| 58 // and gets the web state and passes it in to the web view utility. | |
| 59 web::shell_test_util::LoadUrl(URL); | 33 web::shell_test_util::LoadUrl(URL); |
| 60 [[EarlGrey selectElementWithMatcher:web::addressFieldText(URL.spec())] | 34 [[EarlGrey selectElementWithMatcher:web::addressFieldText(URL.spec())] |
| 61 assertWithMatcher:grey_notNil()]; | 35 assertWithMatcher:grey_notNil()]; |
| 62 | 36 |
| 63 web::shell_test_util::TapWebViewElementWithId( | 37 web::shell_test_util::TapWebViewElementWithId( |
| 64 "basic-link-navigation-to-about-blank"); | 38 "basic-link-navigation-to-about-blank"); |
| 65 | 39 |
| 66 [[EarlGrey selectElementWithMatcher:web::addressFieldText("about:blank")] | 40 [[EarlGrey selectElementWithMatcher:web::addressFieldText("about:blank")] |
| 67 assertWithMatcher:grey_notNil()]; | 41 assertWithMatcher:grey_notNil()]; |
| 68 } | 42 } |
| (...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 197 web::shell_test_util::TapWebViewElementWithId("link"); | 171 web::shell_test_util::TapWebViewElementWithId("link"); |
| 198 | 172 |
| 199 [[EarlGrey selectElementWithMatcher:web::addressFieldText(URL.spec())] | 173 [[EarlGrey selectElementWithMatcher:web::addressFieldText(URL.spec())] |
| 200 assertWithMatcher:grey_notNil()]; | 174 assertWithMatcher:grey_notNil()]; |
| 201 [[EarlGrey | 175 [[EarlGrey |
| 202 selectElementWithMatcher:web::webViewContainingText("No navigation!")] | 176 selectElementWithMatcher:web::webViewContainingText("No navigation!")] |
| 203 assertWithMatcher:grey_notNil()]; | 177 assertWithMatcher:grey_notNil()]; |
| 204 } | 178 } |
| 205 | 179 |
| 206 @end | 180 @end |
| OLD | NEW |