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 {TestBrowserProxy} | 9 * @extends {TestBrowserProxy} |
10 */ | 10 */ |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
87 manageProfile.profileName = 'Initial Fake Name'; | 87 manageProfile.profileName = 'Initial Fake Name'; |
88 manageProfile.syncStatus = {supervisedUser: false, childUser: false}; | 88 manageProfile.syncStatus = {supervisedUser: false, childUser: false}; |
89 document.body.appendChild(manageProfile); | 89 document.body.appendChild(manageProfile); |
90 settings.navigateTo(settings.Route.MANAGE_PROFILE); | 90 settings.navigateTo(settings.Route.MANAGE_PROFILE); |
91 }); | 91 }); |
92 | 92 |
93 teardown(function() { manageProfile.remove(); }); | 93 teardown(function() { manageProfile.remove(); }); |
94 | 94 |
95 // Tests that the manage profile subpage | 95 // Tests that the manage profile subpage |
96 // - gets and receives all the available icons | 96 // - gets and receives all the available icons |
97 // - has the correct icon selected | |
98 // - can select a new icon | 97 // - can select a new icon |
99 test('ManageProfileChangeIcon', function() { | 98 test('ManageProfileChangeIcon', function() { |
100 var selector = manageProfile.$.selector.$['avatar-grid']; | 99 var items = null; |
101 assertTrue(!!selector); | |
102 | |
103 return browserProxy.whenCalled('getAvailableIcons') | 100 return browserProxy.whenCalled('getAvailableIcons') |
104 .then(function() { | 101 .then(function() { |
105 Polymer.dom.flush(); | 102 Polymer.dom.flush(); |
| 103 items = manageProfile.$.selector.$['avatar-grid']. |
| 104 querySelectorAll('.avatar'); |
106 | 105 |
107 assertEquals('fake-icon-1.png', manageProfile.profileIconUrl); | 106 // Initially no item is selected, because of crbug.com/710660. |
108 assertEquals(3, selector.items.length); | 107 assertFalse(!!manageProfile.profileAvatar); |
109 assertTrue(selector.items[0].classList.contains('iron-selected')); | 108 assertEquals(3, items.length); |
110 assertFalse( | 109 assertFalse(items[0].classList.contains('iron-selected')); |
111 selector.items[1].classList.contains('iron-selected')); | 110 assertFalse(items[1].classList.contains('iron-selected')); |
112 assertFalse( | 111 assertFalse(items[2].classList.contains('iron-selected')); |
113 selector.items[2].classList.contains('iron-selected')); | |
114 | 112 |
115 MockInteractions.tap(selector.items[1]); | 113 MockInteractions.tap(items[1]); |
116 return browserProxy.whenCalled('setProfileIconToDefaultAvatar'); | 114 return browserProxy.whenCalled('setProfileIconToDefaultAvatar'); |
117 }) | 115 }) |
118 .then(function(args) { | 116 .then(function(args) { |
119 assertEquals('fake-icon-2.png', args[0]); | 117 assertEquals('fake-icon-2.png', args[0]); |
120 | 118 |
121 MockInteractions.tap(selector.items[2]); | 119 MockInteractions.tap(items[2]); |
122 return browserProxy.whenCalled('setProfileIconToGaiaAvatar'); | 120 return browserProxy.whenCalled('setProfileIconToGaiaAvatar'); |
123 }); | 121 }); |
124 }); | 122 }); |
125 | 123 |
126 // Tests profile icon updates pushed from the browser. | |
127 test('ManageProfileIconUpdated', function() { | |
128 var selector = manageProfile.$.selector.$['avatar-grid']; | |
129 assertTrue(!!selector); | |
130 | |
131 return browserProxy.whenCalled('getAvailableIcons').then(function() { | |
132 manageProfile.profileIconUrl = 'fake-icon-2.png'; | |
133 | |
134 Polymer.dom.flush(); | |
135 | |
136 assertEquals('fake-icon-2.png', manageProfile.profileIconUrl); | |
137 assertEquals(3, selector.items.length); | |
138 assertFalse(selector.items[0].classList.contains('iron-selected')); | |
139 assertTrue(selector.items[1].classList.contains('iron-selected')); | |
140 assertFalse(selector.items[2].classList.contains('iron-selected')); | |
141 }); | |
142 }); | |
143 | |
144 test('ManageProfileChangeName', function() { | 124 test('ManageProfileChangeName', function() { |
145 var nameField = manageProfile.$.name; | 125 var nameField = manageProfile.$.name; |
146 assertTrue(!!nameField); | 126 assertTrue(!!nameField); |
147 assertFalse(!!nameField.disabled); | 127 assertFalse(!!nameField.disabled); |
148 | 128 |
149 assertEquals('Initial Fake Name', nameField.value); | 129 assertEquals('Initial Fake Name', nameField.value); |
150 | 130 |
151 nameField.value = 'New Name'; | 131 nameField.value = 'New Name'; |
152 nameField.fire('change'); | 132 nameField.fire('change'); |
153 | 133 |
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
286 }); | 266 }); |
287 }); | 267 }); |
288 } | 268 } |
289 | 269 |
290 return { | 270 return { |
291 registerTests: function() { | 271 registerTests: function() { |
292 registerManageProfileTests(); | 272 registerManageProfileTests(); |
293 }, | 273 }, |
294 }; | 274 }; |
295 }); | 275 }); |
OLD | NEW |