Commit 15b10725 authored by Mohamad Ahmadi's avatar Mohamad Ahmadi Committed by Commit Bot

Fixes SCPaymentsEditorTestCase.testNavigationByTappingReturn

Bug: 759904
Change-Id: I1a66f126cc2c47b76e1fdb2acbf9eeec61d96ea9
Reviewed-on: https://chromium-review.googlesource.com/677985
Commit-Queue: Moe Ahmadi <mahmadi@chromium.org>
Reviewed-by: default avataredchin <edchin@chromium.org>
Cr-Commit-Position: refs/heads/master@{#504386}
parent 0fd5cf35
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
#import "ios/chrome/browser/ui/payments/payment_request_edit_view_controller.h" #import "ios/chrome/browser/ui/payments/payment_request_edit_view_controller.h"
#include "ios/chrome/browser/ui/ui_util.h" #include "ios/chrome/browser/ui/ui_util.h"
#include "ios/chrome/grit/ios_strings.h" #include "ios/chrome/grit/ios_strings.h"
#import "ios/chrome/test/earl_grey/chrome_matchers.h"
#import "ios/showcase/test/showcase_eg_utils.h" #import "ios/showcase/test/showcase_eg_utils.h"
#import "ios/showcase/test/showcase_test_case.h" #import "ios/showcase/test/showcase_test_case.h"
#include "ui/base/l10n/l10n_util.h" #include "ui/base/l10n/l10n_util.h"
...@@ -79,6 +80,13 @@ id<GREYMatcher> UIAlertViewMessageForDelegateCallWithArgument( ...@@ -79,6 +80,13 @@ id<GREYMatcher> UIAlertViewMessageForDelegateCallWithArgument(
grey_sufficientlyVisible(), nil); grey_sufficientlyVisible(), nil);
} }
// Matcher for the return key on the keyboard.
id<GREYMatcher> KeyboardReturnKey(NSString* label) {
return grey_allOf(chrome_test_util::ButtonWithAccessibilityLabel(label),
grey_accessibilityTrait(UIAccessibilityTraitKeyboardKey),
grey_sufficientlyVisible(), nil);
}
} // namespace } // namespace
// Tests for the payment request editor view controller. // Tests for the payment request editor view controller.
...@@ -286,11 +294,6 @@ id<GREYMatcher> UIAlertViewMessageForDelegateCallWithArgument( ...@@ -286,11 +294,6 @@ id<GREYMatcher> UIAlertViewMessageForDelegateCallWithArgument(
// get focus except for the last textfield in which case causes the focus to go // get focus except for the last textfield in which case causes the focus to go
// away from the textfield. // away from the textfield.
- (void)testNavigationByTappingReturn { - (void)testNavigationByTappingReturn {
// TODO(crbug.com/759904): Reenable on iOS11 iPad when working on iPad iOS 11
// devices.
if (base::ios::IsRunningOnIOS11OrLater() && IsIPadIdiom()) {
EARL_GREY_TEST_DISABLED(@"Test disabled on iOS 11.");
}
// Tap the name textfield. // Tap the name textfield.
[[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"Name_textField")] [[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"Name_textField")]
performAction:grey_tap()]; performAction:grey_tap()];
...@@ -298,9 +301,9 @@ id<GREYMatcher> UIAlertViewMessageForDelegateCallWithArgument( ...@@ -298,9 +301,9 @@ id<GREYMatcher> UIAlertViewMessageForDelegateCallWithArgument(
// Assert the name textfield is focused. // Assert the name textfield is focused.
AssertTextFieldWithAccessibilityIDIsFirstResponder(@"Name_textField"); AssertTextFieldWithAccessibilityIDIsFirstResponder(@"Name_textField");
// Press the return key on the name textfield. // Press the return key.
[[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"Name_textField")] [[EarlGrey selectElementWithMatcher:KeyboardReturnKey(@"Next")]
performAction:grey_typeText(@"\n")]; performAction:grey_tap()];
// Assert the province textfield is focused. // Assert the province textfield is focused.
AssertTextFieldWithAccessibilityIDIsFirstResponder( AssertTextFieldWithAccessibilityIDIsFirstResponder(
...@@ -321,18 +324,24 @@ id<GREYMatcher> UIAlertViewMessageForDelegateCallWithArgument( ...@@ -321,18 +324,24 @@ id<GREYMatcher> UIAlertViewMessageForDelegateCallWithArgument(
// Assert the address textfield is focused. // Assert the address textfield is focused.
AssertTextFieldWithAccessibilityIDIsFirstResponder(@"Address_textField"); AssertTextFieldWithAccessibilityIDIsFirstResponder(@"Address_textField");
// Press the return key on the address textfield. // Press the return key.
[[EarlGrey [[EarlGrey selectElementWithMatcher:KeyboardReturnKey(@"Next")]
selectElementWithMatcher:grey_accessibilityID(@"Address_textField")] performAction:grey_tap()];
performAction:grey_typeText(@"\n")];
if (IsIPadIdiom()) {
// Disable EarlGrey's synchronization.
// TODO(crbug.com/768864): Investigate why synchronization gets blocked.
[[GREYConfiguration sharedInstance]
setValue:@NO
forConfigKey:kGREYConfigKeySynchronizationEnabled];
}
// Assert the postal code textfield is focused. // Assert the postal code textfield is focused.
AssertTextFieldWithAccessibilityIDIsFirstResponder(@"Postal Code_textField"); AssertTextFieldWithAccessibilityIDIsFirstResponder(@"Postal Code_textField");
// Press the return key on the postal code textfield. // Press the return key.
[[EarlGrey [[EarlGrey selectElementWithMatcher:KeyboardReturnKey(@"Next")]
selectElementWithMatcher:grey_accessibilityID(@"Postal Code_textField")] performAction:grey_tap()];
performAction:grey_typeText(@"\n")];
// Expect non of the textfields to be focused. // Expect non of the textfields to be focused.
UIResponder* firstResponder = UIResponder* firstResponder =
...@@ -340,6 +349,13 @@ id<GREYMatcher> UIAlertViewMessageForDelegateCallWithArgument( ...@@ -340,6 +349,13 @@ id<GREYMatcher> UIAlertViewMessageForDelegateCallWithArgument(
GREYAssertFalse([firstResponder isKindOfClass:[UITextField class]], GREYAssertFalse([firstResponder isKindOfClass:[UITextField class]],
@"Expected first responder not to be of kind %@.", @"Expected first responder not to be of kind %@.",
[UITextField class]); [UITextField class]);
if (IsIPadIdiom()) {
// Reenable synchronization.
[[GREYConfiguration sharedInstance]
setValue:@YES
forConfigKey:kGREYConfigKeySynchronizationEnabled];
}
} }
@end @end
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