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

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: 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/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 return Array.prototype.slice.call(element.children, 0, -1);
michaelpg 2016/07/21 03:56:13 Comment here what the -1 is for (the <template>)
hcarmona 2016/07/26 18:28:48 Done.
94 },
95
96 /**
87 * Skips over the template and returns all visible children of an iron-list. 97 * Skips over the template and returns all visible children of an iron-list.
88 * @param {!Element} ironList 98 * @param {!Element} ironList
89 * @return {!Array<!Element>} 99 * @return {!Array<!Element>}
90 * @private 100 * @private
91 */ 101 */
92 getIronListChildren_: function(ironList) { 102 getIronListChildren_: function(ironList) {
93 return Polymer.dom(ironList).children.filter(function(child, i) { 103 return Polymer.dom(ironList).children.filter(function(child, i) {
94 return i != 0 && !child.hidden; 104 return i != 0 && !child.hidden;
95 }); 105 });
96 }, 106 },
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
152 return false; 162 return false;
153 }, 163 },
154 164
155 /** 165 /**
156 * Allow the iron-list to be sized properly. 166 * Allow the iron-list to be sized properly.
157 * @param {!Object} passwordsSection 167 * @param {!Object} passwordsSection
158 * @private 168 * @private
159 */ 169 */
160 flushPasswordSection_: function(passwordsSection) { 170 flushPasswordSection_: function(passwordsSection) {
161 passwordsSection.$.passwordList.notifyResize(); 171 passwordsSection.$.passwordList.notifyResize();
162 passwordsSection.$.passwordExceptionsList.notifyResize();
163 Polymer.dom.flush(); 172 Polymer.dom.flush();
164 }, 173 },
165 }; 174 };
166 175
167 /** 176 /**
168 * This test will validate that the section is loaded with data. 177 * This test will validate that the section is loaded with data.
169 */ 178 */
170 TEST_F('SettingsPasswordSectionBrowserTest', 'uiTests', function() { 179 TEST_F('SettingsPasswordSectionBrowserTest', 'uiTests', function() {
171 var self = this; 180 var self = this;
172 181
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
273 FakeDataMaker.exceptionEntry('docs.google.com'), 282 FakeDataMaker.exceptionEntry('docs.google.com'),
274 FakeDataMaker.exceptionEntry('mail.com'), 283 FakeDataMaker.exceptionEntry('mail.com'),
275 FakeDataMaker.exceptionEntry('google.com'), 284 FakeDataMaker.exceptionEntry('google.com'),
276 FakeDataMaker.exceptionEntry('inbox.google.com'), 285 FakeDataMaker.exceptionEntry('inbox.google.com'),
277 FakeDataMaker.exceptionEntry('maps.google.com'), 286 FakeDataMaker.exceptionEntry('maps.google.com'),
278 FakeDataMaker.exceptionEntry('plus.google.com'), 287 FakeDataMaker.exceptionEntry('plus.google.com'),
279 ]; 288 ];
280 289
281 var passwordsSection = self.createPasswordsSection_([], exceptionList); 290 var passwordsSection = self.createPasswordsSection_([], exceptionList);
282 291
283 // Assert that the data is passed into the iron list. If this fails,
284 // then other expectations will also fail.
285 assertEquals(exceptionList,
286 passwordsSection.$.passwordExceptionsList.items);
287
288 self.validateExceptionList_( 292 self.validateExceptionList_(
289 self.getIronListChildren_(passwordsSection.$.passwordExceptionsList), 293 self.getDomRepeatChildren_(passwordsSection.$.passwordExceptionsList),
290 exceptionList); 294 exceptionList);
291 }); 295 });
292 296
293 // Test verifies that removing an exception will update the elements. 297 // Test verifies that removing an exception will update the elements.
294 test('verifyPasswordExceptionRemove', function() { 298 test('verifyPasswordExceptionRemove', function() {
295 var exceptionList = [ 299 var exceptionList = [
296 FakeDataMaker.exceptionEntry('docs.google.com'), 300 FakeDataMaker.exceptionEntry('docs.google.com'),
297 FakeDataMaker.exceptionEntry('mail.com'), 301 FakeDataMaker.exceptionEntry('mail.com'),
298 FakeDataMaker.exceptionEntry('google.com'), 302 FakeDataMaker.exceptionEntry('google.com'),
299 FakeDataMaker.exceptionEntry('inbox.google.com'), 303 FakeDataMaker.exceptionEntry('inbox.google.com'),
300 FakeDataMaker.exceptionEntry('maps.google.com'), 304 FakeDataMaker.exceptionEntry('maps.google.com'),
301 FakeDataMaker.exceptionEntry('plus.google.com'), 305 FakeDataMaker.exceptionEntry('plus.google.com'),
302 ]; 306 ];
303 307
304 var passwordsSection = self.createPasswordsSection_([], exceptionList); 308 var passwordsSection = self.createPasswordsSection_([], exceptionList);
305 309
306 self.validateExceptionList_( 310 self.validateExceptionList_(
307 self.getIronListChildren_(passwordsSection.$.passwordExceptionsList), 311 self.getDomRepeatChildren_(passwordsSection.$.passwordExceptionsList),
308 exceptionList); 312 exceptionList);
309 313
310 // Simulate 'mail.com' being removed from the list. 314 // Simulate 'mail.com' being removed from the list.
311 passwordsSection.splice('passwordExceptions', 1, 1); 315 passwordsSection.splice('passwordExceptions', 1, 1);
312 assertFalse(self.exceptionsListContainsUrl( 316 assertFalse(self.exceptionsListContainsUrl(
313 passwordsSection.passwordExceptions, 'mail.com')); 317 passwordsSection.passwordExceptions, 'mail.com'));
314 assertFalse(self.exceptionsListContainsUrl(exceptionList, 'mail.com')); 318 assertFalse(self.exceptionsListContainsUrl(exceptionList, 'mail.com'));
315 self.flushPasswordSection_(passwordsSection); 319 self.flushPasswordSection_(passwordsSection);
316 320
317 self.validateExceptionList_( 321 self.validateExceptionList_(
318 self.getIronListChildren_(passwordsSection.$.passwordExceptionsList), 322 self.getDomRepeatChildren_(passwordsSection.$.passwordExceptionsList),
319 exceptionList); 323 exceptionList);
320 }); 324 });
321 325
322 // Test verifies that pressing the 'remove' button will trigger a remove 326 // Test verifies that pressing the 'remove' button will trigger a remove
323 // event. Does not actually remove any exceptions. 327 // event. Does not actually remove any exceptions.
324 test('verifyPasswordExceptionRemoveButton', function(done) { 328 test('verifyPasswordExceptionRemoveButton', function(done) {
325 var exceptionList = [ 329 var exceptionList = [
326 FakeDataMaker.exceptionEntry('docs.google.com'), 330 FakeDataMaker.exceptionEntry('docs.google.com'),
327 FakeDataMaker.exceptionEntry('mail.com'), 331 FakeDataMaker.exceptionEntry('mail.com'),
328 FakeDataMaker.exceptionEntry('google.com'), 332 FakeDataMaker.exceptionEntry('google.com'),
329 FakeDataMaker.exceptionEntry('inbox.google.com'), 333 FakeDataMaker.exceptionEntry('inbox.google.com'),
330 FakeDataMaker.exceptionEntry('maps.google.com'), 334 FakeDataMaker.exceptionEntry('maps.google.com'),
331 FakeDataMaker.exceptionEntry('plus.google.com'), 335 FakeDataMaker.exceptionEntry('plus.google.com'),
332 ]; 336 ];
333 337
334 var passwordsSection = self.createPasswordsSection_([], exceptionList); 338 var passwordsSection = self.createPasswordsSection_([], exceptionList);
335 339
336 var exceptions = 340 var exceptions =
337 self.getIronListChildren_(passwordsSection.$.passwordExceptionsList); 341 self.getDomRepeatChildren_(passwordsSection.$.passwordExceptionsList);
338 342
339 // The index of the button currently being checked. 343 // The index of the button currently being checked.
340 var index = 0; 344 var index = 0;
341 345
342 var clickRemoveButton = function() { 346 var clickRemoveButton = function() {
343 MockInteractions.tap( 347 MockInteractions.tap(
344 exceptions[index].querySelector('#removeExceptionButton')); 348 exceptions[index].querySelector('#removeExceptionButton'));
345 }; 349 };
346 350
347 // Listen for the remove event. If this event isn't received, the test 351 // 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
389 assertEquals(item.loginPair.username, event.detail.username); 393 assertEquals(item.loginPair.username, event.detail.username);
390 done(); 394 done();
391 }); 395 });
392 396
393 MockInteractions.tap(passwordDialog.$.showPasswordButton); 397 MockInteractions.tap(passwordDialog.$.showPasswordButton);
394 }); 398 });
395 }); 399 });
396 400
397 mocha.run(); 401 mocha.run();
398 }); 402 });
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