Chromium Code Reviews| Index: chrome/test/data/webui/settings/certificate_manager_page_test.js |
| diff --git a/chrome/test/data/webui/settings/certificate_manager_page_test.js b/chrome/test/data/webui/settings/certificate_manager_page_test.js |
| index ed3c20fae5db77e8c274cb6d06baf2c229e74095..e6677dc445882342890bf9b15ebbd1df148d5f41 100644 |
| --- a/chrome/test/data/webui/settings/certificate_manager_page_test.js |
| +++ b/chrome/test/data/webui/settings/certificate_manager_page_test.js |
| @@ -19,6 +19,7 @@ cr.define('certificate_manager_page', function() { |
| 'exportPersonalCertificatePasswordSelected', |
| 'getCaCertificateTrust', |
| 'importPersonalCertificatePasswordSelected', |
| + 'refreshCertificates', |
| ]); |
| /** @private {!CaTrustInfo} */ |
| @@ -68,14 +69,30 @@ cr.define('certificate_manager_page', function() { |
| 'importPersonalCertificatePasswordSelected').resolve(password); |
| return Promise.resolve(); |
| }, |
| + |
| + /** @override */ |
| + refreshCertificates: function() { |
| + this.methodCalled('refreshCertificates'); |
| + }, |
| }; |
| + /** @return {!Certificate} */ |
| + function createSampleCertificate() { |
| + return { |
| + id: 'dummyCertificateId', |
| + name: 'dummyCertificateName', |
| + subnodes: [ |
| + createSampleCertificateSubnode() |
| + ], |
| + }; |
| + } |
| + |
| /** @return {!CertificateSubnode} */ |
| function createSampleCertificateSubnode() { |
| return { |
| extractable: false, |
| - id: 'dummyId', |
| - name: 'dummyName', |
| + id: 'dummySubnodeId', |
| + name: 'dummySubnodeName', |
| policy: false, |
| readonly: false, |
| untrusted: false, |
| @@ -301,12 +318,83 @@ cr.define('certificate_manager_page', function() { |
| }); |
| } |
| + function registerPageTests() { |
| + /** @type {?SettingsCertificateManagerPage} */ |
| + var page = null; |
| + |
| + /** @type {?TestCertificatesBrowserProxy} */ |
| + var browserProxy = null; |
| + |
| + suite('CertificateManagerPageTests', function() { |
| + setup(function() { |
| + browserProxy = new TestCertificatesBrowserProxy(); |
| + settings.CertificatesBrowserProxyImpl.instance_ = browserProxy; |
| + PolymerTest.clearBody(); |
| + page = document.createElement('settings-certificate-manager-page'); |
| + document.body.appendChild(page); |
| + }); |
| + |
| + teardown(function() { page.remove(); }); |
| + |
| + /** |
| + * Test that the page requests information from the browser on startup and |
| + * that it gets populated accordingly. |
| + */ |
| + test('Initialization', function() { |
| + // Trigger all category tabs to be added to the DOM. |
| + var paperTabsElement = page.shadowRoot.querySelector('paper-tabs'); |
| + paperTabsElement.selected = 0; |
|
Dan Beam
2016/03/22 02:08:28
what is different about how the selection code wor
dpapad
2016/03/22 18:07:02
Later in this test I am testing that those 4 secti
|
| + Polymer.dom.flush(); |
| + paperTabsElement.selected = 1; |
| + Polymer.dom.flush(); |
| + paperTabsElement.selected = 2; |
| + Polymer.dom.flush(); |
| + paperTabsElement.selected = 3; |
| + Polymer.dom.flush(); |
| + var certificateLists = page.shadowRoot.querySelectorAll( |
| + 'settings-certificate-list'); |
| + assertEquals(4, certificateLists.length); |
| + |
| + var assertCertificateListLength = function( |
| + listIndex, expectedSize) { |
| + var certificateEntries = |
| + certificateLists[listIndex].shadowRoot.querySelectorAll( |
| + 'settings-certificate-entry'); |
| + assertEquals(expectedSize, certificateEntries.length); |
| + }; |
| + |
| + assertCertificateListLength(0 /* personalCerts */, 0); |
|
Dan Beam
2016/03/22 02:08:29
can you use an enum instead of copying the constan
dpapad
2016/03/22 18:07:02
Done.
|
| + assertCertificateListLength(1 /* serverCerts */, 0); |
| + assertCertificateListLength(2 /* caCerts */, 0); |
| + assertCertificateListLength(3 /* otherCerts */, 0); |
| + |
| + return browserProxy.whenCalled('refreshCertificates').then( |
| + function() { |
| + // Simulate response for personal and CA certificates. |
| + cr.webUIListenerCallback( |
| + 'certificates-changed', 'personalCerts', |
| + [createSampleCertificate()]); |
| + cr.webUIListenerCallback( |
| + 'certificates-changed', 'caCerts', |
| + [createSampleCertificate(), createSampleCertificate()]); |
| + Polymer.dom.flush(); |
| + |
| + assertCertificateListLength(0 /* personalCerts */, 1); |
| + assertCertificateListLength(1 /* serverCerts */, 0); |
| + assertCertificateListLength(2 /* caCerts */, 2); |
| + assertCertificateListLength(3 /* otherCerts */, 0); |
| + }); |
| + }); |
| + }); |
| + } |
| + |
| return { |
| registerTests: function() { |
| registerCaTrustEditDialogTests(); |
| registerDeleteDialogTests(); |
| registerPasswordEncryptDialogTests(); |
| registerPasswordDecryptDialogTests(); |
| + registerPageTests(); |
| }, |
| }; |
| }); |