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

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

Issue 2170713002: Use dom-repeat for addresses, credit cards, and exceptions. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Verify Template is a Template Created 4 years, 4 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/test/data/webui/settings/settings_autofill_section_browsertest.js ('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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 Password Settings tests. */ 5 /** @fileoverview Runs the Polymer Password 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 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 var node = nodes[index]; 77 var node = nodes[index];
78 var exception = exceptionList[index]; 78 var exception = exceptionList[index];
79 assertEquals(exception.exceptionUrl, 79 assertEquals(exception.exceptionUrl,
80 node.querySelector('#exception').textContent); 80 node.querySelector('#exception').textContent);
81 assertEquals(exception.linkUrl, 81 assertEquals(exception.linkUrl,
82 node.querySelector('#exception').href); 82 node.querySelector('#exception').href);
83 } 83 }
84 }, 84 },
85 85
86 /** 86 /**
87 * Returns all children of an element that has children added by a dom-repeat.
88 * @param {!Element} element
89 * @return {!Array<!Element>}
90 * @private
91 */
92 getDomRepeatChildren_: function(element) {
93 var template = element.children[element.children.length - 1];
94 assertEquals('TEMPLATE', template.tagName);
95 // The template is at the end of the list of children and should be skipped.
96 return Array.prototype.slice.call(element.children, 0, -1);
97 },
98
99 /**
87 * Skips over the template and returns all visible children of an iron-list. 100 * Skips over the template and returns all visible children of an iron-list.
88 * @param {!Element} ironList 101 * @param {!Element} ironList
89 * @return {!Array<!Element>} 102 * @return {!Array<!Element>}
90 * @private 103 * @private
91 */ 104 */
92 getIronListChildren_: function(ironList) { 105 getIronListChildren_: function(ironList) {
93 return Polymer.dom(ironList).children.filter(function(child, i) { 106 return Polymer.dom(ironList).children.filter(function(child, i) {
94 return i != 0 && !child.hidden; 107 return i != 0 && !child.hidden;
95 }); 108 });
96 }, 109 },
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
152 return false; 165 return false;
153 }, 166 },
154 167
155 /** 168 /**
156 * Allow the iron-list to be sized properly. 169 * Allow the iron-list to be sized properly.
157 * @param {!Object} passwordsSection 170 * @param {!Object} passwordsSection
158 * @private 171 * @private
159 */ 172 */
160 flushPasswordSection_: function(passwordsSection) { 173 flushPasswordSection_: function(passwordsSection) {
161 passwordsSection.$.passwordList.notifyResize(); 174 passwordsSection.$.passwordList.notifyResize();
162 passwordsSection.$.passwordExceptionsList.notifyResize();
163 Polymer.dom.flush(); 175 Polymer.dom.flush();
164 }, 176 },
165 }; 177 };
166 178
167 /** 179 /**
168 * This test will validate that the section is loaded with data. 180 * This test will validate that the section is loaded with data.
169 */ 181 */
170 TEST_F('SettingsPasswordSectionBrowserTest', 'uiTests', function() { 182 TEST_F('SettingsPasswordSectionBrowserTest', 'uiTests', function() {
171 var self = this; 183 var self = this;
172 184
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
309 Polymer.dom.flush(); 321 Polymer.dom.flush();
310 322
311 var expectedExceptionList = [ 323 var expectedExceptionList = [
312 FakeDataMaker.exceptionEntry('docsshow.google.com'), 324 FakeDataMaker.exceptionEntry('docsshow.google.com'),
313 FakeDataMaker.exceptionEntry('showmail.com'), 325 FakeDataMaker.exceptionEntry('showmail.com'),
314 FakeDataMaker.exceptionEntry('mapsshow.google.com'), 326 FakeDataMaker.exceptionEntry('mapsshow.google.com'),
315 FakeDataMaker.exceptionEntry('plus.google.comshow'), 327 FakeDataMaker.exceptionEntry('plus.google.comshow'),
316 ]; 328 ];
317 329
318 self.validateExceptionList_( 330 self.validateExceptionList_(
319 self.getIronListChildren_(passwordsSection.$.passwordExceptionsList), 331 self.getDomRepeatChildren_(passwordsSection.$.passwordExceptionsList),
320 expectedExceptionList); 332 expectedExceptionList);
321 }); 333 });
322 334
323 test('verifyPasswordExceptions', function() { 335 test('verifyPasswordExceptions', function() {
324 var exceptionList = [ 336 var exceptionList = [
325 FakeDataMaker.exceptionEntry('docs.google.com'), 337 FakeDataMaker.exceptionEntry('docs.google.com'),
326 FakeDataMaker.exceptionEntry('mail.com'), 338 FakeDataMaker.exceptionEntry('mail.com'),
327 FakeDataMaker.exceptionEntry('google.com'), 339 FakeDataMaker.exceptionEntry('google.com'),
328 FakeDataMaker.exceptionEntry('inbox.google.com'), 340 FakeDataMaker.exceptionEntry('inbox.google.com'),
329 FakeDataMaker.exceptionEntry('maps.google.com'), 341 FakeDataMaker.exceptionEntry('maps.google.com'),
330 FakeDataMaker.exceptionEntry('plus.google.com'), 342 FakeDataMaker.exceptionEntry('plus.google.com'),
331 ]; 343 ];
332 344
333 var passwordsSection = self.createPasswordsSection_([], exceptionList); 345 var passwordsSection = self.createPasswordsSection_([], exceptionList);
334 346
335 // Assert that the data is passed into the iron list. If this fails,
336 // then other expectations will also fail.
337 assertEquals(exceptionList,
338 passwordsSection.$.passwordExceptionsList.items);
339
340 self.validateExceptionList_( 347 self.validateExceptionList_(
341 self.getIronListChildren_(passwordsSection.$.passwordExceptionsList), 348 self.getDomRepeatChildren_(passwordsSection.$.passwordExceptionsList),
342 exceptionList); 349 exceptionList);
343 }); 350 });
344 351
345 // Test verifies that removing an exception will update the elements. 352 // Test verifies that removing an exception will update the elements.
346 test('verifyPasswordExceptionRemove', function() { 353 test('verifyPasswordExceptionRemove', function() {
347 var exceptionList = [ 354 var exceptionList = [
348 FakeDataMaker.exceptionEntry('docs.google.com'), 355 FakeDataMaker.exceptionEntry('docs.google.com'),
349 FakeDataMaker.exceptionEntry('mail.com'), 356 FakeDataMaker.exceptionEntry('mail.com'),
350 FakeDataMaker.exceptionEntry('google.com'), 357 FakeDataMaker.exceptionEntry('google.com'),
351 FakeDataMaker.exceptionEntry('inbox.google.com'), 358 FakeDataMaker.exceptionEntry('inbox.google.com'),
352 FakeDataMaker.exceptionEntry('maps.google.com'), 359 FakeDataMaker.exceptionEntry('maps.google.com'),
353 FakeDataMaker.exceptionEntry('plus.google.com'), 360 FakeDataMaker.exceptionEntry('plus.google.com'),
354 ]; 361 ];
355 362
356 var passwordsSection = self.createPasswordsSection_([], exceptionList); 363 var passwordsSection = self.createPasswordsSection_([], exceptionList);
357 364
358 self.validateExceptionList_( 365 self.validateExceptionList_(
359 self.getIronListChildren_(passwordsSection.$.passwordExceptionsList), 366 self.getDomRepeatChildren_(passwordsSection.$.passwordExceptionsList),
360 exceptionList); 367 exceptionList);
361 368
362 // Simulate 'mail.com' being removed from the list. 369 // Simulate 'mail.com' being removed from the list.
363 passwordsSection.splice('passwordExceptions', 1, 1); 370 passwordsSection.splice('passwordExceptions', 1, 1);
364 assertFalse(self.exceptionsListContainsUrl( 371 assertFalse(self.exceptionsListContainsUrl(
365 passwordsSection.passwordExceptions, 'mail.com')); 372 passwordsSection.passwordExceptions, 'mail.com'));
366 assertFalse(self.exceptionsListContainsUrl(exceptionList, 'mail.com')); 373 assertFalse(self.exceptionsListContainsUrl(exceptionList, 'mail.com'));
367 self.flushPasswordSection_(passwordsSection); 374 self.flushPasswordSection_(passwordsSection);
368 375
369 self.validateExceptionList_( 376 self.validateExceptionList_(
370 self.getIronListChildren_(passwordsSection.$.passwordExceptionsList), 377 self.getDomRepeatChildren_(passwordsSection.$.passwordExceptionsList),
371 exceptionList); 378 exceptionList);
372 }); 379 });
373 380
374 // Test verifies that pressing the 'remove' button will trigger a remove 381 // Test verifies that pressing the 'remove' button will trigger a remove
375 // event. Does not actually remove any exceptions. 382 // event. Does not actually remove any exceptions.
376 test('verifyPasswordExceptionRemoveButton', function(done) { 383 test('verifyPasswordExceptionRemoveButton', function(done) {
377 var exceptionList = [ 384 var exceptionList = [
378 FakeDataMaker.exceptionEntry('docs.google.com'), 385 FakeDataMaker.exceptionEntry('docs.google.com'),
379 FakeDataMaker.exceptionEntry('mail.com'), 386 FakeDataMaker.exceptionEntry('mail.com'),
380 FakeDataMaker.exceptionEntry('google.com'), 387 FakeDataMaker.exceptionEntry('google.com'),
381 FakeDataMaker.exceptionEntry('inbox.google.com'), 388 FakeDataMaker.exceptionEntry('inbox.google.com'),
382 FakeDataMaker.exceptionEntry('maps.google.com'), 389 FakeDataMaker.exceptionEntry('maps.google.com'),
383 FakeDataMaker.exceptionEntry('plus.google.com'), 390 FakeDataMaker.exceptionEntry('plus.google.com'),
384 ]; 391 ];
385 392
386 var passwordsSection = self.createPasswordsSection_([], exceptionList); 393 var passwordsSection = self.createPasswordsSection_([], exceptionList);
387 394
388 var exceptions = 395 var exceptions =
389 self.getIronListChildren_(passwordsSection.$.passwordExceptionsList); 396 self.getDomRepeatChildren_(passwordsSection.$.passwordExceptionsList);
390 397
391 // The index of the button currently being checked. 398 // The index of the button currently being checked.
392 var index = 0; 399 var index = 0;
393 400
394 var clickRemoveButton = function() { 401 var clickRemoveButton = function() {
395 MockInteractions.tap( 402 MockInteractions.tap(
396 exceptions[index].querySelector('#removeExceptionButton')); 403 exceptions[index].querySelector('#removeExceptionButton'));
397 }; 404 };
398 405
399 // Listen for the remove event. If this event isn't received, the test 406 // Listen for the remove event. If this event isn't received, the test
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
441 assertEquals(item.loginPair.username, event.detail.username); 448 assertEquals(item.loginPair.username, event.detail.username);
442 done(); 449 done();
443 }); 450 });
444 451
445 MockInteractions.tap(passwordDialog.$.showPasswordButton); 452 MockInteractions.tap(passwordDialog.$.showPasswordButton);
446 }); 453 });
447 }); 454 });
448 455
449 mocha.run(); 456 mocha.run();
450 }); 457 });
OLDNEW
« no previous file with comments | « chrome/test/data/webui/settings/settings_autofill_section_browsertest.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698