| 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('settings_people_page_manage_profile', function() { | 5 cr.define('settings_people_page_manage_profile', function() { |
| 6 /** | 6 /** |
| 7 * @constructor | 7 * @constructor |
| 8 * @implements {settings.ManageProfileBrowserProxy} | 8 * @implements {settings.ManageProfileBrowserProxy} |
| 9 * @extends {settings.TestBrowserProxy} | 9 * @extends {settings.TestBrowserProxy} |
| 10 */ | 10 */ |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 46 document.body.appendChild(manageProfile); | 46 document.body.appendChild(manageProfile); |
| 47 }); | 47 }); |
| 48 | 48 |
| 49 teardown(function() { manageProfile.remove(); }); | 49 teardown(function() { manageProfile.remove(); }); |
| 50 | 50 |
| 51 // Tests that the manage profile subpage | 51 // Tests that the manage profile subpage |
| 52 // - gets and receives all the available icons | 52 // - gets and receives all the available icons |
| 53 // - has the correct icon selected | 53 // - has the correct icon selected |
| 54 // - can select a new icon | 54 // - can select a new icon |
| 55 test('ManageProfileChangeIcon', function() { | 55 test('ManageProfileChangeIcon', function() { |
| 56 var selector = manageProfile.$.selector.$.selector; | 56 var selector = manageProfile.$.selector.$['avatar-grid']; |
| 57 assertTrue(!!selector); | 57 assertTrue(!!selector); |
| 58 | 58 |
| 59 return browserProxy.whenCalled('getAvailableIcons').then(function() { | 59 return browserProxy.whenCalled('getAvailableIcons').then(function() { |
| 60 Polymer.dom.flush(); | 60 Polymer.dom.flush(); |
| 61 | 61 |
| 62 assertEquals('fake-icon-1.png', manageProfile.profileIconUrl); | 62 assertEquals('fake-icon-1.png', manageProfile.profileIconUrl); |
| 63 assertEquals(2, selector.items.length); | 63 assertEquals(2, selector.items.length); |
| 64 assertTrue(selector.items[0].classList.contains('iron-selected')); | 64 assertTrue(selector.items[0].classList.contains('iron-selected')); |
| 65 assertFalse(selector.items[1].classList.contains('iron-selected')); | 65 assertFalse(selector.items[1].classList.contains('iron-selected')); |
| 66 | 66 |
| 67 MockInteractions.tap(selector.items[1]); | 67 MockInteractions.tap(selector.items[1]); |
| 68 return browserProxy.whenCalled('setProfileIconAndName').then( | 68 return browserProxy.whenCalled('setProfileIconAndName').then( |
| 69 function(args) { | 69 function(args) { |
| 70 assertEquals('fake-icon-2.png', args[0]); | 70 assertEquals('fake-icon-2.png', args[0]); |
| 71 assertEquals('Initial Fake Name', args[1]); | 71 assertEquals('Initial Fake Name', args[1]); |
| 72 }); | 72 }); |
| 73 }); | 73 }); |
| 74 }); | 74 }); |
| 75 | 75 |
| 76 // Tests profile icon updates pushed from the browser. | 76 // Tests profile icon updates pushed from the browser. |
| 77 test('ManageProfileIconUpdated', function() { | 77 test('ManageProfileIconUpdated', function() { |
| 78 var selector = manageProfile.$.selector.$.selector; | 78 var selector = manageProfile.$.selector.$['avatar-grid']; |
| 79 assertTrue(!!selector); | 79 assertTrue(!!selector); |
| 80 | 80 |
| 81 return browserProxy.whenCalled('getAvailableIcons').then(function() { | 81 return browserProxy.whenCalled('getAvailableIcons').then(function() { |
| 82 manageProfile.profileIconUrl = 'fake-icon-2.png'; | 82 manageProfile.profileIconUrl = 'fake-icon-2.png'; |
| 83 | 83 |
| 84 Polymer.dom.flush(); | 84 Polymer.dom.flush(); |
| 85 | 85 |
| 86 assertEquals('fake-icon-2.png', manageProfile.profileIconUrl); | 86 assertEquals('fake-icon-2.png', manageProfile.profileIconUrl); |
| 87 assertEquals(2, selector.items.length); | 87 assertEquals(2, selector.items.length); |
| 88 assertFalse(selector.items[0].classList.contains('iron-selected')); | 88 assertFalse(selector.items[0].classList.contains('iron-selected')); |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 121 }); | 121 }); |
| 122 }); | 122 }); |
| 123 } | 123 } |
| 124 | 124 |
| 125 return { | 125 return { |
| 126 registerTests: function() { | 126 registerTests: function() { |
| 127 registerManageProfileTests(); | 127 registerManageProfileTests(); |
| 128 }, | 128 }, |
| 129 }; | 129 }; |
| 130 }); | 130 }); |
| OLD | NEW |