| 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/navigation_test_util.h" | 14 #include "ios/web/public/test/navigation_test_util.h" |
| 15 #import "ios/web/shell/test/shell_matchers.h" | 15 #include "ios/web/shell/test/app/web_shell_test_util.h" |
| 16 #import "ios/web/shell/test/web_view_matchers.h" | 16 #import "ios/web/shell/test/earl_grey/shell_matchers.h" |
| 17 | 17 |
| 18 // Navigation test cases for the web shell. These are Earl Grey integration | 18 // Navigation test cases for the web shell. These are Earl Grey integration |
| 19 // tests, which are based on XCTest. | 19 // tests, which are based on XCTest. |
| 20 @interface CRWWebShellNavigationTest : XCTestCase | 20 @interface CRWWebShellNavigationTest : XCTestCase |
| 21 | 21 |
| 22 @end | 22 @end |
| 23 | 23 |
| 24 @implementation CRWWebShellNavigationTest | 24 @implementation CRWWebShellNavigationTest |
| 25 | 25 |
| 26 // Set up called once for the class. | 26 // Set up called once for the class. |
| (...skipping 28 matching lines...) Expand all Loading... |
| 55 const GURL URL1 = web::test::HttpServer::MakeUrl("http://firstURL"); | 55 const GURL URL1 = web::test::HttpServer::MakeUrl("http://firstURL"); |
| 56 NSString* response1 = @"Test Page 1"; | 56 NSString* response1 = @"Test Page 1"; |
| 57 responses[URL1] = base::SysNSStringToUTF8(response1); | 57 responses[URL1] = base::SysNSStringToUTF8(response1); |
| 58 | 58 |
| 59 const GURL URL2 = web::test::HttpServer::MakeUrl("http://secondURL"); | 59 const GURL URL2 = web::test::HttpServer::MakeUrl("http://secondURL"); |
| 60 NSString* response2 = @"Test Page 2"; | 60 NSString* response2 = @"Test Page 2"; |
| 61 responses[URL2] = base::SysNSStringToUTF8(response2); | 61 responses[URL2] = base::SysNSStringToUTF8(response2); |
| 62 | 62 |
| 63 web::test::SetUpSimpleHttpServer(responses); | 63 web::test::SetUpSimpleHttpServer(responses); |
| 64 | 64 |
| 65 web::navigation_test_util::LoadUrl(URL1); | 65 web::WebState* webState = web::web_shell_test_util::GetCurrentWebState(); |
| 66 |
| 67 web::navigation_test_util::LoadUrl(webState, URL1); |
| 66 | 68 |
| 67 [[EarlGrey selectElementWithMatcher:web::webViewContainingText(response1)] | 69 [[EarlGrey selectElementWithMatcher:web::webViewContainingText(response1)] |
| 68 assertWithMatcher:grey_notNil()]; | 70 assertWithMatcher:grey_notNil()]; |
| 69 | 71 |
| 70 web::navigation_test_util::LoadUrl(URL2); | 72 web::navigation_test_util::LoadUrl(webState, URL2); |
| 71 | 73 |
| 72 [[EarlGrey selectElementWithMatcher:web::webViewContainingText(response2)] | 74 [[EarlGrey selectElementWithMatcher:web::webViewContainingText(response2)] |
| 73 assertWithMatcher:grey_notNil()]; | 75 assertWithMatcher:grey_notNil()]; |
| 74 | 76 |
| 75 [[EarlGrey selectElementWithMatcher:web::backButton()] | 77 [[EarlGrey selectElementWithMatcher:web::backButton()] |
| 76 performAction:grey_tap()]; | 78 performAction:grey_tap()]; |
| 77 | 79 |
| 78 [[EarlGrey selectElementWithMatcher:web::webViewContainingText(response1)] | 80 [[EarlGrey selectElementWithMatcher:web::webViewContainingText(response1)] |
| 79 assertWithMatcher:grey_notNil()]; | 81 assertWithMatcher:grey_notNil()]; |
| 80 | 82 |
| 81 [[EarlGrey selectElementWithMatcher:web::forwardButton()] | 83 [[EarlGrey selectElementWithMatcher:web::forwardButton()] |
| 82 performAction:grey_tap()]; | 84 performAction:grey_tap()]; |
| 83 | 85 |
| 84 [[EarlGrey selectElementWithMatcher:web::webViewContainingText(response2)] | 86 [[EarlGrey selectElementWithMatcher:web::webViewContainingText(response2)] |
| 85 assertWithMatcher:grey_notNil()]; | 87 assertWithMatcher:grey_notNil()]; |
| 86 } | 88 } |
| 87 | 89 |
| 88 @end | 90 @end |
| OLD | NEW |