| OLD | NEW |
| 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 cr.define('user_manager.create_profile_tests', function() { | 5 cr.define('user_manager.create_profile_tests', function() { |
| 6 /** @return {!CreateProfileElement} */ | 6 /** @return {!CreateProfileElement} */ |
| 7 function createElement() { | 7 function createElement() { |
| 8 PolymerTest.clearBody(); | |
| 9 var createProfileElement = document.createElement('create-profile'); | 8 var createProfileElement = document.createElement('create-profile'); |
| 10 document.body.appendChild(createProfileElement); | 9 document.body.appendChild(createProfileElement); |
| 11 return createProfileElement; | 10 return createProfileElement; |
| 12 } | 11 } |
| 13 | 12 |
| 14 function registerTests() { | 13 function registerTests() { |
| 15 /** @type {?TestProfileBrowserProxy} */ | 14 /** @type {?TestProfileBrowserProxy} */ |
| 16 var browserProxy = null; | 15 var browserProxy = null; |
| 17 | 16 |
| 18 /** @type {?CreateProfileElement} */ | 17 /** @type {?CreateProfileElement} */ |
| (...skipping 14 matching lines...) Expand all Loading... |
| 33 onCurrentDevice: true}, | 32 onCurrentDevice: true}, |
| 34 {name: 'existing name 2', | 33 {name: 'existing name 2', |
| 35 onCurrentDevice: false}]); | 34 onCurrentDevice: false}]); |
| 36 | 35 |
| 37 createProfileElement = createElement(); | 36 createProfileElement = createElement(); |
| 38 | 37 |
| 39 // Make sure DOM is up to date. | 38 // Make sure DOM is up to date. |
| 40 Polymer.dom.flush(); | 39 Polymer.dom.flush(); |
| 41 }); | 40 }); |
| 42 | 41 |
| 43 teardown(function() { createProfileElement.remove(); }); | 42 teardown(function(done) { |
| 43 createProfileElement.remove(); |
| 44 // Allow asynchronous tasks to finish. |
| 45 setTimeout(done); |
| 46 }); |
| 44 | 47 |
| 45 test('Handles available profile icons', function() { | 48 test('Handles available profile icons', function() { |
| 46 return browserProxy.whenCalled('getAvailableIcons').then(function() { | 49 return browserProxy.whenCalled('getAvailableIcons').then(function() { |
| 47 assertEquals('icon1.png', createProfileElement.profileIconUrl_); | 50 assertEquals('icon1.png', createProfileElement.profileIconUrl_); |
| 48 }); | 51 }); |
| 49 }); | 52 }); |
| 50 | 53 |
| 51 test('Handles signed in users', function() { | 54 test('Handles signed in users', function() { |
| 52 return browserProxy.whenCalled('getSignedInUsers').then(function() { | 55 return browserProxy.whenCalled('getSignedInUsers').then(function() { |
| 53 assertEquals(1, createProfileElement.signedInUsers_.length); | 56 assertEquals(1, createProfileElement.signedInUsers_.length); |
| (...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 368 signin.ProfileBrowserProxyImpl.instance_ = browserProxy; | 371 signin.ProfileBrowserProxyImpl.instance_ = browserProxy; |
| 369 | 372 |
| 370 browserProxy.setIcons([{url: 'icon1.png', label: 'icon1'}]); | 373 browserProxy.setIcons([{url: 'icon1.png', label: 'icon1'}]); |
| 371 | 374 |
| 372 createProfileElement = createElement(); | 375 createProfileElement = createElement(); |
| 373 | 376 |
| 374 // Make sure DOM is up to date. | 377 // Make sure DOM is up to date. |
| 375 Polymer.dom.flush(); | 378 Polymer.dom.flush(); |
| 376 }); | 379 }); |
| 377 | 380 |
| 378 teardown(function() { createProfileElement.remove(); }); | 381 teardown(function(done) { |
| 382 createProfileElement.remove(); |
| 383 // Allow asynchronous tasks to finish. |
| 384 setTimeout(done); |
| 385 }); |
| 379 | 386 |
| 380 test('Handles no signed in users', function() { | 387 test('Handles no signed in users', function() { |
| 381 return browserProxy.whenCalled('getSignedInUsers').then(function() { | 388 return browserProxy.whenCalled('getSignedInUsers').then(function() { |
| 382 assertEquals(0, createProfileElement.signedInUsers_.length); | 389 assertEquals(0, createProfileElement.signedInUsers_.length); |
| 383 | 390 |
| 384 // Simulate checking the checkbox. | 391 // Simulate checking the checkbox. |
| 385 MockInteractions.tap(createProfileElement.$$('paper-checkbox')); | 392 MockInteractions.tap(createProfileElement.$$('paper-checkbox')); |
| 386 Polymer.dom.flush(); | 393 Polymer.dom.flush(); |
| 387 | 394 |
| 388 // The dropdown menu is not visible when there are no signed in users. | 395 // The dropdown menu is not visible when there are no signed in users. |
| 389 assertFalse(!!createProfileElement.$$('paper-dropdown-menu')); | 396 assertFalse(!!createProfileElement.$$('paper-dropdown-menu')); |
| 390 | 397 |
| 391 // Instead a message containing a link to the Help Center on how | 398 // Instead a message containing a link to the Help Center on how |
| 392 // to sign in to Chrome is displaying. | 399 // to sign in to Chrome is displaying. |
| 393 assertTrue(!!createProfileElement.$$('#sign-in-to-chrome')); | 400 assertTrue(!!createProfileElement.$$('#sign-in-to-chrome')); |
| 394 }); | 401 }); |
| 395 }); | 402 }); |
| 396 | 403 |
| 397 test('Create button is disabled', function() { | 404 test('Create button is disabled', function() { |
| 398 assertTrue(createProfileElement.$.save.disabled); | 405 assertTrue(createProfileElement.$.save.disabled); |
| 399 }); | 406 }); |
| 400 }); | 407 }); |
| 401 } | 408 } |
| 402 | 409 |
| 403 return { | 410 return { |
| 404 registerTests: registerTests, | 411 registerTests: registerTests, |
| 405 }; | 412 }; |
| 406 }); | 413 }); |
| OLD | NEW |