| 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. |
| 11 GEN_INCLUDE([ | 11 GEN_INCLUDE([ |
| 12 ROOT_PATH + 'chrome/test/data/webui/polymer_browser_test_base.js', | 12 ROOT_PATH + 'chrome/test/data/webui/polymer_browser_test_base.js', |
| 13 ]); | 13 ]); |
| 14 | 14 |
| 15 /** | 15 /** |
| 16 * Test implementation. | 16 * Test implementation. |
| 17 * @implements {settings.address.CountryDetailManager} | 17 * @implements {settings.address.CountryDetailManager} |
| 18 * @constructor | 18 * @constructor |
| 19 */ | 19 */ |
| 20 function CountryDetailManagerTestImpl() {} | 20 function CountryDetailManagerTestImpl() {} |
| 21 |
| 21 CountryDetailManagerTestImpl.prototype = { | 22 CountryDetailManagerTestImpl.prototype = { |
| 22 /** @override */ | 23 /** @override */ |
| 23 getCountryList: function() { | 24 getCountryList: function() { |
| 24 return new Promise(function(resolve) { | 25 return new Promise(function(resolve) { |
| 25 resolve([ | 26 resolve([ |
| 26 {name: 'United States', countryCode: 'US'}, // Default test country. | 27 {name: 'United States', countryCode: 'US'}, // Default test country. |
| 27 {name: 'Israel', countryCode: 'IL'}, | 28 {name: 'Israel', countryCode: 'IL'}, |
| 28 {name: 'United Kingdom', countryCode: 'GB'}, | 29 {name: 'United Kingdom', countryCode: 'GB'}, |
| 29 ]); | 30 ]); |
| 30 }); | 31 }); |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 119 }, | 120 }, |
| 120 | 121 |
| 121 /** | 122 /** |
| 122 * Creates the autofill section for the given lists. | 123 * Creates the autofill section for the given lists. |
| 123 * @param {!Array<!chrome.passwordsPrivate.PasswordUiEntry>} passwordList | 124 * @param {!Array<!chrome.passwordsPrivate.PasswordUiEntry>} passwordList |
| 124 * @param {!Array<!chrome.passwordsPrivate.ExceptionPair>} exceptionList | 125 * @param {!Array<!chrome.passwordsPrivate.ExceptionPair>} exceptionList |
| 125 * @return {!Object} | 126 * @return {!Object} |
| 126 * @private | 127 * @private |
| 127 */ | 128 */ |
| 128 createAutofillSection_: function(addresses, creditCards) { | 129 createAutofillSection_: function(addresses, creditCards) { |
| 130 // Override the AutofillManagerImpl for testing. |
| 131 this.autofillManager = new TestAutofillManager(); |
| 132 this.autofillManager.data.addresses = addresses; |
| 133 this.autofillManager.data.creditCards = creditCards; |
| 134 AutofillManagerImpl.instance_ = this.autofillManager; |
| 135 |
| 129 var section = document.createElement('settings-autofill-section'); | 136 var section = document.createElement('settings-autofill-section'); |
| 130 section.addresses = addresses; | |
| 131 section.creditCards = creditCards; | |
| 132 document.body.appendChild(section); | 137 document.body.appendChild(section); |
| 133 Polymer.dom.flush(); | 138 Polymer.dom.flush(); |
| 134 return section; | 139 return section; |
| 135 }, | 140 }, |
| 136 | 141 |
| 137 /** | 142 /** |
| 138 * Creates the Edit Address dialog and fulfills the promise when the dialog | 143 * Creates the Edit Address dialog and fulfills the promise when the dialog |
| 139 * has actually opened. | 144 * has actually opened. |
| 140 * @param {!chrome.autofillPrivate.AddressEntry} address | 145 * @param {!chrome.autofillPrivate.AddressEntry} address |
| 141 * @return {!Promise<Object>} | 146 * @return {!Promise<Object>} |
| (...skipping 19 matching lines...) Expand all Loading... |
| 161 section.creditCard = creditCardItem; | 166 section.creditCard = creditCardItem; |
| 162 document.body.appendChild(section); | 167 document.body.appendChild(section); |
| 163 Polymer.dom.flush(); | 168 Polymer.dom.flush(); |
| 164 return section; | 169 return section; |
| 165 }, | 170 }, |
| 166 }; | 171 }; |
| 167 | 172 |
| 168 TEST_F('SettingsAutofillSectionBrowserTest', 'CreditCardTests', function() { | 173 TEST_F('SettingsAutofillSectionBrowserTest', 'CreditCardTests', function() { |
| 169 var self = this; | 174 var self = this; |
| 170 | 175 |
| 176 setup(function() { |
| 177 PolymerTest.clearBody(); |
| 178 }); |
| 179 |
| 171 suite('AutofillSection', function() { | 180 suite('AutofillSection', function() { |
| 172 test('verifyCreditCardCount', function() { | 181 test('verifyCreditCardCount', function() { |
| 173 var section = self.createAutofillSection_([], []); | 182 var section = self.createAutofillSection_([], []); |
| 174 assertTrue(!!section); | 183 assertTrue(!!section); |
| 175 | 184 |
| 176 var creditCardList = section.$.creditCardList; | 185 var creditCardList = section.$.creditCardList; |
| 177 assertTrue(!!creditCardList); | 186 assertTrue(!!creditCardList); |
| 178 // +1 for the template element. | 187 // +1 for the template element. |
| 179 assertEquals(1, creditCardList.children.length); | 188 assertEquals(1, creditCardList.children.length); |
| 180 | 189 |
| (...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 395 }); | 404 }); |
| 396 }); | 405 }); |
| 397 }); | 406 }); |
| 398 | 407 |
| 399 mocha.run(); | 408 mocha.run(); |
| 400 }); | 409 }); |
| 401 | 410 |
| 402 TEST_F('SettingsAutofillSectionBrowserTest', 'AddressTests', function() { | 411 TEST_F('SettingsAutofillSectionBrowserTest', 'AddressTests', function() { |
| 403 var self = this; | 412 var self = this; |
| 404 | 413 |
| 414 setup(function() { |
| 415 PolymerTest.clearBody(); |
| 416 }); |
| 417 |
| 405 suite('AutofillSection', function() { | 418 suite('AutofillSection', function() { |
| 406 test('verifyNoAddresses', function() { | 419 test('verifyNoAddresses', function() { |
| 407 var section = self.createAutofillSection_([], []); | 420 var section = self.createAutofillSection_([], []); |
| 408 assertTrue(!!section); | 421 assertTrue(!!section); |
| 409 | 422 |
| 410 var addressList = section.$.addressList; | 423 var addressList = section.$.addressList; |
| 411 assertTrue(!!addressList); | 424 assertTrue(!!addressList); |
| 412 // 1 for the template element. | 425 // 1 for the template element. |
| 413 assertEquals(1, addressList.children.length); | 426 assertEquals(1, addressList.children.length); |
| 414 | 427 |
| (...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 665 }); | 678 }); |
| 666 }); | 679 }); |
| 667 }); | 680 }); |
| 668 | 681 |
| 669 mocha.run(); | 682 mocha.run(); |
| 670 }); | 683 }); |
| 671 | 684 |
| 672 TEST_F('SettingsAutofillSectionBrowserTest', 'AddressLocaleTests', function() { | 685 TEST_F('SettingsAutofillSectionBrowserTest', 'AddressLocaleTests', function() { |
| 673 var self = this; | 686 var self = this; |
| 674 | 687 |
| 688 setup(function() { |
| 689 PolymerTest.clearBody(); |
| 690 }); |
| 691 |
| 675 suite('AutofillSection', function() { | 692 suite('AutofillSection', function() { |
| 676 // US address has 3 fields on the same line. | 693 // US address has 3 fields on the same line. |
| 677 test('verifyEditingUSAddress', function() { | 694 test('verifyEditingUSAddress', function() { |
| 678 var address = FakeDataMaker.emptyAddressEntry(); | 695 var address = FakeDataMaker.emptyAddressEntry(); |
| 679 | 696 |
| 680 address.fullNames = [ 'Name' ]; | 697 address.fullNames = [ 'Name' ]; |
| 681 address.companyName = 'Organization'; | 698 address.companyName = 'Organization'; |
| 682 address.addressLines = 'Street address'; | 699 address.addressLines = 'Street address'; |
| 683 address.addressLevel2 = 'City'; | 700 address.addressLevel2 = 'City'; |
| 684 address.addressLevel1 = 'State'; | 701 address.addressLevel1 = 'State'; |
| (...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 896 assertEquals(city, cols[0].value); | 913 assertEquals(city, cols[0].value); |
| 897 assertEquals(state, cols[1].value); | 914 assertEquals(state, cols[1].value); |
| 898 assertEquals(zip, cols[2].value); | 915 assertEquals(zip, cols[2].value); |
| 899 }); | 916 }); |
| 900 }); | 917 }); |
| 901 }); | 918 }); |
| 902 }); | 919 }); |
| 903 | 920 |
| 904 mocha.run(); | 921 mocha.run(); |
| 905 }); | 922 }); |
| OLD | NEW |