| 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 /** @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 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 122 this.accessibilityAuditConfig.auditRulesToIgnore.push('humanLangMissing'); | 122 this.accessibilityAuditConfig.auditRulesToIgnore.push('humanLangMissing'); |
| 123 | 123 |
| 124 // Faking 'strings.js' for this test. | 124 // Faking 'strings.js' for this test. |
| 125 loadTimeData.data = this.i18nStrings; | 125 loadTimeData.data = this.i18nStrings; |
| 126 | 126 |
| 127 settings.address.CountryDetailManagerImpl.instance_ = | 127 settings.address.CountryDetailManagerImpl.instance_ = |
| 128 new CountryDetailManagerTestImpl(); | 128 new CountryDetailManagerTestImpl(); |
| 129 }, | 129 }, |
| 130 | 130 |
| 131 /** | 131 /** |
| 132 * Allow the iron-list to be sized properly. | |
| 133 * @param {!Object} autofillSection | |
| 134 * @private | |
| 135 */ | |
| 136 flushAutofillSection_: function(autofillSection) { | |
| 137 autofillSection.$.addressList.notifyResize(); | |
| 138 autofillSection.$.creditCardList.notifyResize(); | |
| 139 Polymer.dom.flush(); | |
| 140 }, | |
| 141 | |
| 142 /** | |
| 143 * Creates the autofill section for the given lists. | 132 * Creates the autofill section for the given lists. |
| 144 * @param {!Array<!chrome.passwordsPrivate.PasswordUiEntry>} passwordList | 133 * @param {!Array<!chrome.passwordsPrivate.PasswordUiEntry>} passwordList |
| 145 * @param {!Array<!chrome.passwordsPrivate.ExceptionPair>} exceptionList | 134 * @param {!Array<!chrome.passwordsPrivate.ExceptionPair>} exceptionList |
| 146 * @return {!Object} | 135 * @return {!Object} |
| 147 * @private | 136 * @private |
| 148 */ | 137 */ |
| 149 createAutofillSection_: function(addresses, creditCards) { | 138 createAutofillSection_: function(addresses, creditCards) { |
| 150 var section = document.createElement('settings-autofill-section'); | 139 var section = document.createElement('settings-autofill-section'); |
| 151 section.addresses = addresses; | 140 section.addresses = addresses; |
| 152 section.creditCards = creditCards; | 141 section.creditCards = creditCards; |
| 153 document.body.appendChild(section); | 142 document.body.appendChild(section); |
| 154 this.flushAutofillSection_(section); | 143 Polymer.dom.flush(); |
| 155 return section; | 144 return section; |
| 156 }, | 145 }, |
| 157 | 146 |
| 158 /** | 147 /** |
| 159 * Creates the Edit Address dialog and fulfills the promise when the dialog | 148 * Creates the Edit Address dialog and fulfills the promise when the dialog |
| 160 * has actually opened. | 149 * has actually opened. |
| 161 * @param {!chrome.autofillPrivate.AddressEntry} address | 150 * @param {!chrome.autofillPrivate.AddressEntry} address |
| 162 * @return {!Promise<Object>} | 151 * @return {!Promise<Object>} |
| 163 */ | 152 */ |
| 164 createAddressDialog_: function(address) { | 153 createAddressDialog_: function(address) { |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 198 FakeDataMaker.creditCardEntry(), | 187 FakeDataMaker.creditCardEntry(), |
| 199 FakeDataMaker.creditCardEntry(), | 188 FakeDataMaker.creditCardEntry(), |
| 200 FakeDataMaker.creditCardEntry(), | 189 FakeDataMaker.creditCardEntry(), |
| 201 ]; | 190 ]; |
| 202 | 191 |
| 203 var section = self.createAutofillSection_([], creditCards); | 192 var section = self.createAutofillSection_([], creditCards); |
| 204 | 193 |
| 205 assertTrue(!!section); | 194 assertTrue(!!section); |
| 206 var creditCardList = section.$.creditCardList; | 195 var creditCardList = section.$.creditCardList; |
| 207 assertTrue(!!creditCardList); | 196 assertTrue(!!creditCardList); |
| 208 assertEquals(creditCards, creditCardList.items); | |
| 209 // +1 for the template element. | 197 // +1 for the template element. |
| 210 assertEquals(creditCards.length + 1, creditCardList.children.length); | 198 assertEquals(creditCards.length + 1, creditCardList.children.length); |
| 211 }); | 199 }); |
| 212 | 200 |
| 213 test('verifyCreditCardFields', function() { | 201 test('verifyCreditCardFields', function() { |
| 214 var creditCard = FakeDataMaker.creditCardEntry(); | 202 var creditCard = FakeDataMaker.creditCardEntry(); |
| 215 var section = self.createAutofillSection_([], [creditCard]); | 203 var section = self.createAutofillSection_([], [creditCard]); |
| 216 var creditCardList = section.$.creditCardList; | 204 var creditCardList = section.$.creditCardList; |
| 217 var row = creditCardList.children[1]; // Skip over the template. | 205 var row = creditCardList.children[0]; |
| 218 assertTrue(!!row); | 206 assertTrue(!!row); |
| 219 | 207 |
| 220 assertEquals(creditCard.metadata.summaryLabel, | 208 assertEquals(creditCard.metadata.summaryLabel, |
| 221 row.querySelector('#creditCardLabel').textContent); | 209 row.querySelector('#creditCardLabel').textContent); |
| 222 assertEquals(creditCard.expirationMonth + '/' + creditCard.expirationYear, | 210 assertEquals(creditCard.expirationMonth + '/' + creditCard.expirationYear, |
| 223 row.querySelector('#creditCardExpiration').textContent); | 211 row.querySelector('#creditCardExpiration').textContent); |
| 224 }); | 212 }); |
| 225 | 213 |
| 226 test('verifyAddVsEditCreditCardTitle', function() { | 214 test('verifyAddVsEditCreditCardTitle', function() { |
| 227 var newCreditCard = FakeDataMaker.emptyCreditCardEntry(); | 215 var newCreditCard = FakeDataMaker.emptyCreditCardEntry(); |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 339 FakeDataMaker.addressEntry(), | 327 FakeDataMaker.addressEntry(), |
| 340 FakeDataMaker.addressEntry(), | 328 FakeDataMaker.addressEntry(), |
| 341 FakeDataMaker.addressEntry(), | 329 FakeDataMaker.addressEntry(), |
| 342 ]; | 330 ]; |
| 343 | 331 |
| 344 var section = self.createAutofillSection_(addresses, []); | 332 var section = self.createAutofillSection_(addresses, []); |
| 345 | 333 |
| 346 assertTrue(!!section); | 334 assertTrue(!!section); |
| 347 var addressList = section.$.addressList; | 335 var addressList = section.$.addressList; |
| 348 assertTrue(!!addressList); | 336 assertTrue(!!addressList); |
| 349 assertEquals(addresses, addressList.items); | |
| 350 // +1 for the template element. | 337 // +1 for the template element. |
| 351 assertEquals(addresses.length + 1, addressList.children.length); | 338 assertEquals(addresses.length + 1, addressList.children.length); |
| 352 }); | 339 }); |
| 353 | 340 |
| 354 test('verifyAddressFields', function() { | 341 test('verifyAddressFields', function() { |
| 355 var address = FakeDataMaker.addressEntry(); | 342 var address = FakeDataMaker.addressEntry(); |
| 356 var section = self.createAutofillSection_([address], []); | 343 var section = self.createAutofillSection_([address], []); |
| 357 var addressList = section.$.addressList; | 344 var addressList = section.$.addressList; |
| 358 var row = addressList.children[1]; // Skip over the template. | 345 var row = addressList.children[0]; |
| 359 assertTrue(!!row); | 346 assertTrue(!!row); |
| 360 | 347 |
| 361 var addressSummary = address.metadata.summaryLabel + | 348 var addressSummary = address.metadata.summaryLabel + |
| 362 address.metadata.summarySublabel; | 349 address.metadata.summarySublabel; |
| 363 | 350 |
| 364 assertEquals(addressSummary, | 351 assertEquals(addressSummary, |
| 365 row.querySelector('#addressSummary').textContent); | 352 row.querySelector('#addressSummary').textContent); |
| 366 }); | 353 }); |
| 367 | 354 |
| 368 test('verifyAddAddressDialog', function() { | 355 test('verifyAddAddressDialog', function() { |
| (...skipping 395 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 764 assertEquals(city, cols[0].value); | 751 assertEquals(city, cols[0].value); |
| 765 assertEquals(state, cols[1].value); | 752 assertEquals(state, cols[1].value); |
| 766 assertEquals(zip, cols[2].value); | 753 assertEquals(zip, cols[2].value); |
| 767 }); | 754 }); |
| 768 }); | 755 }); |
| 769 }); | 756 }); |
| 770 }); | 757 }); |
| 771 | 758 |
| 772 mocha.run(); | 759 mocha.run(); |
| 773 }); | 760 }); |
| OLD | NEW |