| 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/mac/scoped_nsobject.h" | 7 #include "base/mac/scoped_nsobject.h" |
| 8 #include "base/memory/ptr_util.h" | 8 #include "base/memory/ptr_util.h" |
| 9 #include "base/strings/stringprintf.h" | 9 #include "base/strings/stringprintf.h" |
| 10 #include "base/strings/sys_string_conversions.h" | 10 #include "base/strings/sys_string_conversions.h" |
| 11 #include "components/strings/grit/components_strings.h" | 11 #include "components/strings/grit/components_strings.h" |
| 12 #import "ios/chrome/browser/ui/commands/generic_chrome_command.h" | 12 #import "ios/chrome/browser/ui/commands/generic_chrome_command.h" |
| 13 #include "ios/chrome/browser/ui/commands/ios_command_ids.h" | 13 #include "ios/chrome/browser/ui/commands/ios_command_ids.h" |
| 14 #include "ios/chrome/browser/ui/ui_util.h" | 14 #include "ios/chrome/browser/ui/ui_util.h" |
| 15 #import "ios/chrome/test/app/chrome_test_util.h" | 15 #import "ios/chrome/test/app/chrome_test_util.h" |
| 16 #include "ios/chrome/test/app/navigation_test_util.h" | 16 #include "ios/chrome/test/app/navigation_test_util.h" |
| 17 #include "ios/chrome/test/app/web_view_interaction_test_util.h" | 17 #include "ios/chrome/test/app/web_view_interaction_test_util.h" |
| 18 #import "ios/chrome/test/earl_grey/chrome_earl_grey.h" | 18 #import "ios/chrome/test/earl_grey/chrome_earl_grey.h" |
| 19 #import "ios/chrome/test/earl_grey/chrome_matchers.h" | 19 #import "ios/chrome/test/earl_grey/chrome_matchers.h" |
| 20 #import "ios/chrome/test/earl_grey/chrome_test_case.h" | 20 #import "ios/chrome/test/earl_grey/chrome_test_case.h" |
| 21 #import "ios/testing/wait_util.h" | 21 #import "ios/testing/wait_util.h" |
| 22 #import "ios/web/public/test/http_server.h" | 22 #import "ios/web/public/test/http_server.h" |
| 23 #import "ios/web/public/test/http_server_util.h" | 23 #import "ios/web/public/test/http_server_util.h" |
| 24 #include "ios/web/public/test/response_providers/data_response_provider.h" | 24 #include "ios/web/public/test/response_providers/data_response_provider.h" |
| 25 #include "ios/web/public/test/url_test_util.h" |
| 25 | 26 |
| 26 namespace { | 27 namespace { |
| 27 | 28 |
| 28 // URL for a generic website in the user navigation flow. | 29 // URL for a generic website in the user navigation flow. |
| 29 const char kGenericUrl[] = "http://generic"; | 30 const char kGenericUrl[] = "http://generic"; |
| 30 | 31 |
| 31 // URL to print the HTTP method and the request body. | 32 // URL to print the HTTP method and the request body. |
| 32 const char kPrintFormDataUrl[] = "http://printFormData"; | 33 const char kPrintFormDataUrl[] = "http://printFormData"; |
| 33 | 34 |
| 34 // URL that redirects to kPrintPostData with a 302. | 35 // URL that redirects to kPrintPostData with a 302. |
| (...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 269 - (void)testRepostFormAfterIndexNavigation { | 270 - (void)testRepostFormAfterIndexNavigation { |
| 270 [ChromeEarlGrey loadURL:TestResponseProvider::GetFormUrl()]; | 271 [ChromeEarlGrey loadURL:TestResponseProvider::GetFormUrl()]; |
| 271 [self submitForm]; | 272 [self submitForm]; |
| 272 | 273 |
| 273 // Go to a new page. | 274 // Go to a new page. |
| 274 [ChromeEarlGrey loadURL:TestResponseProvider::GetGenericUrl()]; | 275 [ChromeEarlGrey loadURL:TestResponseProvider::GetGenericUrl()]; |
| 275 | 276 |
| 276 [self openBackHistory]; | 277 [self openBackHistory]; |
| 277 [self waitForTabHistoryView]; | 278 [self waitForTabHistoryView]; |
| 278 | 279 |
| 279 id<GREYMatcher> historyItem = grey_text(base::SysUTF8ToNSString( | 280 GURL history_url = TestResponseProvider::GetPrintFormDataUrl(); |
| 280 TestResponseProvider::GetPrintFormDataUrl().spec())); | 281 id<GREYMatcher> historyItem = grey_text( |
| 282 base::SysUTF16ToNSString(web::GetDisplayTitleForUrl(history_url))); |
| 281 [[EarlGrey selectElementWithMatcher:historyItem] performAction:grey_tap()]; | 283 [[EarlGrey selectElementWithMatcher:historyItem] performAction:grey_tap()]; |
| 282 | 284 |
| 283 [ChromeEarlGrey waitForPageToFinishLoading]; | 285 [ChromeEarlGrey waitForPageToFinishLoading]; |
| 284 | 286 |
| 285 [self confirmResendWarning]; | 287 [self confirmResendWarning]; |
| 286 [self waitForExpectedResponse:kExpectedPostData]; | 288 [self waitForExpectedResponse:kExpectedPostData]; |
| 287 } | 289 } |
| 288 | 290 |
| 289 // When data is not re-sent, the request is done with a GET method. | 291 // When data is not re-sent, the request is done with a GET method. |
| 290 - (void)testRepostFormCancelling { | 292 - (void)testRepostFormCancelling { |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 328 id<GREYMatcher> resendWarning = | 330 id<GREYMatcher> resendWarning = |
| 329 chrome_test_util::ButtonWithAccessibilityLabelId( | 331 chrome_test_util::ButtonWithAccessibilityLabelId( |
| 330 IDS_HTTP_POST_WARNING_RESEND); | 332 IDS_HTTP_POST_WARNING_RESEND); |
| 331 [[EarlGrey selectElementWithMatcher:resendWarning] | 333 [[EarlGrey selectElementWithMatcher:resendWarning] |
| 332 assertWithMatcher:grey_nil()]; | 334 assertWithMatcher:grey_nil()]; |
| 333 | 335 |
| 334 [self waitForExpectedResponse:"GET"]; | 336 [self waitForExpectedResponse:"GET"]; |
| 335 } | 337 } |
| 336 | 338 |
| 337 @end | 339 @end |
| OLD | NEW |