Chromium Code Reviews| 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 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 197 settings.address.CountryDetailManagerImpl.instance_ = | 197 settings.address.CountryDetailManagerImpl.instance_ = |
| 198 new CountryDetailManagerTestImpl(); | 198 new CountryDetailManagerTestImpl(); |
| 199 }); | 199 }); |
| 200 | 200 |
| 201 setup(function() { | 201 setup(function() { |
| 202 PolymerTest.clearBody(); | 202 PolymerTest.clearBody(); |
| 203 }); | 203 }); |
| 204 | 204 |
| 205 test('verifyCreditCardCount', function() { | 205 test('verifyCreditCardCount', function() { |
| 206 var section = self.createAutofillSection_([], []); | 206 var section = self.createAutofillSection_([], []); |
| 207 assertTrue(!!section); | |
| 208 | 207 |
| 209 var creditCardList = section.$.creditCardList; | 208 var creditCardList = section.$.creditCardList; |
| 210 assertTrue(!!creditCardList); | 209 assertTrue(!!creditCardList); |
| 211 // +1 for the template element. | 210 assertEquals(0, creditCardList.querySelectorAll('.list-item').length); |
| 212 assertEquals(1, creditCardList.children.length); | |
| 213 | 211 |
| 214 assertFalse(section.$.noCreditCardsLabel.hidden); | 212 assertFalse(section.$.noCreditCardsLabel.hidden); |
| 215 assertTrue(section.$.creditCardsHeading.hidden); | 213 assertTrue(section.$.creditCardsHeading.hidden); |
| 216 }); | 214 }); |
| 217 | 215 |
| 218 test('verifyCreditCardCount', function() { | 216 test('verifyCreditCardCount', function() { |
| 219 var creditCards = [ | 217 var creditCards = [ |
| 220 FakeDataMaker.creditCardEntry(), | 218 FakeDataMaker.creditCardEntry(), |
| 221 FakeDataMaker.creditCardEntry(), | 219 FakeDataMaker.creditCardEntry(), |
| 222 FakeDataMaker.creditCardEntry(), | 220 FakeDataMaker.creditCardEntry(), |
| 223 FakeDataMaker.creditCardEntry(), | 221 FakeDataMaker.creditCardEntry(), |
| 224 FakeDataMaker.creditCardEntry(), | 222 FakeDataMaker.creditCardEntry(), |
| 225 FakeDataMaker.creditCardEntry(), | 223 FakeDataMaker.creditCardEntry(), |
| 226 ]; | 224 ]; |
| 227 | 225 |
| 228 var section = self.createAutofillSection_([], creditCards); | 226 var section = self.createAutofillSection_([], creditCards); |
| 229 | 227 |
| 230 assertTrue(!!section); | |
| 231 var creditCardList = section.$.creditCardList; | 228 var creditCardList = section.$.creditCardList; |
| 232 assertTrue(!!creditCardList); | 229 assertTrue(!!creditCardList); |
| 233 // +1 for the template element. | 230 assertEquals(creditCards.length, |
| 234 assertEquals(creditCards.length + 1, creditCardList.children.length); | 231 creditCardList.querySelectorAll('.list-item').length); |
| 235 | 232 |
| 236 assertTrue(section.$.noCreditCardsLabel.hidden); | 233 assertTrue(section.$.noCreditCardsLabel.hidden); |
| 237 assertFalse(section.$.creditCardsHeading.hidden); | 234 assertFalse(section.$.creditCardsHeading.hidden); |
| 238 }); | 235 }); |
| 239 | 236 |
| 240 test('verifyCreditCardFields', function() { | 237 test('verifyCreditCardFields', function() { |
| 241 var creditCard = FakeDataMaker.creditCardEntry(); | 238 var creditCard = FakeDataMaker.creditCardEntry(); |
| 242 var section = self.createAutofillSection_([], [creditCard]); | 239 var section = self.createAutofillSection_([], [creditCard]); |
| 243 var creditCardList = section.$.creditCardList; | 240 var creditCardList = section.$.creditCardList; |
| 244 var row = creditCardList.children[0]; | 241 var row = creditCardList.children[0]; |
| (...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 426 | 423 |
| 427 creditCardDialog.addEventListener('close', function() { | 424 creditCardDialog.addEventListener('close', function() { |
| 428 // Test is |done| in a timeout in order to ensure that | 425 // Test is |done| in a timeout in order to ensure that |
| 429 // 'save-credit-card' is NOT fired after this test. | 426 // 'save-credit-card' is NOT fired after this test. |
| 430 window.setTimeout(done, 100); | 427 window.setTimeout(done, 100); |
| 431 }); | 428 }); |
| 432 | 429 |
| 433 MockInteractions.tap(creditCardDialog.$.cancelButton); | 430 MockInteractions.tap(creditCardDialog.$.cancelButton); |
| 434 }); | 431 }); |
| 435 }); | 432 }); |
| 433 | |
| 434 test('verifyLocalCreditCardMenu', function() { | |
| 435 var creditCard = FakeDataMaker.creditCardEntry(); | |
| 436 | |
| 437 // When credit card is local, |isCached| will be undefined. | |
| 438 creditCard.metadata.isLocal = true; | |
| 439 creditCard.metadata.isCached = undefined; | |
| 440 | |
| 441 var section = self.createAutofillSection_([], [creditCard]); | |
| 442 var creditCardList = section.$.creditCardList; | |
| 443 assertTrue(!!creditCardList); | |
| 444 assertEquals(1, creditCardList.querySelectorAll('.list-item').length); | |
| 445 var row = creditCardList.children[0]; | |
| 446 | |
| 447 // Local credit cards will show the overflow menu. | |
| 448 assertFalse(!!row.querySelector('#remoteCreditCardLink')); | |
| 449 var menuButton = row.querySelector('#creditCardMenu') | |
|
dpapad
2017/06/27 23:28:20
Semicolon missing
hcarmona
2017/06/28 17:43:12
Fixed here and elsewhere.
| |
| 450 assertTrue(!!menuButton); | |
| 451 | |
| 452 menuButton.click(); | |
| 453 Polymer.dom.flush(); | |
| 454 | |
| 455 var menu = section.$.creditCardSharedMenu; | |
| 456 | |
| 457 // Menu should have 2 options. | |
| 458 assertFalse(menu.querySelector('#menuEditCreditCard').hidden); | |
| 459 assertFalse(menu.querySelector('#menuRemoveCreditCard').hidden); | |
| 460 assertTrue(menu.querySelector('#menuClearCreditCard').hidden); | |
| 461 | |
| 462 menu.close(); | |
| 463 Polymer.dom.flush(); | |
| 464 }); | |
| 465 | |
| 466 test('verifyCachedCreditCardMenu', function() { | |
| 467 var creditCard = FakeDataMaker.creditCardEntry(); | |
| 468 | |
| 469 creditCard.metadata.isLocal = false; | |
| 470 creditCard.metadata.isCached = true; | |
| 471 | |
| 472 var section = self.createAutofillSection_([], [creditCard]); | |
| 473 var creditCardList = section.$.creditCardList; | |
| 474 assertTrue(!!creditCardList); | |
| 475 assertEquals(1, creditCardList.querySelectorAll('.list-item').length); | |
| 476 var row = creditCardList.children[0]; | |
| 477 | |
| 478 // Cached remote CCs will show overflow menu. | |
| 479 assertFalse(!!row.querySelector('#remoteCreditCardLink')); | |
| 480 var menuButton = row.querySelector('#creditCardMenu') | |
| 481 assertTrue(!!menuButton); | |
| 482 | |
| 483 menuButton.click(); | |
| 484 Polymer.dom.flush(); | |
| 485 | |
| 486 var menu = section.$.creditCardSharedMenu; | |
| 487 | |
| 488 // Menu should have 2 options. | |
| 489 assertFalse(menu.querySelector('#menuEditCreditCard').hidden); | |
| 490 assertTrue(menu.querySelector('#menuRemoveCreditCard').hidden); | |
| 491 assertFalse(menu.querySelector('#menuClearCreditCard').hidden); | |
| 492 | |
| 493 menu.close(); | |
| 494 Polymer.dom.flush(); | |
| 495 }); | |
| 496 | |
| 497 test('verifyNotCachedCreditCardMenu', function() { | |
| 498 var creditCard = FakeDataMaker.creditCardEntry(); | |
| 499 | |
| 500 creditCard.metadata.isLocal = false; | |
| 501 creditCard.metadata.isCached = false; | |
| 502 | |
| 503 var section = self.createAutofillSection_([], [creditCard]); | |
| 504 var creditCardList = section.$.creditCardList; | |
| 505 assertTrue(!!creditCardList); | |
| 506 assertEquals(1, creditCardList.querySelectorAll('.list-item').length); | |
| 507 var row = creditCardList.children[0]; | |
| 508 | |
| 509 // No overflow menu when not cached. | |
| 510 assertTrue(!!row.querySelector('#remoteCreditCardLink')); | |
| 511 assertFalse(!!row.querySelector('#creditCardMenu')); | |
| 512 }); | |
| 436 }); | 513 }); |
| 437 | 514 |
| 438 mocha.run(); | 515 mocha.run(); |
| 439 }); | 516 }); |
| 440 | 517 |
| 441 TEST_F('SettingsAutofillSectionBrowserTest', 'AddressTests', function() { | 518 TEST_F('SettingsAutofillSectionBrowserTest', 'AddressTests', function() { |
| 442 var self = this; | 519 var self = this; |
| 443 | 520 |
| 444 | 521 |
| 445 suite('AutofillSection', function() { | 522 suite('AutofillSection', function() { |
| 446 suiteSetup(function() { | 523 suiteSetup(function() { |
| 447 settings.address.CountryDetailManagerImpl.instance_ = | 524 settings.address.CountryDetailManagerImpl.instance_ = |
| 448 new CountryDetailManagerTestImpl(); | 525 new CountryDetailManagerTestImpl(); |
| 449 }); | 526 }); |
| 450 | 527 |
| 451 setup(function() { | 528 setup(function() { |
| 452 PolymerTest.clearBody(); | 529 PolymerTest.clearBody(); |
| 453 }); | 530 }); |
| 454 | 531 |
| 455 test('verifyNoAddresses', function() { | 532 test('verifyNoAddresses', function() { |
| 456 var section = self.createAutofillSection_([], []); | 533 var section = self.createAutofillSection_([], []); |
| 457 assertTrue(!!section); | |
| 458 | 534 |
| 459 var addressList = section.$.addressList; | 535 var addressList = section.$.addressList; |
| 460 assertTrue(!!addressList); | 536 assertTrue(!!addressList); |
| 461 // 1 for the template element. | 537 // 1 for the template element. |
| 462 assertEquals(1, addressList.children.length); | 538 assertEquals(1, addressList.children.length); |
| 463 | 539 |
| 464 assertFalse(section.$.noAddressesLabel.hidden); | 540 assertFalse(section.$.noAddressesLabel.hidden); |
| 465 }); | 541 }); |
| 466 | 542 |
| 467 test('verifyAddressCount', function() { | 543 test('verifyAddressCount', function() { |
| 468 var addresses = [ | 544 var addresses = [ |
| 469 FakeDataMaker.addressEntry(), | 545 FakeDataMaker.addressEntry(), |
| 470 FakeDataMaker.addressEntry(), | 546 FakeDataMaker.addressEntry(), |
| 471 FakeDataMaker.addressEntry(), | 547 FakeDataMaker.addressEntry(), |
| 472 FakeDataMaker.addressEntry(), | 548 FakeDataMaker.addressEntry(), |
| 473 FakeDataMaker.addressEntry(), | 549 FakeDataMaker.addressEntry(), |
| 474 ]; | 550 ]; |
| 475 | 551 |
| 476 var section = self.createAutofillSection_(addresses, []); | 552 var section = self.createAutofillSection_(addresses, []); |
| 477 | 553 |
| 478 assertTrue(!!section); | |
| 479 var addressList = section.$.addressList; | 554 var addressList = section.$.addressList; |
| 480 assertTrue(!!addressList); | 555 assertTrue(!!addressList); |
| 481 // +1 for the template element. | 556 assertEquals(addresses.length, |
| 482 assertEquals(addresses.length + 1, addressList.children.length); | 557 addressList.querySelectorAll('.list-item').length); |
| 483 | 558 |
| 484 assertTrue(section.$.noAddressesLabel.hidden); | 559 assertTrue(section.$.noAddressesLabel.hidden); |
| 485 }); | 560 }); |
| 486 | 561 |
| 487 test('verifyAddressFields', function() { | 562 test('verifyAddressFields', function() { |
| 488 var address = FakeDataMaker.addressEntry(); | 563 var address = FakeDataMaker.addressEntry(); |
| 489 var section = self.createAutofillSection_([address], []); | 564 var section = self.createAutofillSection_([address], []); |
| 490 var addressList = section.$.addressList; | 565 var addressList = section.$.addressList; |
| 491 var row = addressList.children[0]; | 566 var row = addressList.children[0]; |
| 492 assertTrue(!!row); | 567 assertTrue(!!row); |
| (...skipping 461 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 954 assertEquals(city, cols[0].value); | 1029 assertEquals(city, cols[0].value); |
| 955 assertEquals(state, cols[1].value); | 1030 assertEquals(state, cols[1].value); |
| 956 assertEquals(zip, cols[2].value); | 1031 assertEquals(zip, cols[2].value); |
| 957 }); | 1032 }); |
| 958 }); | 1033 }); |
| 959 }); | 1034 }); |
| 960 }); | 1035 }); |
| 961 | 1036 |
| 962 mocha.run(); | 1037 mocha.run(); |
| 963 }); | 1038 }); |
| OLD | NEW |