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

Side by Side Diff: chrome/browser/ui/webui/options/autofill_options_browsertest.js

Issue 1166563002: Remove support for variant info in chrome://settings/autofill (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix tests Created 5 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 GEN_INCLUDE(['options_browsertest_base.js']); 5 GEN_INCLUDE(['options_browsertest_base.js']);
6 6
7 /** 7 /**
8 * Returns the HTML element for the |field|. 8 * Returns the HTML element for the |field|.
9 * @param {string} field The field name for the element. 9 * @param {string} field The field name for the element.
10 * @return {HTMLElement} The HTML element. 10 * @return {HTMLElement} The HTML element.
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 AutofillEditAddressWebUITest.prototype = { 56 AutofillEditAddressWebUITest.prototype = {
57 __proto__: OptionsBrowsertestBase.prototype, 57 __proto__: OptionsBrowsertestBase.prototype,
58 58
59 /** @override */ 59 /** @override */
60 browsePreload: 'chrome://settings-frame/autofillEditAddress', 60 browsePreload: 'chrome://settings-frame/autofillEditAddress',
61 }; 61 };
62 62
63 TEST_F('AutofillEditAddressWebUITest', 'testInitialFormLayout', function() { 63 TEST_F('AutofillEditAddressWebUITest', 'testInitialFormLayout', function() {
64 assertEquals(this.browsePreload, document.location.href); 64 assertEquals(this.browsePreload, document.location.href);
65 65
66 assertEquals(getField('country').value, ''); 66 var fields = ['country', 'phone', 'email', 'fullName', 'city'];
67 assertEquals(0, getListSize(getField('phone'))); 67 for (field in fields) {
68 assertEquals(0, getListSize(getField('email'))); 68 assertEquals('', getField(fields[field]).value, 'Field: ' + fields[field]);
69 assertEquals(0, getListSize(getField('fullName'))); 69 }
70 assertEquals('', getField('city').value);
71 70
72 testDone(); 71 testDone();
73 }); 72 });
74 73
75 TEST_F('AutofillEditAddressWebUITest', 'testLoadAddress', function() { 74 TEST_F('AutofillEditAddressWebUITest', 'testLoadAddress', function() {
76 // http://crbug.com/434502 75 // http://crbug.com/434502
77 // Accessibility failure was originally (and consistently) seen on Mac OS and 76 // Accessibility failure was originally (and consistently) seen on Mac OS and
78 // Chromium OS. Disabling for all OSs because of a flake in Windows. There is 77 // Chromium OS. Disabling for all OSs because of a flake in Windows. There is
79 // a possibility for flake in linux too. 78 // a possibility for flake in linux too.
80 this.disableAccessibilityChecks(); 79 this.disableAccessibilityChecks();
81 80
82 assertEquals(this.browsePreload, document.location.href); 81 assertEquals(this.browsePreload, document.location.href);
83 82
84 var testAddress = { 83 var testAddress = {
85 guid: 'GUID Value', 84 guid: 'GUID Value',
86 fullName: ['Full Name 1', 'Full Name 2'], 85 fullName: 'Full Name 1',
87 companyName: 'Company Name Value', 86 companyName: 'Company Name Value',
88 addrLines: 'First Line Value\nSecond Line Value', 87 addrLines: 'First Line Value\nSecond Line Value',
89 dependentLocality: 'Dependent Locality Value', 88 dependentLocality: 'Dependent Locality Value',
90 city: 'City Value', 89 city: 'City Value',
91 state: 'State Value', 90 state: 'State Value',
92 postalCode: 'Postal Code Value', 91 postalCode: 'Postal Code Value',
93 sortingCode: 'Sorting Code Value', 92 sortingCode: 'Sorting Code Value',
94 country: 'CH', 93 country: 'CH',
95 phone: ['123', '456'], 94 phone: '123',
96 email: ['a@b.c', 'x@y.z'], 95 email: 'a@b.c',
97 languageCode: 'de', 96 languageCode: 'de',
98 components: [[ 97 components: [[
99 {field: 'postalCode', length: 'short'}, 98 {field: 'postalCode', length: 'short'},
100 {field: 'sortingCode', length: 'short'}, 99 {field: 'sortingCode', length: 'short'},
101 {field: 'dependentLocality', length: 'short'}, 100 {field: 'dependentLocality', length: 'short'},
102 {field: 'city', length: 'short'}, 101 {field: 'city', length: 'short'},
103 {field: 'state', length: 'short'}, 102 {field: 'state', length: 'short'},
104 {field: 'addrLines', length: 'long'}, 103 {field: 'addrLines', length: 'long'},
105 {field: 'companyName', length: 'long'}, 104 {field: 'companyName', length: 'long'},
106 {field: 'country', length: 'long'}, 105 {field: 'country', length: 'long'},
107 {field: 'fullName', length: 'long', placeholder: 'Add name'} 106 {field: 'fullName', length: 'long', placeholder: 'Add name'}
108 ]] 107 ]]
109 }; 108 };
110 AutofillEditAddressOverlay.loadAddress(testAddress); 109 AutofillEditAddressOverlay.loadAddress(testAddress);
111 110
112 var overlay = AutofillEditAddressOverlay.getInstance(); 111 var overlay = AutofillEditAddressOverlay.getInstance();
113 assertEquals(testAddress.guid, overlay.guid_); 112 assertEquals(testAddress.guid, overlay.guid_);
114 assertEquals(testAddress.languageCode, overlay.languageCode_); 113 assertEquals(testAddress.languageCode, overlay.languageCode_);
115 114
116 var lists = ['fullName', 'email', 'phone'];
117 for (var i in lists) {
118 var field = getField(lists[i]);
119 assertEquals(testAddress[lists[i]].length, getListSize(field));
120 assertTrue(field.getAttribute('placeholder').length > 0);
121 assertTrue(field instanceof cr.ui.List);
122 }
123
124 var inputs = ['companyName', 'dependentLocality', 'city', 'state', 115 var inputs = ['companyName', 'dependentLocality', 'city', 'state',
125 'postalCode', 'sortingCode']; 116 'postalCode', 'sortingCode', 'fullName', 'email', 'phone'];
126 for (var i in inputs) { 117 for (var i in inputs) {
127 var field = getField(inputs[i]); 118 var field = getField(inputs[i]);
128 assertEquals(testAddress[inputs[i]], field.value); 119 assertEquals(testAddress[inputs[i]], field.value);
129 assertTrue(field instanceof HTMLInputElement); 120 assertTrue(field instanceof HTMLInputElement);
130 } 121 }
131 122
132 var addrLines = getField('addrLines'); 123 var addrLines = getField('addrLines');
133 assertEquals(testAddress.addrLines, addrLines.value); 124 assertEquals(testAddress.addrLines, addrLines.value);
134 assertTrue(addrLines instanceof HTMLTextAreaElement); 125 assertTrue(addrLines instanceof HTMLTextAreaElement);
135 126
(...skipping 30 matching lines...) Expand all
166 components: [[{field: 'state'}]] 157 components: [[{field: 'state'}]]
167 }); 158 });
168 assertEquals(null, getField('city')); 159 assertEquals(null, getField('city'));
169 160
170 AutofillEditAddressOverlay.loadAddressComponents({ 161 AutofillEditAddressOverlay.loadAddressComponents({
171 languageCode: 'en', 162 languageCode: 'en',
172 components: [[{field: 'city'}]] 163 components: [[{field: 'city'}]]
173 }); 164 });
174 assertEquals('New York', getField('city').value); 165 assertEquals('New York', getField('city').value);
175 }); 166 });
176
177 /**
178 * Class to test the autofill edit address overlay asynchronously.
179 * @extends {testing.Test}
180 * @constructor
181 */
182 function AutofillEditAddressAsyncWebUITest() {}
183
184 AutofillEditAddressAsyncWebUITest.prototype = {
185 __proto__: testing.Test.prototype,
186
187 /** @override */
188 browsePreload: 'chrome://settings-frame/autofillEditAddress',
189
190 /** @override */
191 isAsync: true,
192 };
193
194 TEST_F('AutofillEditAddressAsyncWebUITest',
195 'testAutofillPhoneValueListDoneValidating',
196 function() {
197 assertEquals(this.browsePreload, document.location.href);
198
199 var phoneList = getField('phone');
200 expectEquals(0, phoneList.validationRequests_);
201 phoneList.doneValidating().then(function() {
202 phoneList.focus();
203 var input = phoneList.querySelector('input');
204 input.focus();
205 document.execCommand('insertText', false, '111-222-333');
206 assertEquals('111-222-333', input.value);
207 // TODO(bondd, dbeam): The way that focus/blur interact with the testing
208 // system is rather confusing. The next line was originally
209 // input.blur();
210 // but the test would time out when run as a single test locally (i.e.
211 // --gtest_filter=<test_name>), and complete successfully when other tests
212 // were run first (e.g. by the trybot, or locally with a wider
213 // gtest_filter). Changing the line to
214 // phoneList.blur();
215 // makes the result more deterministic when the test is run by itself.
216 //
217 // phoneList.blur() calls cr.ui.List.handleElementBlur_, which triggers
218 // InlineEditableItemList.handleListFocusChange_, which sends the
219 // 'commitedit' event.
220 phoneList.blur();
221 phoneList.doneValidating().then(testDone);
222 });
223 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698