Commit 2e6f9e37 authored by Mike Baxley's avatar Mike Baxley Committed by Commit Bot

Replace TapOK with EarlGrey method using OKButton().

Create OKButton shared matcher, since this button is likely used
other places.

Bug: 
Change-Id: Ib45265f6be2ebc2d59f3e912bc4d6e6fb628771d
Reviewed-on: https://chromium-review.googlesource.com/503493Reviewed-by: default avatarEugene But <eugenebut@chromium.org>
Commit-Queue: Mike Baxley <baxley@chromium.org>
Cr-Commit-Position: refs/heads/master@{#471126}
parent e3d7e30c
...@@ -34,6 +34,7 @@ ...@@ -34,6 +34,7 @@
#endif #endif
using chrome_test_util::NavigationBarDoneButton; using chrome_test_util::NavigationBarDoneButton;
using chrome_test_util::OKButton;
using web::test::HttpServer; using web::test::HttpServer;
namespace { namespace {
...@@ -258,12 +259,6 @@ void TypeInPrompt(NSString* input) { ...@@ -258,12 +259,6 @@ void TypeInPrompt(NSString* input) {
performAction:grey_typeText(input)]; performAction:grey_typeText(input)];
} }
void TapOK() {
id<GREYMatcher> ok_button =
chrome_test_util::ButtonWithAccessibilityLabelId(IDS_OK);
[[EarlGrey selectElementWithMatcher:ok_button] performAction:grey_tap()];
}
void TapCancel() { void TapCancel() {
[[EarlGrey selectElementWithMatcher:chrome_test_util::CancelButton()] [[EarlGrey selectElementWithMatcher:chrome_test_util::CancelButton()]
performAction:grey_tap()]; performAction:grey_tap()];
...@@ -352,8 +347,7 @@ void TapSuppressDialogsButton() { ...@@ -352,8 +347,7 @@ void TapSuppressDialogsButton() {
[self loadBlankTestPage]; [self loadBlankTestPage];
ShowJavaScriptDialog(JavaScriptAlertType::ALERT); ShowJavaScriptDialog(JavaScriptAlertType::ALERT);
// Tap the OK button. [[EarlGrey selectElementWithMatcher:OKButton()] performAction:grey_tap()];
TapOK();
// Wait for the html body to be reset to the correct value. // Wait for the html body to be reset to the correct value.
WaitForWebDisplay(kAlertResultBody); WaitForWebDisplay(kAlertResultBody);
...@@ -373,8 +367,7 @@ void TapSuppressDialogsButton() { ...@@ -373,8 +367,7 @@ void TapSuppressDialogsButton() {
[self loadBlankTestPage]; [self loadBlankTestPage];
ShowJavaScriptDialog(JavaScriptAlertType::CONFIRMATION); ShowJavaScriptDialog(JavaScriptAlertType::CONFIRMATION);
// Tap the OK button. [[EarlGrey selectElementWithMatcher:OKButton()] performAction:grey_tap()];
TapOK();
// Wait for the html body to be reset to the correct value. // Wait for the html body to be reset to the correct value.
WaitForWebDisplay(kConfirmationResultBodyOK); WaitForWebDisplay(kConfirmationResultBodyOK);
...@@ -418,8 +411,7 @@ void TapSuppressDialogsButton() { ...@@ -418,8 +411,7 @@ void TapSuppressDialogsButton() {
// Enter text into text field. // Enter text into text field.
TypeInPrompt(@(kPromptTestUserInput)); TypeInPrompt(@(kPromptTestUserInput));
// Tap the OK button. [[EarlGrey selectElementWithMatcher:OKButton()] performAction:grey_tap()];
TapOK();
// Wait for the html body to be reset to the input text. // Wait for the html body to be reset to the input text.
WaitForWebDisplay(kPromptTestUserInput); WaitForWebDisplay(kPromptTestUserInput);
...@@ -458,8 +450,7 @@ void TapSuppressDialogsButton() { ...@@ -458,8 +450,7 @@ void TapSuppressDialogsButton() {
webState->ExecuteJavaScript(base::SysNSStringToUTF16(script)); webState->ExecuteJavaScript(base::SysNSStringToUTF16(script));
WaitForJavaScripDialogToBeShown(); WaitForJavaScripDialogToBeShown();
// Tap the OK button and wait for another dialog to be shown. [[EarlGrey selectElementWithMatcher:OKButton()] performAction:grey_tap()];
TapOK();
WaitForJavaScripDialogToBeShown(); WaitForJavaScripDialogToBeShown();
// Tap the suppress dialogs button. // Tap the suppress dialogs button.
...@@ -511,8 +502,7 @@ void TapSuppressDialogsButton() { ...@@ -511,8 +502,7 @@ void TapSuppressDialogsButton() {
// Make sure the alert is present. // Make sure the alert is present.
WaitForJavaScripDialogToBeShown(); WaitForJavaScripDialogToBeShown();
// Tap the OK button. [[EarlGrey selectElementWithMatcher:OKButton()] performAction:grey_tap()];
TapOK();
// Wait for the html body to be reset to the correct value. // Wait for the html body to be reset to the correct value.
WaitForWebDisplay(kAlertResultBody); WaitForWebDisplay(kAlertResultBody);
...@@ -541,8 +531,7 @@ void TapSuppressDialogsButton() { ...@@ -541,8 +531,7 @@ void TapSuppressDialogsButton() {
// Show an alert and assert it is present. // Show an alert and assert it is present.
ShowJavaScriptDialog(JavaScriptAlertType::ALERT); ShowJavaScriptDialog(JavaScriptAlertType::ALERT);
// Tap the OK button. [[EarlGrey selectElementWithMatcher:OKButton()] performAction:grey_tap()];
TapOK();
// Wait for the html body to be reset to the correct value. // Wait for the html body to be reset to the correct value.
WaitForWebDisplay(kAlertResultBody); WaitForWebDisplay(kAlertResultBody);
...@@ -596,8 +585,7 @@ void TapSuppressDialogsButton() { ...@@ -596,8 +585,7 @@ void TapSuppressDialogsButton() {
[[EarlGrey selectElementWithMatcher:chrome_test_util::OmniboxText(title)] [[EarlGrey selectElementWithMatcher:chrome_test_util::OmniboxText(title)]
assertWithMatcher:grey_notNil()]; assertWithMatcher:grey_notNil()];
// Close the alert. [[EarlGrey selectElementWithMatcher:OKButton()] performAction:grey_tap()];
TapOK();
// Reenable synchronization on iPads now that the dialog has been dismissed. // Reenable synchronization on iPads now that the dialog has been dismissed.
if (IsIPadIdiom()) { if (IsIPadIdiom()) {
......
...@@ -101,6 +101,9 @@ id<GREYMatcher> ClearBrowsingDataCollectionView(); ...@@ -101,6 +101,9 @@ id<GREYMatcher> ClearBrowsingDataCollectionView();
// Returns matcher for the settings button in the tools menu. // Returns matcher for the settings button in the tools menu.
id<GREYMatcher> SettingsMenuButton(); id<GREYMatcher> SettingsMenuButton();
// Returns matcher for the OK button.
id<GREYMatcher> OKButton();
} // namespace chrome_test_util } // namespace chrome_test_util
#endif // IOS_CHROME_TEST_EARL_GREY_CHROME_MATCHERS_H_ #endif // IOS_CHROME_TEST_EARL_GREY_CHROME_MATCHERS_H_
...@@ -186,4 +186,8 @@ id<GREYMatcher> SettingsMenuButton() { ...@@ -186,4 +186,8 @@ id<GREYMatcher> SettingsMenuButton() {
return grey_accessibilityID(kToolsMenuSettingsId); return grey_accessibilityID(kToolsMenuSettingsId);
} }
id<GREYMatcher> OKButton() {
return ButtonWithAccessibilityLabelId(IDS_OK);
}
} // namespace chrome_test_util } // namespace chrome_test_util
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment