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