| 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 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 105 * @param {!Array<!string>} exceptionList | 105 * @param {!Array<!string>} exceptionList |
| 106 * @return {!Object} | 106 * @return {!Object} |
| 107 * @private | 107 * @private |
| 108 */ | 108 */ |
| 109 createPasswordsSection_: function(passwordList, exceptionList) { | 109 createPasswordsSection_: function(passwordList, exceptionList) { |
| 110 // Create a passwords-section to use for testing. | 110 // Create a passwords-section to use for testing. |
| 111 var passwordsSection = document.createElement('passwords-section'); | 111 var passwordsSection = document.createElement('passwords-section'); |
| 112 passwordsSection.savedPasswords = passwordList; | 112 passwordsSection.savedPasswords = passwordList; |
| 113 passwordsSection.passwordExceptions = exceptionList; | 113 passwordsSection.passwordExceptions = exceptionList; |
| 114 document.body.appendChild(passwordsSection); | 114 document.body.appendChild(passwordsSection); |
| 115 | 115 this.flush_(passwordsSection); |
| 116 // Allow polymer binding to finish. | |
| 117 Polymer.dom.flush(); | |
| 118 | |
| 119 return passwordsSection; | 116 return passwordsSection; |
| 120 }, | 117 }, |
| 121 | 118 |
| 122 /** | 119 /** |
| 123 * Helper method used to test for a url in a list of passwords. | 120 * Helper method used to test for a url in a list of passwords. |
| 124 * @param {!Array<!chrome.passwordsPrivate.PasswordUiEntry>} passwordList | 121 * @param {!Array<!chrome.passwordsPrivate.PasswordUiEntry>} passwordList |
| 125 * @param {!String} url The URL that is being searched for. | 122 * @param {!String} url The URL that is being searched for. |
| 126 */ | 123 */ |
| 127 listContainsUrl(passwordList, url) { | 124 listContainsUrl(passwordList, url) { |
| 128 for (var i = 0; i < passwordList.length; ++i) { | 125 for (var i = 0; i < passwordList.length; ++i) { |
| 129 if (passwordList[i].loginPair.originUrl == url) | 126 if (passwordList[i].loginPair.originUrl == url) |
| 130 return true; | 127 return true; |
| 131 } | 128 } |
| 132 return false; | 129 return false; |
| 133 }, | 130 }, |
| 131 |
| 132 /** |
| 133 * Allow the iron-list to be sized properly. |
| 134 * @param {!Object} passwordsSection |
| 135 * @private |
| 136 */ |
| 137 flush_: function(passwordsSection) { |
| 138 passwordsSection.$.passwordList.notifyResize(); |
| 139 passwordsSection.$.passwordExceptionsList.notifyResize(); |
| 140 Polymer.dom.flush(); |
| 141 }, |
| 134 }; | 142 }; |
| 135 | 143 |
| 136 /** | 144 /** |
| 137 * This test will validate that the section is loaded with data. | 145 * This test will validate that the section is loaded with data. |
| 138 */ | 146 */ |
| 139 TEST_F('SettingsPasswordSectionBrowserTest', 'uiTests', function() { | 147 TEST_F('SettingsPasswordSectionBrowserTest', 'uiTests', function() { |
| 140 var self = this; | 148 var self = this; |
| 141 | 149 |
| 142 suite('PasswordsSection', function() { | 150 suite('PasswordsSection', function() { |
| 143 test('verifySavedPasswordLength', function() { | 151 test('verifySavedPasswordLength', function() { |
| (...skipping 27 matching lines...) Expand all Loading... |
| 171 self.createPasswordItem_('website.com', 'mario', 70) | 179 self.createPasswordItem_('website.com', 'mario', 70) |
| 172 ]; | 180 ]; |
| 173 | 181 |
| 174 var passwordsSection = self.createPasswordsSection_(passwordList, []); | 182 var passwordsSection = self.createPasswordsSection_(passwordList, []); |
| 175 | 183 |
| 176 self.validatePasswordList( | 184 self.validatePasswordList( |
| 177 self.getIronListChildren_(passwordsSection.$.passwordList), | 185 self.getIronListChildren_(passwordsSection.$.passwordList), |
| 178 passwordList); | 186 passwordList); |
| 179 // Simulate 'longwebsite.com' being removed from the list. | 187 // Simulate 'longwebsite.com' being removed from the list. |
| 180 passwordsSection.splice('savedPasswords', 1, 1); | 188 passwordsSection.splice('savedPasswords', 1, 1); |
| 181 Polymer.dom.flush(); | 189 self.flush_(passwordsSection); |
| 182 | 190 |
| 183 assertFalse(self.listContainsUrl(passwordsSection.savedPasswords, | 191 assertFalse(self.listContainsUrl(passwordsSection.savedPasswords, |
| 184 'longwebsite.com')); | 192 'longwebsite.com')); |
| 185 assertFalse(self.listContainsUrl(passwordList, 'longwebsite.com')); | 193 assertFalse(self.listContainsUrl(passwordList, 'longwebsite.com')); |
| 186 | 194 |
| 187 self.validatePasswordList( | 195 self.validatePasswordList( |
| 188 self.getIronListChildren_(passwordsSection.$.passwordList), | 196 self.getIronListChildren_(passwordsSection.$.passwordList), |
| 189 passwordList); | 197 passwordList); |
| 190 }); | 198 }); |
| 191 | 199 |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 273 var passwordsSection = self.createPasswordsSection_([], exceptionList); | 281 var passwordsSection = self.createPasswordsSection_([], exceptionList); |
| 274 | 282 |
| 275 self.validateExceptionList_( | 283 self.validateExceptionList_( |
| 276 self.getIronListChildren_(passwordsSection.$.passwordExceptionsList), | 284 self.getIronListChildren_(passwordsSection.$.passwordExceptionsList), |
| 277 exceptionList); | 285 exceptionList); |
| 278 | 286 |
| 279 // Simulate 'mail.com' being removed from the list. | 287 // Simulate 'mail.com' being removed from the list. |
| 280 passwordsSection.splice('passwordExceptions', 1, 1); | 288 passwordsSection.splice('passwordExceptions', 1, 1); |
| 281 assertEquals(-1, passwordsSection.passwordExceptions.indexOf('mail.com')); | 289 assertEquals(-1, passwordsSection.passwordExceptions.indexOf('mail.com')); |
| 282 assertEquals(-1, exceptionList.indexOf('mail.com')); | 290 assertEquals(-1, exceptionList.indexOf('mail.com')); |
| 283 Polymer.dom.flush(); | 291 self.flush_(passwordsSection); |
| 284 | 292 |
| 285 self.validateExceptionList_( | 293 self.validateExceptionList_( |
| 286 self.getIronListChildren_(passwordsSection.$.passwordExceptionsList), | 294 self.getIronListChildren_(passwordsSection.$.passwordExceptionsList), |
| 287 exceptionList); | 295 exceptionList); |
| 288 }); | 296 }); |
| 289 | 297 |
| 290 // Test verifies that pressing the 'remove' button will trigger a remove | 298 // Test verifies that pressing the 'remove' button will trigger a remove |
| 291 // event. Does not actually remove any exceptions. | 299 // event. Does not actually remove any exceptions. |
| 292 test('verifyPasswordExceptionRemoveButton', function(done) { | 300 test('verifyPasswordExceptionRemoveButton', function(done) { |
| 293 var exceptionList = [ | 301 var exceptionList = [ |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 325 done(); | 333 done(); |
| 326 }); | 334 }); |
| 327 | 335 |
| 328 // Start removing. | 336 // Start removing. |
| 329 clickRemoveButton(); | 337 clickRemoveButton(); |
| 330 }); | 338 }); |
| 331 }); | 339 }); |
| 332 | 340 |
| 333 mocha.run(); | 341 mocha.run(); |
| 334 }); | 342 }); |
| OLD | NEW |