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

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

Issue 2111643005: [MD Settings] Make Passwords and Autofill actionable if tap will work. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: tests! Created 4 years, 5 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
« no previous file with comments | « chrome/browser/resources/settings/passwords_and_forms_page/passwords_and_forms_page.html ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 /** @fileoverview Runs the Polymer Passwords and Forms tests. */ 5 /** @fileoverview Runs the Polymer Passwords and Forms 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 205 matching lines...) Expand 10 before | Expand all | Expand 10 after
216 function PasswordsAndFormsBrowserTest() {} 216 function PasswordsAndFormsBrowserTest() {}
217 217
218 PasswordsAndFormsBrowserTest.prototype = { 218 PasswordsAndFormsBrowserTest.prototype = {
219 __proto__: PolymerTest.prototype, 219 __proto__: PolymerTest.prototype,
220 220
221 /** @override */ 221 /** @override */
222 browsePreload: 'chrome://md-settings/passwords_and_forms_page/' + 222 browsePreload: 'chrome://md-settings/passwords_and_forms_page/' +
223 'passwords_and_forms_page.html', 223 'passwords_and_forms_page.html',
224 224
225 /** @override */ 225 /** @override */
226 extraLibraries: PolymerTest.getLibraries(ROOT_PATH), 226 extraLibraries: PolymerTest.getLibraries(ROOT_PATH).concat([
227 '../fake_chrome_event.js',
228 'fake_settings_private.js',
229 ]),
227 230
228 /** @override */ 231 /** @override */
229 setUp: function() { 232 setUp: function() {
230 PolymerTest.prototype.setUp.call(this); 233 PolymerTest.prototype.setUp.call(this);
231 234
232 // Test is run on an individual element that won't have a page language. 235 // Test is run on an individual element that won't have a page language.
233 this.accessibilityAuditConfig.auditRulesToIgnore.push('humanLangMissing'); 236 this.accessibilityAuditConfig.auditRulesToIgnore.push('humanLangMissing');
234 237
235 // Override the PasswordManagerImpl for testing. 238 // Override the PasswordManagerImpl for testing.
236 this.passwordManager = new TestPasswordManager(); 239 this.passwordManager = new TestPasswordManager();
237 PasswordManagerImpl.instance_ = this.passwordManager; 240 PasswordManagerImpl.instance_ = this.passwordManager;
238 241
239 // Override the AutofillManagerImpl for testing. 242 // Override the AutofillManagerImpl for testing.
240 this.autofillManager = new TestAutofillManager(); 243 this.autofillManager = new TestAutofillManager();
241 AutofillManagerImpl.instance_ = this.autofillManager; 244 AutofillManagerImpl.instance_ = this.autofillManager;
242 }, 245 },
243 246
247 /** @override */
248 tearDown: function() {
249 PolymerTest.clearBody();
250 },
251
244 /** 252 /**
245 * Creates a new passwords and forms element. 253 * Creates a new passwords and forms element.
246 * @return {!Object} 254 * @return {!Object}
247 */ 255 */
248 createPasswordsAndFormsElement: function() { 256 createPasswordsAndFormsElement: function() {
249 var element = document.createElement('settings-passwords-and-forms-page'); 257 var element = document.createElement('settings-passwords-and-forms-page');
250 document.body.appendChild(element); 258 document.body.appendChild(element);
251 Polymer.dom.flush(); 259 Polymer.dom.flush();
252 return element; 260 return element;
253 }, 261 },
254 262
255 /** 263 /**
264 * @pram {boolean} autofill Whether autofill is enabled or not.
265 * @param {boolean} passwords Whether passwords are enable or not.
Dan Beam 2016/07/07 00:05:01 enable -> enabled
hcarmona 2016/07/11 23:03:43 Done.
266 * @return {!Promise<!Element>} The |prefs| object.
267 */
268 createPrefs(autofill, passwords) {
Dan Beam 2016/07/07 00:05:01 nit: arguably don't use ES6 features yet (i.e. cre
hcarmona 2016/07/11 23:03:43 Done.
269 return new Promise(function(resolve) {
270 CrSettingsPrefs.deferInitialization = true;
271 var prefs = document.createElement('settings-prefs');
272 document.body.appendChild(prefs);
273 prefs.initializeForTesting(new settings.FakeSettingsPrivate([
274 {
275 key: 'autofill.enabled',
276 type: chrome.settingsPrivate.PrefType.BOOLEAN,
277 value: autofill,
278 },
279 {
280 key: 'profile.password_manager_enabled',
281 type: chrome.settingsPrivate.PrefType.BOOLEAN,
282 value: passwords,
283 },
284 ]));
285
286 CrSettingsPrefs.initialized.then(function() {
287 resolve(prefs);
288 });
289 });
290 },
291
292 /**
293 * Cleans up prefs so tests can continue to run.
294 * @param {!Element} prefs The prefs element.
295 */
296 destroyPrefs(prefs) {
297 console.log('destroying prefs');
Dan Beam 2016/07/07 00:05:01 nit: remove
hcarmona 2016/07/11 23:03:43 Done.
298 CrSettingsPrefs.resetForTesting();
299 CrSettingsPrefs.deferInitialization = false;
300 prefs.resetForTesting();
301 },
302
303 /**
256 * Creates PasswordManagerExpectations with the values expected after first 304 * Creates PasswordManagerExpectations with the values expected after first
257 * creating the element. 305 * creating the element.
258 * @return {!PasswordManagerExpectations} 306 * @return {!PasswordManagerExpectations}
259 */ 307 */
260 basePasswordExpectations: function() { 308 basePasswordExpectations: function() {
261 var expected = new PasswordManagerExpectations(); 309 var expected = new PasswordManagerExpectations();
262 expected.requested.passwords = 1; 310 expected.requested.passwords = 1;
263 expected.requested.exceptions = 1; 311 expected.requested.exceptions = 1;
264 expected.listening.passwords = 1; 312 expected.listening.passwords = 1;
265 expected.listening.exceptions = 1; 313 expected.listening.exceptions = 1;
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
365 self.autofillManager.lastCallback.addCreditCardListChangedListener(list); 413 self.autofillManager.lastCallback.addCreditCardListChangedListener(list);
366 Polymer.dom.flush(); 414 Polymer.dom.flush();
367 415
368 assertEquals(list, element.creditCards); 416 assertEquals(list, element.creditCards);
369 417
370 // The callback is coming from the manager, so the element shouldn't have 418 // The callback is coming from the manager, so the element shouldn't have
371 // additional calls to the manager after the base expectations. 419 // additional calls to the manager after the base expectations.
372 self.passwordManager.assertExpectations(self.basePasswordExpectations()); 420 self.passwordManager.assertExpectations(self.basePasswordExpectations());
373 self.autofillManager.assertExpectations(self.baseAutofillExpectations()); 421 self.autofillManager.assertExpectations(self.baseAutofillExpectations());
374 }); 422 });
423
424 test('testActionabilityNope', function() {
425 return self.createPrefs(false, false).then(function(prefs) {
426 var element = self.createPasswordsAndFormsElement();
427 element.prefs = prefs.prefs;
428 Polymer.dom.flush();
429
430 assertFalse(element.$.autofillManagerButton.hasAttribute('actionable'));
431 assertFalse(element.$.passwordManagerButton.hasAttribute('actionable'));
432
433 self.destroyPrefs(prefs);
434 });
435 });
436
437 test('testActionabilityYes', function() {
438 return self.createPrefs(true, true).then(function(prefs) {
439 var element = self.createPasswordsAndFormsElement();
440 element.prefs = prefs.prefs;
441 Polymer.dom.flush();
442
443 assertTrue(element.$.autofillManagerButton.hasAttribute('actionable'));
444 assertTrue(element.$.passwordManagerButton.hasAttribute('actionable'));
445
446 self.destroyPrefs(prefs);
447 });
448 });
375 }); 449 });
376 450
377 mocha.run(); 451 mocha.run();
378 }); 452 });
OLDNEW
« no previous file with comments | « chrome/browser/resources/settings/passwords_and_forms_page/passwords_and_forms_page.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698