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