| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 /** @fileoverview Runs the Polymer Autofill Settings tests. */ | 5 /** @fileoverview Runs the Polymer Autofill Settings tests. */ |
| 6 | 6 |
| 7 /** @const {string} Path to root from chrome/test/data/webui/settings/. */ | 7 /** @const {string} Path to root from chrome/test/data/webui/settings/. */ |
| 8 var ROOT_PATH = '../../../../../'; | 8 var ROOT_PATH = '../../../../../'; |
| 9 | 9 |
| 10 // Polymer BrowserTest fixture. | 10 // Polymer BrowserTest fixture. |
| (...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 296 now.getFullYear().toString(), | 296 now.getFullYear().toString(), |
| 297 yearOptions[0].textContent.trim()); | 297 yearOptions[0].textContent.trim()); |
| 298 assertEquals( | 298 assertEquals( |
| 299 maxYear.toString(), | 299 maxYear.toString(), |
| 300 yearOptions[yearOptions.length -1].textContent.trim()); | 300 yearOptions[yearOptions.length -1].textContent.trim()); |
| 301 assertEquals( | 301 assertEquals( |
| 302 creditCard.expirationYear, creditCardDialog.$.year.value); | 302 creditCard.expirationYear, creditCardDialog.$.year.value); |
| 303 }); | 303 }); |
| 304 }); | 304 }); |
| 305 | 305 |
| 306 test('verifySaveExpiredCreditCardEdit', function(done) { |
| 307 var creditCard = FakeDataMaker.emptyCreditCardEntry(); |
| 308 |
| 309 var now = new Date(); |
| 310 creditCard.expirationYear = now.getFullYear() - 2; |
| 311 // works fine for January. |
| 312 creditCard.expirationMonth = now.getMonth() - 1; |
| 313 |
| 314 var creditCardDialog = self.createCreditCardDialog_(creditCard); |
| 315 |
| 316 return test_util.whenAttributeIs( |
| 317 creditCardDialog.$.dialog, 'open', true).then(function() { |
| 318 creditCardDialog.addEventListener('save-credit-card', function() { |
| 319 // Fail the test because the save event should not be called when |
| 320 // the card is expired. |
| 321 assertTrue(false); |
| 322 }); |
| 323 creditCardDialog.addEventListener('tap', function() { |
| 324 // Test is |done| in a timeout in order to ensure that |
| 325 // 'save-credit-card' is NOT fired after this test. |
| 326 assertFalse(creditCardDialog.$.expired.hidden); |
| 327 window.setTimeout(done, 100); |
| 328 }); |
| 329 MockInteractions.tap(creditCardDialog.$.saveButton); |
| 330 }); |
| 331 }); |
| 332 |
| 306 // Test will timeout if event is not received. | 333 // Test will timeout if event is not received. |
| 307 test('verifySaveCreditCardEdit', function(done) { | 334 test('verifySaveCreditCardEdit', function(done) { |
| 308 var creditCard = FakeDataMaker.emptyCreditCardEntry(); | 335 var creditCard = FakeDataMaker.emptyCreditCardEntry(); |
| 309 var creditCardDialog = self.createCreditCardDialog_(creditCard); | 336 var creditCardDialog = self.createCreditCardDialog_(creditCard); |
| 310 | 337 |
| 311 return test_util.whenAttributeIs( | 338 return test_util.whenAttributeIs( |
| 312 creditCardDialog.$.dialog, 'open', true).then(function() { | 339 creditCardDialog.$.dialog, 'open', true).then(function() { |
| 340 assertTrue(creditCardDialog.$.expired.hidden); |
| 313 creditCardDialog.addEventListener('save-credit-card', function(event) { | 341 creditCardDialog.addEventListener('save-credit-card', function(event) { |
| 314 assertEquals(creditCard.guid, event.detail.guid); | 342 assertEquals(creditCard.guid, event.detail.guid); |
| 315 done(); | 343 done(); |
| 316 }); | 344 }); |
| 317 MockInteractions.tap(creditCardDialog.$.saveButton); | 345 MockInteractions.tap(creditCardDialog.$.saveButton); |
| 318 }); | 346 }); |
| 319 }); | 347 }); |
| 320 | 348 |
| 321 test('verifyCancelCreditCardEdit', function(done) { | 349 test('verifyCancelCreditCardEdit', function(done) { |
| 322 var creditCard = FakeDataMaker.emptyCreditCardEntry(); | 350 var creditCard = FakeDataMaker.emptyCreditCardEntry(); |
| (...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 558 }); | 586 }); |
| 559 }); | 587 }); |
| 560 | 588 |
| 561 test('verifyCancelDoesNotSaveAddress', function(done) { | 589 test('verifyCancelDoesNotSaveAddress', function(done) { |
| 562 self.createAddressDialog_( | 590 self.createAddressDialog_( |
| 563 FakeDataMaker.addressEntry()).then(function(dialog) { | 591 FakeDataMaker.addressEntry()).then(function(dialog) { |
| 564 dialog.addEventListener('save-address', function() { | 592 dialog.addEventListener('save-address', function() { |
| 565 // Fail the test because the save event should not be called when | 593 // Fail the test because the save event should not be called when |
| 566 // cancel is clicked. | 594 // cancel is clicked. |
| 567 assertTrue(false); | 595 assertTrue(false); |
| 568 done(); | |
| 569 }); | 596 }); |
| 570 | 597 |
| 571 dialog.addEventListener('close', function() { | 598 dialog.addEventListener('close', function() { |
| 572 // Test is |done| in a timeout in order to ensure that | 599 // Test is |done| in a timeout in order to ensure that |
| 573 // 'save-address' is NOT fired after this test. | 600 // 'save-address' is NOT fired after this test. |
| 574 window.setTimeout(done, 100); | 601 window.setTimeout(done, 100); |
| 575 }); | 602 }); |
| 576 | 603 |
| 577 MockInteractions.tap(dialog.$.cancelButton); | 604 MockInteractions.tap(dialog.$.cancelButton); |
| 578 }); | 605 }); |
| (...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 809 assertEquals(city, cols[0].value); | 836 assertEquals(city, cols[0].value); |
| 810 assertEquals(state, cols[1].value); | 837 assertEquals(state, cols[1].value); |
| 811 assertEquals(zip, cols[2].value); | 838 assertEquals(zip, cols[2].value); |
| 812 }); | 839 }); |
| 813 }); | 840 }); |
| 814 }); | 841 }); |
| 815 }); | 842 }); |
| 816 | 843 |
| 817 mocha.run(); | 844 mocha.run(); |
| 818 }); | 845 }); |
| OLD | NEW |