Commit 17ab08ce authored by rbpotter's avatar rbpotter Committed by Commit Bot

Settings: use cr.define/classes for autofill/passwords test utils

Instead of defining a function object and then adding functions to it,
wrap everything in a cr.define, which can be removed later once
these tests are fully migrated to use JS modules.

Update all test classes to es6 classes.

Bug: 1026426
Change-Id: I004fb0798b5a855bda2de9c3f996fe346937e1cd
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2088650Reviewed-by: default avatardpapad <dpapad@chromium.org>
Commit-Queue: Rebekah Potter <rbpotter@chromium.org>
Cr-Commit-Position: refs/heads/master@{#747471}
parent 380630a9
...@@ -94,7 +94,7 @@ AccessibilityTest.define('SettingsA11yPasswords', { ...@@ -94,7 +94,7 @@ AccessibilityTest.define('SettingsA11yPasswords', {
'Accessible with 10 passwords': function() { 'Accessible with 10 passwords': function() {
const fakePasswords = []; const fakePasswords = [];
for (let i = 0; i < 10; i++) { for (let i = 0; i < 10; i++) {
fakePasswords.push(FakeDataMaker.passwordEntry()); fakePasswords.push(autofill_test_util.createPasswordEntry());
} }
// Set list of passwords. // Set list of passwords.
this.passwordManager.lastCallback.addSavedPasswordListChangedListener( this.passwordManager.lastCallback.addSavedPasswordListChangedListener(
......
...@@ -76,10 +76,10 @@ cr.define('settings_autofill_page', function() { ...@@ -76,10 +76,10 @@ cr.define('settings_autofill_page', function() {
/** /**
* Creates PasswordManagerExpectations with the values expected after first * Creates PasswordManagerExpectations with the values expected after first
* creating the element. * creating the element.
* @return {!PasswordManagerExpectations} * @return {!autofill_test_util.PasswordManagerExpectations}
*/ */
function basePasswordExpectations() { function basePasswordExpectations() {
const expected = new PasswordManagerExpectations(); const expected = new autofill_test_util.PasswordManagerExpectations();
expected.requested.passwords = 1; expected.requested.passwords = 1;
expected.requested.exceptions = 1; expected.requested.exceptions = 1;
expected.requested.accountStorageOptInState = 1; expected.requested.accountStorageOptInState = 1;
...@@ -92,10 +92,10 @@ cr.define('settings_autofill_page', function() { ...@@ -92,10 +92,10 @@ cr.define('settings_autofill_page', function() {
/** /**
* Creates AutofillManagerExpectations with the values expected after first * Creates AutofillManagerExpectations with the values expected after first
* creating the element. * creating the element.
* @return {!AutofillManagerExpectations} * @return {!autofill_test_util.AutofillManagerExpectations}
*/ */
function baseAutofillExpectations() { function baseAutofillExpectations() {
const expected = new AutofillManagerExpectations(); const expected = new autofill_test_util.AutofillManagerExpectations();
expected.requestedAddresses = 1; expected.requestedAddresses = 1;
expected.listeningAddresses = 1; expected.listeningAddresses = 1;
return expected; return expected;
...@@ -104,10 +104,10 @@ cr.define('settings_autofill_page', function() { ...@@ -104,10 +104,10 @@ cr.define('settings_autofill_page', function() {
/** /**
* Creates PaymentsManagerExpectations with the values expected after first * Creates PaymentsManagerExpectations with the values expected after first
* creating the element. * creating the element.
* @return {!PaymentsManagerExpectations} * @return {!autofill_test_util.PaymentsManagerExpectations}
*/ */
function basePaymentsExpectations() { function basePaymentsExpectations() {
const expected = new PaymentsManagerExpectations(); const expected = new autofill_test_util.PaymentsManagerExpectations();
expected.requestedCreditCards = 1; expected.requestedCreditCards = 1;
expected.listeningCreditCards = 1; expected.listeningCreditCards = 1;
return expected; return expected;
...@@ -127,11 +127,11 @@ cr.define('settings_autofill_page', function() { ...@@ -127,11 +127,11 @@ cr.define('settings_autofill_page', function() {
PasswordManagerImpl.instance_ = passwordManager; PasswordManagerImpl.instance_ = passwordManager;
// Override the AutofillManagerImpl for testing. // Override the AutofillManagerImpl for testing.
autofillManager = new TestAutofillManager(); autofillManager = new autofill_test_util.TestAutofillManager();
settings.AutofillManagerImpl.instance_ = autofillManager; settings.AutofillManagerImpl.instance_ = autofillManager;
// Override the PaymentsManagerImpl for testing. // Override the PaymentsManagerImpl for testing.
paymentsManager = new TestPaymentsManager(); paymentsManager = new autofill_test_util.TestPaymentsManager();
settings.PaymentsManagerImpl.instance_ = paymentsManager; settings.PaymentsManagerImpl.instance_ = paymentsManager;
}); });
...@@ -170,8 +170,10 @@ cr.define('settings_autofill_page', function() { ...@@ -170,8 +170,10 @@ cr.define('settings_autofill_page', function() {
return createPrefs(true, true).then(function(prefs) { return createPrefs(true, true).then(function(prefs) {
const element = createAutofillElement(prefs); const element = createAutofillElement(prefs);
const list = const list = [
[FakeDataMaker.passwordEntry(), FakeDataMaker.passwordEntry()]; autofill_test_util.createPasswordEntry(),
autofill_test_util.createPasswordEntry()
];
passwordManager.lastCallback.addSavedPasswordListChangedListener(list); passwordManager.lastCallback.addSavedPasswordListChangedListener(list);
Polymer.dom.flush(); Polymer.dom.flush();
...@@ -195,8 +197,10 @@ cr.define('settings_autofill_page', function() { ...@@ -195,8 +197,10 @@ cr.define('settings_autofill_page', function() {
return createPrefs(true, true).then(function(prefs) { return createPrefs(true, true).then(function(prefs) {
const element = createAutofillElement(prefs); const element = createAutofillElement(prefs);
const list = const list = [
[FakeDataMaker.exceptionEntry(), FakeDataMaker.exceptionEntry()]; autofill_test_util.createExceptionEntry(),
autofill_test_util.createExceptionEntry()
];
passwordManager.lastCallback.addExceptionListChangedListener(list); passwordManager.lastCallback.addExceptionListChangedListener(list);
Polymer.dom.flush(); Polymer.dom.flush();
...@@ -216,10 +220,14 @@ cr.define('settings_autofill_page', function() { ...@@ -216,10 +220,14 @@ cr.define('settings_autofill_page', function() {
return createPrefs(true, true).then(function(prefs) { return createPrefs(true, true).then(function(prefs) {
const element = createAutofillElement(prefs); const element = createAutofillElement(prefs);
const addressList = const addressList = [
[FakeDataMaker.addressEntry(), FakeDataMaker.addressEntry()]; autofill_test_util.createAddressEntry(),
const cardList = autofill_test_util.createAddressEntry()
[FakeDataMaker.creditCardEntry(), FakeDataMaker.creditCardEntry()]; ];
const cardList = [
autofill_test_util.createCreditCardEntry(),
autofill_test_util.createCreditCardEntry()
];
autofillManager.lastCallback.setPersonalDataManagerListener( autofillManager.lastCallback.setPersonalDataManagerListener(
addressList, cardList); addressList, cardList);
Polymer.dom.flush(); Polymer.dom.flush();
...@@ -240,10 +248,14 @@ cr.define('settings_autofill_page', function() { ...@@ -240,10 +248,14 @@ cr.define('settings_autofill_page', function() {
return createPrefs(true, true).then(function(prefs) { return createPrefs(true, true).then(function(prefs) {
const element = createAutofillElement(prefs); const element = createAutofillElement(prefs);
const addressList = const addressList = [
[FakeDataMaker.addressEntry(), FakeDataMaker.addressEntry()]; autofill_test_util.createAddressEntry(),
const cardList = autofill_test_util.createAddressEntry()
[FakeDataMaker.creditCardEntry(), FakeDataMaker.creditCardEntry()]; ];
const cardList = [
autofill_test_util.createCreditCardEntry(),
autofill_test_util.createCreditCardEntry()
];
paymentsManager.lastCallback.setPersonalDataManagerListener( paymentsManager.lastCallback.setPersonalDataManagerListener(
addressList, cardList); addressList, cardList);
Polymer.dom.flush(); Polymer.dom.flush();
......
...@@ -58,7 +58,7 @@ cr.define('settings_autofill_section', function() { ...@@ -58,7 +58,7 @@ cr.define('settings_autofill_section', function() {
*/ */
function createAutofillSection(addresses, prefValues) { function createAutofillSection(addresses, prefValues) {
// Override the AutofillManagerImpl for testing. // Override the AutofillManagerImpl for testing.
this.autofillManager = new TestAutofillManager(); this.autofillManager = new autofill_test_util.TestAutofillManager();
this.autofillManager.data.addresses = addresses; this.autofillManager.data.addresses = addresses;
settings.AutofillManagerImpl.instance_ = this.autofillManager; settings.AutofillManagerImpl.instance_ = this.autofillManager;
...@@ -153,11 +153,11 @@ cr.define('settings_autofill_section', function() { ...@@ -153,11 +153,11 @@ cr.define('settings_autofill_section', function() {
test('verifyAddressCount', function() { test('verifyAddressCount', function() {
const addresses = [ const addresses = [
FakeDataMaker.addressEntry(), autofill_test_util.createAddressEntry(),
FakeDataMaker.addressEntry(), autofill_test_util.createAddressEntry(),
FakeDataMaker.addressEntry(), autofill_test_util.createAddressEntry(),
FakeDataMaker.addressEntry(), autofill_test_util.createAddressEntry(),
FakeDataMaker.addressEntry(), autofill_test_util.createAddressEntry(),
]; ];
const section = const section =
...@@ -182,7 +182,7 @@ cr.define('settings_autofill_section', function() { ...@@ -182,7 +182,7 @@ cr.define('settings_autofill_section', function() {
}); });
test('verifyAddressFields', function() { test('verifyAddressFields', function() {
const address = FakeDataMaker.addressEntry(); const address = autofill_test_util.createAddressEntry();
const section = createAutofillSection([address], {}); const section = createAutofillSection([address], {});
const addressList = section.$.addressList; const addressList = section.$.addressList;
const row = addressList.children[0]; const row = addressList.children[0];
...@@ -203,7 +203,7 @@ cr.define('settings_autofill_section', function() { ...@@ -203,7 +203,7 @@ cr.define('settings_autofill_section', function() {
}); });
test('verifyAddressRowButtonIsDropdownWhenLocal', function() { test('verifyAddressRowButtonIsDropdownWhenLocal', function() {
const address = FakeDataMaker.addressEntry(); const address = autofill_test_util.createAddressEntry();
address.metadata.isLocal = true; address.metadata.isLocal = true;
const section = createAutofillSection([address], {}); const section = createAutofillSection([address], {});
const addressList = section.$.addressList; const addressList = section.$.addressList;
...@@ -216,7 +216,7 @@ cr.define('settings_autofill_section', function() { ...@@ -216,7 +216,7 @@ cr.define('settings_autofill_section', function() {
}); });
test('verifyAddressRowButtonIsOutlinkWhenRemote', function() { test('verifyAddressRowButtonIsOutlinkWhenRemote', function() {
const address = FakeDataMaker.addressEntry(); const address = autofill_test_util.createAddressEntry();
address.metadata.isLocal = false; address.metadata.isLocal = false;
const section = createAutofillSection([address], {}); const section = createAutofillSection([address], {});
const addressList = section.$.addressList; const addressList = section.$.addressList;
...@@ -229,7 +229,7 @@ cr.define('settings_autofill_section', function() { ...@@ -229,7 +229,7 @@ cr.define('settings_autofill_section', function() {
}); });
test('verifyAddAddressDialog', function() { test('verifyAddAddressDialog', function() {
return createAddressDialog(FakeDataMaker.emptyAddressEntry()) return createAddressDialog(autofill_test_util.createEmptyAddressEntry())
.then(function(dialog) { .then(function(dialog) {
const title = dialog.$$('[slot=title]'); const title = dialog.$$('[slot=title]');
assertEquals( assertEquals(
...@@ -240,7 +240,7 @@ cr.define('settings_autofill_section', function() { ...@@ -240,7 +240,7 @@ cr.define('settings_autofill_section', function() {
}); });
test('verifyEditAddressDialog', function() { test('verifyEditAddressDialog', function() {
return createAddressDialog(FakeDataMaker.addressEntry()) return createAddressDialog(autofill_test_util.createAddressEntry())
.then(function(dialog) { .then(function(dialog) {
const title = dialog.$$('[slot=title]'); const title = dialog.$$('[slot=title]');
assertEquals( assertEquals(
...@@ -252,7 +252,7 @@ cr.define('settings_autofill_section', function() { ...@@ -252,7 +252,7 @@ cr.define('settings_autofill_section', function() {
}); });
test('verifyCountryIsSaved', function() { test('verifyCountryIsSaved', function() {
const address = FakeDataMaker.emptyAddressEntry(); const address = autofill_test_util.createEmptyAddressEntry();
return createAddressDialog(address).then(function(dialog) { return createAddressDialog(address).then(function(dialog) {
const countrySelect = dialog.$$('select'); const countrySelect = dialog.$$('select');
assertEquals('', countrySelect.value); assertEquals('', countrySelect.value);
...@@ -266,7 +266,7 @@ cr.define('settings_autofill_section', function() { ...@@ -266,7 +266,7 @@ cr.define('settings_autofill_section', function() {
}); });
test('verifyPhoneAndEmailAreSaved', function() { test('verifyPhoneAndEmailAreSaved', function() {
const address = FakeDataMaker.emptyAddressEntry(); const address = autofill_test_util.createEmptyAddressEntry();
return createAddressDialog(address).then(function(dialog) { return createAddressDialog(address).then(function(dialog) {
assertEquals('', dialog.$.phoneInput.value); assertEquals('', dialog.$.phoneInput.value);
assertFalse(!!(address.phoneNumbers && address.phoneNumbers[0])); assertFalse(!!(address.phoneNumbers && address.phoneNumbers[0]));
...@@ -293,7 +293,7 @@ cr.define('settings_autofill_section', function() { ...@@ -293,7 +293,7 @@ cr.define('settings_autofill_section', function() {
}); });
test('verifyPhoneAndEmailAreRemoved', function() { test('verifyPhoneAndEmailAreRemoved', function() {
const address = FakeDataMaker.emptyAddressEntry(); const address = autofill_test_util.createEmptyAddressEntry();
const phoneNumber = '(555) 555-5555'; const phoneNumber = '(555) 555-5555';
const emailAddress = 'no-reply@chromium.org'; const emailAddress = 'no-reply@chromium.org';
...@@ -322,7 +322,7 @@ cr.define('settings_autofill_section', function() { ...@@ -322,7 +322,7 @@ cr.define('settings_autofill_section', function() {
// save button is enabled, then it will clear the field and verify that the // save button is enabled, then it will clear the field and verify that the
// save button is disabled. Test passes after all elements have been tested. // save button is disabled. Test passes after all elements have been tested.
test('verifySaveIsNotClickableIfAllInputFieldsAreEmpty', function() { test('verifySaveIsNotClickableIfAllInputFieldsAreEmpty', function() {
return createAddressDialog(FakeDataMaker.emptyAddressEntry()) return createAddressDialog(autofill_test_util.createEmptyAddressEntry())
.then(function(dialog) { .then(function(dialog) {
const saveButton = dialog.$.saveButton; const saveButton = dialog.$.saveButton;
const testElements = const testElements =
...@@ -366,7 +366,7 @@ cr.define('settings_autofill_section', function() { ...@@ -366,7 +366,7 @@ cr.define('settings_autofill_section', function() {
countrySelect.dispatchEvent(new CustomEvent('change')); countrySelect.dispatchEvent(new CustomEvent('change'));
}; };
return createAddressDialog(FakeDataMaker.emptyAddressEntry()) return createAddressDialog(autofill_test_util.createEmptyAddressEntry())
.then(function(d) { .then(function(d) {
dialog = d; dialog = d;
assertTrue(dialog.$.saveButton.disabled); assertTrue(dialog.$.saveButton.disabled);
...@@ -389,7 +389,7 @@ cr.define('settings_autofill_section', function() { ...@@ -389,7 +389,7 @@ cr.define('settings_autofill_section', function() {
// Test will timeout if save-address event is not fired. // Test will timeout if save-address event is not fired.
test('verifyDefaultCountryIsAppliedWhenSaving', function() { test('verifyDefaultCountryIsAppliedWhenSaving', function() {
const address = FakeDataMaker.emptyAddressEntry(); const address = autofill_test_util.createEmptyAddressEntry();
address.fullNames = ['Name']; address.fullNames = ['Name'];
return createAddressDialog(address).then(function(dialog) { return createAddressDialog(address).then(function(dialog) {
return expectEvent(dialog, 'save-address', function() { return expectEvent(dialog, 'save-address', function() {
...@@ -404,7 +404,7 @@ cr.define('settings_autofill_section', function() { ...@@ -404,7 +404,7 @@ cr.define('settings_autofill_section', function() {
}); });
test('verifyCancelDoesNotSaveAddress', function(done) { test('verifyCancelDoesNotSaveAddress', function(done) {
createAddressDialog(FakeDataMaker.addressEntry()) createAddressDialog(autofill_test_util.createAddressEntry())
.then(function(dialog) { .then(function(dialog) {
test_util.eventToPromise('save-address', dialog).then(function() { test_util.eventToPromise('save-address', dialog).then(function() {
// Fail the test because the save event should not be called when // Fail the test because the save event should not be called when
...@@ -435,7 +435,7 @@ cr.define('settings_autofill_section', function() { ...@@ -435,7 +435,7 @@ cr.define('settings_autofill_section', function() {
// US address has 3 fields on the same line. // US address has 3 fields on the same line.
test('verifyEditingUSAddress', function() { test('verifyEditingUSAddress', function() {
const address = FakeDataMaker.emptyAddressEntry(); const address = autofill_test_util.createEmptyAddressEntry();
const company_enabled = loadTimeData.getBoolean('EnableCompanyName'); const company_enabled = loadTimeData.getBoolean('EnableCompanyName');
address.fullNames = ['Name']; address.fullNames = ['Name'];
address.companyName = 'Organization'; address.companyName = 'Organization';
...@@ -499,7 +499,7 @@ cr.define('settings_autofill_section', function() { ...@@ -499,7 +499,7 @@ cr.define('settings_autofill_section', function() {
// GB address has 1 field per line for all lines that change. // GB address has 1 field per line for all lines that change.
test('verifyEditingGBAddress', function() { test('verifyEditingGBAddress', function() {
const address = FakeDataMaker.emptyAddressEntry(); const address = autofill_test_util.createEmptyAddressEntry();
const company_enabled = loadTimeData.getBoolean('EnableCompanyName'); const company_enabled = loadTimeData.getBoolean('EnableCompanyName');
address.fullNames = ['Name']; address.fullNames = ['Name'];
...@@ -568,7 +568,7 @@ cr.define('settings_autofill_section', function() { ...@@ -568,7 +568,7 @@ cr.define('settings_autofill_section', function() {
// IL address has 2 fields on the same line and is an RTL locale. // IL address has 2 fields on the same line and is an RTL locale.
// RTL locale shouldn't affect this test. // RTL locale shouldn't affect this test.
test('verifyEditingILAddress', function() { test('verifyEditingILAddress', function() {
const address = FakeDataMaker.emptyAddressEntry(); const address = autofill_test_util.createEmptyAddressEntry();
const company_enabled = loadTimeData.getBoolean('EnableCompanyName'); const company_enabled = loadTimeData.getBoolean('EnableCompanyName');
address.fullNames = ['Name']; address.fullNames = ['Name'];
...@@ -632,7 +632,7 @@ cr.define('settings_autofill_section', function() { ...@@ -632,7 +632,7 @@ cr.define('settings_autofill_section', function() {
// US has an extra field 'State'. Validate that this field is // US has an extra field 'State'. Validate that this field is
// persisted when switching to IL then back to US. // persisted when switching to IL then back to US.
test('verifyAddressPersistanceWhenSwitchingCountries', function() { test('verifyAddressPersistanceWhenSwitchingCountries', function() {
const address = FakeDataMaker.emptyAddressEntry(); const address = autofill_test_util.createEmptyAddressEntry();
const company_enabled = loadTimeData.getBoolean('EnableCompanyName'); const company_enabled = loadTimeData.getBoolean('EnableCompanyName');
address.countryCode = 'US'; address.countryCode = 'US';
......
...@@ -77,10 +77,13 @@ cr.define('settings_passwords_check', function() { ...@@ -77,10 +77,13 @@ cr.define('settings_passwords_check', function() {
// Test verifies that compromised credentials are displayed in a proper way // Test verifies that compromised credentials are displayed in a proper way
test('testSomeCompromisedCredentials', function() { test('testSomeCompromisedCredentials', function() {
const leakedPasswords = [ const leakedPasswords = [
FakeDataMaker.makeCompromisedCredentials('one.com', 'test4', 'LEAKED'), autofill_test_util.makeCompromisedCredentials(
FakeDataMaker.makeCompromisedCredentials('two.com', 'test3', 'PHISHED'), 'one.com', 'test4', 'LEAKED'),
autofill_test_util.makeCompromisedCredentials(
'two.com', 'test3', 'PHISHED'),
]; ];
const leakedPasswordsInfo = FakeDataMaker.makeCompromisedCredentialsInfo( const leakedPasswordsInfo =
autofill_test_util.makeCompromisedCredentialsInfo(
leakedPasswords, '5 min ago'); leakedPasswords, '5 min ago');
passwordManager.data.leakedCredentials = leakedPasswordsInfo; passwordManager.data.leakedCredentials = leakedPasswordsInfo;
const checkPasswordSection = createCheckPasswordSection(); const checkPasswordSection = createCheckPasswordSection();
......
...@@ -2,13 +2,8 @@ ...@@ -2,13 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
/** cr.define('autofill_test_util', function() {
* Used to create fake data for both passwords and autofill. /**
* These sections are related, so it made sense to share this.
*/
function FakeDataMaker() {}
/**
* Creates a single item for the list of passwords. * Creates a single item for the list of passwords.
* @param {string=} url * @param {string=} url
* @param {string=} username * @param {string=} username
...@@ -16,10 +11,10 @@ function FakeDataMaker() {} ...@@ -16,10 +11,10 @@ function FakeDataMaker() {}
* @param {number=} id * @param {number=} id
* @return {chrome.passwordsPrivate.PasswordUiEntry} * @return {chrome.passwordsPrivate.PasswordUiEntry}
*/ */
FakeDataMaker.passwordEntry = function(url, username, passwordLength, id) { function createPasswordEntry(url, username, passwordLength, id) {
// Generate fake data if param is undefined. // Generate fake data if param is undefined.
url = url || FakeDataMaker.patternMaker_('www.xxxxxx.com', 16); url = url || patternMaker_('www.xxxxxx.com', 16);
username = username || FakeDataMaker.patternMaker_('user_xxxxx', 16); username = username || patternMaker_('user_xxxxx', 16);
passwordLength = passwordLength || Math.floor(Math.random() * 15) + 3; passwordLength = passwordLength || Math.floor(Math.random() * 15) + 3;
id = id || 0; id = id || 0;
...@@ -33,16 +28,16 @@ FakeDataMaker.passwordEntry = function(url, username, passwordLength, id) { ...@@ -33,16 +28,16 @@ FakeDataMaker.passwordEntry = function(url, username, passwordLength, id) {
numCharactersInPassword: passwordLength, numCharactersInPassword: passwordLength,
id: id, id: id,
}; };
}; }
/** /**
* Creates a single item for the list of password exceptions. * Creates a single item for the list of password exceptions.
* @param {string=} url * @param {string=} url
* @param {number=} id * @param {number=} id
* @return {chrome.passwordsPrivate.ExceptionEntry} * @return {chrome.passwordsPrivate.ExceptionEntry}
*/ */
FakeDataMaker.exceptionEntry = function(url, id) { function createExceptionEntry(url, id) {
url = url || FakeDataMaker.patternMaker_('www.xxxxxx.com', 16); url = url || patternMaker_('www.xxxxxx.com', 16);
id = id || 0; id = id || 0;
return { return {
urls: { urls: {
...@@ -52,61 +47,61 @@ FakeDataMaker.exceptionEntry = function(url, id) { ...@@ -52,61 +47,61 @@ FakeDataMaker.exceptionEntry = function(url, id) {
}, },
id: id, id: id,
}; };
}; }
/** /**
* Creates a new fake address entry for testing. * Creates a new fake address entry for testing.
* @return {!chrome.autofillPrivate.AddressEntry} * @return {!chrome.autofillPrivate.AddressEntry}
*/ */
FakeDataMaker.emptyAddressEntry = function() { function createEmptyAddressEntry() {
return {}; return {};
}; }
/** /**
* Creates a fake address entry for testing. * Creates a fake address entry for testing.
* @return {!chrome.autofillPrivate.AddressEntry} * @return {!chrome.autofillPrivate.AddressEntry}
*/ */
FakeDataMaker.addressEntry = function() { function createAddressEntry() {
const ret = {}; const ret = {};
ret.guid = FakeDataMaker.makeGuid_(); ret.guid = makeGuid_();
ret.fullNames = ['John Doe']; ret.fullNames = ['John Doe'];
ret.companyName = 'Google'; ret.companyName = 'Google';
ret.addressLines = FakeDataMaker.patternMaker_('xxxx Main St', 10); ret.addressLines = patternMaker_('xxxx Main St', 10);
ret.addressLevel1 = 'CA'; ret.addressLevel1 = 'CA';
ret.addressLevel2 = 'Venice'; ret.addressLevel2 = 'Venice';
ret.postalCode = FakeDataMaker.patternMaker_('xxxxx', 10); ret.postalCode = patternMaker_('xxxxx', 10);
ret.countryCode = 'US'; ret.countryCode = 'US';
ret.phoneNumbers = [FakeDataMaker.patternMaker_('(xxx) xxx-xxxx', 10)]; ret.phoneNumbers = [patternMaker_('(xxx) xxx-xxxx', 10)];
ret.emailAddresses = [FakeDataMaker.patternMaker_('userxxxx@gmail.com', 16)]; ret.emailAddresses = [patternMaker_('userxxxx@gmail.com', 16)];
ret.languageCode = 'EN-US'; ret.languageCode = 'EN-US';
ret.metadata = {isLocal: true}; ret.metadata = {isLocal: true};
ret.metadata.summaryLabel = ret.fullNames[0]; ret.metadata.summaryLabel = ret.fullNames[0];
ret.metadata.summarySublabel = ', ' + ret.addressLines; ret.metadata.summarySublabel = ', ' + ret.addressLines;
return ret; return ret;
}; }
/** /**
* Creates a new empty credit card entry for testing. * Creates a new empty credit card entry for testing.
* @return {!chrome.autofillPrivate.CreditCardEntry} * @return {!chrome.autofillPrivate.CreditCardEntry}
*/ */
FakeDataMaker.emptyCreditCardEntry = function() { function createEmptyCreditCardEntry() {
const now = new Date(); const now = new Date();
const expirationMonth = now.getMonth() + 1; const expirationMonth = now.getMonth() + 1;
const ret = {}; const ret = {};
ret.expirationMonth = expirationMonth.toString(); ret.expirationMonth = expirationMonth.toString();
ret.expirationYear = now.getFullYear().toString(); ret.expirationYear = now.getFullYear().toString();
return ret; return ret;
}; }
/** /**
* Creates a new random credit card entry for testing. * Creates a new random credit card entry for testing.
* @return {!chrome.autofillPrivate.CreditCardEntry} * @return {!chrome.autofillPrivate.CreditCardEntry}
*/ */
FakeDataMaker.creditCardEntry = function() { function createCreditCardEntry() {
const ret = {}; const ret = {};
ret.guid = FakeDataMaker.makeGuid_(); ret.guid = makeGuid_();
ret.name = 'Jane Doe'; ret.name = 'Jane Doe';
ret.cardNumber = FakeDataMaker.patternMaker_('xxxx xxxx xxxx xxxx', 10); ret.cardNumber = patternMaker_('xxxx xxxx xxxx xxxx', 10);
ret.expirationMonth = Math.ceil(Math.random() * 11).toString(); ret.expirationMonth = Math.ceil(Math.random() * 11).toString();
ret.expirationYear = (2016 + Math.floor(Math.random() * 5)).toString(); ret.expirationYear = (2016 + Math.floor(Math.random() * 5)).toString();
ret.metadata = {isLocal: true}; ret.metadata = {isLocal: true};
...@@ -115,32 +110,9 @@ FakeDataMaker.creditCardEntry = function() { ...@@ -115,32 +110,9 @@ FakeDataMaker.creditCardEntry = function() {
ret.metadata.summaryLabel = card + ' ' + ret.metadata.summaryLabel = card + ' ' +
'****' + ret.cardNumber.substr(-4); '****' + ret.cardNumber.substr(-4);
return ret; return ret;
}; }
/**
* Creates a new random GUID for testing.
* @return {string}
* @private
*/
FakeDataMaker.makeGuid_ = function() {
return FakeDataMaker.patternMaker_(
'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx', 16);
};
/**
* Replaces any 'x' in a string with a random number of the base.
* @param {string} pattern The pattern that should be used as an input.
* @param {number} base The number base. ie: 16 for hex or 10 for decimal.
* @return {string}
* @private
*/
FakeDataMaker.patternMaker_ = function(pattern, base) {
return pattern.replace(/x/g, function() {
return Math.floor(Math.random() * base).toString(base);
});
};
/** /**
* Creates a new compromised credential. * Creates a new compromised credential.
* @param {string=} url * @param {string=} url
* @param {string=} username * @param {string=} username
...@@ -148,7 +120,7 @@ FakeDataMaker.patternMaker_ = function(pattern, base) { ...@@ -148,7 +120,7 @@ FakeDataMaker.patternMaker_ = function(pattern, base) {
* @return {chrome.passwordsPrivate.CompromisedCredential} * @return {chrome.passwordsPrivate.CompromisedCredential}
* @private * @private
*/ */
FakeDataMaker.makeCompromisedCredentials = function(url, username, type) { function makeCompromisedCredentials(url, username, type) {
return { return {
formattedOrigin: url, formattedOrigin: url,
changePasswordUrl: 'http://${url}/', changePasswordUrl: 'http://${url}/',
...@@ -157,27 +129,49 @@ FakeDataMaker.makeCompromisedCredentials = function(url, username, type) { ...@@ -157,27 +129,49 @@ FakeDataMaker.makeCompromisedCredentials = function(url, username, type) {
(Math.floor(Math.random() * 60)).toString() + ' min ago', (Math.floor(Math.random() * 60)).toString() + ' min ago',
compromiseType: type, compromiseType: type,
}; };
}; }
/** /**
* Creates a new compromised credential info. * Creates a new compromised credential info.
* @param {!Array<!chrome.passwordsPrivate.CompromisedCredential>} list * @param {!Array<!chrome.passwordsPrivate.CompromisedCredential>} list
* @param {string=} lastCheck * @param {string=} lastCheck
* @return {chrome.passwordsPrivate.CompromisedCredentialsInfo} * @return {chrome.passwordsPrivate.CompromisedCredentialsInfo}
* @private * @private
*/ */
FakeDataMaker.makeCompromisedCredentialsInfo = function(list, lastCheck) { function makeCompromisedCredentialsInfo(list, lastCheck) {
return { return {
compromisedCredentials: list, compromisedCredentials: list,
elapsedTimeSinceLastCheck: lastCheck, elapsedTimeSinceLastCheck: lastCheck,
}; };
}; }
/**
* Creates a new random GUID for testing.
* @return {string}
* @private
*/
function makeGuid_() {
return patternMaker_('xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx', 16);
}
/**
* Replaces any 'x' in a string with a random number of the base.
* @param {string} pattern The pattern that should be used as an input.
* @param {number} base The number base. ie: 16 for hex or 10 for decimal.
* @return {string}
* @private
*/
function patternMaker_(pattern, base) {
return pattern.replace(/x/g, function() {
return Math.floor(Math.random() * base).toString(base);
});
}
/** /**
* Helper class for creating password-section sub-element from fake data and * Helper class for creating password-section sub-element from fake data and
* appending them to the document. * appending them to the document.
*/ */
class PasswordSectionElementFactory { class PasswordSectionElementFactory {
/** /**
* @param {HTMLDocument} document The test's |document| object. * @param {HTMLDocument} document The test's |document| object.
*/ */
...@@ -218,7 +212,8 @@ class PasswordSectionElementFactory { ...@@ -218,7 +212,8 @@ class PasswordSectionElementFactory {
* @return {!Object} * @return {!Object}
*/ */
createPasswordListItem(passwordEntry) { createPasswordListItem(passwordEntry) {
const passwordListItem = this.document.createElement('password-list-item'); const passwordListItem =
this.document.createElement('password-list-item');
passwordListItem.item = {entry: passwordEntry, password: ''}; passwordListItem.item = {entry: passwordEntry, password: ''};
this.document.body.appendChild(passwordListItem); this.document.body.appendChild(passwordListItem);
Polymer.dom.flush(); Polymer.dom.flush();
...@@ -231,7 +226,8 @@ class PasswordSectionElementFactory { ...@@ -231,7 +226,8 @@ class PasswordSectionElementFactory {
* @return {!Object} * @return {!Object}
*/ */
createPasswordEditDialog(passwordEntry) { createPasswordEditDialog(passwordEntry) {
const passwordDialog = this.document.createElement('password-edit-dialog'); const passwordDialog =
this.document.createElement('password-edit-dialog');
passwordDialog.item = {entry: passwordEntry, password: ''}; passwordDialog.item = {entry: passwordEntry, password: ''};
this.document.body.appendChild(passwordDialog); this.document.body.appendChild(passwordDialog);
Polymer.dom.flush(); Polymer.dom.flush();
...@@ -264,10 +260,10 @@ class PasswordSectionElementFactory { ...@@ -264,10 +260,10 @@ class PasswordSectionElementFactory {
return dialog; return dialog;
} }
} }
/** @constructor */ class PasswordManagerExpectations {
function PasswordManagerExpectations() { constructor() {
this.requested = { this.requested = {
passwords: 0, passwords: 0,
exceptions: 0, exceptions: 0,
...@@ -285,22 +281,23 @@ function PasswordManagerExpectations() { ...@@ -285,22 +281,23 @@ function PasswordManagerExpectations() {
exceptions: 0, exceptions: 0,
accountStorageOptInState: 0, accountStorageOptInState: 0,
}; };
} }
}
/** Helper class to track AutofillManager expectations. */ /** Helper class to track AutofillManager expectations. */
class AutofillManagerExpectations { class AutofillManagerExpectations {
constructor() { constructor() {
this.requestedAddresses = 0; this.requestedAddresses = 0;
this.listeningAddresses = 0; this.listeningAddresses = 0;
} }
} }
/** /**
* Test implementation * Test implementation
* @implements {AutofillManager} * @implements {AutofillManager}
* @constructor
*/ */
function TestAutofillManager() { class TestAutofillManager {
constructor() {
this.actual_ = new AutofillManagerExpectations(); this.actual_ = new AutofillManagerExpectations();
// Set these to have non-empty data. // Set these to have non-empty data.
...@@ -312,51 +309,50 @@ function TestAutofillManager() { ...@@ -312,51 +309,50 @@ function TestAutofillManager() {
this.lastCallback = { this.lastCallback = {
setPersonalDataManagerListener: null, setPersonalDataManagerListener: null,
}; };
} }
TestAutofillManager.prototype = {
/** @override */ /** @override */
setPersonalDataManagerListener: function(listener) { setPersonalDataManagerListener(listener) {
this.actual_.listeningAddresses++; this.actual_.listeningAddresses++;
this.lastCallback.setPersonalDataManagerListener = listener; this.lastCallback.setPersonalDataManagerListener = listener;
}, }
/** @override */ /** @override */
removePersonalDataManagerListener: function(listener) { removePersonalDataManagerListener(listener) {
this.actual_.listeningAddresses--; this.actual_.listeningAddresses--;
}, }
/** @override */ /** @override */
getAddressList: function(callback) { getAddressList(callback) {
this.actual_.requestedAddresses++; this.actual_.requestedAddresses++;
callback(this.data.addresses); callback(this.data.addresses);
}, }
/** /**
* Verifies expectations. * Verifies expectations.
* @param {!AutofillManagerExpectations} expected * @param {!AutofillManagerExpectations} expected
*/ */
assertExpectations: function(expected) { assertExpectations(expected) {
const actual = this.actual_; const actual = this.actual_;
assertEquals(expected.requestedAddresses, actual.requestedAddresses); assertEquals(expected.requestedAddresses, actual.requestedAddresses);
assertEquals(expected.listeningAddresses, actual.listeningAddresses); assertEquals(expected.listeningAddresses, actual.listeningAddresses);
}, }
}; }
/** Helper class to track PaymentsManager expectations. */ /** Helper class to track PaymentsManager expectations. */
class PaymentsManagerExpectations { class PaymentsManagerExpectations {
constructor() { constructor() {
this.requestedCreditCards = 0; this.requestedCreditCards = 0;
this.listeningCreditCards = 0; this.listeningCreditCards = 0;
} }
} }
/** /**
* Test implementation * Test implementation
* @implements {PaymentsManager} * @implements {PaymentsManager}
* @constructor
*/ */
function TestPaymentsManager() { class TestPaymentsManager {
constructor() {
this.actual_ = new PaymentsManagerExpectations(); this.actual_ = new PaymentsManagerExpectations();
// Set these to have non-empty data. // Set these to have non-empty data.
...@@ -369,39 +365,57 @@ function TestPaymentsManager() { ...@@ -369,39 +365,57 @@ function TestPaymentsManager() {
this.lastCallback = { this.lastCallback = {
setPersonalDataManagerListener: null, setPersonalDataManagerListener: null,
}; };
} }
TestPaymentsManager.prototype = {
/** @override */ /** @override */
setPersonalDataManagerListener: function(listener) { setPersonalDataManagerListener(listener) {
this.actual_.listeningCreditCards++; this.actual_.listeningCreditCards++;
this.lastCallback.setPersonalDataManagerListener = listener; this.lastCallback.setPersonalDataManagerListener = listener;
}, }
/** @override */ /** @override */
removePersonalDataManagerListener: function(listener) { removePersonalDataManagerListener(listener) {
this.actual_.listeningCreditCards--; this.actual_.listeningCreditCards--;
}, }
/** @override */ /** @override */
getCreditCardList: function(callback) { getCreditCardList(callback) {
this.actual_.requestedCreditCards++; this.actual_.requestedCreditCards++;
callback(this.data.creditCards); callback(this.data.creditCards);
}, }
/** @override */ /** @override */
getUpiIdList: function(callback) { getUpiIdList(callback) {
this.actual_.requestedUpiIds++; this.actual_.requestedUpiIds++;
callback(this.data.upiIds); callback(this.data.upiIds);
}, }
/** /**
* Verifies expectations. * Verifies expectations.
* @param {!PaymentsManagerExpectations} expected * @param {!PaymentsManagerExpectations} expected
*/ */
assertExpectations: function(expected) { assertExpectations(expected) {
const actual = this.actual_; const actual = this.actual_;
assertEquals(expected.requestedCreditCards, actual.requestedCreditCards); assertEquals(expected.requestedCreditCards, actual.requestedCreditCards);
assertEquals(expected.listeningCreditCards, actual.listeningCreditCards); assertEquals(expected.listeningCreditCards, actual.listeningCreditCards);
}, }
}; }
// #cr_define_end
return {
createPasswordEntry: createPasswordEntry,
createExceptionEntry: createExceptionEntry,
createEmptyAddressEntry: createEmptyAddressEntry,
createAddressEntry: createAddressEntry,
createEmptyCreditCardEntry: createEmptyCreditCardEntry,
createCreditCardEntry: createCreditCardEntry,
makeCompromisedCredentials: makeCompromisedCredentials,
makeCompromisedCredentialsInfo: makeCompromisedCredentialsInfo,
TestPaymentsManager: TestPaymentsManager,
PaymentsManagerExpectations: PaymentsManagerExpectations,
TestAutofillManager: TestAutofillManager,
AutofillManagerExpectations: AutofillManagerExpectations,
PasswordSectionElementFactory: PasswordSectionElementFactory,
PasswordManagerExpectations: PasswordManagerExpectations,
};
});
...@@ -106,7 +106,7 @@ cr.define('settings_passwords_section', function() { ...@@ -106,7 +106,7 @@ cr.define('settings_passwords_section', function() {
/** @type {TestPasswordManagerProxy} */ /** @type {TestPasswordManagerProxy} */
let passwordManager = null; let passwordManager = null;
/** @type {PasswordSectionElementFactory} */ /** @type {autofill_test_util.PasswordSectionElementFactory} */
let elementFactory = null; let elementFactory = null;
suiteSetup(function() { suiteSetup(function() {
...@@ -118,7 +118,8 @@ cr.define('settings_passwords_section', function() { ...@@ -118,7 +118,8 @@ cr.define('settings_passwords_section', function() {
// Override the PasswordManagerImpl for testing. // Override the PasswordManagerImpl for testing.
passwordManager = new TestPasswordManagerProxy(); passwordManager = new TestPasswordManagerProxy();
PasswordManagerImpl.instance_ = passwordManager; PasswordManagerImpl.instance_ = passwordManager;
elementFactory = new PasswordSectionElementFactory(document); elementFactory =
new autofill_test_util.PasswordSectionElementFactory(document);
}); });
test('testPasswordsExtensionIndicator', function() { test('testPasswordsExtensionIndicator', function() {
...@@ -148,12 +149,12 @@ cr.define('settings_passwords_section', function() { ...@@ -148,12 +149,12 @@ cr.define('settings_passwords_section', function() {
test('verifySavedPasswordLength', function() { test('verifySavedPasswordLength', function() {
const passwordList = [ const passwordList = [
FakeDataMaker.passwordEntry('site1.com', 'luigi', 1), autofill_test_util.createPasswordEntry('site1.com', 'luigi', 1),
FakeDataMaker.passwordEntry('longwebsite.com', 'peach', 7), autofill_test_util.createPasswordEntry('longwebsite.com', 'peach', 7),
FakeDataMaker.passwordEntry('site2.com', 'mario', 70), autofill_test_util.createPasswordEntry('site2.com', 'mario', 70),
FakeDataMaker.passwordEntry('site1.com', 'peach', 11), autofill_test_util.createPasswordEntry('site1.com', 'peach', 11),
FakeDataMaker.passwordEntry('google.com', 'mario', 7), autofill_test_util.createPasswordEntry('google.com', 'mario', 7),
FakeDataMaker.passwordEntry('site2.com', 'luigi', 8), autofill_test_util.createPasswordEntry('site2.com', 'luigi', 8),
]; ];
const passwordsSection = elementFactory.createPasswordsSection( const passwordsSection = elementFactory.createPasswordsSection(
...@@ -174,9 +175,11 @@ cr.define('settings_passwords_section', function() { ...@@ -174,9 +175,11 @@ cr.define('settings_passwords_section', function() {
// Test verifies that removing a password will update the elements. // Test verifies that removing a password will update the elements.
test('verifyPasswordListRemove', function() { test('verifyPasswordListRemove', function() {
const passwordList = [ const passwordList = [
FakeDataMaker.passwordEntry('anotherwebsite.com', 'luigi', 1, 0), autofill_test_util.createPasswordEntry(
FakeDataMaker.passwordEntry('longwebsite.com', 'peach', 7, 1), 'anotherwebsite.com', 'luigi', 1, 0),
FakeDataMaker.passwordEntry('website.com', 'mario', 70, 2) autofill_test_util.createPasswordEntry(
'longwebsite.com', 'peach', 7, 1),
autofill_test_util.createPasswordEntry('website.com', 'mario', 70, 2)
]; ];
const passwordsSection = elementFactory.createPasswordsSection( const passwordsSection = elementFactory.createPasswordsSection(
...@@ -200,8 +203,10 @@ cr.define('settings_passwords_section', function() { ...@@ -200,8 +203,10 @@ cr.define('settings_passwords_section', function() {
// Test verifies that adding a password will update the elements. // Test verifies that adding a password will update the elements.
test('verifyPasswordListAdd', function() { test('verifyPasswordListAdd', function() {
const passwordList = [ const passwordList = [
FakeDataMaker.passwordEntry('anotherwebsite.com', 'luigi', 1, 0), autofill_test_util.createPasswordEntry(
FakeDataMaker.passwordEntry('longwebsite.com', 'peach', 7, 1), 'anotherwebsite.com', 'luigi', 1, 0),
autofill_test_util.createPasswordEntry(
'longwebsite.com', 'peach', 7, 1),
]; ];
const passwordsSection = elementFactory.createPasswordsSection( const passwordsSection = elementFactory.createPasswordsSection(
...@@ -209,8 +214,8 @@ cr.define('settings_passwords_section', function() { ...@@ -209,8 +214,8 @@ cr.define('settings_passwords_section', function() {
validatePasswordList(passwordsSection.$.passwordList, passwordList); validatePasswordList(passwordsSection.$.passwordList, passwordList);
// Simulate 'website.com' being added to the list. // Simulate 'website.com' being added to the list.
passwordList.unshift( passwordList.unshift(autofill_test_util.createPasswordEntry(
FakeDataMaker.passwordEntry('website.com', 'mario', 70, 2)); 'website.com', 'mario', 70, 2));
passwordManager.lastCallback.addSavedPasswordListChangedListener( passwordManager.lastCallback.addSavedPasswordListChangedListener(
passwordList); passwordList);
Polymer.dom.flush(); Polymer.dom.flush();
...@@ -226,8 +231,8 @@ cr.define('settings_passwords_section', function() { ...@@ -226,8 +231,8 @@ cr.define('settings_passwords_section', function() {
// Set-up initial list. // Set-up initial list.
let passwordList = [ let passwordList = [
FakeDataMaker.passwordEntry('website.com', 'mario', 1, 0), autofill_test_util.createPasswordEntry('website.com', 'mario', 1, 0),
FakeDataMaker.passwordEntry('website.com', 'luigi', 7, 1) autofill_test_util.createPasswordEntry('website.com', 'luigi', 7, 1)
]; ];
passwordManager.lastCallback.addSavedPasswordListChangedListener( passwordManager.lastCallback.addSavedPasswordListChangedListener(
...@@ -254,12 +259,12 @@ cr.define('settings_passwords_section', function() { ...@@ -254,12 +259,12 @@ cr.define('settings_passwords_section', function() {
// event. Does not actually remove any passwords. // event. Does not actually remove any passwords.
test('verifyPasswordItemRemoveButton', function(done) { test('verifyPasswordItemRemoveButton', function(done) {
const passwordList = [ const passwordList = [
FakeDataMaker.passwordEntry('one', 'six', 5), autofill_test_util.createPasswordEntry('one', 'six', 5),
FakeDataMaker.passwordEntry('two', 'five', 3), autofill_test_util.createPasswordEntry('two', 'five', 3),
FakeDataMaker.passwordEntry('three', 'four', 1), autofill_test_util.createPasswordEntry('three', 'four', 1),
FakeDataMaker.passwordEntry('four', 'three', 2), autofill_test_util.createPasswordEntry('four', 'three', 2),
FakeDataMaker.passwordEntry('five', 'two', 4), autofill_test_util.createPasswordEntry('five', 'two', 4),
FakeDataMaker.passwordEntry('six', 'one', 6), autofill_test_util.createPasswordEntry('six', 'one', 6),
]; ];
const passwordsSection = elementFactory.createPasswordsSection( const passwordsSection = elementFactory.createPasswordsSection(
...@@ -288,7 +293,7 @@ cr.define('settings_passwords_section', function() { ...@@ -288,7 +293,7 @@ cr.define('settings_passwords_section', function() {
// (passwordless) credentials. Does not test Copy button. // (passwordless) credentials. Does not test Copy button.
test('verifyCopyAbsentForFederatedPasswordInMenu', function() { test('verifyCopyAbsentForFederatedPasswordInMenu', function() {
const passwordList = [ const passwordList = [
FakeDataMaker.passwordEntry('one.com', 'hey', 0), autofill_test_util.createPasswordEntry('one.com', 'hey', 0),
]; ];
passwordList[0].federationText = 'with chromium.org'; passwordList[0].federationText = 'with chromium.org';
...@@ -304,7 +309,7 @@ cr.define('settings_passwords_section', function() { ...@@ -304,7 +309,7 @@ cr.define('settings_passwords_section', function() {
// credentials. Does not test Copy button. // credentials. Does not test Copy button.
test('verifyCopyPresentInMenu', function() { test('verifyCopyPresentInMenu', function() {
const passwordList = [ const passwordList = [
FakeDataMaker.passwordEntry('one.com', 'hey', 5), autofill_test_util.createPasswordEntry('one.com', 'hey', 5),
]; ];
const passwordsSection = elementFactory.createPasswordsSection( const passwordsSection = elementFactory.createPasswordsSection(
passwordManager, passwordList, []); passwordManager, passwordList, []);
...@@ -316,12 +321,12 @@ cr.define('settings_passwords_section', function() { ...@@ -316,12 +321,12 @@ cr.define('settings_passwords_section', function() {
test('verifyFilterPasswords', function() { test('verifyFilterPasswords', function() {
const passwordList = [ const passwordList = [
FakeDataMaker.passwordEntry('one.com', 'SHOW', 5), autofill_test_util.createPasswordEntry('one.com', 'SHOW', 5),
FakeDataMaker.passwordEntry('two.com', 'shower', 3), autofill_test_util.createPasswordEntry('two.com', 'shower', 3),
FakeDataMaker.passwordEntry('three.com/show', 'four', 1), autofill_test_util.createPasswordEntry('three.com/show', 'four', 1),
FakeDataMaker.passwordEntry('four.com', 'three', 2), autofill_test_util.createPasswordEntry('four.com', 'three', 2),
FakeDataMaker.passwordEntry('five.com', 'two', 4), autofill_test_util.createPasswordEntry('five.com', 'two', 4),
FakeDataMaker.passwordEntry('six-show.com', 'one', 6), autofill_test_util.createPasswordEntry('six-show.com', 'one', 6),
]; ];
const passwordsSection = elementFactory.createPasswordsSection( const passwordsSection = elementFactory.createPasswordsSection(
...@@ -330,10 +335,10 @@ cr.define('settings_passwords_section', function() { ...@@ -330,10 +335,10 @@ cr.define('settings_passwords_section', function() {
Polymer.dom.flush(); Polymer.dom.flush();
const expectedList = [ const expectedList = [
FakeDataMaker.passwordEntry('one.com', 'SHOW', 5), autofill_test_util.createPasswordEntry('one.com', 'SHOW', 5),
FakeDataMaker.passwordEntry('two.com', 'shower', 3), autofill_test_util.createPasswordEntry('two.com', 'shower', 3),
FakeDataMaker.passwordEntry('three.com/show', 'four', 1), autofill_test_util.createPasswordEntry('three.com/show', 'four', 1),
FakeDataMaker.passwordEntry('six-show.com', 'one', 6), autofill_test_util.createPasswordEntry('six-show.com', 'one', 6),
]; ];
validatePasswordList(passwordsSection.$.passwordList, expectedList); validatePasswordList(passwordsSection.$.passwordList, expectedList);
...@@ -341,12 +346,12 @@ cr.define('settings_passwords_section', function() { ...@@ -341,12 +346,12 @@ cr.define('settings_passwords_section', function() {
test('verifyFilterPasswordsWithRemoval', function() { test('verifyFilterPasswordsWithRemoval', function() {
const passwordList = [ const passwordList = [
FakeDataMaker.passwordEntry('one.com', 'SHOW', 5, 0), autofill_test_util.createPasswordEntry('one.com', 'SHOW', 5, 0),
FakeDataMaker.passwordEntry('two.com', 'shower', 3, 1), autofill_test_util.createPasswordEntry('two.com', 'shower', 3, 1),
FakeDataMaker.passwordEntry('three.com/show', 'four', 1, 2), autofill_test_util.createPasswordEntry('three.com/show', 'four', 1, 2),
FakeDataMaker.passwordEntry('four.com', 'three', 2, 3), autofill_test_util.createPasswordEntry('four.com', 'three', 2, 3),
FakeDataMaker.passwordEntry('five.com', 'two', 4, 4), autofill_test_util.createPasswordEntry('five.com', 'two', 4, 4),
FakeDataMaker.passwordEntry('six-show.com', 'one', 6, 5), autofill_test_util.createPasswordEntry('six-show.com', 'one', 6, 5),
]; ];
const passwordsSection = elementFactory.createPasswordsSection( const passwordsSection = elementFactory.createPasswordsSection(
...@@ -355,10 +360,10 @@ cr.define('settings_passwords_section', function() { ...@@ -355,10 +360,10 @@ cr.define('settings_passwords_section', function() {
Polymer.dom.flush(); Polymer.dom.flush();
let expectedList = [ let expectedList = [
FakeDataMaker.passwordEntry('one.com', 'SHOW', 5, 0), autofill_test_util.createPasswordEntry('one.com', 'SHOW', 5, 0),
FakeDataMaker.passwordEntry('two.com', 'shower', 3, 1), autofill_test_util.createPasswordEntry('two.com', 'shower', 3, 1),
FakeDataMaker.passwordEntry('three.com/show', 'four', 1, 2), autofill_test_util.createPasswordEntry('three.com/show', 'four', 1, 2),
FakeDataMaker.passwordEntry('six-show.com', 'one', 6, 5), autofill_test_util.createPasswordEntry('six-show.com', 'one', 6, 5),
]; ];
validatePasswordList(passwordsSection.$.passwordList, expectedList); validatePasswordList(passwordsSection.$.passwordList, expectedList);
...@@ -367,9 +372,9 @@ cr.define('settings_passwords_section', function() { ...@@ -367,9 +372,9 @@ cr.define('settings_passwords_section', function() {
passwordList.splice(2, 1); passwordList.splice(2, 1);
expectedList = [ expectedList = [
FakeDataMaker.passwordEntry('one.com', 'SHOW', 5, 0), autofill_test_util.createPasswordEntry('one.com', 'SHOW', 5, 0),
FakeDataMaker.passwordEntry('two.com', 'shower', 3, 1), autofill_test_util.createPasswordEntry('two.com', 'shower', 3, 1),
FakeDataMaker.passwordEntry('six-show.com', 'one', 6, 5), autofill_test_util.createPasswordEntry('six-show.com', 'one', 6, 5),
]; ];
passwordManager.lastCallback.addSavedPasswordListChangedListener( passwordManager.lastCallback.addSavedPasswordListChangedListener(
...@@ -380,12 +385,12 @@ cr.define('settings_passwords_section', function() { ...@@ -380,12 +385,12 @@ cr.define('settings_passwords_section', function() {
test('verifyFilterPasswordExceptions', function() { test('verifyFilterPasswordExceptions', function() {
const exceptionList = [ const exceptionList = [
FakeDataMaker.exceptionEntry('docsshoW.google.com'), autofill_test_util.createExceptionEntry('docsshoW.google.com'),
FakeDataMaker.exceptionEntry('showmail.com'), autofill_test_util.createExceptionEntry('showmail.com'),
FakeDataMaker.exceptionEntry('google.com'), autofill_test_util.createExceptionEntry('google.com'),
FakeDataMaker.exceptionEntry('inbox.google.com'), autofill_test_util.createExceptionEntry('inbox.google.com'),
FakeDataMaker.exceptionEntry('mapsshow.google.com'), autofill_test_util.createExceptionEntry('mapsshow.google.com'),
FakeDataMaker.exceptionEntry('plus.google.comshow'), autofill_test_util.createExceptionEntry('plus.google.comshow'),
]; ];
const passwordsSection = elementFactory.createPasswordsSection( const passwordsSection = elementFactory.createPasswordsSection(
...@@ -394,10 +399,10 @@ cr.define('settings_passwords_section', function() { ...@@ -394,10 +399,10 @@ cr.define('settings_passwords_section', function() {
Polymer.dom.flush(); Polymer.dom.flush();
const expectedExceptionList = [ const expectedExceptionList = [
FakeDataMaker.exceptionEntry('docsshoW.google.com'), autofill_test_util.createExceptionEntry('docsshoW.google.com'),
FakeDataMaker.exceptionEntry('showmail.com'), autofill_test_util.createExceptionEntry('showmail.com'),
FakeDataMaker.exceptionEntry('mapsshow.google.com'), autofill_test_util.createExceptionEntry('mapsshow.google.com'),
FakeDataMaker.exceptionEntry('plus.google.comshow'), autofill_test_util.createExceptionEntry('plus.google.comshow'),
]; ];
validateExceptionList( validateExceptionList(
...@@ -417,12 +422,12 @@ cr.define('settings_passwords_section', function() { ...@@ -417,12 +422,12 @@ cr.define('settings_passwords_section', function() {
test('verifyPasswordExceptions', function() { test('verifyPasswordExceptions', function() {
const exceptionList = [ const exceptionList = [
FakeDataMaker.exceptionEntry('docs.google.com'), autofill_test_util.createExceptionEntry('docs.google.com'),
FakeDataMaker.exceptionEntry('mail.com'), autofill_test_util.createExceptionEntry('mail.com'),
FakeDataMaker.exceptionEntry('google.com'), autofill_test_util.createExceptionEntry('google.com'),
FakeDataMaker.exceptionEntry('inbox.google.com'), autofill_test_util.createExceptionEntry('inbox.google.com'),
FakeDataMaker.exceptionEntry('maps.google.com'), autofill_test_util.createExceptionEntry('maps.google.com'),
FakeDataMaker.exceptionEntry('plus.google.com'), autofill_test_util.createExceptionEntry('plus.google.com'),
]; ];
const passwordsSection = elementFactory.createPasswordsSection( const passwordsSection = elementFactory.createPasswordsSection(
...@@ -438,12 +443,12 @@ cr.define('settings_passwords_section', function() { ...@@ -438,12 +443,12 @@ cr.define('settings_passwords_section', function() {
// Test verifies that removing an exception will update the elements. // Test verifies that removing an exception will update the elements.
test('verifyPasswordExceptionRemove', function() { test('verifyPasswordExceptionRemove', function() {
const exceptionList = [ const exceptionList = [
FakeDataMaker.exceptionEntry('docs.google.com'), autofill_test_util.createExceptionEntry('docs.google.com'),
FakeDataMaker.exceptionEntry('mail.com'), autofill_test_util.createExceptionEntry('mail.com'),
FakeDataMaker.exceptionEntry('google.com'), autofill_test_util.createExceptionEntry('google.com'),
FakeDataMaker.exceptionEntry('inbox.google.com'), autofill_test_util.createExceptionEntry('inbox.google.com'),
FakeDataMaker.exceptionEntry('maps.google.com'), autofill_test_util.createExceptionEntry('maps.google.com'),
FakeDataMaker.exceptionEntry('plus.google.com'), autofill_test_util.createExceptionEntry('plus.google.com'),
]; ];
const passwordsSection = elementFactory.createPasswordsSection( const passwordsSection = elementFactory.createPasswordsSection(
...@@ -469,12 +474,12 @@ cr.define('settings_passwords_section', function() { ...@@ -469,12 +474,12 @@ cr.define('settings_passwords_section', function() {
// event. Does not actually remove any exceptions. // event. Does not actually remove any exceptions.
test('verifyPasswordExceptionRemoveButton', function(done) { test('verifyPasswordExceptionRemoveButton', function(done) {
const exceptionList = [ const exceptionList = [
FakeDataMaker.exceptionEntry('docs.google.com'), autofill_test_util.createExceptionEntry('docs.google.com'),
FakeDataMaker.exceptionEntry('mail.com'), autofill_test_util.createExceptionEntry('mail.com'),
FakeDataMaker.exceptionEntry('google.com'), autofill_test_util.createExceptionEntry('google.com'),
FakeDataMaker.exceptionEntry('inbox.google.com'), autofill_test_util.createExceptionEntry('inbox.google.com'),
FakeDataMaker.exceptionEntry('maps.google.com'), autofill_test_util.createExceptionEntry('maps.google.com'),
FakeDataMaker.exceptionEntry('plus.google.com'), autofill_test_util.createExceptionEntry('plus.google.com'),
]; ];
const passwordsSection = elementFactory.createPasswordsSection( const passwordsSection = elementFactory.createPasswordsSection(
...@@ -510,7 +515,7 @@ cr.define('settings_passwords_section', function() { ...@@ -510,7 +515,7 @@ cr.define('settings_passwords_section', function() {
}); });
test('verifyFederatedPassword', function() { test('verifyFederatedPassword', function() {
const item = FakeDataMaker.passwordEntry('goo.gl', 'bart', 0); const item = autofill_test_util.createPasswordEntry('goo.gl', 'bart', 0);
item.federationText = 'with chromium.org'; item.federationText = 'with chromium.org';
const passwordDialog = elementFactory.createPasswordEditDialog(item); const passwordDialog = elementFactory.createPasswordEditDialog(item);
...@@ -524,8 +529,8 @@ cr.define('settings_passwords_section', function() { ...@@ -524,8 +529,8 @@ cr.define('settings_passwords_section', function() {
test('showSavedPasswordEditDialog', function() { test('showSavedPasswordEditDialog', function() {
const PASSWORD = 'bAn@n@5'; const PASSWORD = 'bAn@n@5';
const item = const item = autofill_test_util.createPasswordEntry(
FakeDataMaker.passwordEntry('goo.gl', 'bart', PASSWORD.length); 'goo.gl', 'bart', PASSWORD.length);
const passwordDialog = elementFactory.createPasswordEditDialog(item); const passwordDialog = elementFactory.createPasswordEditDialog(item);
assertFalse(passwordDialog.$.showPasswordButton.hidden); assertFalse(passwordDialog.$.showPasswordButton.hidden);
...@@ -541,8 +546,8 @@ cr.define('settings_passwords_section', function() { ...@@ -541,8 +546,8 @@ cr.define('settings_passwords_section', function() {
test('showSavedPasswordListItem', function() { test('showSavedPasswordListItem', function() {
const PASSWORD = 'bAn@n@5'; const PASSWORD = 'bAn@n@5';
const item = const item = autofill_test_util.createPasswordEntry(
FakeDataMaker.passwordEntry('goo.gl', 'bart', PASSWORD.length); 'goo.gl', 'bart', PASSWORD.length);
const passwordListItem = elementFactory.createPasswordListItem(item); const passwordListItem = elementFactory.createPasswordListItem(item);
// Hidden passwords should be disabled. // Hidden passwords should be disabled.
assertTrue(passwordListItem.$$('#password').disabled); assertTrue(passwordListItem.$$('#password').disabled);
...@@ -564,7 +569,8 @@ cr.define('settings_passwords_section', function() { ...@@ -564,7 +569,8 @@ cr.define('settings_passwords_section', function() {
// Tests that invoking the plaintext password sets the corresponding // Tests that invoking the plaintext password sets the corresponding
// password. // password.
test('onShowSavedPasswordEditDialog', function() { test('onShowSavedPasswordEditDialog', function() {
const expectedItem = FakeDataMaker.passwordEntry('goo.gl', 'bart', 8, 1); const expectedItem =
autofill_test_util.createPasswordEntry('goo.gl', 'bart', 8, 1);
const passwordDialog = const passwordDialog =
elementFactory.createPasswordEditDialog(expectedItem); elementFactory.createPasswordEditDialog(expectedItem);
assertEquals('', passwordDialog.item.password); assertEquals('', passwordDialog.item.password);
...@@ -580,7 +586,8 @@ cr.define('settings_passwords_section', function() { ...@@ -580,7 +586,8 @@ cr.define('settings_passwords_section', function() {
}); });
test('onShowSavedPasswordListItem', function() { test('onShowSavedPasswordListItem', function() {
const expectedItem = FakeDataMaker.passwordEntry('goo.gl', 'bart', 8, 1); const expectedItem =
autofill_test_util.createPasswordEntry('goo.gl', 'bart', 8, 1);
const passwordListItem = const passwordListItem =
elementFactory.createPasswordListItem(expectedItem); elementFactory.createPasswordListItem(expectedItem);
assertEquals('', passwordListItem.item.password); assertEquals('', passwordListItem.item.password);
...@@ -596,7 +603,8 @@ cr.define('settings_passwords_section', function() { ...@@ -596,7 +603,8 @@ cr.define('settings_passwords_section', function() {
}); });
test('onCopyPasswordListItem', function() { test('onCopyPasswordListItem', function() {
const expectedItem = FakeDataMaker.passwordEntry('goo.gl', 'bart', 8, 1); const expectedItem =
autofill_test_util.createPasswordEntry('goo.gl', 'bart', 8, 1);
const passwordsSection = elementFactory.createPasswordsSection( const passwordsSection = elementFactory.createPasswordsSection(
passwordManager, [expectedItem], []); passwordManager, [expectedItem], []);
...@@ -611,7 +619,8 @@ cr.define('settings_passwords_section', function() { ...@@ -611,7 +619,8 @@ cr.define('settings_passwords_section', function() {
}); });
test('closingPasswordsSectionHidesUndoToast', function(done) { test('closingPasswordsSectionHidesUndoToast', function(done) {
const passwordEntry = FakeDataMaker.passwordEntry('goo.gl', 'bart', 1); const passwordEntry =
autofill_test_util.createPasswordEntry('goo.gl', 'bart', 1);
const passwordsSection = elementFactory.createPasswordsSection( const passwordsSection = elementFactory.createPasswordsSection(
passwordManager, [passwordEntry], []); passwordManager, [passwordEntry], []);
const toastManager = cr.toastManager.getToastManager(); const toastManager = cr.toastManager.getToastManager();
...@@ -633,7 +642,7 @@ cr.define('settings_passwords_section', function() { ...@@ -633,7 +642,7 @@ cr.define('settings_passwords_section', function() {
// Chrome offers the export option when there are passwords. // Chrome offers the export option when there are passwords.
test('offerExportWhenPasswords', function(done) { test('offerExportWhenPasswords', function(done) {
const passwordList = [ const passwordList = [
FakeDataMaker.passwordEntry('googoo.com', 'Larry', 1), autofill_test_util.createPasswordEntry('googoo.com', 'Larry', 1),
]; ];
const passwordsSection = elementFactory.createPasswordsSection( const passwordsSection = elementFactory.createPasswordsSection(
passwordManager, passwordList, []); passwordManager, passwordList, []);
...@@ -659,7 +668,7 @@ cr.define('settings_passwords_section', function() { ...@@ -659,7 +668,7 @@ cr.define('settings_passwords_section', function() {
// dialog. // dialog.
test('exportOpen', function(done) { test('exportOpen', function(done) {
const passwordList = [ const passwordList = [
FakeDataMaker.passwordEntry('googoo.com', 'Larry', 1), autofill_test_util.createPasswordEntry('googoo.com', 'Larry', 1),
]; ];
const passwordsSection = elementFactory.createPasswordsSection( const passwordsSection = elementFactory.createPasswordsSection(
passwordManager, passwordList, []); passwordManager, passwordList, []);
......
...@@ -28,7 +28,7 @@ cr.define('settings_passwords_section_cros', function() { ...@@ -28,7 +28,7 @@ cr.define('settings_passwords_section_cros', function() {
* tests to track auth token and saved password requests. * tests to track auth token and saved password requests.
*/ */
class CrosPasswordSectionElementFactory extends class CrosPasswordSectionElementFactory extends
PasswordSectionElementFactory { autofill_test_util.PasswordSectionElementFactory {
/** /**
* @param {HTMLDocument} document The test's |document| object. * @param {HTMLDocument} document The test's |document| object.
* @param {request: Function} tokenRequestManager Fake for * @param {request: Function} tokenRequestManager Fake for
...@@ -119,7 +119,7 @@ cr.define('settings_passwords_section_cros', function() { ...@@ -119,7 +119,7 @@ cr.define('settings_passwords_section_cros', function() {
let passwordItem; let passwordItem;
passwordPromise = new Promise(resolve => { passwordPromise = new Promise(resolve => {
passwordItem = { passwordItem = {
entry: FakeDataMaker.passwordEntry(), entry: autofill_test_util.createPasswordEntry(),
set password(newPassword) { set password(newPassword) {
if (newPassword && newPassword != this.password_) { if (newPassword && newPassword != this.password_) {
resolve(newPassword); resolve(newPassword);
......
...@@ -41,7 +41,7 @@ cr.define('settings_payments_section', function() { ...@@ -41,7 +41,7 @@ cr.define('settings_payments_section', function() {
*/ */
function createPaymentsSection(creditCards, upiIds, prefValues) { function createPaymentsSection(creditCards, upiIds, prefValues) {
// Override the PaymentsManagerImpl for testing. // Override the PaymentsManagerImpl for testing.
const paymentsManager = new TestPaymentsManager(); const paymentsManager = new autofill_test_util.TestPaymentsManager();
paymentsManager.data.creditCards = creditCards; paymentsManager.data.creditCards = creditCards;
paymentsManager.data.upiIds = upiIds; paymentsManager.data.upiIds = upiIds;
settings.PaymentsManagerImpl.instance_ = paymentsManager; settings.PaymentsManagerImpl.instance_ = paymentsManager;
...@@ -142,12 +142,12 @@ cr.define('settings_payments_section', function() { ...@@ -142,12 +142,12 @@ cr.define('settings_payments_section', function() {
test('verifyCreditCardCount', function() { test('verifyCreditCardCount', function() {
const creditCards = [ const creditCards = [
FakeDataMaker.creditCardEntry(), autofill_test_util.createCreditCardEntry(),
FakeDataMaker.creditCardEntry(), autofill_test_util.createCreditCardEntry(),
FakeDataMaker.creditCardEntry(), autofill_test_util.createCreditCardEntry(),
FakeDataMaker.creditCardEntry(), autofill_test_util.createCreditCardEntry(),
FakeDataMaker.creditCardEntry(), autofill_test_util.createCreditCardEntry(),
FakeDataMaker.creditCardEntry(), autofill_test_util.createCreditCardEntry(),
]; ];
const section = createPaymentsSection( const section = createPaymentsSection(
...@@ -164,7 +164,7 @@ cr.define('settings_payments_section', function() { ...@@ -164,7 +164,7 @@ cr.define('settings_payments_section', function() {
}); });
test('verifyCreditCardFields', function() { test('verifyCreditCardFields', function() {
const creditCard = FakeDataMaker.creditCardEntry(); const creditCard = autofill_test_util.createCreditCardEntry();
const section = createPaymentsSection( const section = createPaymentsSection(
[creditCard], /*upiIds=*/[], /*prefValues=*/ {}); [creditCard], /*upiIds=*/[], /*prefValues=*/ {});
const rowShadowRoot = getCardRowShadowRoot(section.$$('#paymentsList')); const rowShadowRoot = getCardRowShadowRoot(section.$$('#paymentsList'));
...@@ -178,7 +178,7 @@ cr.define('settings_payments_section', function() { ...@@ -178,7 +178,7 @@ cr.define('settings_payments_section', function() {
}); });
test('verifyCreditCardRowButtonIsDropdownWhenLocal', function() { test('verifyCreditCardRowButtonIsDropdownWhenLocal', function() {
const creditCard = FakeDataMaker.creditCardEntry(); const creditCard = autofill_test_util.createCreditCardEntry();
creditCard.metadata.isLocal = true; creditCard.metadata.isLocal = true;
const section = createPaymentsSection( const section = createPaymentsSection(
[creditCard], /*upiIds=*/[], /*prefValues=*/ {}); [creditCard], /*upiIds=*/[], /*prefValues=*/ {});
...@@ -191,7 +191,7 @@ cr.define('settings_payments_section', function() { ...@@ -191,7 +191,7 @@ cr.define('settings_payments_section', function() {
}); });
test('verifyCreditCardRowButtonIsOutlinkWhenRemote', function() { test('verifyCreditCardRowButtonIsOutlinkWhenRemote', function() {
const creditCard = FakeDataMaker.creditCardEntry(); const creditCard = autofill_test_util.createCreditCardEntry();
creditCard.metadata.isLocal = false; creditCard.metadata.isLocal = false;
const section = createPaymentsSection( const section = createPaymentsSection(
[creditCard], /*upiIds=*/[], /*prefValues=*/ {}); [creditCard], /*upiIds=*/[], /*prefValues=*/ {});
...@@ -204,9 +204,9 @@ cr.define('settings_payments_section', function() { ...@@ -204,9 +204,9 @@ cr.define('settings_payments_section', function() {
}); });
test('verifyAddVsEditCreditCardTitle', function() { test('verifyAddVsEditCreditCardTitle', function() {
const newCreditCard = FakeDataMaker.emptyCreditCardEntry(); const newCreditCard = autofill_test_util.createEmptyCreditCardEntry();
const newCreditCardDialog = createCreditCardDialog(newCreditCard); const newCreditCardDialog = createCreditCardDialog(newCreditCard);
const oldCreditCard = FakeDataMaker.creditCardEntry(); const oldCreditCard = autofill_test_util.createCreditCardEntry();
const oldCreditCardDialog = createCreditCardDialog(oldCreditCard); const oldCreditCardDialog = createCreditCardDialog(oldCreditCard);
assertNotEquals(oldCreditCardDialog.title_, newCreditCardDialog.title_); assertNotEquals(oldCreditCardDialog.title_, newCreditCardDialog.title_);
...@@ -221,7 +221,7 @@ cr.define('settings_payments_section', function() { ...@@ -221,7 +221,7 @@ cr.define('settings_payments_section', function() {
}); });
test('verifyExpiredCreditCardYear', function() { test('verifyExpiredCreditCardYear', function() {
const creditCard = FakeDataMaker.creditCardEntry(); const creditCard = autofill_test_util.createCreditCardEntry();
// 2015 is over unless time goes wobbly. // 2015 is over unless time goes wobbly.
const twentyFifteen = 2015; const twentyFifteen = 2015;
...@@ -245,7 +245,7 @@ cr.define('settings_payments_section', function() { ...@@ -245,7 +245,7 @@ cr.define('settings_payments_section', function() {
}); });
test('verifyVeryFutureCreditCardYear', function() { test('verifyVeryFutureCreditCardYear', function() {
const creditCard = FakeDataMaker.creditCardEntry(); const creditCard = autofill_test_util.createCreditCardEntry();
// Expiring 25 years from now is unusual. // Expiring 25 years from now is unusual.
const now = new Date(); const now = new Date();
...@@ -270,7 +270,7 @@ cr.define('settings_payments_section', function() { ...@@ -270,7 +270,7 @@ cr.define('settings_payments_section', function() {
}); });
test('verifyVeryNormalCreditCardYear', function() { test('verifyVeryNormalCreditCardYear', function() {
const creditCard = FakeDataMaker.creditCardEntry(); const creditCard = autofill_test_util.createCreditCardEntry();
// Expiring 2 years from now is not unusual. // Expiring 2 years from now is not unusual.
const now = new Date(); const now = new Date();
...@@ -296,7 +296,7 @@ cr.define('settings_payments_section', function() { ...@@ -296,7 +296,7 @@ cr.define('settings_payments_section', function() {
}); });
test('verify save disabled for expired credit card', function() { test('verify save disabled for expired credit card', function() {
const creditCard = FakeDataMaker.emptyCreditCardEntry(); const creditCard = autofill_test_util.createEmptyCreditCardEntry();
const now = new Date(); const now = new Date();
creditCard.expirationYear = now.getFullYear() - 2; creditCard.expirationYear = now.getFullYear() - 2;
...@@ -312,7 +312,7 @@ cr.define('settings_payments_section', function() { ...@@ -312,7 +312,7 @@ cr.define('settings_payments_section', function() {
}); });
test('verify save new credit card', function() { test('verify save new credit card', function() {
const creditCard = FakeDataMaker.emptyCreditCardEntry(); const creditCard = autofill_test_util.createEmptyCreditCardEntry();
const creditCardDialog = createCreditCardDialog(creditCard); const creditCardDialog = createCreditCardDialog(creditCard);
return test_util.whenAttributeIs(creditCardDialog.$.dialog, 'open', '') return test_util.whenAttributeIs(creditCardDialog.$.dialog, 'open', '')
...@@ -341,7 +341,7 @@ cr.define('settings_payments_section', function() { ...@@ -341,7 +341,7 @@ cr.define('settings_payments_section', function() {
}); });
test('verifyCancelCreditCardEdit', function(done) { test('verifyCancelCreditCardEdit', function(done) {
const creditCard = FakeDataMaker.emptyCreditCardEntry(); const creditCard = autofill_test_util.createEmptyCreditCardEntry();
const creditCardDialog = createCreditCardDialog(creditCard); const creditCardDialog = createCreditCardDialog(creditCard);
test_util.whenAttributeIs(creditCardDialog.$.dialog, 'open', '') test_util.whenAttributeIs(creditCardDialog.$.dialog, 'open', '')
...@@ -366,7 +366,7 @@ cr.define('settings_payments_section', function() { ...@@ -366,7 +366,7 @@ cr.define('settings_payments_section', function() {
}); });
test('verifyLocalCreditCardMenu', function() { test('verifyLocalCreditCardMenu', function() {
const creditCard = FakeDataMaker.creditCardEntry(); const creditCard = autofill_test_util.createCreditCardEntry();
// When credit card is local, |isCached| will be undefined. // When credit card is local, |isCached| will be undefined.
creditCard.metadata.isLocal = true; creditCard.metadata.isLocal = true;
...@@ -397,7 +397,7 @@ cr.define('settings_payments_section', function() { ...@@ -397,7 +397,7 @@ cr.define('settings_payments_section', function() {
}); });
test('verifyCachedCreditCardMenu', function() { test('verifyCachedCreditCardMenu', function() {
const creditCard = FakeDataMaker.creditCardEntry(); const creditCard = autofill_test_util.createCreditCardEntry();
creditCard.metadata.isLocal = false; creditCard.metadata.isLocal = false;
creditCard.metadata.isCached = true; creditCard.metadata.isCached = true;
...@@ -427,7 +427,7 @@ cr.define('settings_payments_section', function() { ...@@ -427,7 +427,7 @@ cr.define('settings_payments_section', function() {
}); });
test('verifyNotCachedCreditCardMenu', function() { test('verifyNotCachedCreditCardMenu', function() {
const creditCard = FakeDataMaker.creditCardEntry(); const creditCard = autofill_test_util.createCreditCardEntry();
creditCard.metadata.isLocal = false; creditCard.metadata.isLocal = false;
creditCard.metadata.isCached = false; creditCard.metadata.isCached = false;
...@@ -447,7 +447,7 @@ cr.define('settings_payments_section', function() { ...@@ -447,7 +447,7 @@ cr.define('settings_payments_section', function() {
loadTimeData.overrideValues({migrationEnabled: false}); loadTimeData.overrideValues({migrationEnabled: false});
// Add one migratable credit card. // Add one migratable credit card.
const creditCard = FakeDataMaker.creditCardEntry(); const creditCard = autofill_test_util.createCreditCardEntry();
creditCard.metadata.isMigratable = true; creditCard.metadata.isMigratable = true;
const section = createPaymentsSection( const section = createPaymentsSection(
[creditCard], /*upiIds=*/[], {credit_card_enabled: {value: true}}); [creditCard], /*upiIds=*/[], {credit_card_enabled: {value: true}});
...@@ -457,7 +457,7 @@ cr.define('settings_payments_section', function() { ...@@ -457,7 +457,7 @@ cr.define('settings_payments_section', function() {
test('verifyMigrationButtonNotShownIfCreditCardDisabled', function() { test('verifyMigrationButtonNotShownIfCreditCardDisabled', function() {
// Add one migratable credit card. // Add one migratable credit card.
const creditCard = FakeDataMaker.creditCardEntry(); const creditCard = autofill_test_util.createCreditCardEntry();
creditCard.metadata.isMigratable = true; creditCard.metadata.isMigratable = true;
// Mock credit card save toggle is turned off by users. // Mock credit card save toggle is turned off by users.
const section = createPaymentsSection( const section = createPaymentsSection(
...@@ -468,7 +468,7 @@ cr.define('settings_payments_section', function() { ...@@ -468,7 +468,7 @@ cr.define('settings_payments_section', function() {
test('verifyMigrationButtonNotShownIfNoCardIsMigratable', function() { test('verifyMigrationButtonNotShownIfNoCardIsMigratable', function() {
// Add one migratable credit card. // Add one migratable credit card.
const creditCard = FakeDataMaker.creditCardEntry(); const creditCard = autofill_test_util.createCreditCardEntry();
// Mock credit card is not valid. // Mock credit card is not valid.
creditCard.metadata.isMigratable = false; creditCard.metadata.isMigratable = false;
const section = createPaymentsSection( const section = createPaymentsSection(
...@@ -479,7 +479,7 @@ cr.define('settings_payments_section', function() { ...@@ -479,7 +479,7 @@ cr.define('settings_payments_section', function() {
test('verifyMigrationButtonShown', function() { test('verifyMigrationButtonShown', function() {
// Add one migratable credit card. // Add one migratable credit card.
const creditCard = FakeDataMaker.creditCardEntry(); const creditCard = autofill_test_util.createCreditCardEntry();
creditCard.metadata.isMigratable = true; creditCard.metadata.isMigratable = true;
const section = createPaymentsSection( const section = createPaymentsSection(
[creditCard], /*upiIds=*/[], {credit_card_enabled: {value: true}}); [creditCard], /*upiIds=*/[], {credit_card_enabled: {value: true}});
......
...@@ -17,13 +17,14 @@ class TestPasswordManagerProxy extends TestBrowserProxy { ...@@ -17,13 +17,14 @@ class TestPasswordManagerProxy extends TestBrowserProxy {
'getCompromisedCredentialsInfo', 'getCompromisedCredentialsInfo',
]); ]);
this.actual_ = new PasswordManagerExpectations(); this.actual_ = new autofill_test_util.PasswordManagerExpectations();
// Set these to have non-empty data. // Set these to have non-empty data.
this.data = { this.data = {
passwords: [], passwords: [],
exceptions: [], exceptions: [],
leakedCredentials: FakeDataMaker.makeCompromisedCredentialsInfo([], ''), leakedCredentials:
autofill_test_util.makeCompromisedCredentialsInfo([], ''),
}; };
// Holds the last callbacks so they can be called when needed/ // Holds the last callbacks so they can be called when needed/
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment