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

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

Issue 2798773002: Create ChromeEarlGrey waitForWebViewContainingText. (Closed)
Patch Set: better formatting Created 3 years, 8 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 "base/strings/sys_string_conversions.h"
7 #include "components/strings/grit/components_strings.h" 8 #include "components/strings/grit/components_strings.h"
8 #import "ios/chrome/test/app/chrome_test_util.h" 9 #import "ios/chrome/test/app/chrome_test_util.h"
9 #include "ios/chrome/test/app/web_view_interaction_test_util.h" 10 #include "ios/chrome/test/app/web_view_interaction_test_util.h"
10 #import "ios/chrome/test/earl_grey/chrome_earl_grey.h" 11 #import "ios/chrome/test/earl_grey/chrome_earl_grey.h"
11 #import "ios/chrome/test/earl_grey/chrome_matchers.h" 12 #import "ios/chrome/test/earl_grey/chrome_matchers.h"
12 #import "ios/chrome/test/earl_grey/chrome_test_case.h" 13 #import "ios/chrome/test/earl_grey/chrome_test_case.h"
14 #import "ios/web/public/test/earl_grey/web_view_matchers.h"
13 #import "ios/web/public/test/http_server.h" 15 #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" 16 #include "ios/web/public/test/http_server_util.h"
16 #include "ios/web/public/test/response_providers/data_response_provider.h" 17 #include "ios/web/public/test/response_providers/data_response_provider.h"
17 #include "ios/web/public/test/response_providers/error_page_response_provider.h" 18 #include "ios/web/public/test/response_providers/error_page_response_provider.h"
18 #include "ui/base/l10n/l10n_util.h" 19 #include "ui/base/l10n/l10n_util.h"
19 #include "ui/base/l10n/l10n_util_mac.h" 20 #include "ui/base/l10n/l10n_util_mac.h"
20 21
21 #if !defined(__has_feature) || !__has_feature(objc_arc) 22 #if !defined(__has_feature) || !__has_feature(objc_arc)
22 #error "This file requires ARC support." 23 #error "This file requires ARC support."
23 #endif 24 #endif
24 25
25 using chrome_test_util::OmniboxText; 26 using chrome_test_util::OmniboxText;
26 using chrome_test_util::TapWebViewElementWithId; 27 using chrome_test_util::TapWebViewElementWithId;
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 ErrorPageTestCase : 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
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
132 "<script>setTimeout(" + "function() { document.body.innerHTML+='<p>" + 132 "<script>setTimeout(" + "function() { document.body.innerHTML+='<p>" +
133 kTimerCompleted + "</p>" + "<iframe src=\"" + 133 kTimerCompleted + "</p>" + "<iframe src=\"" +
134 ErrorPageResponseProvider::GetDnsFailureUrl().spec() + 134 ErrorPageResponseProvider::GetDnsFailureUrl().spec() +
135 "\"></iframe>'}, 1000);" + "</script>"; 135 "\"></iframe>'}, 1000);" + "</script>";
136 std::unique_ptr<web::DataResponseProvider> provider( 136 std::unique_ptr<web::DataResponseProvider> provider(
137 new ErrorPageResponseProvider(responses)); 137 new ErrorPageResponseProvider(responses));
138 web::test::SetUpHttpServer(std::move(provider)); 138 web::test::SetUpHttpServer(std::move(provider));
139 139
140 [ChromeEarlGrey loadURL:URL]; 140 [ChromeEarlGrey loadURL:URL];
141 // Check that the timer has completed. 141 // Check that the timer has completed.
142 [[EarlGrey selectElementWithMatcher:WebViewContainingText(kTimerCompleted)] 142 [ChromeEarlGrey
143 assertWithMatcher:grey_notNil()]; 143 waitForWebViewContainingText:base::SysUTF8ToNSString(kTimerCompleted)];
144 // DNS error page should still not appear. 144 // DNS error page should still not appear.
145 [self checkErrorPageIsNotVisible]; 145 [self checkErrorPageIsNotVisible];
146 } 146 }
147 147
148 // Tests that the error page is not displayed if the navigation was not 148 // Tests that the error page is not displayed if the navigation was not
149 // user-initiated. 149 // user-initiated.
150 - (void)testErrorPageNoUserInteraction { 150 - (void)testErrorPageNoUserInteraction {
151 // Create map of canned responses and set up the test HTML server. 151 // Create map of canned responses and set up the test HTML server.
152 std::map<GURL, std::string> responses; 152 std::map<GURL, std::string> responses;
153 const GURL URL = 153 const GURL URL =
(...skipping 15 matching lines...) Expand all
169 "</p><iframe src=" + 169 "</p><iframe src=" +
170 ErrorPageResponseProvider::GetDnsFailureUrl().spec() + 170 ErrorPageResponseProvider::GetDnsFailureUrl().spec() +
171 ">\"}, " + kTimeoutMs + ");'></form>"; 171 ">\"}, " + kTimeoutMs + ");'></form>";
172 std::unique_ptr<web::DataResponseProvider> provider( 172 std::unique_ptr<web::DataResponseProvider> provider(
173 new ErrorPageResponseProvider(responses)); 173 new ErrorPageResponseProvider(responses));
174 web::test::SetUpHttpServer(std::move(provider)); 174 web::test::SetUpHttpServer(std::move(provider));
175 175
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 [ChromeEarlGrey
180 assertWithMatcher:grey_notNil()]; 180 waitForWebViewContainingText:base::SysUTF8ToNSString(kTimerCompleted)];
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
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698