| 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 #import "base/mac/bind_objc_block.h" | 7 #import "base/mac/bind_objc_block.h" |
| 8 #import "ios/chrome/browser/ui/tools_menu/tools_menu_view_controller.h" | 8 #import "ios/chrome/browser/ui/tools_menu/tools_menu_view_controller.h" |
| 9 #include "ios/chrome/grit/ios_strings.h" | 9 #include "ios/chrome/grit/ios_strings.h" |
| 10 #include "ios/chrome/test/app/web_view_interaction_test_util.h" | 10 #include "ios/chrome/test/app/web_view_interaction_test_util.h" |
| 11 #include "ios/chrome/test/earl_grey/accessibility_util.h" | 11 #include "ios/chrome/test/earl_grey/accessibility_util.h" |
| 12 #import "ios/chrome/test/earl_grey/chrome_earl_grey.h" | 12 #import "ios/chrome/test/earl_grey/chrome_earl_grey.h" |
| 13 #import "ios/chrome/test/earl_grey/chrome_earl_grey_ui.h" | 13 #import "ios/chrome/test/earl_grey/chrome_earl_grey_ui.h" |
| 14 #import "ios/chrome/test/earl_grey/chrome_matchers.h" | 14 #import "ios/chrome/test/earl_grey/chrome_matchers.h" |
| 15 #import "ios/chrome/test/earl_grey/chrome_test_case.h" | 15 #import "ios/chrome/test/earl_grey/chrome_test_case.h" |
| 16 #import "ios/web/public/test/http_server.h" | 16 #import "ios/web/public/test/http_server.h" |
| 17 #include "ios/web/public/test/http_server_util.h" | 17 #include "ios/web/public/test/http_server_util.h" |
| 18 #include "ui/base/l10n/l10n_util.h" | 18 #include "ui/base/l10n/l10n_util.h" |
| 19 | 19 |
| 20 using chrome_test_util::ButtonWithAccessibilityLabel; | 20 using chrome_test_util::ButtonWithAccessibilityLabel; |
| 21 using chrome_test_util::ButtonWithAccessibilityLabelId; | 21 using chrome_test_util::ButtonWithAccessibilityLabelId; |
| 22 using chrome_test_util::NavigationBarDoneButton; |
| 22 | 23 |
| 23 namespace { | 24 namespace { |
| 24 | 25 |
| 25 // Expectation of how the saved autofill profile looks like, a map from cell | 26 // Expectation of how the saved autofill profile looks like, a map from cell |
| 26 // name IDs to expected contents. | 27 // name IDs to expected contents. |
| 27 struct DisplayStringIDToExpectedResult { | 28 struct DisplayStringIDToExpectedResult { |
| 28 int display_string_id; | 29 int display_string_id; |
| 29 NSString* expected_result; | 30 NSString* expected_result; |
| 30 }; | 31 }; |
| 31 | 32 |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 94 grey_accessibilityTrait( | 95 grey_accessibilityTrait( |
| 95 UIAccessibilityTraitStaticText), | 96 UIAccessibilityTraitStaticText), |
| 96 nil)] performAction:grey_tap()]; | 97 nil)] performAction:grey_tap()]; |
| 97 [[EarlGrey | 98 [[EarlGrey |
| 98 selectElementWithMatcher:grey_allOf(grey_accessibilityLabel(@"Cut"), | 99 selectElementWithMatcher:grey_allOf(grey_accessibilityLabel(@"Cut"), |
| 99 grey_accessibilityTrait( | 100 grey_accessibilityTrait( |
| 100 UIAccessibilityTraitStaticText), | 101 UIAccessibilityTraitStaticText), |
| 101 nil)] performAction:grey_tap()]; | 102 nil)] performAction:grey_tap()]; |
| 102 | 103 |
| 103 // Switch off edit mode. | 104 // Switch off edit mode. |
| 104 [[EarlGrey selectElementWithMatcher:ButtonWithAccessibilityLabelId( | 105 [[EarlGrey selectElementWithMatcher:NavigationBarDoneButton()] |
| 105 IDS_IOS_NAVIGATION_BAR_DONE_BUTTON)] | |
| 106 performAction:grey_tap()]; | 106 performAction:grey_tap()]; |
| 107 } | 107 } |
| 108 | 108 |
| 109 } // namespace | 109 } // namespace |
| 110 | 110 |
| 111 // Various tests for the Autofill section of the settings. | 111 // Various tests for the Autofill section of the settings. |
| 112 @interface AutofillSettingsTestCase : ChromeTestCase | 112 @interface AutofillSettingsTestCase : ChromeTestCase |
| 113 @end | 113 @end |
| 114 | 114 |
| 115 @implementation AutofillSettingsTestCase | 115 @implementation AutofillSettingsTestCase |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 152 grey_accessibilityID(backButtonA11yId), | 152 grey_accessibilityID(backButtonA11yId), |
| 153 grey_accessibilityTrait( | 153 grey_accessibilityTrait( |
| 154 UIAccessibilityTraitButton), | 154 UIAccessibilityTraitButton), |
| 155 nil)] performAction:grey_tap()]; | 155 nil)] performAction:grey_tap()]; |
| 156 [[EarlGrey | 156 [[EarlGrey |
| 157 selectElementWithMatcher:grey_allOf( | 157 selectElementWithMatcher:grey_allOf( |
| 158 grey_accessibilityID(backButtonA11yId), | 158 grey_accessibilityID(backButtonA11yId), |
| 159 grey_accessibilityTrait( | 159 grey_accessibilityTrait( |
| 160 UIAccessibilityTraitButton), | 160 UIAccessibilityTraitButton), |
| 161 nil)] performAction:grey_tap()]; | 161 nil)] performAction:grey_tap()]; |
| 162 [[EarlGrey selectElementWithMatcher:ButtonWithAccessibilityLabelId( | 162 [[EarlGrey selectElementWithMatcher:NavigationBarDoneButton()] |
| 163 IDS_IOS_NAVIGATION_BAR_DONE_BUTTON)] | |
| 164 performAction:grey_tap()]; | 163 performAction:grey_tap()]; |
| 165 // Wait for UI components to finish loading. | 164 // Wait for UI components to finish loading. |
| 166 [[GREYUIThreadExecutor sharedInstance] drainUntilIdle]; | 165 [[GREYUIThreadExecutor sharedInstance] drainUntilIdle]; |
| 167 } | 166 } |
| 168 | 167 |
| 169 // Test that submitting a form ensures saving the data as an autofill profile. | 168 // Test that submitting a form ensures saving the data as an autofill profile. |
| 170 - (void)testAutofillProfileSaving { | 169 - (void)testAutofillProfileSaving { |
| 171 [self loadAndSubmitTheForm]; | 170 [self loadAndSubmitTheForm]; |
| 172 [self openEditAddress:@"George Washington, 1600 Pennsylvania Ave NW"]; | 171 [self openEditAddress:@"George Washington, 1600 Pennsylvania Ave NW"]; |
| 173 | 172 |
| (...skipping 25 matching lines...) Expand all Loading... |
| 199 [[EarlGrey selectElementWithMatcher:ButtonWithAccessibilityLabelId( | 198 [[EarlGrey selectElementWithMatcher:ButtonWithAccessibilityLabelId( |
| 200 IDS_IOS_NAVIGATION_BAR_EDIT_BUTTON)] | 199 IDS_IOS_NAVIGATION_BAR_EDIT_BUTTON)] |
| 201 performAction:grey_tap()]; | 200 performAction:grey_tap()]; |
| 202 | 201 |
| 203 // Type the user-version of the country. | 202 // Type the user-version of the country. |
| 204 [[EarlGrey selectElementWithMatcher:grey_accessibilityID(GetTextFieldForID( | 203 [[EarlGrey selectElementWithMatcher:grey_accessibilityID(GetTextFieldForID( |
| 205 IDS_IOS_AUTOFILL_COUNTRY))] | 204 IDS_IOS_AUTOFILL_COUNTRY))] |
| 206 performAction:grey_typeText(expectation.user_typed_country)]; | 205 performAction:grey_typeText(expectation.user_typed_country)]; |
| 207 | 206 |
| 208 // Switch off edit mode. | 207 // Switch off edit mode. |
| 209 [[EarlGrey selectElementWithMatcher:ButtonWithAccessibilityLabelId( | 208 [[EarlGrey selectElementWithMatcher:NavigationBarDoneButton()] |
| 210 IDS_IOS_NAVIGATION_BAR_DONE_BUTTON)] | |
| 211 performAction:grey_tap()]; | 209 performAction:grey_tap()]; |
| 212 | 210 |
| 213 // Verify that the country value was changed to canonical. | 211 // Verify that the country value was changed to canonical. |
| 214 [[EarlGrey | 212 [[EarlGrey |
| 215 selectElementWithMatcher: | 213 selectElementWithMatcher: |
| 216 grey_accessibilityLabel([NSString | 214 grey_accessibilityLabel([NSString |
| 217 stringWithFormat:@"%@, %@", l10n_util::GetNSString( | 215 stringWithFormat:@"%@, %@", l10n_util::GetNSString( |
| 218 IDS_IOS_AUTOFILL_COUNTRY), | 216 IDS_IOS_AUTOFILL_COUNTRY), |
| 219 expectation.expected_result])] | 217 expectation.expected_result])] |
| 220 assertWithMatcher:grey_notNil()]; | 218 assertWithMatcher:grey_notNil()]; |
| (...skipping 18 matching lines...) Expand all Loading... |
| 239 // Switch on edit mode. | 237 // Switch on edit mode. |
| 240 [[EarlGrey selectElementWithMatcher:ButtonWithAccessibilityLabelId( | 238 [[EarlGrey selectElementWithMatcher:ButtonWithAccessibilityLabelId( |
| 241 IDS_IOS_NAVIGATION_BAR_EDIT_BUTTON)] | 239 IDS_IOS_NAVIGATION_BAR_EDIT_BUTTON)] |
| 242 performAction:grey_tap()]; | 240 performAction:grey_tap()]; |
| 243 chrome_test_util::VerifyAccessibilityForCurrentScreen(); | 241 chrome_test_util::VerifyAccessibilityForCurrentScreen(); |
| 244 | 242 |
| 245 [self exitSettingsMenu]; | 243 [self exitSettingsMenu]; |
| 246 } | 244 } |
| 247 | 245 |
| 248 @end | 246 @end |
| OLD | NEW |