Chromium Code Reviews| Index: chrome/browser/ui/webui/options/manage_profile_browsertest.js |
| diff --git a/chrome/browser/ui/webui/options/manage_profile_browsertest.js b/chrome/browser/ui/webui/options/manage_profile_browsertest.js |
| index a592709c88f55b984971102cbe078960cbbe54e8..2868aa454042c94063d38360cf1a7304673ad2ba 100644 |
| --- a/chrome/browser/ui/webui/options/manage_profile_browsertest.js |
| +++ b/chrome/browser/ui/webui/options/manage_profile_browsertest.js |
| @@ -151,13 +151,13 @@ TEST_F('ManageProfileUITest', 'CreateExistingManagedUser', function() { |
| this.setProfileManaged_(false, 'create'); |
| // Initialize the list of existing managed users. |
| - var managedUserListData = options.ManagedUserListData.getInstance(); |
| - managedUserListData.managedUsers_ = [ |
|
Bernhard Bauer
2014/01/10 13:52:08
Would this work if you inject a fulfilled promise
Adrian Kuegel
2014/01/10 16:52:01
Yes, it does. Thanks for the suggestion.
|
| + var managedUsers = [ |
| { |
| id: 'managedUser1', |
| name: 'Rosalie', |
| iconURL: 'chrome://path/to/icon/image', |
| onCurrentDevice: false, |
| + nameConflict: false, |
| needAvatar: false |
| }, |
| { |
| @@ -165,6 +165,7 @@ TEST_F('ManageProfileUITest', 'CreateExistingManagedUser', function() { |
| name: 'Fritz', |
| iconURL: 'chrome://path/to/icon/image', |
| onCurrentDevice: false, |
| + nameConflict: false, |
| needAvatar: true |
| }, |
| { |
| @@ -172,8 +173,10 @@ TEST_F('ManageProfileUITest', 'CreateExistingManagedUser', function() { |
| name: 'Test', |
| iconURL: 'chrome://path/to/icon/image', |
| onCurrentDevice: true, |
| + nameConflict: true, |
| needAvatar: false |
| }]; |
| + options.ManagedUserListData.receiveExistingManagedUsers(managedUsers); |
| // Also add the name 'Test' to |profileNames_| to simulate that the profile |
| // exists on the device. |
| ManageProfileOverlay.getInstance().profileNames_.Test = true; |
| @@ -189,24 +192,28 @@ TEST_F('ManageProfileUITest', 'CreateExistingManagedUser', function() { |
| // A profile which already has an avatar. |
| nameField.value = 'Rosalie'; |
| ManageProfileOverlay.getInstance().onNameChanged_('create'); |
| - assertTrue($('create-profile-ok').disabled); |
| - assertFalse($('supervised-user-import') == null); |
| - // A profile which doesn't have an avatar yet. |
| - nameField.value = 'Fritz'; |
| - ManageProfileOverlay.getInstance().onNameChanged_('create'); |
| - assertTrue($('create-profile-ok').disabled); |
| - assertFalse($('supervised-user-import') == null); |
| - // A profile which already exists on the device. |
| - nameField.value = 'Test'; |
| - ManageProfileOverlay.getInstance().onNameChanged_('create'); |
| - assertTrue($('create-profile-ok').disabled); |
| - assertTrue($('supervised-user-import') == null); |
| - |
| - // A profile which does not exist yet. |
| - nameField.value = 'NewProfileName'; |
| - ManageProfileOverlay.getInstance().onNameChanged_('create'); |
| - assertFalse($('create-profile-ok').disabled); |
| - assertTrue($('supervised-user-import') == null); |
| + // Need to wait until the promise resolves for the first time. The first time |
| + // resolves asynchronously even if the resolve method was already called. Bug? |
| + options.ManagedUserListData.getInstance().promise_.then(function() { |
| + assertTrue($('create-profile-ok').disabled); |
| + assertFalse($('supervised-user-import') == null); |
| + // A profile which doesn't have an avatar yet. |
| + nameField.value = 'Fritz'; |
| + ManageProfileOverlay.getInstance().onNameChanged_('create'); |
| + assertTrue($('create-profile-ok').disabled); |
| + assertFalse($('supervised-user-import') == null); |
| + // A profile which already exists on the device. |
| + nameField.value = 'Test'; |
| + ManageProfileOverlay.getInstance().onNameChanged_('create'); |
| + assertTrue($('create-profile-ok').disabled); |
| + assertTrue($('supervised-user-import') == null); |
| + |
| + // A profile which does not exist yet. |
| + nameField.value = 'NewProfileName'; |
| + ManageProfileOverlay.getInstance().onNameChanged_('create'); |
| + assertFalse($('create-profile-ok').disabled); |
| + assertTrue($('supervised-user-import') == null); |
| + }); |
| }); |
| // Managed users should not be able to edit their profile names, and the initial |
| @@ -328,14 +335,15 @@ TEST_F('ManageProfileUITest', 'CreateConfirmationText', function () { |
| // Test elision. MAX_LENGTH = 50, minus 3 for the ellipsis. |
| var name47Characters = '01234567890123456789012345678901234567890123456'; |
| var name60Characters = name47Characters + '0123456789012'; |
| - checkDialog(name60Characters, name47Characters + '...'); |
| + checkDialog(name60Characters, name47Characters + '\u2026'); |
| // Test both elision and HTML escaping. The allowed string length is the |
| // visible length, not the length including the entity names. |
| name47Characters = name47Characters.replace('0', '&').replace('1', '>'); |
| name60Characters = name60Characters.replace('0', '&').replace('1', '>'); |
| var escaped = name47Characters.replace('&', '&').replace('>', '>'); |
| - checkDialog(name60Characters, name47Characters + '...', escaped + '...'); |
| + checkDialog( |
| + name60Characters, name47Characters + '\u2026', escaped + '\u2026'); |
| }); |
| // An additional warning should be shown when deleting a managed user. |
| @@ -469,9 +477,8 @@ TEST_F('ManageProfileUITest', 'ManagedDelete', function() { |
| this.setProfileManaged_(false, 'manage'); |
| var messages = clickAndListen(); |
| - assertEquals(2, messages.length); |
| + assertEquals(1, messages.length); |
| assertEquals('deleteProfile', messages[0]); |
| - assertEquals('requestManagedUserImportUpdate', messages[1]); |
| assertEquals('settings', OptionsPage.getTopmostVisiblePage().name); |
| ManageProfileOverlay.showDeleteDialog(this.testProfileInfo_(false)); |