| 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 <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 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 51 // Button ids for history_go.html. | 51 // Button ids for history_go.html. |
| 52 NSString* const kGoNoParameterID = @"go-no-parameter"; | 52 NSString* const kGoNoParameterID = @"go-no-parameter"; |
| 53 NSString* const kGoZeroID = @"go-zero"; | 53 NSString* const kGoZeroID = @"go-zero"; |
| 54 NSString* const kGoTwoID = @"go-2"; | 54 NSString* const kGoTwoID = @"go-2"; |
| 55 NSString* const kGoBackTwoID = @"go-back-2"; | 55 NSString* const kGoBackTwoID = @"go-back-2"; |
| 56 | 56 |
| 57 // URLs and labels for tests that navigate back and forward. | 57 // URLs and labels for tests that navigate back and forward. |
| 58 const char kBackHTMLButtonLabel[] = "BackHTMLButton"; | 58 const char kBackHTMLButtonLabel[] = "BackHTMLButton"; |
| 59 const char kForwardHTMLButtonLabel[] = "ForwardHTMLButton"; | 59 const char kForwardHTMLButtonLabel[] = "ForwardHTMLButton"; |
| 60 const char kForwardHTMLSentinel[] = "Forward page loaded"; | 60 const char kForwardHTMLSentinel[] = "Forward page loaded"; |
| 61 const char kTestPageSentinel[] = "Test Page"; |
| 61 const char kBackURL[] = "http://back"; | 62 const char kBackURL[] = "http://back"; |
| 62 const char kForwardURL[] = "http://forward"; | 63 const char kForwardURL[] = "http://forward"; |
| 63 const char kTestURL[] = "http://test"; | 64 const char kTestURL[] = "http://test"; |
| 64 | 65 |
| 65 // URLs and labels for scenarioWindowLocation* tests. | 66 // URLs and labels for scenarioWindowLocation* tests. |
| 66 const char kHashChangeWithHistoryLabel[] = "hashChangedWithHistory"; | 67 const char kHashChangeWithHistoryLabel[] = "hashChangedWithHistory"; |
| 67 const char kHashChangeWithoutHistoryLabel[] = "hashChangedWithoutHistory"; | 68 const char kHashChangeWithoutHistoryLabel[] = "hashChangedWithoutHistory"; |
| 68 const char kPage1URL[] = "http://page1"; | 69 const char kPage1URL[] = "http://page1"; |
| 69 const char kHashChangedWithHistoryURL[] = | 70 const char kHashChangedWithHistoryURL[] = |
| 70 "http://page1/#hashChangedWithHistory"; | 71 "http://page1/#hashChangedWithHistory"; |
| (...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 371 // Tap the forward button in the toolbar and verify the second URL is loaded. | 372 // Tap the forward button in the toolbar and verify the second URL is loaded. |
| 372 [[EarlGrey selectElementWithMatcher:forwardButton()] | 373 [[EarlGrey selectElementWithMatcher:forwardButton()] |
| 373 performAction:grey_tap()]; | 374 performAction:grey_tap()]; |
| 374 [[EarlGrey selectElementWithMatcher:chrome_test_util::omniboxText( | 375 [[EarlGrey selectElementWithMatcher:chrome_test_util::omniboxText( |
| 375 secondURL.GetContent())] | 376 secondURL.GetContent())] |
| 376 assertWithMatcher:grey_notNil()]; | 377 assertWithMatcher:grey_notNil()]; |
| 377 } | 378 } |
| 378 | 379 |
| 379 // Tests going back via back button then forward via history.forward(). | 380 // Tests going back via back button then forward via history.forward(). |
| 380 - (void)testHistoryForwardNavigation { | 381 - (void)testHistoryForwardNavigation { |
| 381 // TODO(crbug.com/677129): Reenable this test. | |
| 382 #if TARGET_OS_IPHONE | |
| 383 EARL_GREY_TEST_SKIPPED(@"flaky on devices"); | |
| 384 #endif // TARGET_OS_IPHONE | |
| 385 | |
| 386 SetupBackAndForwardResponseProvider(); | 382 SetupBackAndForwardResponseProvider(); |
| 387 | 383 |
| 388 // Navigate to an HTML page with a forward button. | 384 // Navigate to an HTML page with a forward button. |
| 389 const GURL firstURL = web::test::HttpServer::MakeUrl(kForwardURL); | 385 const GURL firstURL = web::test::HttpServer::MakeUrl(kForwardURL); |
| 390 [ChromeEarlGrey loadURL:firstURL]; | 386 [ChromeEarlGrey loadURL:firstURL]; |
| 391 | 387 |
| 392 // Navigate to some other page. | 388 // Navigate to some other page. |
| 393 const GURL secondURL = web::test::HttpServer::MakeUrl(kTestURL); | 389 const GURL secondURL = web::test::HttpServer::MakeUrl(kTestURL); |
| 394 [ChromeEarlGrey loadURL:secondURL]; | 390 [ChromeEarlGrey loadURL:secondURL]; |
| 395 | 391 |
| 396 // Tap the back button in the toolbar and verify the page with forward button | 392 // Tap the back button in the toolbar and verify the page with forward button |
| 397 // is loaded. | 393 // is loaded. |
| 398 [[EarlGrey selectElementWithMatcher:backButton()] performAction:grey_tap()]; | 394 [[EarlGrey selectElementWithMatcher:backButton()] performAction:grey_tap()]; |
| 395 [[EarlGrey |
| 396 selectElementWithMatcher:webViewContainingText(kForwardHTMLSentinel)] |
| 397 assertWithMatcher:grey_notNil()]; |
| 399 [[EarlGrey selectElementWithMatcher:chrome_test_util::omniboxText( | 398 [[EarlGrey selectElementWithMatcher:chrome_test_util::omniboxText( |
| 400 firstURL.GetContent())] | 399 firstURL.GetContent())] |
| 401 assertWithMatcher:grey_notNil()]; | 400 assertWithMatcher:grey_notNil()]; |
| 402 [[EarlGrey | |
| 403 selectElementWithMatcher:webViewContainingText(kForwardHTMLSentinel)] | |
| 404 assertWithMatcher:grey_notNil()]; | |
| 405 | 401 |
| 406 // Tap the forward button in the HTML and verify the second URL is loaded. | 402 // Tap the forward button in the HTML and verify the second URL is loaded. |
| 407 TapWebViewElementWithId(kForwardHTMLButtonLabel); | 403 TapWebViewElementWithId(kForwardHTMLButtonLabel); |
| 404 [[EarlGrey selectElementWithMatcher:webViewContainingText(kTestPageSentinel)] |
| 405 assertWithMatcher:grey_notNil()]; |
| 408 [[EarlGrey selectElementWithMatcher:chrome_test_util::omniboxText( | 406 [[EarlGrey selectElementWithMatcher:chrome_test_util::omniboxText( |
| 409 secondURL.GetContent())] | 407 secondURL.GetContent())] |
| 410 assertWithMatcher:grey_notNil()]; | 408 assertWithMatcher:grey_notNil()]; |
| 411 | 409 |
| 412 // Verify that the forward button is not enabled. | 410 // Verify that the forward button is not enabled. |
| 413 // TODO(crbug.com/638674): Evaluate if size class determination can move to | 411 // TODO(crbug.com/638674): Evaluate if size class determination can move to |
| 414 // shared code. | 412 // shared code. |
| 415 if (UIApplication.sharedApplication.keyWindow.traitCollection | 413 if (UIApplication.sharedApplication.keyWindow.traitCollection |
| 416 .horizontalSizeClass == UIUserInterfaceSizeClassCompact) { | 414 .horizontalSizeClass == UIUserInterfaceSizeClassCompact) { |
| 417 // In horizontally compact environments, the forward button is not visible. | 415 // In horizontally compact environments, the forward button is not visible. |
| (...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 688 // Navigate forward and assert the the resulting page is the proper | 686 // Navigate forward and assert the the resulting page is the proper |
| 689 // destination. | 687 // destination. |
| 690 [[EarlGrey selectElementWithMatcher:forwardButton()] | 688 [[EarlGrey selectElementWithMatcher:forwardButton()] |
| 691 performAction:grey_tap()]; | 689 performAction:grey_tap()]; |
| 692 [[EarlGrey selectElementWithMatcher:chrome_test_util::omniboxText( | 690 [[EarlGrey selectElementWithMatcher:chrome_test_util::omniboxText( |
| 693 destinationURL.GetContent())] | 691 destinationURL.GetContent())] |
| 694 assertWithMatcher:grey_notNil()]; | 692 assertWithMatcher:grey_notNil()]; |
| 695 } | 693 } |
| 696 | 694 |
| 697 @end | 695 @end |
| OLD | NEW |