Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(93)

Side by Side Diff: ios/chrome/browser/ui/external_url_error_page_egtest.mm

Issue 2798773002: Create ChromeEarlGrey waitForWebViewContainingText. (Closed)
Patch Set: more cleanup Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/earl_grey/web_view_matchers.h"
14 #include "ios/web/public/test/http_server/data_response_provider.h" 14 #include "ios/web/public/test/http_server/data_response_provider.h"
15 #include "ios/web/public/test/http_server/error_page_response_provider.h" 15 #include "ios/web/public/test/http_server/error_page_response_provider.h"
16 #import "ios/web/public/test/http_server/http_server.h" 16 #import "ios/web/public/test/http_server/http_server.h"
17 #include "ios/web/public/test/http_server/http_server_util.h" 17 #include "ios/web/public/test/http_server/http_server_util.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;
28 using chrome_test_util::WebViewNotContainingText; 27 using chrome_test_util::WebViewNotContainingText;
29 28
30 using web::test::HttpServer; 29 using web::test::HttpServer;
31 30
32 // Tests display of error pages for bad URLs. 31 // Tests display of error pages for bad URLs.
33 @interface ExternalURLErrorPageTestCase : ChromeTestCase 32 @interface ExternalURLErrorPageTestCase : ChromeTestCase
34 33
35 // Checks that the DNS error page is not visible. 34 // Checks that the DNS error page is not visible.
36 - (void)checkErrorPageIsNotVisible; 35 - (void)checkErrorPageIsNotVisible;
37 36
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
132 "<script>setTimeout(" + "function() { document.body.innerHTML+='<p>" + 131 "<script>setTimeout(" + "function() { document.body.innerHTML+='<p>" +
133 kTimerCompleted + "</p>" + "<iframe src=\"" + 132 kTimerCompleted + "</p>" + "<iframe src=\"" +
134 ErrorPageResponseProvider::GetDnsFailureUrl().spec() + 133 ErrorPageResponseProvider::GetDnsFailureUrl().spec() +
135 "\"></iframe>'}, 1000);" + "</script>"; 134 "\"></iframe>'}, 1000);" + "</script>";
136 std::unique_ptr<web::DataResponseProvider> provider( 135 std::unique_ptr<web::DataResponseProvider> provider(
137 new ErrorPageResponseProvider(responses)); 136 new ErrorPageResponseProvider(responses));
138 web::test::SetUpHttpServer(std::move(provider)); 137 web::test::SetUpHttpServer(std::move(provider));
139 138
140 [ChromeEarlGrey loadURL:URL]; 139 [ChromeEarlGrey loadURL:URL];
141 // Check that the timer has completed. 140 // Check that the timer has completed.
142 [[EarlGrey selectElementWithMatcher:WebViewContainingText(kTimerCompleted)] 141 [ChromeEarlGrey waitForWebViewContainingText:kTimerCompleted];
143 assertWithMatcher:grey_notNil()];
144 // DNS error page should still not appear. 142 // DNS error page should still not appear.
145 [self checkErrorPageIsNotVisible]; 143 [self checkErrorPageIsNotVisible];
146 } 144 }
147 145
148 // Tests that the error page is not displayed if the navigation was not 146 // Tests that the error page is not displayed if the navigation was not
149 // user-initiated. 147 // user-initiated.
150 - (void)testErrorPageNoUserInteraction { 148 - (void)testErrorPageNoUserInteraction {
151 // Create map of canned responses and set up the test HTML server. 149 // Create map of canned responses and set up the test HTML server.
152 std::map<GURL, std::string> responses; 150 std::map<GURL, std::string> responses;
153 const GURL URL = 151 const GURL URL =
(...skipping 15 matching lines...) Expand all
169 "</p><iframe src=" + 167 "</p><iframe src=" +
170 ErrorPageResponseProvider::GetDnsFailureUrl().spec() + 168 ErrorPageResponseProvider::GetDnsFailureUrl().spec() +
171 ">\"}, " + kTimeoutMs + ");'></form>"; 169 ">\"}, " + kTimeoutMs + ");'></form>";
172 std::unique_ptr<web::DataResponseProvider> provider( 170 std::unique_ptr<web::DataResponseProvider> provider(
173 new ErrorPageResponseProvider(responses)); 171 new ErrorPageResponseProvider(responses));
174 web::test::SetUpHttpServer(std::move(provider)); 172 web::test::SetUpHttpServer(std::move(provider));
175 173
176 [ChromeEarlGrey loadURL:URL]; 174 [ChromeEarlGrey loadURL:URL];
177 TapWebViewElementWithId(kButtonId); 175 TapWebViewElementWithId(kButtonId);
178 // Check that the timer has completed. 176 // Check that the timer has completed.
179 [[EarlGrey selectElementWithMatcher:WebViewContainingText(kTimerCompleted)] 177 [ChromeEarlGrey waitForWebViewContainingText:kTimerCompleted];
180 assertWithMatcher:grey_notNil()];
181 // DNS error page should still not appear. 178 // DNS error page should still not appear.
182 [self checkErrorPageIsNotVisible]; 179 [self checkErrorPageIsNotVisible];
183 } 180 }
184 181
185 @end 182 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698