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

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

Issue 2832853002: Handle correctly start and commit of non-latest navigations. (Closed)
Patch Set: 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
« no previous file with comments | « ios/chrome/browser/web/BUILD.gn ('k') | ios/web/navigation/crw_session_controller.h » ('j') | 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 #include "base/memory/ptr_util.h" 7 #include "base/memory/ptr_util.h"
8 #include "base/strings/stringprintf.h" 8 #include "base/strings/stringprintf.h"
9 #include "base/strings/sys_string_conversions.h" 9 #include "base/strings/sys_string_conversions.h"
10 #include "base/strings/utf_string_conversions.h"
11 #include "components/version_info/version_info.h"
12 #include "ios/chrome/browser/chrome_url_constants.h"
13 #import "ios/chrome/browser/ui/commands/generic_chrome_command.h"
14 #include "ios/chrome/browser/ui/commands/ios_command_ids.h"
10 #include "ios/chrome/browser/ui/ui_util.h" 15 #include "ios/chrome/browser/ui/ui_util.h"
11 #import "ios/chrome/test/app/chrome_test_util.h" 16 #import "ios/chrome/test/app/chrome_test_util.h"
12 #import "ios/chrome/test/earl_grey/chrome_earl_grey.h" 17 #import "ios/chrome/test/earl_grey/chrome_earl_grey.h"
13 #import "ios/chrome/test/earl_grey/chrome_earl_grey_ui.h" 18 #import "ios/chrome/test/earl_grey/chrome_earl_grey_ui.h"
14 #import "ios/chrome/test/earl_grey/chrome_matchers.h" 19 #import "ios/chrome/test/earl_grey/chrome_matchers.h"
15 #import "ios/chrome/test/earl_grey/chrome_test_case.h" 20 #import "ios/chrome/test/earl_grey/chrome_test_case.h"
16 #import "ios/web/public/test/http_server.h" 21 #import "ios/web/public/test/http_server.h"
17 #include "ios/web/public/test/http_server_util.h" 22 #include "ios/web/public/test/http_server_util.h"
18 #include "ios/web/public/test/response_providers/html_response_provider.h" 23 #include "ios/web/public/test/response_providers/html_response_provider.h"
19 #include "ios/web/public/test/url_test_util.h" 24 #include "ios/web/public/test/url_test_util.h"
(...skipping 471 matching lines...) Expand 10 before | Expand all | Expand 10 after
491 assertWithMatcher:grey_notNil()]; 496 assertWithMatcher:grey_notNil()];
492 497
493 // Make server respond so URL1 becomes committed. 498 // Make server respond so URL1 becomes committed.
494 [self setServerPaused:NO]; 499 [self setServerPaused:NO];
495 [[EarlGrey selectElementWithMatcher:WebViewContainingText(kTestPage1)] 500 [[EarlGrey selectElementWithMatcher:WebViewContainingText(kTestPage1)]
496 assertWithMatcher:grey_notNil()]; 501 assertWithMatcher:grey_notNil()];
497 [[EarlGrey selectElementWithMatcher:OmniboxText(_testURL1.GetContent())] 502 [[EarlGrey selectElementWithMatcher:OmniboxText(_testURL1.GetContent())]
498 assertWithMatcher:grey_notNil()]; 503 assertWithMatcher:grey_notNil()];
499 } 504 }
500 505
506 // Tests that visible URL is always the same as last committed URL if user
507 // issues 2 go forward commands to WebUI page (crbug.com/711465).
508 - (void)testDoubleForwardNavigationToWebUIPage {
509 // Create 3rd entry in the history, to be able to go back twice.
510 GURL URL(kChromeUIVersionURL);
511 [ChromeEarlGrey loadURL:GURL(kChromeUIVersionURL)];
512
513 // Tap the back button twice in the toolbar and wait for URL 1 to load.
514 [[EarlGrey selectElementWithMatcher:chrome_test_util::BackButton()]
515 performAction:grey_tap()];
516 [[EarlGrey selectElementWithMatcher:chrome_test_util::BackButton()]
517 performAction:grey_tap()];
518 [[EarlGrey selectElementWithMatcher:WebViewContainingText(kTestPage1)]
519 assertWithMatcher:grey_notNil()];
520
521 // Quickly (using chrome command) navigate forward twice and wait for
522 // kChromeUIVersionURL to load.
523 base::scoped_nsobject<GenericChromeCommand> forwardCommand(
524 [[GenericChromeCommand alloc] initWithTag:IDC_FORWARD]);
525 chrome_test_util::RunCommandWithActiveViewController(forwardCommand);
526 chrome_test_util::RunCommandWithActiveViewController(forwardCommand);
527
528 const std::string version = version_info::GetVersionNumber();
529 [[EarlGrey selectElementWithMatcher:WebViewContainingText(version)]
530 assertWithMatcher:grey_notNil()];
531
532 // Make sure that kChromeUIVersionURL URL is displayed in the omnibox.
533 std::string expectedText = base::UTF16ToUTF8(web::GetDisplayTitleForUrl(URL));
534 [[EarlGrey selectElementWithMatcher:OmniboxText(expectedText)]
535 assertWithMatcher:grey_notNil()];
536 }
537
501 // Tests that visible URL is always the same as last committed URL if page calls 538 // Tests that visible URL is always the same as last committed URL if page calls
502 // window.history.back() twice. 539 // window.history.back() twice.
503 - (void)testDoubleBackJSNavigation { 540 - (void)testDoubleBackJSNavigation {
504 // Create 3rd entry in the history, to be able to go back twice. 541 // Create 3rd entry in the history, to be able to go back twice.
505 [ChromeEarlGrey loadURL:_testURL3]; 542 [ChromeEarlGrey loadURL:_testURL3];
506 543
507 // Purge web view caches and pause the server to make sure that tests can 544 // Purge web view caches and pause the server to make sure that tests can
508 // verify omnibox state before server starts responding. 545 // verify omnibox state before server starts responding.
509 PurgeCachedWebViewPages(); 546 PurgeCachedWebViewPages();
510 [self setServerPaused:YES]; 547 [self setServerPaused:YES];
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
549 - (BOOL)waitForServerToReceiveRequestWithURL:(GURL)URL { 586 - (BOOL)waitForServerToReceiveRequestWithURL:(GURL)URL {
550 return [[GREYCondition 587 return [[GREYCondition
551 conditionWithName:@"Wait for received request" 588 conditionWithName:@"Wait for received request"
552 block:^{ 589 block:^{
553 return _responseProvider->last_request_url() == URL ? YES 590 return _responseProvider->last_request_url() == URL ? YES
554 : NO; 591 : NO;
555 }] waitWithTimeout:10]; 592 }] waitWithTimeout:10];
556 } 593 }
557 594
558 @end 595 @end
OLDNEW
« no previous file with comments | « ios/chrome/browser/web/BUILD.gn ('k') | ios/web/navigation/crw_session_controller.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698