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

Side by Side Diff: chrome/test/data/webui/settings/certificate_manager_page_test.js

Issue 1784553004: MD Settings: Certificate manager, delete confirmation dialog. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@certificates_catrustedit
Patch Set: Nits. Created 4 years, 9 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 unified diff | Download patch
OLDNEW
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 cr.define('certificate_manager_page', function() { 5 cr.define('certificate_manager_page', function() {
6 /** 6 /**
7 * A test version of CertificatesBrowserProxy. Provides helper methods 7 * A test version of CertificatesBrowserProxy. Provides helper methods
8 * for allowing tests to know when a method was called, as well as 8 * for allowing tests to know when a method was called, as well as
9 * specifying mock responses. 9 * specifying mock responses.
10 * 10 *
11 * @constructor 11 * @constructor
12 * @implements {settings.CertificatesBrowserProxy} 12 * @implements {settings.CertificatesBrowserProxy}
13 */ 13 */
14 var TestCertificatesBrowserProxy = function() { 14 var TestCertificatesBrowserProxy = function() {
15 /** @private {!Map<string, !PromiseResolver>} */ 15 /** @private {!Map<string, !PromiseResolver>} */
16 this.resolverMap_ = new Map(); 16 this.resolverMap_ = new Map();
17 var wrapperMethods = [ 17 var wrapperMethods = [
18 'getCaCertificateTrust', 18 'getCaCertificateTrust',
19 'editCaCertificateTrust', 19 'editCaCertificateTrust',
20 'deleteCertificate',
Dan Beam 2016/03/10 05:03:06 nit: alphabetize, maybe?
dpapad 2016/03/10 18:31:07 Done.
20 ]; 21 ];
21 wrapperMethods.forEach(this.resetResolver, this); 22 wrapperMethods.forEach(this.resetResolver, this);
22 23
23 /** @private {!CaTrustInfo} */ 24 /** @private {!CaTrustInfo} */
24 this.caTrustInfo_ = {ssl: true, email: true, objSign: true}; 25 this.caTrustInfo_ = {ssl: true, email: true, objSign: true};
25 }; 26 };
26 27
27 TestCertificatesBrowserProxy.prototype = { 28 TestCertificatesBrowserProxy.prototype = {
28 /** 29 /**
29 * @param {string} methodName 30 * @param {string} methodName
(...skipping 25 matching lines...) Expand all
55 return Promise.resolve(this.caTrustInfo_); 56 return Promise.resolve(this.caTrustInfo_);
56 }, 57 },
57 58
58 /** @override */ 59 /** @override */
59 editCaCertificateTrust: function(id, ssl, email, objSign) { 60 editCaCertificateTrust: function(id, ssl, email, objSign) {
60 this.resolverMap_.get('editCaCertificateTrust').resolve({ 61 this.resolverMap_.get('editCaCertificateTrust').resolve({
61 id: id, ssl: ssl, email: email, objSign: objSign, 62 id: id, ssl: ssl, email: email, objSign: objSign,
62 }); 63 });
63 return Promise.resolve(); 64 return Promise.resolve();
64 }, 65 },
66
67 /** @override */
68 deleteCertificate: function(id) {
69 this.resolverMap_.get('deleteCertificate').resolve(id);
70 return Promise.resolve();
71 },
65 }; 72 };
66 73
67 /** @return {!CertificateSubnode} */ 74 /** @return {!CertificateSubnode} */
68 var createSampleCertificateSubnode = function() { 75 var createSampleCertificateSubnode = function() {
69 return { 76 return {
70 extractable: false, 77 extractable: false,
71 id: 'dummyId', 78 id: 'dummyId',
72 name: 'dummyName', 79 name: 'dummyName',
73 policy: false, 80 policy: false,
74 readonly: false, 81 readonly: false,
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
129 assertEquals(caTrustInfo.email, !args.email); 136 assertEquals(caTrustInfo.email, !args.email);
130 assertEquals(caTrustInfo.objSign, !args.objSign); 137 assertEquals(caTrustInfo.objSign, !args.objSign);
131 // Check that the dialog is closed. 138 // Check that the dialog is closed.
132 assertFalse(dialog.$.dialog.opened); 139 assertFalse(dialog.$.dialog.opened);
133 }); 140 });
134 }); 141 });
135 }); 142 });
136 }); 143 });
137 } 144 }
138 145
146 function registerDeleteDialogTests() {
147 /** @type {?SettingsCertificateDeleteConfirmationDialogElement} */
148 var dialog = null;
149
150 /** @type {?TestCertificatesBrowserProxy} */
151 var browserProxy = null;
152
153 /** @type {!CertificateSubnode} */
154 var model = createSampleCertificateSubnode();
155
156 suite('CertificateDeleteConfirmationDialogTests', function() {
157 setup(function() {
158 browserProxy = new TestCertificatesBrowserProxy();
159 settings.CertificatesBrowserProxyImpl.instance_ = browserProxy;
160 PolymerTest.clearBody();
161 dialog = document.createElement(
162 'settings-certificate-delete-confirmation-dialog');
163 dialog.model = model;
164 dialog.certificateType = settings.CertificateType.PERSONAL;
165 document.body.appendChild(dialog);
166 });
167
168 teardown(function() { dialog.remove(); });
169
170 test('DeleteSuccess', function() {
171 // Check that the dialog title includes the certificate name.
172 var titleEl = Polymer.dom(dialog.$.dialog).querySelector('.title');
173 assertTrue(titleEl.textContent.includes(model.name));
174
175 // Simulate clicking 'OK'.
176 MockInteractions.tap(dialog.$.ok);
177
178 return browserProxy.whenCalled('deleteCertificate').then(
179 function(id) {
180 assertEquals(model.id, id);
181 // Check that the dialog is closed.
182 assertFalse(dialog.$.dialog.opened);
183 });
184 });
185 });
186 }
187
139 return { 188 return {
140 registerCaTrustEditDialogTests: registerCaTrustEditDialogTests, 189 registerCaTrustEditDialogTests: registerCaTrustEditDialogTests,
190 registerDeleteDialogTests: registerDeleteDialogTests,
141 }; 191 };
142 }); 192 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698