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,11 +77,14 @@ cr.define('settings_passwords_check', function() { ...@@ -77,11 +77,14 @@ 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 =
leakedPasswords, '5 min ago'); autofill_test_util.makeCompromisedCredentialsInfo(
leakedPasswords, '5 min ago');
passwordManager.data.leakedCredentials = leakedPasswordsInfo; passwordManager.data.leakedCredentials = leakedPasswordsInfo;
const checkPasswordSection = createCheckPasswordSection(); const checkPasswordSection = createCheckPasswordSection();
return passwordManager.whenCalled('getCompromisedCredentialsInfo') return passwordManager.whenCalled('getCompromisedCredentialsInfo')
......
...@@ -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