OLD | NEW |
---|---|
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 // None of these tests is relevant for Chrome OS. | 5 // None of these tests is relevant for Chrome OS. |
6 GEN('#if !defined(OS_CHROMEOS)'); | 6 GEN('#if !defined(OS_CHROMEOS)'); |
7 | 7 |
8 GEN('#include "base/command_line.h"'); | 8 GEN('#include "base/command_line.h"'); |
9 GEN('#include "chrome/common/chrome_switches.h"'); | 9 GEN('#include "chrome/common/chrome_switches.h"'); |
10 | 10 |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
133 assertNotEquals(-1, signedInText.textContent.indexOf(custodianEmail)); | 133 assertNotEquals(-1, signedInText.textContent.indexOf(custodianEmail)); |
134 | 134 |
135 CreateProfileOverlay.updateSignedInStatus(''); | 135 CreateProfileOverlay.updateSignedInStatus(''); |
136 assertEquals('', CreateProfileOverlay.getInstance().signedInEmail_); | 136 assertEquals('', CreateProfileOverlay.getInstance().signedInEmail_); |
137 assertTrue(signedInText.hidden); | 137 assertTrue(signedInText.hidden); |
138 assertFalse(notSignedInText.hidden); | 138 assertFalse(notSignedInText.hidden); |
139 assertFalse($('create-profile-managed').checked); | 139 assertFalse($('create-profile-managed').checked); |
140 assertTrue($('create-profile-managed').disabled); | 140 assertTrue($('create-profile-managed').disabled); |
141 }); | 141 }); |
142 | 142 |
143 function ManageProfileAsyncUITest() {} | |
Bernhard Bauer
2014/01/16 15:26:34
Nit: Async test fixtures are usually named <thing>
Adrian Kuegel
2014/01/16 15:51:38
Done.
| |
144 | |
145 ManageProfileAsyncUITest.prototype = { | |
146 __proto__: ManageProfileUITest.prototype, | |
147 | |
148 isAsync: true, | |
149 }; | |
150 | |
143 // The import link should show up if the user tries to create a profile with the | 151 // The import link should show up if the user tries to create a profile with the |
144 // same name as an existing managed user profile. | 152 // same name as an existing managed user profile. |
145 TEST_F('ManageProfileUITest', 'CreateExistingManagedUser', function() { | 153 TEST_F('ManageProfileAsyncUITest', 'CreateExistingManagedUser', function() { |
146 ManageProfileOverlay.getInstance().initializePage(); | |
147 var custodianEmail = 'chrome.playpen.test@gmail.com'; | |
148 CreateProfileOverlay.updateSignedInStatus(custodianEmail); | |
149 assertEquals(custodianEmail, | |
150 CreateProfileOverlay.getInstance().signedInEmail_); | |
151 this.setProfileManaged_(false, 'create'); | |
152 | |
153 // Initialize the list of existing managed users. | 154 // Initialize the list of existing managed users. |
154 var managedUserListData = options.ManagedUserListData.getInstance(); | 155 var managedUsers = [ |
155 managedUserListData.managedUsers_ = [ | |
156 { | 156 { |
157 id: 'managedUser1', | 157 id: 'managedUser1', |
158 name: 'Rosalie', | 158 name: 'Rosalie', |
159 iconURL: 'chrome://path/to/icon/image', | 159 iconURL: 'chrome://path/to/icon/image', |
160 onCurrentDevice: false, | 160 onCurrentDevice: false, |
161 needAvatar: false | 161 needAvatar: false |
162 }, | 162 }, |
163 { | 163 { |
164 id: 'managedUser2', | 164 id: 'managedUser2', |
165 name: 'Fritz', | 165 name: 'Fritz', |
166 iconURL: 'chrome://path/to/icon/image', | 166 iconURL: 'chrome://path/to/icon/image', |
167 onCurrentDevice: false, | 167 onCurrentDevice: false, |
168 needAvatar: true | 168 needAvatar: true |
169 }, | 169 }, |
170 { | 170 { |
171 id: 'managedUser3', | 171 id: 'managedUser3', |
172 name: 'Test', | 172 name: 'Test', |
173 iconURL: 'chrome://path/to/icon/image', | 173 iconURL: 'chrome://path/to/icon/image', |
174 onCurrentDevice: true, | 174 onCurrentDevice: true, |
175 needAvatar: false | 175 needAvatar: false |
176 }, | |
177 { | |
178 id: 'managedUser4', | |
179 name: 'SameName', | |
180 iconURL: 'chrome://path/to/icon/image', | |
181 onCurrentDevice: false, | |
182 needAvatar: false | |
176 }]; | 183 }]; |
177 // Also add the name 'Test' to |profileNames_| to simulate that the profile | 184 var promise = Promise.resolve(managedUsers); |
178 // exists on the device. | 185 options.ManagedUserListData.getInstance().promise_ = promise; |
186 | |
187 // Initialize the ManageProfileOverlay. | |
188 ManageProfileOverlay.getInstance().initializePage(); | |
189 var custodianEmail = 'chrome.playpen.test@gmail.com'; | |
190 CreateProfileOverlay.updateSignedInStatus(custodianEmail); | |
191 assertEquals(custodianEmail, | |
192 CreateProfileOverlay.getInstance().signedInEmail_); | |
193 this.setProfileManaged_(false, 'create'); | |
194 | |
195 // Also add the names 'Test' and 'Test2' to |profileNames_| to simulate that | |
196 // profiles with that names exist on the device. | |
Bernhard Bauer
2014/01/16 15:26:34
Nit: "with those names"
Adrian Kuegel
2014/01/16 15:51:38
Done.
| |
179 ManageProfileOverlay.getInstance().profileNames_.Test = true; | 197 ManageProfileOverlay.getInstance().profileNames_.Test = true; |
198 ManageProfileOverlay.getInstance().profileNames_.SameName = true; | |
180 | 199 |
181 // Initially, the ok button should be enabled and the import link should not | 200 // Initially, the ok button should be enabled and the import link should not |
182 // exist. | 201 // exist. |
183 assertFalse($('create-profile-ok').disabled); | 202 assertFalse($('create-profile-ok').disabled); |
184 assertTrue($('supervised-user-import') == null); | 203 assertTrue($('supervised-user-import') == null); |
185 | 204 |
186 // Now try to create profiles with the names of existing supervised users. | 205 // Now try to create profiles with the names of existing supervised users. |
187 $('create-profile-managed').checked = true; | 206 $('create-profile-managed').checked = true; |
188 var nameField = $('create-profile-name'); | 207 var nameField = $('create-profile-name'); |
189 // A profile which already has an avatar. | 208 // A profile which already has an avatar. |
190 nameField.value = 'Rosalie'; | 209 nameField.value = 'Rosalie'; |
191 ManageProfileOverlay.getInstance().onNameChanged_('create'); | 210 ManageProfileOverlay.getInstance().onNameChanged_('create'); |
192 assertTrue($('create-profile-ok').disabled); | 211 // Need to wait until the promise resolves. |
193 assertFalse($('supervised-user-import') == null); | 212 promise.then(function() { |
194 // A profile which doesn't have an avatar yet. | 213 assertTrue($('create-profile-ok').disabled); |
195 nameField.value = 'Fritz'; | 214 assertFalse($('supervised-user-import') == null); |
196 ManageProfileOverlay.getInstance().onNameChanged_('create'); | |
197 assertTrue($('create-profile-ok').disabled); | |
198 assertFalse($('supervised-user-import') == null); | |
199 // A profile which already exists on the device. | |
200 nameField.value = 'Test'; | |
201 ManageProfileOverlay.getInstance().onNameChanged_('create'); | |
202 assertTrue($('create-profile-ok').disabled); | |
203 assertTrue($('supervised-user-import') == null); | |
204 | 215 |
205 // A profile which does not exist yet. | 216 // A profile which doesn't have an avatar yet. |
206 nameField.value = 'NewProfileName'; | 217 nameField.value = 'Fritz'; |
207 ManageProfileOverlay.getInstance().onNameChanged_('create'); | 218 ManageProfileOverlay.getInstance().onNameChanged_('create'); |
208 assertFalse($('create-profile-ok').disabled); | 219 return options.ManagedUserListData.getInstance().promise_; |
209 assertTrue($('supervised-user-import') == null); | 220 }).then(function() { |
221 assertTrue($('create-profile-ok').disabled); | |
222 assertFalse($('supervised-user-import') == null); | |
223 | |
224 // A profile which already exists on the device. | |
225 nameField.value = 'Test'; | |
226 ManageProfileOverlay.getInstance().onNameChanged_('create'); | |
227 return options.ManagedUserListData.getInstance().promise_; | |
228 }).then(function() { | |
229 assertTrue($('create-profile-ok').disabled); | |
230 assertTrue($('supervised-user-import') == null); | |
231 | |
232 // A profile which does not exist on the device, but there is a profile with | |
233 // the same name already on the device. | |
234 nameField.value = 'SameName'; | |
235 ManageProfileOverlay.getInstance().onNameChanged_('create'); | |
236 return options.ManagedUserListData.getInstance().promise_; | |
237 }).then(function() { | |
238 assertTrue($('create-profile-ok').disabled); | |
239 assertFalse($('supervised-user-import') == null); | |
240 | |
241 // A profile which does not exist yet. | |
242 nameField.value = 'NewProfileName'; | |
243 ManageProfileOverlay.getInstance().onNameChanged_('create'); | |
244 return options.ManagedUserListData.getInstance().promise_; | |
245 }).then(function() { | |
246 assertFalse($('create-profile-ok').disabled); | |
247 assertTrue($('supervised-user-import') == null); | |
248 testDone(); | |
249 }); | |
210 }); | 250 }); |
211 | 251 |
212 // Managed users should not be able to edit their profile names, and the initial | 252 // Managed users should not be able to edit their profile names, and the initial |
213 // focus should be adjusted accordingly. | 253 // focus should be adjusted accordingly. |
214 TEST_F('ManageProfileUITest', 'EditManagedUserNameAllowed', function() { | 254 TEST_F('ManageProfileUITest', 'EditManagedUserNameAllowed', function() { |
215 var nameField = $('manage-profile-name'); | 255 var nameField = $('manage-profile-name'); |
216 | 256 |
217 this.setProfileManaged_(false, 'manage'); | 257 this.setProfileManaged_(false, 'manage'); |
218 ManageProfileOverlay.showManageDialog(); | 258 ManageProfileOverlay.showManageDialog(); |
219 expectFalse(nameField.disabled); | 259 expectFalse(nameField.disabled); |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
318 assertEquals('createProfile', OptionsPage.getTopmostVisiblePage().name); | 358 assertEquals('createProfile', OptionsPage.getTopmostVisiblePage().name); |
319 | 359 |
320 checkDialog('OneWord'); | 360 checkDialog('OneWord'); |
321 checkDialog('Multiple Words'); | 361 checkDialog('Multiple Words'); |
322 checkDialog('It\'s "<HTML> injection" & more!', | 362 checkDialog('It\'s "<HTML> injection" & more!', |
323 'It\'s "<HTML> injection" & more!', | 363 'It\'s "<HTML> injection" & more!', |
324 // The innerHTML getter doesn't escape quotation marks, | 364 // The innerHTML getter doesn't escape quotation marks, |
325 // independent of whether they were escaped in the setter. | 365 // independent of whether they were escaped in the setter. |
326 'It\'s "<HTML> injection" & more!'); | 366 'It\'s "<HTML> injection" & more!'); |
327 | 367 |
328 // Test elision. MAX_LENGTH = 50, minus 3 for the ellipsis. | 368 // Test elision. MAX_LENGTH = 50, minus 1 for the ellipsis. |
329 var name47Characters = '01234567890123456789012345678901234567890123456'; | 369 var name49Characters = '0123456789012345678901234567890123456789012345678'; |
330 var name60Characters = name47Characters + '0123456789012'; | 370 var name50Characters = name49Characters + '9'; |
331 checkDialog(name60Characters, name47Characters + '...'); | 371 var name51Characters = name50Characters + '0'; |
372 var name60Characters = name51Characters + '123456789'; | |
373 checkDialog(name49Characters, name49Characters); | |
374 checkDialog(name50Characters, name50Characters); | |
375 checkDialog(name51Characters, name49Characters + '\u2026'); | |
376 checkDialog(name60Characters, name49Characters + '\u2026'); | |
332 | 377 |
333 // Test both elision and HTML escaping. The allowed string length is the | 378 // Test both elision and HTML escaping. The allowed string length is the |
334 // visible length, not the length including the entity names. | 379 // visible length, not the length including the entity names. |
335 name47Characters = name47Characters.replace('0', '&').replace('1', '>'); | 380 name49Characters = name49Characters.replace('0', '&').replace('1', '>'); |
336 name60Characters = name60Characters.replace('0', '&').replace('1', '>'); | 381 name60Characters = name60Characters.replace('0', '&').replace('1', '>'); |
337 var escaped = name47Characters.replace('&', '&').replace('>', '>'); | 382 var escaped = name49Characters.replace('&', '&').replace('>', '>'); |
338 checkDialog(name60Characters, name47Characters + '...', escaped + '...'); | 383 checkDialog( |
384 name60Characters, name49Characters + '\u2026', escaped + '\u2026'); | |
339 }); | 385 }); |
340 | 386 |
341 // An additional warning should be shown when deleting a managed user. | 387 // An additional warning should be shown when deleting a managed user. |
342 TEST_F('ManageProfileUITest', 'DeleteManagedUserWarning', function() { | 388 TEST_F('ManageProfileUITest', 'DeleteManagedUserWarning', function() { |
343 var addendum = $('delete-managed-profile-addendum'); | 389 var addendum = $('delete-managed-profile-addendum'); |
344 | 390 |
345 ManageProfileOverlay.showDeleteDialog(this.testProfileInfo_(true)); | 391 ManageProfileOverlay.showDeleteDialog(this.testProfileInfo_(true)); |
346 assertFalse(addendum.hidden); | 392 assertFalse(addendum.hidden); |
347 | 393 |
348 ManageProfileOverlay.showDeleteDialog(this.testProfileInfo_(false)); | 394 ManageProfileOverlay.showDeleteDialog(this.testProfileInfo_(false)); |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
462 chromeSendMessages.push(message); | 508 chromeSendMessages.push(message); |
463 }; | 509 }; |
464 $('delete-profile-ok').onclick(); | 510 $('delete-profile-ok').onclick(); |
465 // Restore the original function so the test framework can use it. | 511 // Restore the original function so the test framework can use it. |
466 chrome.send = originalChromeSend; | 512 chrome.send = originalChromeSend; |
467 return chromeSendMessages; | 513 return chromeSendMessages; |
468 } | 514 } |
469 | 515 |
470 this.setProfileManaged_(false, 'manage'); | 516 this.setProfileManaged_(false, 'manage'); |
471 var messages = clickAndListen(); | 517 var messages = clickAndListen(); |
472 assertEquals(2, messages.length); | 518 assertEquals(1, messages.length); |
473 assertEquals('deleteProfile', messages[0]); | 519 assertEquals('deleteProfile', messages[0]); |
474 assertEquals('requestManagedUserImportUpdate', messages[1]); | |
475 assertEquals('settings', OptionsPage.getTopmostVisiblePage().name); | 520 assertEquals('settings', OptionsPage.getTopmostVisiblePage().name); |
476 | 521 |
477 ManageProfileOverlay.showDeleteDialog(this.testProfileInfo_(false)); | 522 ManageProfileOverlay.showDeleteDialog(this.testProfileInfo_(false)); |
478 this.setProfileManaged_(true, 'manage'); | 523 this.setProfileManaged_(true, 'manage'); |
479 messages = clickAndListen(); | 524 messages = clickAndListen(); |
480 assertEquals(0, messages.length); | 525 assertEquals(0, messages.length); |
481 assertEquals('settings', OptionsPage.getTopmostVisiblePage().name); | 526 assertEquals('settings', OptionsPage.getTopmostVisiblePage().name); |
482 }); | 527 }); |
483 | 528 |
484 GEN('#endif // OS_CHROMEOS'); | 529 GEN('#endif // OS_CHROMEOS'); |
OLD | NEW |