| 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 <EarlGrey/EarlGrey.h> | 5 #import <EarlGrey/EarlGrey.h> |
| 6 | 6 |
| 7 #include "components/strings/grit/components_strings.h" | 7 #include "components/strings/grit/components_strings.h" |
| 8 #import "ios/chrome/test/app/chrome_test_util.h" | 8 #import "ios/chrome/test/app/chrome_test_util.h" |
| 9 #include "ios/chrome/test/app/web_view_interaction_test_util.h" | 9 #include "ios/chrome/test/app/web_view_interaction_test_util.h" |
| 10 #import "ios/chrome/test/earl_grey/chrome_earl_grey.h" | 10 #import "ios/chrome/test/earl_grey/chrome_earl_grey.h" |
| 11 #import "ios/chrome/test/earl_grey/chrome_matchers.h" | 11 #import "ios/chrome/test/earl_grey/chrome_matchers.h" |
| 12 #import "ios/chrome/test/earl_grey/chrome_test_case.h" | 12 #import "ios/chrome/test/earl_grey/chrome_test_case.h" |
| 13 #import "ios/web/public/test/earl_grey/web_view_matchers.h" |
| 13 #import "ios/web/public/test/http_server.h" | 14 #import "ios/web/public/test/http_server.h" |
| 14 #import "ios/web/public/test/earl_grey/web_view_matchers.h" | |
| 15 #include "ios/web/public/test/http_server_util.h" | 15 #include "ios/web/public/test/http_server_util.h" |
| 16 #include "ios/web/public/test/response_providers/data_response_provider.h" | 16 #include "ios/web/public/test/response_providers/data_response_provider.h" |
| 17 #include "ios/web/public/test/response_providers/error_page_response_provider.h" | 17 #include "ios/web/public/test/response_providers/error_page_response_provider.h" |
| 18 #include "ui/base/l10n/l10n_util.h" | 18 #include "ui/base/l10n/l10n_util.h" |
| 19 #include "ui/base/l10n/l10n_util_mac.h" | 19 #include "ui/base/l10n/l10n_util_mac.h" |
| 20 | 20 |
| 21 #if !defined(__has_feature) || !__has_feature(objc_arc) | 21 #if !defined(__has_feature) || !__has_feature(objc_arc) |
| 22 #error "This file requires ARC support." | 22 #error "This file requires ARC support." |
| 23 #endif | 23 #endif |
| 24 | 24 |
| 25 using chrome_test_util::OmniboxText; | 25 using chrome_test_util::OmniboxText; |
| 26 using chrome_test_util::TapWebViewElementWithId; | 26 using chrome_test_util::TapWebViewElementWithId; |
| 27 using chrome_test_util::WebViewContainingText; | 27 using chrome_test_util::WebViewContainingText; |
| 28 using chrome_test_util::WebViewNotContainingText; | 28 using chrome_test_util::WebViewNotContainingText; |
| 29 | 29 |
| 30 using web::test::HttpServer; | 30 using web::test::HttpServer; |
| 31 | 31 |
| 32 // Tests display of error pages for bad URLs. | 32 // Tests display of error pages for bad URLs. |
| 33 @interface ErrorPageTestCase : ChromeTestCase | 33 @interface ExternalURLErrorPageTestCase : ChromeTestCase |
| 34 | 34 |
| 35 // Checks that the DNS error page is not visible. | 35 // Checks that the DNS error page is not visible. |
| 36 - (void)checkErrorPageIsNotVisible; | 36 - (void)checkErrorPageIsNotVisible; |
| 37 | 37 |
| 38 @end | 38 @end |
| 39 | 39 |
| 40 @implementation ErrorPageTestCase | 40 @implementation ExternalURLErrorPageTestCase |
| 41 | 41 |
| 42 #pragma mark - utilities | 42 #pragma mark - utilities |
| 43 | 43 |
| 44 - (void)checkErrorPageIsNotVisible { | 44 - (void)checkErrorPageIsNotVisible { |
| 45 // Check that the webview belongs to the web controller, and that the error | 45 // Check that the webview belongs to the web controller, and that the error |
| 46 // text doesn't appear in the webview. | 46 // text doesn't appear in the webview. |
| 47 id<GREYMatcher> webViewMatcher = | 47 id<GREYMatcher> webViewMatcher = |
| 48 web::WebViewInWebState(chrome_test_util::GetCurrentWebState()); | 48 web::WebViewInWebState(chrome_test_util::GetCurrentWebState()); |
| 49 [[EarlGrey selectElementWithMatcher:webViewMatcher] | 49 [[EarlGrey selectElementWithMatcher:webViewMatcher] |
| 50 assertWithMatcher:grey_notNil()]; | 50 assertWithMatcher:grey_notNil()]; |
| (...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 176 [ChromeEarlGrey loadURL:URL]; | 176 [ChromeEarlGrey loadURL:URL]; |
| 177 TapWebViewElementWithId(kButtonId); | 177 TapWebViewElementWithId(kButtonId); |
| 178 // Check that the timer has completed. | 178 // Check that the timer has completed. |
| 179 [[EarlGrey selectElementWithMatcher:WebViewContainingText(kTimerCompleted)] | 179 [[EarlGrey selectElementWithMatcher:WebViewContainingText(kTimerCompleted)] |
| 180 assertWithMatcher:grey_notNil()]; | 180 assertWithMatcher:grey_notNil()]; |
| 181 // DNS error page should still not appear. | 181 // DNS error page should still not appear. |
| 182 [self checkErrorPageIsNotVisible]; | 182 [self checkErrorPageIsNotVisible]; |
| 183 } | 183 } |
| 184 | 184 |
| 185 @end | 185 @end |
| OLD | NEW |