| 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/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/strings/grit/components_strings.h" | 10 #include "components/strings/grit/components_strings.h" |
| 11 #include "ios/chrome/browser/ui/ui_util.h" | 11 #include "ios/chrome/browser/ui/ui_util.h" |
| 12 #import "ios/chrome/test/app/chrome_test_util.h" | 12 #import "ios/chrome/test/app/chrome_test_util.h" |
| 13 #include "ios/chrome/test/app/navigation_test_util.h" | 13 #include "ios/chrome/test/app/navigation_test_util.h" |
| 14 #include "ios/chrome/test/app/web_view_interaction_test_util.h" | 14 #include "ios/chrome/test/app/web_view_interaction_test_util.h" |
| 15 #import "ios/chrome/test/earl_grey/chrome_earl_grey.h" | 15 #import "ios/chrome/test/earl_grey/chrome_earl_grey.h" |
| 16 #import "ios/chrome/test/earl_grey/chrome_earl_grey_ui.h" | 16 #import "ios/chrome/test/earl_grey/chrome_earl_grey_ui.h" |
| 17 #import "ios/chrome/test/earl_grey/chrome_matchers.h" | 17 #import "ios/chrome/test/earl_grey/chrome_matchers.h" |
| 18 #import "ios/chrome/test/earl_grey/chrome_test_case.h" | 18 #import "ios/chrome/test/earl_grey/chrome_test_case.h" |
| 19 #import "ios/testing/wait_util.h" | 19 #import "ios/testing/wait_util.h" |
| 20 #import "ios/web/public/test/http_server.h" | 20 #import "ios/web/public/test/http_server.h" |
| 21 #import "ios/web/public/test/http_server_util.h" | 21 #import "ios/web/public/test/http_server_util.h" |
| 22 #include "ios/web/public/test/response_providers/data_response_provider.h" | 22 #include "ios/web/public/test/response_providers/data_response_provider.h" |
| 23 #include "ios/web/public/test/url_test_util.h" | 23 #include "ios/web/public/test/url_test_util.h" |
| 24 | 24 |
| 25 #if !defined(__has_feature) || !__has_feature(objc_arc) |
| 26 #error "This file requires ARC support." |
| 27 #endif |
| 28 |
| 25 using chrome_test_util::ButtonWithAccessibilityLabelId; | 29 using chrome_test_util::ButtonWithAccessibilityLabelId; |
| 26 using chrome_test_util::OmniboxText; | 30 using chrome_test_util::OmniboxText; |
| 27 using chrome_test_util::WebViewContainingText; | 31 using chrome_test_util::WebViewContainingText; |
| 28 | 32 |
| 29 namespace { | 33 namespace { |
| 30 | 34 |
| 31 // Response shown on the page of |GetDestinationUrl|. | 35 // Response shown on the page of |GetDestinationUrl|. |
| 32 const char kDestinationText[] = "bar!"; | 36 const char kDestinationText[] = "bar!"; |
| 33 | 37 |
| 34 // Label for the button in the form. | 38 // Label for the button in the form. |
| (...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 268 assertWithMatcher:grey_notNil()]; | 272 assertWithMatcher:grey_notNil()]; |
| 269 | 273 |
| 270 [ChromeEarlGrey goBack]; | 274 [ChromeEarlGrey goBack]; |
| 271 [ChromeEarlGrey goForward]; | 275 [ChromeEarlGrey goForward]; |
| 272 | 276 |
| 273 // Abort the reload. | 277 // Abort the reload. |
| 274 // TODO (crbug.com/705020): Use something like ElementToDismissContextMenu | 278 // TODO (crbug.com/705020): Use something like ElementToDismissContextMenu |
| 275 // to cancel form repost. | 279 // to cancel form repost. |
| 276 if (IsIPadIdiom()) { | 280 if (IsIPadIdiom()) { |
| 277 // On tablet, dismiss the popover. | 281 // On tablet, dismiss the popover. |
| 278 base::scoped_nsobject<GREYElementMatcherBlock> matcher([ | 282 GREYElementMatcherBlock* matcher = [[GREYElementMatcherBlock alloc] |
| 279 [GREYElementMatcherBlock alloc] | |
| 280 initWithMatchesBlock:^BOOL(UIView* view) { | 283 initWithMatchesBlock:^BOOL(UIView* view) { |
| 281 return [NSStringFromClass([view class]) hasPrefix:@"UIDimmingView"]; | 284 return [NSStringFromClass([view class]) hasPrefix:@"UIDimmingView"]; |
| 282 } | 285 } |
| 283 descriptionBlock:^(id<GREYDescription> description) { | 286 descriptionBlock:^(id<GREYDescription> description) { |
| 284 [description appendText:@"class prefixed with UIDimmingView"]; | 287 [description appendText:@"class prefixed with UIDimmingView"]; |
| 285 }]); | 288 }]; |
| 286 [[EarlGrey selectElementWithMatcher:matcher] | 289 [[EarlGrey selectElementWithMatcher:matcher] |
| 287 performAction:grey_tapAtPoint(CGPointMake(50.0f, 50.0f))]; | 290 performAction:grey_tapAtPoint(CGPointMake(50.0f, 50.0f))]; |
| 288 } else { | 291 } else { |
| 289 // On handset, dismiss via the cancel button. | 292 // On handset, dismiss via the cancel button. |
| 290 [[EarlGrey selectElementWithMatcher:chrome_test_util::CancelButton()] | 293 [[EarlGrey selectElementWithMatcher:chrome_test_util::CancelButton()] |
| 291 performAction:grey_tap()]; | 294 performAction:grey_tap()]; |
| 292 } | 295 } |
| 293 [ChromeEarlGrey waitForPageToFinishLoading]; | 296 [ChromeEarlGrey waitForPageToFinishLoading]; |
| 294 | 297 |
| 295 // Verify that navigation was cancelled, and forward navigation is possible. | 298 // Verify that navigation was cancelled, and forward navigation is possible. |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 346 ButtonWithAccessibilityLabelId(IDS_HTTP_POST_WARNING_RESEND); | 349 ButtonWithAccessibilityLabelId(IDS_HTTP_POST_WARNING_RESEND); |
| 347 [[EarlGrey selectElementWithMatcher:resendWarning] | 350 [[EarlGrey selectElementWithMatcher:resendWarning] |
| 348 assertWithMatcher:grey_nil()]; | 351 assertWithMatcher:grey_nil()]; |
| 349 [[EarlGrey selectElementWithMatcher:WebViewContainingText("GET")] | 352 [[EarlGrey selectElementWithMatcher:WebViewContainingText("GET")] |
| 350 assertWithMatcher:grey_notNil()]; | 353 assertWithMatcher:grey_notNil()]; |
| 351 [[EarlGrey selectElementWithMatcher:OmniboxText(destinationURL.GetContent())] | 354 [[EarlGrey selectElementWithMatcher:OmniboxText(destinationURL.GetContent())] |
| 352 assertWithMatcher:grey_notNil()]; | 355 assertWithMatcher:grey_notNil()]; |
| 353 } | 356 } |
| 354 | 357 |
| 355 @end | 358 @end |
| OLD | NEW |