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 415 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 426 | 426 |
| 427 creditCardDialog.addEventListener('close', function() { | 427 creditCardDialog.addEventListener('close', function() { |
| 428 // Test is |done| in a timeout in order to ensure that | 428 // Test is |done| in a timeout in order to ensure that |
| 429 // 'save-credit-card' is NOT fired after this test. | 429 // 'save-credit-card' is NOT fired after this test. |
| 430 window.setTimeout(done, 100); | 430 window.setTimeout(done, 100); |
| 431 }); | 431 }); |
| 432 | 432 |
| 433 MockInteractions.tap(creditCardDialog.$.cancelButton); | 433 MockInteractions.tap(creditCardDialog.$.cancelButton); |
| 434 }); | 434 }); |
| 435 }); | 435 }); |
| 436 | |
| 437 test('verifyLocalCreditCardMenu', function() { | |
| 438 var creditCards = [FakeDataMaker.addressEntry()]; | |
|
dpapad
2017/06/27 22:00:36
Shouldn't this be calling creditCardEntry()?
Also
hcarmona
2017/06/27 22:26:41
Yes, good catch.
| |
| 439 | |
| 440 // When CC is local, |isCached| will be undefined. | |
| 441 creditCards[0].metadata.isLocal = true; | |
| 442 creditCards[0].metadata.isCached = undefined; | |
| 443 | |
| 444 var section = self.createAutofillSection_([], creditCards); | |
| 445 assertTrue(!!section); | |
|
dpapad
2017/06/27 22:00:36
Is this assertion necessary? Can it ever fail?
hcarmona
2017/06/27 22:26:41
Removed here and elsewhere.
| |
| 446 var creditCardList = section.$.creditCardList; | |
| 447 assertTrue(!!creditCardList); | |
| 448 assertEquals(2, creditCardList.children.length); // Template + Row. | |
|
dpapad
2017/06/27 22:00:36
How about the following?
assertEquals(1, creditCar
hcarmona
2017/06/27 22:26:41
Done.
| |
| 449 var row = creditCardList.children[0]; | |
| 450 | |
| 451 // Local CCs will show the overflow menu. | |
| 452 assertFalse(!!row.querySelector('#remoteCreditCardLink')); | |
| 453 var menuButton = row.querySelector('#creditCardMenu') | |
| 454 assertTrue(!!menuButton); | |
| 455 | |
| 456 menuButton.click(); | |
| 457 Polymer.dom.flush(); | |
| 458 | |
| 459 var ccMenu = section.$.creditCardSharedMenu; | |
|
dpapad
2017/06/27 22:00:36
Avoid non established abbreviations (per styleguid
hcarmona
2017/06/27 22:26:41
Done.
| |
| 460 | |
| 461 // Menu should have 2 options. | |
| 462 assertFalse(ccMenu.querySelector('#menuEditCreditCard').hidden); | |
| 463 assertFalse(ccMenu.querySelector('#menuRemoveCreditCard').hidden); | |
| 464 assertTrue(ccMenu.querySelector('#menuClearCreditCard').hidden); | |
| 465 | |
| 466 ccMenu.close(); | |
| 467 Polymer.dom.flush(); | |
| 468 }); | |
| 469 | |
| 470 test('verifyCachedCreditCardMenu', function() { | |
| 471 var creditCards = [FakeDataMaker.addressEntry()]; | |
| 472 | |
| 473 creditCards[0].metadata.isLocal = false; | |
| 474 creditCards[0].metadata.isCached = true; | |
| 475 | |
| 476 var section = self.createAutofillSection_([], creditCards); | |
| 477 assertTrue(!!section); | |
| 478 var creditCardList = section.$.creditCardList; | |
| 479 assertTrue(!!creditCardList); | |
| 480 assertEquals(2, creditCardList.children.length); // Template + Row. | |
| 481 var row = creditCardList.children[0]; | |
| 482 | |
| 483 // Cached remote CCs will show overflow menu. | |
| 484 assertFalse(!!row.querySelector('#remoteCreditCardLink')); | |
| 485 var menuButton = row.querySelector('#creditCardMenu') | |
| 486 assertTrue(!!menuButton); | |
| 487 | |
| 488 menuButton.click(); | |
| 489 Polymer.dom.flush(); | |
| 490 | |
| 491 var ccMenu = section.$.creditCardSharedMenu; | |
| 492 | |
| 493 // Menu should have 2 options. | |
| 494 assertFalse(ccMenu.querySelector('#menuEditCreditCard').hidden); | |
| 495 assertTrue(ccMenu.querySelector('#menuRemoveCreditCard').hidden); | |
| 496 assertFalse(ccMenu.querySelector('#menuClearCreditCard').hidden); | |
| 497 | |
| 498 ccMenu.close(); | |
| 499 Polymer.dom.flush(); | |
| 500 }); | |
| 501 | |
| 502 test('verifyNotCachedCreditCardMenu', function() { | |
| 503 var creditCards = [FakeDataMaker.addressEntry()]; | |
| 504 | |
| 505 creditCards[0].metadata.isLocal = false; | |
| 506 creditCards[0].metadata.isCached = false; | |
| 507 | |
| 508 var section = self.createAutofillSection_([], creditCards); | |
| 509 assertTrue(!!section); | |
| 510 var creditCardList = section.$.creditCardList; | |
| 511 assertTrue(!!creditCardList); | |
| 512 assertEquals(2, creditCardList.children.length); // Template + Row. | |
| 513 var row = creditCardList.children[0]; | |
| 514 | |
| 515 // No overflow menu when not cached. | |
| 516 assertTrue(!!row.querySelector('#remoteCreditCardLink')); | |
| 517 assertFalse(!!row.querySelector('#creditCardMenu')); | |
| 518 }); | |
| 436 }); | 519 }); |
| 437 | 520 |
| 438 mocha.run(); | 521 mocha.run(); |
| 439 }); | 522 }); |
| 440 | 523 |
| 441 TEST_F('SettingsAutofillSectionBrowserTest', 'AddressTests', function() { | 524 TEST_F('SettingsAutofillSectionBrowserTest', 'AddressTests', function() { |
| 442 var self = this; | 525 var self = this; |
| 443 | 526 |
| 444 | 527 |
| 445 suite('AutofillSection', function() { | 528 suite('AutofillSection', function() { |
| (...skipping 508 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 954 assertEquals(city, cols[0].value); | 1037 assertEquals(city, cols[0].value); |
| 955 assertEquals(state, cols[1].value); | 1038 assertEquals(state, cols[1].value); |
| 956 assertEquals(zip, cols[2].value); | 1039 assertEquals(zip, cols[2].value); |
| 957 }); | 1040 }); |
| 958 }); | 1041 }); |
| 959 }); | 1042 }); |
| 960 }); | 1043 }); |
| 961 | 1044 |
| 962 mocha.run(); | 1045 mocha.run(); |
| 963 }); | 1046 }); |
| OLD | NEW |