Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(176)

Side by Side Diff: ios/showcase/payments/sc_payments_editor_egtest.mm

Issue 2907103002: [Payment Request] Updates PaymentRequestEditViewController in showcase (Closed)
Patch Set: Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2017 The Chromium Authors. All rights reserved. 1 // Copyright 2017 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 6
7 #import "base/mac/foundation_util.h" 7 #import "base/mac/foundation_util.h"
8 #include "components/strings/grit/components_strings.h" 8 #include "components/strings/grit/components_strings.h"
9 #import "ios/chrome/browser/ui/autofill/autofill_edit_accessory_view.h" 9 #import "ios/chrome/browser/ui/autofill/autofill_edit_accessory_view.h"
10 #import "ios/chrome/browser/ui/payments/payment_request_edit_view_controller.h" 10 #import "ios/chrome/browser/ui/payments/payment_request_edit_view_controller.h"
11 #include "ios/chrome/browser/ui/ui_util.h" 11 #include "ios/chrome/browser/ui/ui_util.h"
12 #include "ios/chrome/grit/ios_strings.h"
12 #import "ios/showcase/test/showcase_eg_utils.h" 13 #import "ios/showcase/test/showcase_eg_utils.h"
13 #import "ios/showcase/test/showcase_test_case.h" 14 #import "ios/showcase/test/showcase_test_case.h"
14 #include "ui/base/l10n/l10n_util.h" 15 #include "ui/base/l10n/l10n_util.h"
15 16
16 #if !defined(__has_feature) || !__has_feature(objc_arc) 17 #if !defined(__has_feature) || !__has_feature(objc_arc)
17 #error "This file requires ARC support." 18 #error "This file requires ARC support."
18 #endif 19 #endif
19 20
20 @interface UIWindow (Hidden) 21 @interface UIWindow (Hidden)
21 - (UIResponder*)firstResponder; 22 - (UIResponder*)firstResponder;
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
101 assertWithMatcher:grey_notNil()]; 102 assertWithMatcher:grey_notNil()];
102 [[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"Name_textField")] 103 [[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"Name_textField")]
103 assertWithMatcher:grey_text(@"John Doe")]; 104 assertWithMatcher:grey_text(@"John Doe")];
104 105
105 [[EarlGrey 106 [[EarlGrey
106 selectElementWithMatcher:grey_allOf(grey_accessibilityLabel(@"Country*"), 107 selectElementWithMatcher:grey_allOf(grey_accessibilityLabel(@"Country*"),
107 grey_accessibilityValue(@"Canada"), 108 grey_accessibilityValue(@"Canada"),
108 nil)] 109 nil)]
109 assertWithMatcher:grey_notNil()]; 110 assertWithMatcher:grey_notNil()];
110 111
112 [[EarlGrey selectElementWithMatcher:grey_accessibilityLabel(@"Province*")]
113 assertWithMatcher:grey_notNil()];
114 [[EarlGrey
115 selectElementWithMatcher:grey_accessibilityID(@"Province_textField")]
116 assertWithMatcher:grey_text(@"Quebec")];
117
111 [[EarlGrey selectElementWithMatcher:grey_accessibilityLabel(@"Address*")] 118 [[EarlGrey selectElementWithMatcher:grey_accessibilityLabel(@"Address*")]
112 assertWithMatcher:grey_notNil()]; 119 assertWithMatcher:grey_notNil()];
113 [[EarlGrey 120 [[EarlGrey
114 selectElementWithMatcher:grey_accessibilityID(@"Address_textField")] 121 selectElementWithMatcher:grey_accessibilityID(@"Address_textField")]
115 assertWithMatcher:grey_text(@"")]; 122 assertWithMatcher:grey_text(@"")];
116 123
117 [[EarlGrey selectElementWithMatcher:grey_accessibilityLabel(@"Postal Code")] 124 [[EarlGrey selectElementWithMatcher:grey_accessibilityLabel(@"Postal Code")]
118 assertWithMatcher:grey_notNil()]; 125 assertWithMatcher:grey_notNil()];
119 [[EarlGrey 126 [[EarlGrey
120 selectElementWithMatcher:grey_accessibilityID(@"Postal Code_textField")] 127 selectElementWithMatcher:grey_accessibilityID(@"Postal Code_textField")]
121 assertWithMatcher:grey_text(@"")]; 128 assertWithMatcher:grey_text(@"")];
129
130 [[EarlGrey
131 selectElementWithMatcher:grey_allOf(grey_accessibilityLabel(@"Save"),
132 grey_accessibilityValue(
133 l10n_util::GetNSString(
134 IDS_IOS_SETTING_ON)),
135 nil)]
136 assertWithMatcher:grey_notNil()];
137 }
138
139 // Tests if the expected input view for the province field is displaying, when
140 // the field is focused, and that the expected row is selected.
141 - (void)testVerifyProvinceFieldInputView {
142 // Tap the province textfield.
143 [[EarlGrey
144 selectElementWithMatcher:grey_accessibilityID(@"Province_textField")]
145 performAction:grey_tap()];
146
147 // Assert that a UIPicker view is displaying and the expected row is selected.
148 [[EarlGrey
149 selectElementWithMatcher:grey_accessibilityID(@"Province_pickerView")]
150 assertWithMatcher:grey_pickerColumnSetToValue(0, @"Quebec")];
122 } 151 }
123 152
124 // Tests if tapping the selector field notifies the delegate. 153 // Tests if tapping the selector field notifies the delegate.
125 - (void)testVerifyTappingSelectorFieldNotifiesDelegate { 154 - (void)testVerifyTappingSelectorFieldNotifiesDelegate {
126 // Tap the selector field. 155 // Tap the selector field.
127 [[EarlGrey 156 [[EarlGrey
128 selectElementWithMatcher:grey_allOf(grey_accessibilityLabel(@"Country*"), 157 selectElementWithMatcher:grey_allOf(grey_accessibilityLabel(@"Country*"),
129 grey_accessibilityValue(@"Canada"), 158 grey_accessibilityValue(@"Canada"),
130 nil)] performAction:grey_tap()]; 159 nil)] performAction:grey_tap()];
131 160
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
186 // Assert the name textfield is focused. 215 // Assert the name textfield is focused.
187 AssertTextFieldWithAccessibilityIDIsFirstResponder(@"Name_textField"); 216 AssertTextFieldWithAccessibilityIDIsFirstResponder(@"Name_textField");
188 217
189 // Assert the input accessory view's previous button is disabled. 218 // Assert the input accessory view's previous button is disabled.
190 [[EarlGrey selectElementWithMatcher:InputAccessoryViewPreviousButton()] 219 [[EarlGrey selectElementWithMatcher:InputAccessoryViewPreviousButton()]
191 assertWithMatcher:grey_not(grey_enabled())]; 220 assertWithMatcher:grey_not(grey_enabled())];
192 // Assert the input accessory view's next button is enabled and tap it. 221 // Assert the input accessory view's next button is enabled and tap it.
193 [[[EarlGrey selectElementWithMatcher:InputAccessoryViewNextButton()] 222 [[[EarlGrey selectElementWithMatcher:InputAccessoryViewNextButton()]
194 assertWithMatcher:grey_enabled()] performAction:grey_tap()]; 223 assertWithMatcher:grey_enabled()] performAction:grey_tap()];
195 224
225 // Assert the province textfield is focused.
226 AssertTextFieldWithAccessibilityIDIsFirstResponder(@"Province_textField");
227
228 // Assert the input accessory view's previous button is enabled.
229 [[EarlGrey selectElementWithMatcher:InputAccessoryViewPreviousButton()]
230 assertWithMatcher:grey_enabled()];
231 // Assert the input accessory view's next button is enabled and tap it.
232 [[[EarlGrey selectElementWithMatcher:InputAccessoryViewNextButton()]
233 assertWithMatcher:grey_enabled()] performAction:grey_tap()];
234
196 // Assert the address textfield is focused. 235 // Assert the address textfield is focused.
197 AssertTextFieldWithAccessibilityIDIsFirstResponder(@"Address_textField"); 236 AssertTextFieldWithAccessibilityIDIsFirstResponder(@"Address_textField");
198 237
199 // Assert the input accessory view's previous button is enabled. 238 // Assert the input accessory view's previous button is enabled.
200 [[EarlGrey selectElementWithMatcher:InputAccessoryViewPreviousButton()] 239 [[EarlGrey selectElementWithMatcher:InputAccessoryViewPreviousButton()]
201 assertWithMatcher:grey_enabled()]; 240 assertWithMatcher:grey_enabled()];
202 // Assert the input accessory view's next button is enabled and tap it. 241 // Assert the input accessory view's next button is enabled and tap it.
203 [[[EarlGrey selectElementWithMatcher:InputAccessoryViewNextButton()] 242 [[[EarlGrey selectElementWithMatcher:InputAccessoryViewNextButton()]
204 assertWithMatcher:grey_enabled()] performAction:grey_tap()]; 243 assertWithMatcher:grey_enabled()] performAction:grey_tap()];
205 244
(...skipping 26 matching lines...) Expand all
232 assertWithMatcher:grey_enabled()]; 271 assertWithMatcher:grey_enabled()];
233 // Assert the input accessory view's previous button is enabled and tap it. 272 // Assert the input accessory view's previous button is enabled and tap it.
234 [[[EarlGrey selectElementWithMatcher:InputAccessoryViewPreviousButton()] 273 [[[EarlGrey selectElementWithMatcher:InputAccessoryViewPreviousButton()]
235 assertWithMatcher:grey_enabled()] performAction:grey_tap()]; 274 assertWithMatcher:grey_enabled()] performAction:grey_tap()];
236 275
237 // Assert the error message disappeared because an address was typed in. 276 // Assert the error message disappeared because an address was typed in.
238 [[EarlGrey selectElementWithMatcher:grey_accessibilityID( 277 [[EarlGrey selectElementWithMatcher:grey_accessibilityID(
239 kWarningMessageAccessibilityID)] 278 kWarningMessageAccessibilityID)]
240 assertWithMatcher:grey_notVisible()]; 279 assertWithMatcher:grey_notVisible()];
241 280
242 // Assert the name textfield is focused. 281 // Assert the province textfield is focused.
243 AssertTextFieldWithAccessibilityIDIsFirstResponder(@"Name_textField"); 282 AssertTextFieldWithAccessibilityIDIsFirstResponder(@"Province_textField");
244 283
245 // Assert the input accessory view's previous button is disabled. 284 // Assert the input accessory view's previous button is enabled.
246 [[EarlGrey selectElementWithMatcher:InputAccessoryViewPreviousButton()] 285 [[EarlGrey selectElementWithMatcher:InputAccessoryViewPreviousButton()]
247 assertWithMatcher:grey_not(grey_enabled())]; 286 assertWithMatcher:grey_enabled()];
248 // Assert the input accessory view's next button is enabled. 287 // Assert the input accessory view's next button is enabled.
249 [[EarlGrey selectElementWithMatcher:InputAccessoryViewNextButton()] 288 [[EarlGrey selectElementWithMatcher:InputAccessoryViewNextButton()]
250 assertWithMatcher:grey_enabled()]; 289 assertWithMatcher:grey_enabled()];
251 } 290 }
252 291
253 // Tests tapping the return key on every textfield causes the next textfield to 292 // Tests tapping the return key on every textfield causes the next textfield to
254 // get focus except for the last textfield in which case causes the focus to go 293 // get focus except for the last textfield in which case causes the focus to go
255 // away from the textfield. 294 // away from the textfield.
256 - (void)testNavigationByTappingReturn { 295 - (void)testNavigationByTappingReturn {
257 // Tap the name textfield. 296 // Tap the name textfield.
258 [[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"Name_textField")] 297 [[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"Name_textField")]
259 performAction:grey_tap()]; 298 performAction:grey_tap()];
260 299
261 // Assert the name textfield is focused. 300 // Assert the name textfield is focused.
262 AssertTextFieldWithAccessibilityIDIsFirstResponder(@"Name_textField"); 301 AssertTextFieldWithAccessibilityIDIsFirstResponder(@"Name_textField");
263 302
264 // Press the return key on the name textfield. 303 // Press the return key on the name textfield.
265 [[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"Name_textField")] 304 [[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"Name_textField")]
266 performAction:grey_typeText(@"\n")]; 305 performAction:grey_typeText(@"\n")];
267 306
307 // Assert the province textfield is focused.
308 AssertTextFieldWithAccessibilityIDIsFirstResponder(@"Province_textField");
309
310 // The standard keyboard does not display for the provonce field. Instead, tap
lpromero 2017/05/30 11:50:36 *province
Moe 2017/05/31 12:04:58 Done.
311 // the address textfield.
312 [[EarlGrey
313 selectElementWithMatcher:grey_accessibilityID(@"Address_textField")]
314 performAction:grey_tap()];
315
268 // Assert the address textfield is focused. 316 // Assert the address textfield is focused.
269 AssertTextFieldWithAccessibilityIDIsFirstResponder(@"Address_textField"); 317 AssertTextFieldWithAccessibilityIDIsFirstResponder(@"Address_textField");
270 318
271 // Press the return key on the address textfield. 319 // Press the return key on the address textfield.
272 [[EarlGrey 320 [[EarlGrey
273 selectElementWithMatcher:grey_accessibilityID(@"Address_textField")] 321 selectElementWithMatcher:grey_accessibilityID(@"Address_textField")]
274 performAction:grey_typeText(@"\n")]; 322 performAction:grey_typeText(@"\n")];
275 323
276 // Assert the postal code textfield is focused. 324 // Assert the postal code textfield is focused.
277 AssertTextFieldWithAccessibilityIDIsFirstResponder(@"Postal Code_textField"); 325 AssertTextFieldWithAccessibilityIDIsFirstResponder(@"Postal Code_textField");
278 326
279 // Press the return key on the postal code textfield. 327 // Press the return key on the postal code textfield.
280 [[EarlGrey 328 [[EarlGrey
281 selectElementWithMatcher:grey_accessibilityID(@"Postal Code_textField")] 329 selectElementWithMatcher:grey_accessibilityID(@"Postal Code_textField")]
282 performAction:grey_typeText(@"\n")]; 330 performAction:grey_typeText(@"\n")];
283 331
284 // Expect non of the textfields to be focused. 332 // Expect non of the textfields to be focused.
285 UIResponder* firstResponder = 333 UIResponder* firstResponder =
286 [[UIApplication sharedApplication].keyWindow firstResponder]; 334 [[UIApplication sharedApplication].keyWindow firstResponder];
287 GREYAssertFalse([firstResponder isKindOfClass:[UITextField class]], 335 GREYAssertFalse([firstResponder isKindOfClass:[UITextField class]],
288 @"Expected first responder not to be of kind %@.", 336 @"Expected first responder not to be of kind %@.",
289 [UITextField class]); 337 [UITextField class]);
290 } 338 }
291 339
292 @end 340 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698