Chromium Code Reviews| 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 navigate forward twice and wait for kChromeUIVersionURL to load. | |
| 520 base::scoped_nsobject<GenericChromeCommand> forwardCommand( | |
| 521 [[GenericChromeCommand alloc] initWithTag:IDC_FORWARD]); | |
| 522 chrome_test_util::RunCommandWithActiveViewController(forwardCommand); | |
| 523 chrome_test_util::RunCommandWithActiveViewController(forwardCommand); | |
|
kkhorimoto
2017/04/18 23:03:15
Why are we using commands to go forward but UI ele
Eugene But (OOO till 7-30)
2017/04/19 00:26:46
Done.
| |
| 524 | |
| 525 const std::string version = version_info::GetVersionNumber(); | |
| 526 [[EarlGrey selectElementWithMatcher:WebViewContainingText(version)] | |
| 527 assertWithMatcher:grey_notNil()]; | |
| 528 | |
| 529 // Make sure that chrome://version URL is displayed in the omnibox. | |
| 530 [[EarlGrey selectElementWithMatcher:OmniboxText("chrome://version")] | |
|
kkhorimoto
2017/04/18 23:03:15
Can we not use kChromeUIVersionURL?
Eugene But (OOO till 7-30)
2017/04/19 00:26:46
No, kChromeUIVersionURL has a trailing slash :(
kkhorimoto
2017/04/19 00:34:41
I think you can use web::GetDisplayTitleForUrl() t
Eugene But (OOO till 7-30)
2017/04/19 01:24:36
I can. Thanks!
| |
| 531 assertWithMatcher:grey_notNil()]; | |
| 532 } | |
| 533 | |
| 501 // Tests that visible URL is always the same as last committed URL if page calls | 534 // Tests that visible URL is always the same as last committed URL if page calls |
| 502 // window.history.back() twice. | 535 // window.history.back() twice. |
| 503 - (void)testDoubleBackJSNavigation { | 536 - (void)testDoubleBackJSNavigation { |
| 504 // Create 3rd entry in the history, to be able to go back twice. | 537 // Create 3rd entry in the history, to be able to go back twice. |
| 505 [ChromeEarlGrey loadURL:_testURL3]; | 538 [ChromeEarlGrey loadURL:_testURL3]; |
| 506 | 539 |
| 507 // Purge web view caches and pause the server to make sure that tests can | 540 // Purge web view caches and pause the server to make sure that tests can |
| 508 // verify omnibox state before server starts responding. | 541 // verify omnibox state before server starts responding. |
| 509 PurgeCachedWebViewPages(); | 542 PurgeCachedWebViewPages(); |
| 510 [self setServerPaused:YES]; | 543 [self setServerPaused:YES]; |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 549 - (BOOL)waitForServerToReceiveRequestWithURL:(GURL)URL { | 582 - (BOOL)waitForServerToReceiveRequestWithURL:(GURL)URL { |
| 550 return [[GREYCondition | 583 return [[GREYCondition |
| 551 conditionWithName:@"Wait for received request" | 584 conditionWithName:@"Wait for received request" |
| 552 block:^{ | 585 block:^{ |
| 553 return _responseProvider->last_request_url() == URL ? YES | 586 return _responseProvider->last_request_url() == URL ? YES |
| 554 : NO; | 587 : NO; |
| 555 }] waitWithTimeout:10]; | 588 }] waitWithTimeout:10]; |
| 556 } | 589 } |
| 557 | 590 |
| 558 @end | 591 @end |
| OLD | NEW |