Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 Loading... | |
| 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 // The template is at the end of the list of children and should be skipped. | |
| 94 return Array.prototype.slice.call(element.children, 0, -1); | |
|
michaelpg
2016/07/26 20:28:39
Do you think we should assert the last element is
hcarmona
2016/07/26 22:08:15
Done.
| |
| 95 }, | |
| 96 | |
| 97 /** | |
| 87 * Skips over the template and returns all visible children of an iron-list. | 98 * Skips over the template and returns all visible children of an iron-list. |
| 88 * @param {!Element} ironList | 99 * @param {!Element} ironList |
| 89 * @return {!Array<!Element>} | 100 * @return {!Array<!Element>} |
| 90 * @private | 101 * @private |
| 91 */ | 102 */ |
| 92 getIronListChildren_: function(ironList) { | 103 getIronListChildren_: function(ironList) { |
| 93 return Polymer.dom(ironList).children.filter(function(child, i) { | 104 return Polymer.dom(ironList).children.filter(function(child, i) { |
| 94 return i != 0 && !child.hidden; | 105 return i != 0 && !child.hidden; |
| 95 }); | 106 }); |
| 96 }, | 107 }, |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 152 return false; | 163 return false; |
| 153 }, | 164 }, |
| 154 | 165 |
| 155 /** | 166 /** |
| 156 * Allow the iron-list to be sized properly. | 167 * Allow the iron-list to be sized properly. |
| 157 * @param {!Object} passwordsSection | 168 * @param {!Object} passwordsSection |
| 158 * @private | 169 * @private |
| 159 */ | 170 */ |
| 160 flushPasswordSection_: function(passwordsSection) { | 171 flushPasswordSection_: function(passwordsSection) { |
| 161 passwordsSection.$.passwordList.notifyResize(); | 172 passwordsSection.$.passwordList.notifyResize(); |
| 162 passwordsSection.$.passwordExceptionsList.notifyResize(); | |
| 163 Polymer.dom.flush(); | 173 Polymer.dom.flush(); |
| 164 }, | 174 }, |
| 165 }; | 175 }; |
| 166 | 176 |
| 167 /** | 177 /** |
| 168 * This test will validate that the section is loaded with data. | 178 * This test will validate that the section is loaded with data. |
| 169 */ | 179 */ |
| 170 TEST_F('SettingsPasswordSectionBrowserTest', 'uiTests', function() { | 180 TEST_F('SettingsPasswordSectionBrowserTest', 'uiTests', function() { |
| 171 var self = this; | 181 var self = this; |
| 172 | 182 |
| (...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 309 Polymer.dom.flush(); | 319 Polymer.dom.flush(); |
| 310 | 320 |
| 311 var expectedExceptionList = [ | 321 var expectedExceptionList = [ |
| 312 FakeDataMaker.exceptionEntry('docsshow.google.com'), | 322 FakeDataMaker.exceptionEntry('docsshow.google.com'), |
| 313 FakeDataMaker.exceptionEntry('showmail.com'), | 323 FakeDataMaker.exceptionEntry('showmail.com'), |
| 314 FakeDataMaker.exceptionEntry('mapsshow.google.com'), | 324 FakeDataMaker.exceptionEntry('mapsshow.google.com'), |
| 315 FakeDataMaker.exceptionEntry('plus.google.comshow'), | 325 FakeDataMaker.exceptionEntry('plus.google.comshow'), |
| 316 ]; | 326 ]; |
| 317 | 327 |
| 318 self.validateExceptionList_( | 328 self.validateExceptionList_( |
| 319 self.getIronListChildren_(passwordsSection.$.passwordExceptionsList), | 329 self.getDomRepeatChildren_(passwordsSection.$.passwordExceptionsList), |
| 320 expectedExceptionList); | 330 expectedExceptionList); |
| 321 }); | 331 }); |
| 322 | 332 |
| 323 test('verifyPasswordExceptions', function() { | 333 test('verifyPasswordExceptions', function() { |
| 324 var exceptionList = [ | 334 var exceptionList = [ |
| 325 FakeDataMaker.exceptionEntry('docs.google.com'), | 335 FakeDataMaker.exceptionEntry('docs.google.com'), |
| 326 FakeDataMaker.exceptionEntry('mail.com'), | 336 FakeDataMaker.exceptionEntry('mail.com'), |
| 327 FakeDataMaker.exceptionEntry('google.com'), | 337 FakeDataMaker.exceptionEntry('google.com'), |
| 328 FakeDataMaker.exceptionEntry('inbox.google.com'), | 338 FakeDataMaker.exceptionEntry('inbox.google.com'), |
| 329 FakeDataMaker.exceptionEntry('maps.google.com'), | 339 FakeDataMaker.exceptionEntry('maps.google.com'), |
| 330 FakeDataMaker.exceptionEntry('plus.google.com'), | 340 FakeDataMaker.exceptionEntry('plus.google.com'), |
| 331 ]; | 341 ]; |
| 332 | 342 |
| 333 var passwordsSection = self.createPasswordsSection_([], exceptionList); | 343 var passwordsSection = self.createPasswordsSection_([], exceptionList); |
| 334 | 344 |
| 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_( | 345 self.validateExceptionList_( |
| 341 self.getIronListChildren_(passwordsSection.$.passwordExceptionsList), | 346 self.getDomRepeatChildren_(passwordsSection.$.passwordExceptionsList), |
| 342 exceptionList); | 347 exceptionList); |
| 343 }); | 348 }); |
| 344 | 349 |
| 345 // Test verifies that removing an exception will update the elements. | 350 // Test verifies that removing an exception will update the elements. |
| 346 test('verifyPasswordExceptionRemove', function() { | 351 test('verifyPasswordExceptionRemove', function() { |
| 347 var exceptionList = [ | 352 var exceptionList = [ |
| 348 FakeDataMaker.exceptionEntry('docs.google.com'), | 353 FakeDataMaker.exceptionEntry('docs.google.com'), |
| 349 FakeDataMaker.exceptionEntry('mail.com'), | 354 FakeDataMaker.exceptionEntry('mail.com'), |
| 350 FakeDataMaker.exceptionEntry('google.com'), | 355 FakeDataMaker.exceptionEntry('google.com'), |
| 351 FakeDataMaker.exceptionEntry('inbox.google.com'), | 356 FakeDataMaker.exceptionEntry('inbox.google.com'), |
| 352 FakeDataMaker.exceptionEntry('maps.google.com'), | 357 FakeDataMaker.exceptionEntry('maps.google.com'), |
| 353 FakeDataMaker.exceptionEntry('plus.google.com'), | 358 FakeDataMaker.exceptionEntry('plus.google.com'), |
| 354 ]; | 359 ]; |
| 355 | 360 |
| 356 var passwordsSection = self.createPasswordsSection_([], exceptionList); | 361 var passwordsSection = self.createPasswordsSection_([], exceptionList); |
| 357 | 362 |
| 358 self.validateExceptionList_( | 363 self.validateExceptionList_( |
| 359 self.getIronListChildren_(passwordsSection.$.passwordExceptionsList), | 364 self.getDomRepeatChildren_(passwordsSection.$.passwordExceptionsList), |
| 360 exceptionList); | 365 exceptionList); |
| 361 | 366 |
| 362 // Simulate 'mail.com' being removed from the list. | 367 // Simulate 'mail.com' being removed from the list. |
| 363 passwordsSection.splice('passwordExceptions', 1, 1); | 368 passwordsSection.splice('passwordExceptions', 1, 1); |
| 364 assertFalse(self.exceptionsListContainsUrl( | 369 assertFalse(self.exceptionsListContainsUrl( |
| 365 passwordsSection.passwordExceptions, 'mail.com')); | 370 passwordsSection.passwordExceptions, 'mail.com')); |
| 366 assertFalse(self.exceptionsListContainsUrl(exceptionList, 'mail.com')); | 371 assertFalse(self.exceptionsListContainsUrl(exceptionList, 'mail.com')); |
| 367 self.flushPasswordSection_(passwordsSection); | 372 self.flushPasswordSection_(passwordsSection); |
| 368 | 373 |
| 369 self.validateExceptionList_( | 374 self.validateExceptionList_( |
| 370 self.getIronListChildren_(passwordsSection.$.passwordExceptionsList), | 375 self.getDomRepeatChildren_(passwordsSection.$.passwordExceptionsList), |
| 371 exceptionList); | 376 exceptionList); |
| 372 }); | 377 }); |
| 373 | 378 |
| 374 // Test verifies that pressing the 'remove' button will trigger a remove | 379 // Test verifies that pressing the 'remove' button will trigger a remove |
| 375 // event. Does not actually remove any exceptions. | 380 // event. Does not actually remove any exceptions. |
| 376 test('verifyPasswordExceptionRemoveButton', function(done) { | 381 test('verifyPasswordExceptionRemoveButton', function(done) { |
| 377 var exceptionList = [ | 382 var exceptionList = [ |
| 378 FakeDataMaker.exceptionEntry('docs.google.com'), | 383 FakeDataMaker.exceptionEntry('docs.google.com'), |
| 379 FakeDataMaker.exceptionEntry('mail.com'), | 384 FakeDataMaker.exceptionEntry('mail.com'), |
| 380 FakeDataMaker.exceptionEntry('google.com'), | 385 FakeDataMaker.exceptionEntry('google.com'), |
| 381 FakeDataMaker.exceptionEntry('inbox.google.com'), | 386 FakeDataMaker.exceptionEntry('inbox.google.com'), |
| 382 FakeDataMaker.exceptionEntry('maps.google.com'), | 387 FakeDataMaker.exceptionEntry('maps.google.com'), |
| 383 FakeDataMaker.exceptionEntry('plus.google.com'), | 388 FakeDataMaker.exceptionEntry('plus.google.com'), |
| 384 ]; | 389 ]; |
| 385 | 390 |
| 386 var passwordsSection = self.createPasswordsSection_([], exceptionList); | 391 var passwordsSection = self.createPasswordsSection_([], exceptionList); |
| 387 | 392 |
| 388 var exceptions = | 393 var exceptions = |
| 389 self.getIronListChildren_(passwordsSection.$.passwordExceptionsList); | 394 self.getDomRepeatChildren_(passwordsSection.$.passwordExceptionsList); |
| 390 | 395 |
| 391 // The index of the button currently being checked. | 396 // The index of the button currently being checked. |
| 392 var index = 0; | 397 var index = 0; |
| 393 | 398 |
| 394 var clickRemoveButton = function() { | 399 var clickRemoveButton = function() { |
| 395 MockInteractions.tap( | 400 MockInteractions.tap( |
| 396 exceptions[index].querySelector('#removeExceptionButton')); | 401 exceptions[index].querySelector('#removeExceptionButton')); |
| 397 }; | 402 }; |
| 398 | 403 |
| 399 // Listen for the remove event. If this event isn't received, the test | 404 // 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 Loading... | |
| 441 assertEquals(item.loginPair.username, event.detail.username); | 446 assertEquals(item.loginPair.username, event.detail.username); |
| 442 done(); | 447 done(); |
| 443 }); | 448 }); |
| 444 | 449 |
| 445 MockInteractions.tap(passwordDialog.$.showPasswordButton); | 450 MockInteractions.tap(passwordDialog.$.showPasswordButton); |
| 446 }); | 451 }); |
| 447 }); | 452 }); |
| 448 | 453 |
| 449 mocha.run(); | 454 mocha.run(); |
| 450 }); | 455 }); |
| OLD | NEW |