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

Side by Side Diff: ios/chrome/browser/web/navigation_egtest.mm

Issue 2784943002: Remove matcher to wait for static HTML view. (Closed)
Patch Set: more better comments 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 <XCTest/XCTest.h> 5 #import <XCTest/XCTest.h>
6 6
7 #include "base/ios/ios_util.h" 7 #include "base/ios/ios_util.h"
8 #include "components/strings/grit/components_strings.h" 8 #include "components/strings/grit/components_strings.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"
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
95 "onclick=\"window.history.back()\" />" 95 "onclick=\"window.history.back()\" />"
96 "</html>"; 96 "</html>";
97 responses[forwardURL] = 97 responses[forwardURL] =
98 "<html>" 98 "<html>"
99 "<input type=\"button\" value=\"ForwardHTMLButton\"" 99 "<input type=\"button\" value=\"ForwardHTMLButton\""
100 "id=\"ForwardHTMLButton\" onclick=\"window.history.forward()\" /></br>" 100 "id=\"ForwardHTMLButton\" onclick=\"window.history.forward()\" /></br>"
101 "Forward page loaded</html>"; 101 "Forward page loaded</html>";
102 web::test::SetUpSimpleHttpServer(responses); 102 web::test::SetUpSimpleHttpServer(responses);
103 } 103 }
104 104
105 // Matcher for the error page.
106 // TODO(crbug.com/638674): Evaluate if this can move to shared code. See
107 // ios/chrome/browser/ui/error_page_egtest.mm.
108 id<GREYMatcher> ErrorPage() {
109 NSString* const kDNSError =
110 l10n_util::GetNSString(IDS_ERRORPAGES_HEADING_NOT_AVAILABLE);
111 NSString* const kInternetDisconnectedError =
112 l10n_util::GetNSString(IDS_ERRORPAGES_HEADING_INTERNET_DISCONNECTED);
baxley 2017/03/31 20:59:22 I chatted with kkhorimoto@ and he thought it was r
113 return grey_anyOf(chrome_test_util::StaticHtmlViewContainingText(kDNSError),
114 chrome_test_util::StaticHtmlViewContainingText(
115 kInternetDisconnectedError),
116 nil);
117 }
118
119 // URLs for server redirect tests. 105 // URLs for server redirect tests.
120 const char kRedirectIndexURL[] = "http://redirect"; 106 const char kRedirectIndexURL[] = "http://redirect";
121 const char kRedirect301URL[] = "http://redirect/redirect?code=301"; 107 const char kRedirect301URL[] = "http://redirect/redirect?code=301";
122 const char kRedirectWindowURL[] = "http://redirect/redirectWindow.html"; 108 const char kRedirectWindowURL[] = "http://redirect/redirectWindow.html";
123 const char kRedirectRefreshURL[] = "http://redirect/redirectRefresh.html"; 109 const char kRedirectRefreshURL[] = "http://redirect/redirectRefresh.html";
124 const char kDestinationURL[] = "http://redirect/destination.html"; 110 const char kDestinationURL[] = "http://redirect/destination.html";
125 const char kLastURL[] = "http://redirect/last.html"; 111 const char kLastURL[] = "http://redirect/last.html";
126 112
127 class RedirectResponseProvider : public web::DataResponseProvider { 113 class RedirectResponseProvider : public web::DataResponseProvider {
128 public: 114 public:
(...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after
430 SetupBackAndForwardResponseProvider(); 416 SetupBackAndForwardResponseProvider();
431 417
432 // Go to page 1 with a button which calls window.history.forward(). 418 // Go to page 1 with a button which calls window.history.forward().
433 const GURL forwardURL = web::test::HttpServer::MakeUrl(kForwardURL); 419 const GURL forwardURL = web::test::HttpServer::MakeUrl(kForwardURL);
434 [ChromeEarlGrey loadURL:forwardURL]; 420 [ChromeEarlGrey loadURL:forwardURL];
435 421
436 // Go to page 2: 'www.badurljkljkljklfloofy.com'. This page should display a 422 // Go to page 2: 'www.badurljkljkljklfloofy.com'. This page should display a
437 // page not available error. 423 // page not available error.
438 const GURL badURL("http://www.badurljkljkljklfloofy.com"); 424 const GURL badURL("http://www.badurljkljkljklfloofy.com");
439 [ChromeEarlGrey loadURL:badURL]; 425 [ChromeEarlGrey loadURL:badURL];
440 [[EarlGrey selectElementWithMatcher:ErrorPage()] 426 [ChromeEarlGrey waitForErrorPage];
441 assertWithMatcher:grey_notNil()];
442 427
443 // Go back to page 1 by clicking back button. 428 // Go back to page 1 by clicking back button.
444 [[EarlGrey selectElementWithMatcher:BackButton()] performAction:grey_tap()]; 429 [[EarlGrey selectElementWithMatcher:BackButton()] performAction:grey_tap()];
445 [[EarlGrey selectElementWithMatcher:chrome_test_util::OmniboxText( 430 [[EarlGrey selectElementWithMatcher:chrome_test_util::OmniboxText(
446 forwardURL.GetContent())] 431 forwardURL.GetContent())]
447 assertWithMatcher:grey_notNil()]; 432 assertWithMatcher:grey_notNil()];
448 433
449 // Go forward to page 2 by calling window.history.forward() and assert that 434 // Go forward to page 2 by calling window.history.forward() and assert that
450 // the error page is shown. 435 // the error page is shown.
451 TapWebViewElementWithId(kForwardHTMLButtonLabel); 436 TapWebViewElementWithId(kForwardHTMLButtonLabel);
452 [[EarlGrey selectElementWithMatcher:ErrorPage()] 437 [ChromeEarlGrey waitForErrorPage];
453 assertWithMatcher:grey_notNil()];
454 } 438 }
455 439
456 #pragma mark window.location.hash operations 440 #pragma mark window.location.hash operations
457 441
458 // Loads a URL and modifies window.location.hash, then goes back and forward 442 // Loads a URL and modifies window.location.hash, then goes back and forward
459 // and verifies the URLs and that hashchange event is fired. 443 // and verifies the URLs and that hashchange event is fired.
460 - (void)testWindowLocationChangeHash { 444 - (void)testWindowLocationChangeHash {
461 std::map<GURL, std::string> responses; 445 std::map<GURL, std::string> responses;
462 const GURL page1URL = web::test::HttpServer::MakeUrl(kPage1URL); 446 const GURL page1URL = web::test::HttpServer::MakeUrl(kPage1URL);
463 const GURL hashChangedWithHistoryURL = 447 const GURL hashChangedWithHistoryURL =
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after
685 // Navigate forward and assert the the resulting page is the proper 669 // Navigate forward and assert the the resulting page is the proper
686 // destination. 670 // destination.
687 [[EarlGrey selectElementWithMatcher:ForwardButton()] 671 [[EarlGrey selectElementWithMatcher:ForwardButton()]
688 performAction:grey_tap()]; 672 performAction:grey_tap()];
689 [[EarlGrey selectElementWithMatcher:chrome_test_util::OmniboxText( 673 [[EarlGrey selectElementWithMatcher:chrome_test_util::OmniboxText(
690 destinationURL.GetContent())] 674 destinationURL.GetContent())]
691 assertWithMatcher:grey_notNil()]; 675 assertWithMatcher:grey_notNil()];
692 } 676 }
693 677
694 @end 678 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698