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

Unified Diff: chrome/test/data/webui/settings/settings_autofill_section_browsertest.js

Issue 2383513003: MD Settings: Migrating add/edit credit card dropdowns to native select. (Closed)
Patch Set: Address comments. Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/resources/settings/passwords_and_forms_page/credit_card_edit_dialog.js ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/test/data/webui/settings/settings_autofill_section_browsertest.js
diff --git a/chrome/test/data/webui/settings/settings_autofill_section_browsertest.js b/chrome/test/data/webui/settings/settings_autofill_section_browsertest.js
index 03203b939ea0283c3aa037149bf927ad5446035c..82f13e00694969d5ce082678004536b00dbc973b 100644
--- a/chrome/test/data/webui/settings/settings_autofill_section_browsertest.js
+++ b/chrome/test/data/webui/settings/settings_autofill_section_browsertest.js
@@ -10,8 +10,6 @@ var ROOT_PATH = '../../../../../';
// Polymer BrowserTest fixture.
GEN_INCLUDE([
ROOT_PATH + 'chrome/test/data/webui/polymer_browser_test_base.js',
- ROOT_PATH +
- 'chrome/test/data/webui/settings/passwords_and_autofill_fake_data.js',
ROOT_PATH + 'ui/webui/resources/js/load_time_data.js',
]);
@@ -98,7 +96,10 @@ SettingsAutofillSectionBrowserTest.prototype = {
'chrome://md-settings/passwords_and_forms_page/autofill_section.html',
/** @override */
- extraLibraries: PolymerTest.getLibraries(ROOT_PATH),
+ extraLibraries: PolymerTest.getLibraries(ROOT_PATH).concat([
+ 'passwords_and_autofill_fake_data.js',
+ 'test_util.js',
+ ]),
/**
* TODO(hcarmona): Increases speed, but disables A11y checks. Enable checks
@@ -246,15 +247,20 @@ TEST_F('SettingsAutofillSectionBrowserTest', 'CreditCardTests', function() {
creditCard.expirationYear = twentyFifteen.toString();
var creditCardDialog = self.createCreditCardDialog_(creditCard);
- var selectableYears = creditCardDialog.$.yearList.items;
- var firstSelectableYear = selectableYears[0];
- var lastSelectableYear = selectableYears[selectableYears.length - 1];
- var now = new Date();
- var maxYear = now.getFullYear() + 9;
-
- assertEquals('2015', firstSelectableYear.textContent.trim());
- assertEquals(maxYear.toString(), lastSelectableYear.textContent.trim());
+ return test_util.whenAttributeIs(
+ creditCardDialog.$.dialog, 'open', true).then(function() {
+ var now = new Date();
+ var maxYear = now.getFullYear() + 9;
+ var yearOptions = creditCardDialog.$.year.options;
+
+ assertEquals('2015', yearOptions[0].textContent.trim());
+ assertEquals(
+ maxYear.toString(),
+ yearOptions[yearOptions.length -1].textContent.trim());
+ assertEquals(
+ creditCard.expirationYear, creditCardDialog.$.year.value);
+ });
});
test('verifyVeryFutureCreditCardYear', function() {
@@ -266,14 +272,20 @@ TEST_F('SettingsAutofillSectionBrowserTest', 'CreditCardTests', function() {
creditCard.expirationYear = farFutureYear.toString();
var creditCardDialog = self.createCreditCardDialog_(creditCard);
- var selectableYears = creditCardDialog.$.yearList.items;
- var firstSelectableYear = selectableYears[0];
- var lastSelectableYear = selectableYears[selectableYears.length - 1];
-
- assertEquals(now.getFullYear().toString(),
- firstSelectableYear.textContent.trim());
- assertEquals(farFutureYear.toString(),
- lastSelectableYear.textContent.trim());
+
+ return test_util.whenAttributeIs(
+ creditCardDialog.$.dialog, 'open', true).then(function() {
+ var yearOptions = creditCardDialog.$.year.options;
+
+ assertEquals(
+ now.getFullYear().toString(),
+ yearOptions[0].textContent.trim());
+ assertEquals(
+ farFutureYear.toString(),
+ yearOptions[yearOptions.length -1].textContent.trim());
+ assertEquals(
+ creditCard.expirationYear, creditCardDialog.$.year.value);
+ });
});
test('verifyVeryNormalCreditCardYear', function() {
@@ -286,13 +298,20 @@ TEST_F('SettingsAutofillSectionBrowserTest', 'CreditCardTests', function() {
var maxYear = now.getFullYear() + 9;
var creditCardDialog = self.createCreditCardDialog_(creditCard);
- var selectableYears = creditCardDialog.$.yearList.items;
- var firstSelectableYear = selectableYears[0];
- var lastSelectableYear = selectableYears[selectableYears.length - 1];
- assertEquals(now.getFullYear().toString(),
- firstSelectableYear.textContent.trim());
- assertEquals(maxYear.toString(), lastSelectableYear.textContent.trim());
+ return test_util.whenAttributeIs(
+ creditCardDialog.$.dialog, 'open', true).then(function() {
+ var yearOptions = creditCardDialog.$.year.options;
+
+ assertEquals(
+ now.getFullYear().toString(),
+ yearOptions[0].textContent.trim());
+ assertEquals(
+ maxYear.toString(),
+ yearOptions[yearOptions.length -1].textContent.trim());
+ assertEquals(
+ creditCard.expirationYear, creditCardDialog.$.year.value);
+ });
});
// Test will timeout if event is not received.
@@ -300,32 +319,37 @@ TEST_F('SettingsAutofillSectionBrowserTest', 'CreditCardTests', function() {
var creditCard = FakeDataMaker.emptyCreditCardEntry();
var creditCardDialog = self.createCreditCardDialog_(creditCard);
- creditCardDialog.addEventListener('save-credit-card', function(event) {
- assertEquals(creditCard.guid, event.detail.guid);
- done();
+ return test_util.whenAttributeIs(
+ creditCardDialog.$.dialog, 'open', true).then(function() {
+ creditCardDialog.addEventListener('save-credit-card', function(event) {
+ assertEquals(creditCard.guid, event.detail.guid);
+ done();
+ });
+ MockInteractions.tap(creditCardDialog.$.saveButton);
});
-
- MockInteractions.tap(creditCardDialog.$.saveButton);
});
test('verifyCancelCreditCardEdit', function(done) {
var creditCard = FakeDataMaker.emptyCreditCardEntry();
var creditCardDialog = self.createCreditCardDialog_(creditCard);
- creditCardDialog.addEventListener('save-credit-card', function() {
- // Fail the test because the save event should not be called when cancel
- // is clicked.
- assertTrue(false);
- done();
- });
+ return test_util.whenAttributeIs(
+ creditCardDialog.$.dialog, 'open', true).then(function() {
+ creditCardDialog.addEventListener('save-credit-card', function() {
+ // Fail the test because the save event should not be called when
+ // cancel is clicked.
+ assertTrue(false);
+ done();
+ });
- creditCardDialog.addEventListener('close', function() {
- // Test is |done| in a timeout in order to ensure that
- // 'save-credit-card' is NOT fired after this test.
- window.setTimeout(done, 100);
- });
+ creditCardDialog.addEventListener('close', function() {
+ // Test is |done| in a timeout in order to ensure that
+ // 'save-credit-card' is NOT fired after this test.
+ window.setTimeout(done, 100);
+ });
- MockInteractions.tap(creditCardDialog.$.cancelButton);
+ MockInteractions.tap(creditCardDialog.$.cancelButton);
+ });
});
});
« no previous file with comments | « chrome/browser/resources/settings/passwords_and_forms_page/credit_card_edit_dialog.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698