| 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 #import <UIKit/UIKit.h> | 6 #import <UIKit/UIKit.h> |
| 7 #import <XCTest/XCTest.h> | 7 #import <XCTest/XCTest.h> |
| 8 | 8 |
| 9 #import "base/strings/sys_string_conversions.h" | 9 #import "base/strings/sys_string_conversions.h" |
| 10 #include "components/strings/grit/components_strings.h" | 10 #include "components/strings/grit/components_strings.h" |
| (...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 232 performAction:grey_typeText(input)]; | 232 performAction:grey_typeText(input)]; |
| 233 } | 233 } |
| 234 | 234 |
| 235 void TapOK() { | 235 void TapOK() { |
| 236 id<GREYMatcher> ok_button = | 236 id<GREYMatcher> ok_button = |
| 237 chrome_test_util::buttonWithAccessibilityLabelId(IDS_OK); | 237 chrome_test_util::buttonWithAccessibilityLabelId(IDS_OK); |
| 238 [[EarlGrey selectElementWithMatcher:ok_button] performAction:grey_tap()]; | 238 [[EarlGrey selectElementWithMatcher:ok_button] performAction:grey_tap()]; |
| 239 } | 239 } |
| 240 | 240 |
| 241 void TapCancel() { | 241 void TapCancel() { |
| 242 id<GREYMatcher> cancel_button = | 242 [[EarlGrey selectElementWithMatcher:chrome_test_util::cancelButton()] |
| 243 chrome_test_util::buttonWithAccessibilityLabelId(IDS_CANCEL); | 243 performAction:grey_tap()]; |
| 244 [[EarlGrey selectElementWithMatcher:cancel_button] performAction:grey_tap()]; | |
| 245 } | 244 } |
| 246 | 245 |
| 247 void TapSuppressDialogsButton() { | 246 void TapSuppressDialogsButton() { |
| 248 id<GREYMatcher> suppress_dialogs_button = | 247 id<GREYMatcher> suppress_dialogs_button = |
| 249 chrome_test_util::buttonWithAccessibilityLabelId( | 248 chrome_test_util::buttonWithAccessibilityLabelId( |
| 250 IDS_IOS_JAVA_SCRIPT_DIALOG_BLOCKING_BUTTON_TEXT); | 249 IDS_IOS_JAVA_SCRIPT_DIALOG_BLOCKING_BUTTON_TEXT); |
| 251 [[EarlGrey selectElementWithMatcher:suppress_dialogs_button] | 250 [[EarlGrey selectElementWithMatcher:suppress_dialogs_button] |
| 252 performAction:grey_tap()]; | 251 performAction:grey_tap()]; |
| 253 } | 252 } |
| 254 | 253 |
| (...skipping 20 matching lines...) Expand all Loading... |
| 275 chrome_test_util::webViewContainingText(std::string("")); | 274 chrome_test_util::webViewContainingText(std::string("")); |
| 276 [[EarlGrey selectElementWithMatcher:response2Matcher] | 275 [[EarlGrey selectElementWithMatcher:response2Matcher] |
| 277 assertWithMatcher:grey_notNil()]; | 276 assertWithMatcher:grey_notNil()]; |
| 278 } | 277 } |
| 279 | 278 |
| 280 - (void)tearDown { | 279 - (void)tearDown { |
| 281 NSError* errorOK = nil; | 280 NSError* errorOK = nil; |
| 282 NSError* errorCancel = nil; | 281 NSError* errorCancel = nil; |
| 283 | 282 |
| 284 // Dismiss JavaScript alert by tapping Cancel. | 283 // Dismiss JavaScript alert by tapping Cancel. |
| 285 id<GREYMatcher> CancelButton = | 284 [[EarlGrey selectElementWithMatcher:chrome_test_util::cancelButton()] |
| 286 chrome_test_util::buttonWithAccessibilityLabelId(IDS_CANCEL); | 285 performAction:grey_tap() |
| 287 [[EarlGrey selectElementWithMatcher:CancelButton] performAction:grey_tap() | 286 error:&errorCancel]; |
| 288 error:&errorCancel]; | |
| 289 // Dismiss JavaScript alert by tapping OK. | 287 // Dismiss JavaScript alert by tapping OK. |
| 290 id<GREYMatcher> OKButton = | 288 id<GREYMatcher> OKButton = |
| 291 chrome_test_util::buttonWithAccessibilityLabelId(IDS_OK); | 289 chrome_test_util::buttonWithAccessibilityLabelId(IDS_OK); |
| 292 [[EarlGrey selectElementWithMatcher:OKButton] performAction:grey_tap() | 290 [[EarlGrey selectElementWithMatcher:OKButton] performAction:grey_tap() |
| 293 error:&errorOK]; | 291 error:&errorOK]; |
| 294 | 292 |
| 295 if (!errorOK || !errorCancel) { | 293 if (!errorOK || !errorCancel) { |
| 296 GREYFail(@"There are still alerts"); | 294 GREYFail(@"There are still alerts"); |
| 297 } | 295 } |
| 298 [super tearDown]; | 296 [super tearDown]; |
| (...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 496 ShowJavaScriptDialog(JavaScriptAlertType::ALERT); | 494 ShowJavaScriptDialog(JavaScriptAlertType::ALERT); |
| 497 | 495 |
| 498 // Tap the OK button. | 496 // Tap the OK button. |
| 499 TapOK(); | 497 TapOK(); |
| 500 | 498 |
| 501 // Wait for the html body to be reset to the correct value. | 499 // Wait for the html body to be reset to the correct value. |
| 502 WaitForWebDisplay(kAlertResultBody); | 500 WaitForWebDisplay(kAlertResultBody); |
| 503 } | 501 } |
| 504 | 502 |
| 505 @end | 503 @end |
| OLD | NEW |