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

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

Issue 243013004: i18n address editing in chrome://settings/autofillEditAddress. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Addressed comments. Created 6 years, 7 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 | Annotate | Revision Log
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 /** 5 /**
6 * Returns the HTML element for the |field|.
7 * @param {string} field The field name for the element.
8 * @return {HTMLElement} The HTML element.
9 */
10 function getField(field) {
11 return document.querySelector(
12 '#autofill-edit-address-overlay [field=' + field + ']');
13 }
14
15 /**
16 * Returns the size of the |list|.
17 * @param {HTMLElement} list The list to check.
18 * @return {int} The size of the list.
19 */
20 function getListSize(list) {
21 // Remove 1 for placeholder input field.
22 return list.items.length - 1;
23 }
24
25 /**
6 * TestFixture for autofill options WebUI testing. 26 * TestFixture for autofill options WebUI testing.
7 * @extends {testing.Test} 27 * @extends {testing.Test}
8 * @constructor 28 * @constructor
9 */ 29 */
10 function AutofillOptionsWebUITest() {} 30 function AutofillOptionsWebUITest() {}
11 31
12 AutofillOptionsWebUITest.prototype = { 32 AutofillOptionsWebUITest.prototype = {
13 __proto__: testing.Test.prototype, 33 __proto__: testing.Test.prototype,
14 34
15 /** 35 /**
(...skipping 24 matching lines...) Expand all
40 60
41 /** @override */ 61 /** @override */
42 isAsync: true, 62 isAsync: true,
43 }; 63 };
44 64
45 TEST_F('AutofillEditAddressWebUITest', 65 TEST_F('AutofillEditAddressWebUITest',
46 'testAutofillPhoneValueListDoneValidating', 66 'testAutofillPhoneValueListDoneValidating',
47 function() { 67 function() {
48 assertEquals(this.browsePreload, document.location.href); 68 assertEquals(this.browsePreload, document.location.href);
49 69
50 var phoneList = $('phone-list'); 70 var phoneList = getField('phone');
51 expectEquals(0, phoneList.validationRequests_); 71 expectEquals(0, phoneList.validationRequests_);
52 phoneList.doneValidating().then(function() { 72 phoneList.doneValidating().then(function() {
53 phoneList.focus(); 73 phoneList.focus();
54 var input = phoneList.querySelector('input'); 74 var input = phoneList.querySelector('input');
55 input.focus(); 75 input.focus();
56 document.execCommand('insertText', false, '111-222-333'); 76 document.execCommand('insertText', false, '111-222-333');
57 assertEquals('111-222-333', input.value); 77 assertEquals('111-222-333', input.value);
58 input.blur(); 78 input.blur();
59 phoneList.doneValidating().then(function() { 79 phoneList.doneValidating().then(function() {
60 testDone(); 80 testDone();
61 }); 81 });
62 }); 82 });
63 }); 83 });
84
85 TEST_F('AutofillEditAddressWebUITest',
86 'testInitialFormLayout',
87 function() {
88 assertEquals(this.browsePreload, document.location.href);
89
90 assertEquals(getField('country').value, '');
91 assertEquals(0, getListSize(getField('phone')));
92 assertEquals(0, getListSize(getField('email')));
93 assertEquals(0, getListSize(getField('fullName')));
94 assertEquals('', getField('city').value);
95
96 testDone();
97 });
98
99 TEST_F('AutofillEditAddressWebUITest',
100 'testLoadAddress',
101 function() {
102 assertEquals(this.browsePreload, document.location.href);
103
104 var testAddress = {
105 guid: 'GUID Value',
106 fullName: ['Full Name 1', 'Full Name 2'],
107 companyName: 'Company Name Value',
108 addrLines: 'First Line Value\nSecond Line Value',
109 dependentLocality: 'Dependent Locality Value',
110 city: 'City Value',
111 state: 'State Value',
112 postalCode: 'Postal Code Value',
113 sortingCode: 'Sorting Code Value',
114 country: 'CH',
115 phone: ['123', '456'],
116 email: ['a@b.c', 'x@y.z'],
117 languageCode: 'de',
118 components: [[
119 {field: 'postalCode', length: 'short'},
120 {field: 'sortingCode', length: 'short'},
121 {field: 'dependentLocality', length: 'short'},
122 {field: 'city', length: 'short'},
123 {field: 'state', length: 'short'},
124 {field: 'addrLines', length: 'long'},
125 {field: 'companyName', length: 'long'},
126 {field: 'country', length: 'long'},
127 {field: 'fullName', length: 'long', placeholder: 'Add name'}
128 ]]
129 };
130 AutofillEditAddressOverlay.loadAddress(testAddress);
131
132 assertEquals(testAddress.guid, AutofillEditAddressOverlay.getInstance().guid);
133 assertEquals(testAddress.languageCode,
134 AutofillEditAddressOverlay.getInstance().languageCode);
135
136 var lists = ['fullName', 'email', 'phone'];
137 for (var i in lists) {
138 var field = getField(lists[i]);
139 assertEquals(testAddress[lists[i]].length, getListSize(field));
140 assertTrue(field.getAttribute('placeholder').length > 0);
141 assertEquals('LIST', field.tagName);
142 }
143
144 var inputs = ['companyName', 'dependentLocality', 'city', 'state',
145 'postalCode', 'sortingCode'];
146 for (var i in inputs) {
147 var field = getField(inputs[i]);
148 assertEquals(testAddress[inputs[i]], field.value);
149 assertEquals('INPUT', field.tagName);
please use gerrit instead 2014/04/30 02:06:15 assertEquals(field instanceof HTMLInputElement) is
Evan Stade 2014/04/30 05:25:22 probably because it requires two arguments and you
please use gerrit instead 2014/04/30 17:23:55 doh
150 }
151
152 var addrLines = getField('addrLines');
153 assertEquals(testAddress.addrLines, addrLines.value);
154 assertEquals('TEXTAREA', addrLines.tagName);;
155
156 var country = getField('country');
157 assertEquals(testAddress.country, country.value);
158 assertEquals('SELECT', country.tagName);;
159
160 testDone();
161 });
162
163 TEST_F('AutofillEditAddressWebUITest',
164 'testLoadAddressComponents',
165 function() {
166 assertEquals(this.browsePreload, document.location.href);
167
168 var testInput = {
169 languageCode: 'fr',
170 components: [[{field: 'city'}],
171 [{field: 'state'}]]
172 };
173 AutofillEditAddressOverlay.loadAddressComponents(testInput);
174
175 assertEquals('fr', AutofillEditAddressOverlay.getInstance().languageCode);
176 expectEquals(2, $('autofill-edit-address-fields').children.length);
177
178 testDone();
179 });
OLDNEW
« no previous file with comments | « chrome/browser/ui/webui/DEPS ('k') | chrome/browser/ui/webui/options/autofill_options_handler.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698