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

Side by Side Diff: ios/web/shell/test/redirect_egtest.mm

Issue 2798773002: Create ChromeEarlGrey waitForWebViewContainingText. (Closed)
Patch Set: review comments 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
« no previous file with comments | « ios/web/shell/test/plugin_placeholder_egtest.mm ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 #import "ios/web/public/test/http_server/html_response_provider.h" 7 #import "ios/web/public/test/http_server/html_response_provider.h"
8 #import "ios/web/public/test/http_server/html_response_provider_impl.h" 8 #import "ios/web/public/test/http_server/html_response_provider_impl.h"
9 #import "ios/web/public/test/http_server/http_server.h" 9 #import "ios/web/public/test/http_server/http_server.h"
10 #include "ios/web/public/test/http_server/http_server_util.h" 10 #include "ios/web/public/test/http_server/http_server_util.h"
11 #import "ios/web/shell/test/earl_grey/shell_earl_grey.h" 11 #import "ios/web/shell/test/earl_grey/shell_earl_grey.h"
12 #import "ios/web/shell/test/earl_grey/shell_matchers.h" 12 #import "ios/web/shell/test/earl_grey/shell_matchers.h"
13 #import "ios/web/shell/test/earl_grey/web_shell_test_case.h" 13 #import "ios/web/shell/test/earl_grey/web_shell_test_case.h"
14 #include "net/http/http_status_code.h" 14 #include "net/http/http_status_code.h"
15 15
16 #if !defined(__has_feature) || !__has_feature(objc_arc) 16 #if !defined(__has_feature) || !__has_feature(objc_arc)
17 #error "This file requires ARC support." 17 #error "This file requires ARC support."
18 #endif 18 #endif
19 19
20 using web::AddressFieldText; 20 using web::AddressFieldText;
21 using web::test::HttpServer; 21 using web::test::HttpServer;
22 using web::WebViewContainingText;
23 22
24 // Redirect test cases for the web shell. 23 // Redirect test cases for the web shell.
25 @interface RedirectTestCase : WebShellTestCase 24 @interface RedirectTestCase : WebShellTestCase
26 @end 25 @end
27 26
28 @implementation RedirectTestCase 27 @implementation RedirectTestCase
29 28
30 // Tests loading of page that is redirected 3 times using a 301 redirect. 29 // Tests loading of page that is redirected 3 times using a 301 redirect.
31 - (void)testMultipleRedirects { 30 - (void)testMultipleRedirects {
32 // Create map of canned responses and set up the test HTML server. 31 // Create map of canned responses and set up the test HTML server.
(...skipping 13 matching lines...) Expand all
46 responses[destinationURL] = 45 responses[destinationURL] =
47 HtmlResponseProviderImpl::GetSimpleResponse(kFinalPageContent); 46 HtmlResponseProviderImpl::GetSimpleResponse(kFinalPageContent);
48 std::unique_ptr<web::DataResponseProvider> provider( 47 std::unique_ptr<web::DataResponseProvider> provider(
49 new HtmlResponseProvider(responses)); 48 new HtmlResponseProvider(responses));
50 web::test::SetUpHttpServer(std::move(provider)); 49 web::test::SetUpHttpServer(std::move(provider));
51 50
52 // Load first URL and expect destination URL to load. 51 // Load first URL and expect destination URL to load.
53 [ShellEarlGrey loadURL:firstRedirectURL]; 52 [ShellEarlGrey loadURL:firstRedirectURL];
54 [[EarlGrey selectElementWithMatcher:AddressFieldText(destinationURL.spec())] 53 [[EarlGrey selectElementWithMatcher:AddressFieldText(destinationURL.spec())]
55 assertWithMatcher:grey_notNil()]; 54 assertWithMatcher:grey_notNil()];
56 [[EarlGrey selectElementWithMatcher:WebViewContainingText(kFinalPageContent)] 55 [ShellEarlGrey waitForWebViewContainingText:kFinalPageContent];
57 assertWithMatcher:grey_notNil()];
58 } 56 }
59 57
60 // Tests simple 301 redirection. 58 // Tests simple 301 redirection.
61 - (void)testRedirection301 { 59 - (void)testRedirection301 {
62 // Create map of canned responses and set up the test HTML server. 60 // Create map of canned responses and set up the test HTML server.
63 std::map<GURL, HtmlResponseProviderImpl::Response> responses; 61 std::map<GURL, HtmlResponseProviderImpl::Response> responses;
64 const GURL firstRedirectURL = HttpServer::MakeUrl("http://firstRedirect/"); 62 const GURL firstRedirectURL = HttpServer::MakeUrl("http://firstRedirect/");
65 const GURL destinationURL = HttpServer::MakeUrl("http://destination/"); 63 const GURL destinationURL = HttpServer::MakeUrl("http://destination/");
66 64
67 responses[firstRedirectURL] = HtmlResponseProviderImpl::GetRedirectResponse( 65 responses[firstRedirectURL] = HtmlResponseProviderImpl::GetRedirectResponse(
68 destinationURL, net::HTTP_MOVED_PERMANENTLY); 66 destinationURL, net::HTTP_MOVED_PERMANENTLY);
69 const char kFinalPageContent[] = "testRedirection301 complete"; 67 const char kFinalPageContent[] = "testRedirection301 complete";
70 responses[destinationURL] = 68 responses[destinationURL] =
71 HtmlResponseProviderImpl::GetSimpleResponse(kFinalPageContent); 69 HtmlResponseProviderImpl::GetSimpleResponse(kFinalPageContent);
72 std::unique_ptr<web::DataResponseProvider> provider( 70 std::unique_ptr<web::DataResponseProvider> provider(
73 new HtmlResponseProvider(responses)); 71 new HtmlResponseProvider(responses));
74 web::test::SetUpHttpServer(std::move(provider)); 72 web::test::SetUpHttpServer(std::move(provider));
75 73
76 // Load first URL and expect destination URL to load. 74 // Load first URL and expect destination URL to load.
77 [ShellEarlGrey loadURL:firstRedirectURL]; 75 [ShellEarlGrey loadURL:firstRedirectURL];
78 [[EarlGrey selectElementWithMatcher:AddressFieldText(destinationURL.spec())] 76 [[EarlGrey selectElementWithMatcher:AddressFieldText(destinationURL.spec())]
79 assertWithMatcher:grey_notNil()]; 77 assertWithMatcher:grey_notNil()];
80 [[EarlGrey selectElementWithMatcher:WebViewContainingText(kFinalPageContent)] 78 [ShellEarlGrey waitForWebViewContainingText:kFinalPageContent];
81 assertWithMatcher:grey_notNil()];
82 } 79 }
83 80
84 // Tests simple 302 redirection. 81 // Tests simple 302 redirection.
85 - (void)testRedirection302 { 82 - (void)testRedirection302 {
86 // Create map of canned responses and set up the test HTML server. 83 // Create map of canned responses and set up the test HTML server.
87 std::map<GURL, HtmlResponseProviderImpl::Response> responses; 84 std::map<GURL, HtmlResponseProviderImpl::Response> responses;
88 const GURL firstRedirectURL = HttpServer::MakeUrl("http://firstRedirect/"); 85 const GURL firstRedirectURL = HttpServer::MakeUrl("http://firstRedirect/");
89 const GURL destinationURL = HttpServer::MakeUrl("http://destination/"); 86 const GURL destinationURL = HttpServer::MakeUrl("http://destination/");
90 87
91 responses[firstRedirectURL] = HtmlResponseProviderImpl::GetRedirectResponse( 88 responses[firstRedirectURL] = HtmlResponseProviderImpl::GetRedirectResponse(
92 destinationURL, net::HTTP_FOUND); 89 destinationURL, net::HTTP_FOUND);
93 const char kFinalPageContent[] = "testRedirection302 complete"; 90 const char kFinalPageContent[] = "testRedirection302 complete";
94 responses[destinationURL] = 91 responses[destinationURL] =
95 HtmlResponseProviderImpl::GetSimpleResponse(kFinalPageContent); 92 HtmlResponseProviderImpl::GetSimpleResponse(kFinalPageContent);
96 std::unique_ptr<web::DataResponseProvider> provider( 93 std::unique_ptr<web::DataResponseProvider> provider(
97 new HtmlResponseProvider(responses)); 94 new HtmlResponseProvider(responses));
98 web::test::SetUpHttpServer(std::move(provider)); 95 web::test::SetUpHttpServer(std::move(provider));
99 96
100 // Load first URL and expect destination URL to load. 97 // Load first URL and expect destination URL to load.
101 [ShellEarlGrey loadURL:firstRedirectURL]; 98 [ShellEarlGrey loadURL:firstRedirectURL];
102 [[EarlGrey selectElementWithMatcher:AddressFieldText(destinationURL.spec())] 99 [[EarlGrey selectElementWithMatcher:AddressFieldText(destinationURL.spec())]
103 assertWithMatcher:grey_notNil()]; 100 assertWithMatcher:grey_notNil()];
104 [[EarlGrey selectElementWithMatcher:WebViewContainingText(kFinalPageContent)] 101 [ShellEarlGrey waitForWebViewContainingText:kFinalPageContent];
105 assertWithMatcher:grey_notNil()];
106 } 102 }
107 103
108 @end 104 @end
OLDNEW
« no previous file with comments | « ios/web/shell/test/plugin_placeholder_egtest.mm ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698