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

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

Issue 2428733002: MD Settings: Migrating autofill cr-shared-menu to settings-action-menu. (Closed)
Patch Set: Re-sort Created 4 years, 2 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
« no previous file with comments | « chrome/browser/resources/settings/passwords_and_forms_page/compiled_resources2.gyp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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.
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 ROOT_PATH + 'ui/webui/resources/js/load_time_data.js',
14 ]); 13 ]);
15 14
16 /** 15 /**
17 * Test implementation. 16 * Test implementation.
18 * @implements {settings.address.CountryDetailManager} 17 * @implements {settings.address.CountryDetailManager}
19 * @constructor 18 * @constructor
20 */ 19 */
21 function CountryDetailManagerTestImpl() {} 20 function CountryDetailManagerTestImpl() {}
22 CountryDetailManagerTestImpl.prototype = { 21 CountryDetailManagerTestImpl.prototype = {
23 /** @override */ 22 /** @override */
24 getCountryList: function() { 23 getCountryList: function() {
25 return new Promise(function(resolve) { 24 return new Promise(function(resolve) {
26 resolve([ 25 resolve([
27 {name: 'United States', countryCode: 'US'}, // Default test country. 26 {name: 'United States', countryCode: 'US'}, // Default test country.
28 {name: 'Israel', countryCode: 'IL'}, 27 {name: 'Israel', countryCode: 'IL'},
29 {name: 'United Kingdom', countryCode: 'GB'}, 28 {name: 'United Kingdom', countryCode: 'GB'},
30 ]); 29 ]);
31 }); 30 });
32 }, 31 },
33 32
34 /** @override */ 33 /** @override */
35 getAddressFormat: function(countryCode) { 34 getAddressFormat: function(countryCode) {
36 return new Promise(function(resolve) { 35 return new Promise(function(resolve) {
37 chrome.autofillPrivate.getAddressComponents(countryCode, resolve); 36 chrome.autofillPrivate.getAddressComponents(countryCode, resolve);
38 }); 37 });
39 }, 38 },
40 }; 39 };
41 40
42 /** 41 /**
43 * Will call |loopBody| for each item in |items|. Will only move to the next 42 * Will call |loopBody| for each item in |items|. Will only move to the next
44 * item after the promise from |loopBody| resolves. 43 * item after the promise from |loopBody| resolves.
45 * @param {!Array<Object>} items 44 * @param {!Array<Object>} items
46 * @param {!function(!Object):!Promise} loopBody 45 * @param {!function(!Object):!Promise} loopBody
47 * @return {!Promise} 46 * @return {!Promise}
48 */ 47 */
49 function asyncForEach(items, loopBody) { 48 function asyncForEach(items, loopBody) {
50 return new Promise(function(finish) { 49 return new Promise(function(resolve) {
51 var index = 0; 50 var index = 0;
52 51
53 function loop() { 52 function loop() {
54 var item = items[index++]; 53 var item = items[index++];
55 if (item) 54 if (item)
56 loopBody(item).then(loop); 55 loopBody(item).then(loop);
57 else 56 else
58 finish(); 57 resolve();
59 }; 58 };
60 59
61 loop(); 60 loop();
62 }); 61 });
63 } 62 }
64 63
65 /** 64 /**
66 * Resolves the promise after the element fires the expected event. Will add and 65 * Resolves the promise after the element fires the expected event. Will add and
67 * remove the listener so it is only triggered once. |causeEvent| is called 66 * remove the listener so it is only triggered once. |causeEvent| is called
68 * after adding a listener to make sure that the event is captured. 67 * after adding a listener to make sure that the event is captured.
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
101 'test_util.js', 100 'test_util.js',
102 ]), 101 ]),
103 102
104 /** 103 /**
105 * TODO(hcarmona): Increases speed, but disables A11y checks. Enable checks 104 * TODO(hcarmona): Increases speed, but disables A11y checks. Enable checks
106 * when we "accessibilityIssuesAreErrors: true" for all tests. 105 * when we "accessibilityIssuesAreErrors: true" for all tests.
107 * @override 106 * @override
108 */ 107 */
109 runAccessibilityChecks: false, 108 runAccessibilityChecks: false,
110 109
111 i18nStrings: {
112 addAddressTitle: 'add-title',
113 addCreditCardTitle: 'add-title',
114 editAddressTitle: 'edit-title',
115 editCreditCardTitle: 'edit-title',
116 },
117
118 /** @override */ 110 /** @override */
119 setUp: function() { 111 setUp: function() {
120 PolymerTest.prototype.setUp.call(this); 112 PolymerTest.prototype.setUp.call(this);
121 113
122 // Test is run on an individual element that won't have a page language. 114 // Test is run on an individual element that won't have a page language.
123 this.accessibilityAuditConfig.auditRulesToIgnore.push('humanLangMissing'); 115 this.accessibilityAuditConfig.auditRulesToIgnore.push('humanLangMissing');
124 116
125 // Faking 'strings.js' for this test.
126 loadTimeData.data = this.i18nStrings;
127
128 settings.address.CountryDetailManagerImpl.instance_ = 117 settings.address.CountryDetailManagerImpl.instance_ =
129 new CountryDetailManagerTestImpl(); 118 new CountryDetailManagerTestImpl();
130 }, 119 },
131 120
132 /** 121 /**
133 * Creates the autofill section for the given lists. 122 * Creates the autofill section for the given lists.
134 * @param {!Array<!chrome.passwordsPrivate.PasswordUiEntry>} passwordList 123 * @param {!Array<!chrome.passwordsPrivate.PasswordUiEntry>} passwordList
135 * @param {!Array<!chrome.passwordsPrivate.ExceptionPair>} exceptionList 124 * @param {!Array<!chrome.passwordsPrivate.ExceptionPair>} exceptionList
136 * @return {!Object} 125 * @return {!Object}
137 * @private 126 * @private
(...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after
403 address.metadata.summarySublabel; 392 address.metadata.summarySublabel;
404 393
405 assertEquals(addressSummary, 394 assertEquals(addressSummary,
406 row.querySelector('#addressSummary').textContent); 395 row.querySelector('#addressSummary').textContent);
407 }); 396 });
408 397
409 test('verifyAddAddressDialog', function() { 398 test('verifyAddAddressDialog', function() {
410 return self.createAddressDialog_( 399 return self.createAddressDialog_(
411 FakeDataMaker.emptyAddressEntry()).then(function(dialog) { 400 FakeDataMaker.emptyAddressEntry()).then(function(dialog) {
412 var title = dialog.$$('.title'); 401 var title = dialog.$$('.title');
413 assertEquals(self.i18nStrings.addAddressTitle, title.textContent); 402 assertEquals(loadTimeData.getString('addAddress'), title.textContent);
414 // Shouldn't be possible to save until something is typed in. 403 // Shouldn't be possible to save until something is typed in.
415 assertTrue(dialog.$.saveButton.disabled); 404 assertTrue(dialog.$.saveButton.disabled);
416 }); 405 });
417 }); 406 });
418 407
419 test('verifyEditAddressDialog', function() { 408 test('verifyEditAddressDialog', function() {
420 return self.createAddressDialog_( 409 return self.createAddressDialog_(
421 FakeDataMaker.addressEntry()).then(function(dialog) { 410 FakeDataMaker.addressEntry()).then(function(dialog) {
422 var title = dialog.$$('.title'); 411 var title = dialog.$$('.title');
423 assertEquals(self.i18nStrings.editAddressTitle, title.textContent); 412 assertEquals(
413 loadTimeData.getString('editAddressTitle'), title.textContent);
424 // Should be possible to save when editing because fields are populated. 414 // Should be possible to save when editing because fields are populated.
425 assertFalse(dialog.$.saveButton.disabled); 415 assertFalse(dialog.$.saveButton.disabled);
426 }); 416 });
427 }); 417 });
428 418
429 test('verifyCountryIsSaved', function() { 419 test('verifyCountryIsSaved', function() {
430 var address = FakeDataMaker.emptyAddressEntry(); 420 var address = FakeDataMaker.emptyAddressEntry();
431 return self.createAddressDialog_(address).then(function(dialog) { 421 return self.createAddressDialog_(address).then(function(dialog) {
432 var countrySelect = dialog.$$('select'); 422 var countrySelect = dialog.$$('select');
433 assertEquals('', countrySelect.value); 423 assertEquals('', countrySelect.value);
(...skipping 391 matching lines...) Expand 10 before | Expand all | Expand 10 after
825 assertEquals(city, cols[0].value); 815 assertEquals(city, cols[0].value);
826 assertEquals(state, cols[1].value); 816 assertEquals(state, cols[1].value);
827 assertEquals(zip, cols[2].value); 817 assertEquals(zip, cols[2].value);
828 }); 818 });
829 }); 819 });
830 }); 820 });
831 }); 821 });
832 822
833 mocha.run(); 823 mocha.run();
834 }); 824 });
OLDNEW
« no previous file with comments | « chrome/browser/resources/settings/passwords_and_forms_page/compiled_resources2.gyp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698