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

Side by Side Diff: chrome/test/data/webui/settings/settings_autofill_section_browsertest.js

Issue 2154263004: [MD Settings] Lazy create dialogs in Passwords and Autofill section. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Feedback 2.0 Created 4 years, 5 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 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 /** @fileoverview Runs the Polymer Autofill Settings tests. */ 5 /** @fileoverview Runs the Polymer Autofill Settings tests. */
6 6
7 /** @const {string} Path to root from chrome/test/data/webui/settings/. */ 7 /** @const {string} Path to root from chrome/test/data/webui/settings/. */
8 var ROOT_PATH = '../../../../../'; 8 var ROOT_PATH = '../../../../../';
9 9
10 // Polymer BrowserTest fixture. 10 // Polymer BrowserTest fixture.
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
157 157
158 /** 158 /**
159 * Creates the Edit Address dialog and fulfills the promise when the dialog 159 * Creates the Edit Address dialog and fulfills the promise when the dialog
160 * has actually opened. 160 * has actually opened.
161 * @param {!chrome.autofillPrivate.AddressEntry} address 161 * @param {!chrome.autofillPrivate.AddressEntry} address
162 * @return {!Promise<Object>} 162 * @return {!Promise<Object>}
163 */ 163 */
164 createAddressDialog_: function(address) { 164 createAddressDialog_: function(address) {
165 return new Promise(function(resolve) { 165 return new Promise(function(resolve) {
166 var section = document.createElement('settings-address-edit-dialog'); 166 var section = document.createElement('settings-address-edit-dialog');
167 section.address = address;
167 document.body.appendChild(section); 168 document.body.appendChild(section);
168 var onOpen = function() { 169 section.addEventListener('iron-overlay-opened', function() {
169 resolve(section); 170 resolve(section);
170 }; 171 });
171 section.addEventListener('iron-overlay-opened', onOpen);
172
173 // |setTimeout| allows the dialog to async get the list of countries
174 // before running any tests.
175 window.setTimeout(function() {
176 section.open(address); // Opening the dialog will add the item.
177 Polymer.dom.flush();
178 }, 0);
179 }); 172 });
180 }, 173 },
181 174
182 /** 175 /**
183 * Creates the Edit Credit Card dialog. 176 * Creates the Edit Credit Card dialog.
184 * @param {!chrome.autofillPrivate.CreditCardEntry} creditCardItem 177 * @param {!chrome.autofillPrivate.CreditCardEntry} creditCardItem
185 * @return {!Object} 178 * @return {!Object}
186 */ 179 */
187 createCreditCardDialog_: function(creditCardItem) { 180 createCreditCardDialog_: function(creditCardItem) {
188 var section = document.createElement('settings-credit-card-edit-dialog'); 181 var section = document.createElement('settings-credit-card-edit-dialog');
182 section.creditCard = creditCardItem;
189 document.body.appendChild(section); 183 document.body.appendChild(section);
190 section.open(creditCardItem); // Opening the dialog will add the item.
191 Polymer.dom.flush(); 184 Polymer.dom.flush();
192 return section; 185 return section;
193 }, 186 },
194 }; 187 };
195 188
196 TEST_F('SettingsAutofillSectionBrowserTest', 'CreditCardTests', function() { 189 TEST_F('SettingsAutofillSectionBrowserTest', 'CreditCardTests', function() {
197 var self = this; 190 var self = this;
198 191
199 suite('AutofillSection', function() { 192 suite('AutofillSection', function() {
200 test('verifyCreditCardCount', function() { 193 test('verifyCreditCardCount', function() {
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after
412 405
413 assertEquals('', dialog.$.emailInput.value); 406 assertEquals('', dialog.$.emailInput.value);
414 assertFalse(!!(address.emailAddresses && address.emailAddresses[0])); 407 assertFalse(!!(address.emailAddresses && address.emailAddresses[0]));
415 408
416 var phoneNumber = '(555) 555-5555'; 409 var phoneNumber = '(555) 555-5555';
417 var emailAddress = 'no-reply@chromium.org'; 410 var emailAddress = 'no-reply@chromium.org';
418 411
419 dialog.$.phoneInput.value = phoneNumber; 412 dialog.$.phoneInput.value = phoneNumber;
420 dialog.$.emailInput.value = emailAddress; 413 dialog.$.emailInput.value = emailAddress;
421 414
422 Polymer.dom.flush(); 415 return expectEvent(dialog, 'save-address', function() {
416 MockInteractions.tap(dialog.$.saveButton);
417 }).then(function() {
418 assertEquals(phoneNumber, dialog.$.phoneInput.value);
419 assertEquals(phoneNumber, address.phoneNumbers[0]);
423 420
424 assertEquals(phoneNumber, dialog.$.phoneInput.value); 421 assertEquals(emailAddress, dialog.$.emailInput.value);
425 assertEquals(phoneNumber, address.phoneNumbers[0]); 422 assertEquals(emailAddress, address.emailAddresses[0]);
426 423 });
427 assertEquals(emailAddress, dialog.$.emailInput.value);
428 assertEquals(emailAddress, address.emailAddresses[0]);
429 }); 424 });
430 }); 425 });
431 426
432 test('verifyPhoneAndEmailAreRemoved', function() { 427 test('verifyPhoneAndEmailAreRemoved', function() {
433 var address = FakeDataMaker.emptyAddressEntry(); 428 var address = FakeDataMaker.emptyAddressEntry();
434 429
435 var phoneNumber = '(555) 555-5555'; 430 var phoneNumber = '(555) 555-5555';
436 var emailAddress = 'no-reply@chromium.org'; 431 var emailAddress = 'no-reply@chromium.org';
437 432
433 address.countryCode = 'US'; // Set to allow save to be active.
438 address.phoneNumbers = [phoneNumber]; 434 address.phoneNumbers = [phoneNumber];
439 address.emailAddresses = [emailAddress]; 435 address.emailAddresses = [emailAddress];
440 436
441 return self.createAddressDialog_(address).then(function(dialog) { 437 return self.createAddressDialog_(address).then(function(dialog) {
442 assertEquals(phoneNumber, dialog.$.phoneInput.value); 438 assertEquals(phoneNumber, dialog.$.phoneInput.value);
443 assertEquals(emailAddress, dialog.$.emailInput.value); 439 assertEquals(emailAddress, dialog.$.emailInput.value);
444 440
445 dialog.$.phoneInput.value = ''; 441 dialog.$.phoneInput.value = '';
446 dialog.$.emailInput.value = ''; 442 dialog.$.emailInput.value = '';
447 443
448 Polymer.dom.flush(); 444 return expectEvent(dialog, 'save-address', function() {
449 445 MockInteractions.tap(dialog.$.saveButton);
450 assertEquals(0, address.phoneNumbers.length); 446 }).then(function() {
451 assertEquals(0, address.emailAddresses.length); 447 assertEquals(0, address.phoneNumbers.length);
448 assertEquals(0, address.emailAddresses.length);
449 });
452 }); 450 });
453 }); 451 });
454 452
455 // Test will set a value of 'foo' in each text field and verify that the 453 // Test will set a value of 'foo' in each text field and verify that the
456 // save button is enabled, then it will clear the field and verify that the 454 // save button is enabled, then it will clear the field and verify that the
457 // save button is disabled. Test passes after all elements have been tested. 455 // save button is disabled. Test passes after all elements have been tested.
458 test('verifySaveIsNotClickableIfAllInputFieldsAreEmpty', function() { 456 test('verifySaveIsNotClickableIfAllInputFieldsAreEmpty', function() {
459 return self.createAddressDialog_( 457 return self.createAddressDialog_(
460 FakeDataMaker.emptyAddressEntry()).then(function(dialog) { 458 FakeDataMaker.emptyAddressEntry()).then(function(dialog) {
461 var saveButton = dialog.$.saveButton; 459 var saveButton = dialog.$.saveButton;
(...skipping 304 matching lines...) Expand 10 before | Expand all | Expand 10 after
766 assertEquals(city, cols[0].value); 764 assertEquals(city, cols[0].value);
767 assertEquals(state, cols[1].value); 765 assertEquals(state, cols[1].value);
768 assertEquals(zip, cols[2].value); 766 assertEquals(zip, cols[2].value);
769 }); 767 });
770 }); 768 });
771 }); 769 });
772 }); 770 });
773 771
774 mocha.run(); 772 mocha.run();
775 }); 773 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698