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

Unified 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, 8 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 side-by-side diff with in-line comments
Download patch
« 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 »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/webui/options/autofill_options_browsertest.js
diff --git a/chrome/browser/ui/webui/options/autofill_options_browsertest.js b/chrome/browser/ui/webui/options/autofill_options_browsertest.js
index 690f29242c76502417d365c48b3fe272db52231a..4c1e4667cecdb87103f557eb730aa2d5e0eceee7 100644
--- a/chrome/browser/ui/webui/options/autofill_options_browsertest.js
+++ b/chrome/browser/ui/webui/options/autofill_options_browsertest.js
@@ -3,6 +3,26 @@
// found in the LICENSE file.
/**
+ * Returns the HTML element for the |field|.
+ * @param {string} field The field name for the element.
+ * @return {HTMLElement} The HTML element.
+ */
+function getField(field) {
+ return document.querySelector(
+ '#autofill-edit-address-overlay [field=' + field + ']');
+}
+
+/**
+ * Returns the size of the |list|.
+ * @param {HTMLElement} list The list to check.
+ * @return {int} The size of the list.
+ */
+function getListSize(list) {
+ // Remove 1 for placeholder input field.
+ return list.items.length - 1;
+}
+
+/**
* TestFixture for autofill options WebUI testing.
* @extends {testing.Test}
* @constructor
@@ -47,7 +67,7 @@ TEST_F('AutofillEditAddressWebUITest',
function() {
assertEquals(this.browsePreload, document.location.href);
- var phoneList = $('phone-list');
+ var phoneList = getField('phone');
expectEquals(0, phoneList.validationRequests_);
phoneList.doneValidating().then(function() {
phoneList.focus();
@@ -61,3 +81,99 @@ TEST_F('AutofillEditAddressWebUITest',
});
});
});
+
+TEST_F('AutofillEditAddressWebUITest',
+ 'testInitialFormLayout',
+ function() {
+ assertEquals(this.browsePreload, document.location.href);
+
+ assertEquals(getField('country').value, '');
+ assertEquals(0, getListSize(getField('phone')));
+ assertEquals(0, getListSize(getField('email')));
+ assertEquals(0, getListSize(getField('fullName')));
+ assertEquals('', getField('city').value);
+
+ testDone();
+});
+
+TEST_F('AutofillEditAddressWebUITest',
+ 'testLoadAddress',
+ function() {
+ assertEquals(this.browsePreload, document.location.href);
+
+ var testAddress = {
+ guid: 'GUID Value',
+ fullName: ['Full Name 1', 'Full Name 2'],
+ companyName: 'Company Name Value',
+ addrLines: 'First Line Value\nSecond Line Value',
+ dependentLocality: 'Dependent Locality Value',
+ city: 'City Value',
+ state: 'State Value',
+ postalCode: 'Postal Code Value',
+ sortingCode: 'Sorting Code Value',
+ country: 'CH',
+ phone: ['123', '456'],
+ email: ['a@b.c', 'x@y.z'],
+ languageCode: 'de',
+ components: [[
+ {field: 'postalCode', length: 'short'},
+ {field: 'sortingCode', length: 'short'},
+ {field: 'dependentLocality', length: 'short'},
+ {field: 'city', length: 'short'},
+ {field: 'state', length: 'short'},
+ {field: 'addrLines', length: 'long'},
+ {field: 'companyName', length: 'long'},
+ {field: 'country', length: 'long'},
+ {field: 'fullName', length: 'long', placeholder: 'Add name'}
+ ]]
+ };
+ AutofillEditAddressOverlay.loadAddress(testAddress);
+
+ assertEquals(testAddress.guid, AutofillEditAddressOverlay.getInstance().guid);
+ assertEquals(testAddress.languageCode,
+ AutofillEditAddressOverlay.getInstance().languageCode);
+
+ var lists = ['fullName', 'email', 'phone'];
+ for (var i in lists) {
+ var field = getField(lists[i]);
+ assertEquals(testAddress[lists[i]].length, getListSize(field));
+ assertTrue(field.getAttribute('placeholder').length > 0);
+ assertEquals('LIST', field.tagName);
+ }
+
+ var inputs = ['companyName', 'dependentLocality', 'city', 'state',
+ 'postalCode', 'sortingCode'];
+ for (var i in inputs) {
+ var field = getField(inputs[i]);
+ assertEquals(testAddress[inputs[i]], field.value);
+ 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
+ }
+
+ var addrLines = getField('addrLines');
+ assertEquals(testAddress.addrLines, addrLines.value);
+ assertEquals('TEXTAREA', addrLines.tagName);;
+
+ var country = getField('country');
+ assertEquals(testAddress.country, country.value);
+ assertEquals('SELECT', country.tagName);;
+
+ testDone();
+});
+
+TEST_F('AutofillEditAddressWebUITest',
+ 'testLoadAddressComponents',
+ function() {
+ assertEquals(this.browsePreload, document.location.href);
+
+ var testInput = {
+ languageCode: 'fr',
+ components: [[{field: 'city'}],
+ [{field: 'state'}]]
+ };
+ AutofillEditAddressOverlay.loadAddressComponents(testInput);
+
+ assertEquals('fr', AutofillEditAddressOverlay.getInstance().languageCode);
+ expectEquals(2, $('autofill-edit-address-fields').children.length);
+
+ testDone();
+});
« 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