Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(99)

Side by Side Diff: chrome/browser/ui/webui/options/manage_profile_browsertest.js

Issue 403343002: Rename "managed (mode|user)" to "supervised user" (part 8) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 /** 8 /**
9 * TestFixture for ManageProfileOverlay and CreateProfileOverlay WebUI testing. 9 * TestFixture for ManageProfileOverlay and CreateProfileOverlay WebUI testing.
10 * @extends {testing.Test} 10 * @extends {testing.Test}
(...skipping 14 matching lines...) Expand all
25 */ 25 */
26 runAccessibilityChecks: false, 26 runAccessibilityChecks: false,
27 27
28 /** 28 /**
29 * Some default profile infos. 29 * Some default profile infos.
30 */ 30 */
31 defaultIconURLs: [], 31 defaultIconURLs: [],
32 defaultNames: [], 32 defaultNames: [],
33 33
34 /** 34 /**
35 * Returns a test profile-info object with configurable "managed" status. 35 * Returns a test profile-info object with configurable "supervised" status.
36 * @param {boolean} managed If true, the test profile will be marked as 36 * @param {boolean} supervised If true, the test profile will be marked as
37 * managed. 37 * supervised.
38 * @return {Object} A test profile-info object. 38 * @return {Object} A test profile-info object.
39 */ 39 */
40 testProfileInfo_: function(managed) { 40 testProfileInfo_: function(supervised) {
41 return { 41 return {
42 name: 'Test Profile', 42 name: 'Test Profile',
43 iconURL: 'chrome://path/to/icon/image', 43 iconURL: 'chrome://path/to/icon/image',
44 filePath: '/path/to/profile/data/on/disk', 44 filePath: '/path/to/profile/data/on/disk',
45 isCurrentProfile: true, 45 isCurrentProfile: true,
46 isManaged: managed 46 isSupervised: supervised
47 }; 47 };
48 }, 48 },
49 49
50 /** 50 /**
51 * Overrides WebUI methods that provide profile info, making them return a 51 * Overrides WebUI methods that provide profile info, making them return a
52 * test profile-info object. 52 * test profile-info object.
53 * @param {boolean} managed Whether the test profile should be marked managed. 53 * @param {boolean} supervised Whether the test profile should be marked
54 * as supervised.
54 * @param {string} mode The mode of the overlay (either 'manage' or 'create'). 55 * @param {string} mode The mode of the overlay (either 'manage' or 'create').
55 */ 56 */
56 setProfileManaged_: function(managed, mode) { 57 setProfileSupervised_: function(supervised, mode) {
57 // Override the BrowserOptions method to return the fake info. 58 // Override the BrowserOptions method to return the fake info.
58 BrowserOptions.getCurrentProfile = function() { 59 BrowserOptions.getCurrentProfile = function() {
59 return this.testProfileInfo_(managed); 60 return this.testProfileInfo_(supervised);
60 }.bind(this); 61 }.bind(this);
61 // Set the profile info in the overlay. 62 // Set the profile info in the overlay.
62 ManageProfileOverlay.setProfileInfo(this.testProfileInfo_(managed), mode); 63 ManageProfileOverlay.setProfileInfo(this.testProfileInfo_(supervised),
64 mode);
63 }, 65 },
64 66
65 /** 67 /**
66 * Set some default profile infos (icon URLs and names). 68 * Set some default profile infos (icon URLs and names).
67 * @param {boolean} managed Whether the test profile should be marked managed. 69 * @param {boolean} supervised Whether the test profile should be marked as
70 * supervised.
68 * @param {string} mode The mode of the overlay (either 'manage' or 'create'). 71 * @param {string} mode The mode of the overlay (either 'manage' or 'create').
69 */ 72 */
70 initDefaultProfiles_: function(mode) { 73 initDefaultProfiles_: function(mode) {
71 OptionsPage.showPageByName(mode + 'Profile'); 74 OptionsPage.showPageByName(mode + 'Profile');
72 75
73 var defaultProfile = { 76 var defaultProfile = {
74 name: 'Default Name', 77 name: 'Default Name',
75 iconURL: '/default/path', 78 iconURL: '/default/path',
76 }; 79 };
77 this.defaultIconURLs = ['/some/path', 80 this.defaultIconURLs = ['/some/path',
(...skipping 28 matching lines...) Expand all
106 } 109 }
107 110
108 // Receiving new profile defaults sets focus to the name field if the create 111 // Receiving new profile defaults sets focus to the name field if the create
109 // overlay is open, and should not change focus at all otherwise. 112 // overlay is open, and should not change focus at all otherwise.
110 checkFocus('manageProfile', 113 checkFocus('manageProfile',
111 $('manage-profile-cancel'), 114 $('manage-profile-cancel'),
112 $('manage-profile-cancel')); 115 $('manage-profile-cancel'));
113 checkFocus('createProfile', 116 checkFocus('createProfile',
114 $('create-profile-name'), 117 $('create-profile-name'),
115 $('create-profile-cancel')); 118 $('create-profile-cancel'));
116 checkFocus('managedUserLearnMore', 119 checkFocus('supervisedUserLearnMore',
117 $('managed-user-learn-more-done'), 120 $('supervised-user-learn-more-done'),
118 $('managed-user-learn-more-done')); 121 $('supervised-user-learn-more-done'));
119 checkFocus('managedUserLearnMore', 122 checkFocus('supervisedUserLearnMore',
120 document.querySelector('#managed-user-learn-more-text a'), 123 document.querySelector('#supervised-user-learn-more-text a'),
121 document.querySelector('#managed-user-learn-more-text a')); 124 document.querySelector('#supervised-user-learn-more-text a'));
122 }); 125 });
123 126
124 // The default options should be reset each time the creation overlay is shown. 127 // The default options should be reset each time the creation overlay is shown.
125 TEST_F('ManageProfileUITest', 'DefaultCreateOptions', function() { 128 TEST_F('ManageProfileUITest', 'DefaultCreateOptions', function() {
126 OptionsPage.showPageByName('createProfile'); 129 OptionsPage.showPageByName('createProfile');
127 var shortcutsAllowed = loadTimeData.getBoolean('profileShortcutsEnabled'); 130 var shortcutsAllowed = loadTimeData.getBoolean('profileShortcutsEnabled');
128 var createShortcut = $('create-shortcut'); 131 var createShortcut = $('create-shortcut');
129 var createManaged = $('create-profile-managed'); 132 var createSupervised = $('create-profile-supervised');
130 assertEquals(shortcutsAllowed, createShortcut.checked); 133 assertEquals(shortcutsAllowed, createShortcut.checked);
131 assertFalse(createManaged.checked); 134 assertFalse(createSupervised.checked);
132 135
133 createShortcut.checked = !shortcutsAllowed; 136 createShortcut.checked = !shortcutsAllowed;
134 createManaged.checked = true; 137 createSupervised.checked = true;
135 OptionsPage.closeOverlay(); 138 OptionsPage.closeOverlay();
136 OptionsPage.showPageByName('createProfile'); 139 OptionsPage.showPageByName('createProfile');
137 assertEquals(shortcutsAllowed, createShortcut.checked); 140 assertEquals(shortcutsAllowed, createShortcut.checked);
138 assertFalse(createManaged.checked); 141 assertFalse(createSupervised.checked);
139 }); 142 });
140 143
141 // The checkbox label should change depending on whether the user is signed in. 144 // The checkbox label should change depending on whether the user is signed in.
142 TEST_F('ManageProfileUITest', 'CreateManagedUserText', function() { 145 TEST_F('ManageProfileUITest', 'CreateSupervisedUserText', function() {
143 var signedInText = $('create-profile-managed-signed-in'); 146 var signedInText = $('create-profile-supervised-signed-in');
144 var notSignedInText = $('create-profile-managed-not-signed-in'); 147 var notSignedInText = $('create-profile-supervised-not-signed-in');
145 148
146 ManageProfileOverlay.getInstance().initializePage(); 149 ManageProfileOverlay.getInstance().initializePage();
147 150
148 var custodianEmail = 'chrome.playpen.test@gmail.com'; 151 var custodianEmail = 'chrome.playpen.test@gmail.com';
149 CreateProfileOverlay.updateSignedInStatus(custodianEmail); 152 CreateProfileOverlay.updateSignedInStatus(custodianEmail);
150 assertEquals(custodianEmail, 153 assertEquals(custodianEmail,
151 CreateProfileOverlay.getInstance().signedInEmail_); 154 CreateProfileOverlay.getInstance().signedInEmail_);
152 assertFalse(signedInText.hidden); 155 assertFalse(signedInText.hidden);
153 assertTrue(notSignedInText.hidden); 156 assertTrue(notSignedInText.hidden);
154 // Make sure the email is in the string somewhere, without depending on the 157 // Make sure the email is in the string somewhere, without depending on the
155 // exact details of the message. 158 // exact details of the message.
156 assertNotEquals(-1, signedInText.textContent.indexOf(custodianEmail)); 159 assertNotEquals(-1, signedInText.textContent.indexOf(custodianEmail));
157 160
158 CreateProfileOverlay.updateSignedInStatus(''); 161 CreateProfileOverlay.updateSignedInStatus('');
159 assertEquals('', CreateProfileOverlay.getInstance().signedInEmail_); 162 assertEquals('', CreateProfileOverlay.getInstance().signedInEmail_);
160 assertTrue(signedInText.hidden); 163 assertTrue(signedInText.hidden);
161 assertFalse(notSignedInText.hidden); 164 assertFalse(notSignedInText.hidden);
162 assertFalse($('create-profile-managed').checked); 165 assertFalse($('create-profile-supervised').checked);
163 assertTrue($('create-profile-managed').disabled); 166 assertTrue($('create-profile-supervised').disabled);
164 }); 167 });
165 168
166 function ManageProfileUITestAsync() {} 169 function ManageProfileUITestAsync() {}
167 170
168 ManageProfileUITestAsync.prototype = { 171 ManageProfileUITestAsync.prototype = {
169 __proto__: ManageProfileUITest.prototype, 172 __proto__: ManageProfileUITest.prototype,
170 173
171 isAsync: true, 174 isAsync: true,
172 }; 175 };
173 176
174 // The import link should show up if the user tries to create a profile with the 177 // The import link should show up if the user tries to create a profile with the
175 // same name as an existing managed user profile. 178 // same name as an existing supervised user profile.
176 TEST_F('ManageProfileUITestAsync', 'CreateExistingManagedUser', function() { 179 TEST_F('ManageProfileUITestAsync', 'CreateExistingSupervisedUser', function() {
177 // Initialize the list of existing managed users. 180 // Initialize the list of existing supervised users.
178 var managedUsers = [ 181 var supervisedUsers = [
179 { 182 {
180 id: 'managedUser1', 183 id: 'supervisedUser1',
181 name: 'Rosalie', 184 name: 'Rosalie',
182 iconURL: 'chrome://path/to/icon/image', 185 iconURL: 'chrome://path/to/icon/image',
183 onCurrentDevice: false, 186 onCurrentDevice: false,
184 needAvatar: false 187 needAvatar: false
185 }, 188 },
186 { 189 {
187 id: 'managedUser2', 190 id: 'supervisedUser2',
188 name: 'Fritz', 191 name: 'Fritz',
189 iconURL: 'chrome://path/to/icon/image', 192 iconURL: 'chrome://path/to/icon/image',
190 onCurrentDevice: false, 193 onCurrentDevice: false,
191 needAvatar: true 194 needAvatar: true
192 }, 195 },
193 { 196 {
194 id: 'managedUser3', 197 id: 'supervisedUser3',
195 name: 'Test', 198 name: 'Test',
196 iconURL: 'chrome://path/to/icon/image', 199 iconURL: 'chrome://path/to/icon/image',
197 onCurrentDevice: true, 200 onCurrentDevice: true,
198 needAvatar: false 201 needAvatar: false
199 }, 202 },
200 { 203 {
201 id: 'managedUser4', 204 id: 'supervisedUser4',
202 name: 'SameName', 205 name: 'SameName',
203 iconURL: 'chrome://path/to/icon/image', 206 iconURL: 'chrome://path/to/icon/image',
204 onCurrentDevice: false, 207 onCurrentDevice: false,
205 needAvatar: false 208 needAvatar: false
206 }]; 209 }];
207 var promise = Promise.resolve(managedUsers); 210 var promise = Promise.resolve(supervisedUsers);
208 options.ManagedUserListData.getInstance().promise_ = promise; 211 options.SupervisedUserListData.getInstance().promise_ = promise;
209 212
210 // Initialize the ManageProfileOverlay. 213 // Initialize the ManageProfileOverlay.
211 ManageProfileOverlay.getInstance().initializePage(); 214 ManageProfileOverlay.getInstance().initializePage();
212 var custodianEmail = 'chrome.playpen.test@gmail.com'; 215 var custodianEmail = 'chrome.playpen.test@gmail.com';
213 CreateProfileOverlay.updateSignedInStatus(custodianEmail); 216 CreateProfileOverlay.updateSignedInStatus(custodianEmail);
214 assertEquals(custodianEmail, 217 assertEquals(custodianEmail,
215 CreateProfileOverlay.getInstance().signedInEmail_); 218 CreateProfileOverlay.getInstance().signedInEmail_);
216 this.setProfileManaged_(false, 'create'); 219 this.setProfileSupervised_(false, 'create');
217 220
218 // Also add the names 'Test' and 'SameName' to |existingProfileNames_| to 221 // Also add the names 'Test' and 'SameName' to |existingProfileNames_| to
219 // simulate that profiles with those names exist on the device. 222 // simulate that profiles with those names exist on the device.
220 ManageProfileOverlay.getInstance().existingProfileNames_.Test = true; 223 ManageProfileOverlay.getInstance().existingProfileNames_.Test = true;
221 ManageProfileOverlay.getInstance().existingProfileNames_.SameName = true; 224 ManageProfileOverlay.getInstance().existingProfileNames_.SameName = true;
222 225
223 // Initially, the ok button should be enabled and the import link should not 226 // Initially, the ok button should be enabled and the import link should not
224 // exist. 227 // exist.
225 assertFalse($('create-profile-ok').disabled); 228 assertFalse($('create-profile-ok').disabled);
226 assertTrue($('supervised-user-import') == null); 229 assertTrue($('supervised-user-import-existing') == null);
227 230
228 // Now try to create profiles with the names of existing supervised users. 231 // Now try to create profiles with the names of existing supervised users.
229 $('create-profile-managed').checked = true; 232 $('create-profile-supervised').checked = true;
230 var nameField = $('create-profile-name'); 233 var nameField = $('create-profile-name');
231 // A profile which already has an avatar. 234 // A profile which already has an avatar.
232 nameField.value = 'Rosalie'; 235 nameField.value = 'Rosalie';
233 ManageProfileOverlay.getInstance().onNameChanged_('create'); 236 ManageProfileOverlay.getInstance().onNameChanged_('create');
234 // Need to wait until the promise resolves. 237 // Need to wait until the promise resolves.
235 promise.then(function() { 238 promise.then(function() {
236 assertTrue($('create-profile-ok').disabled); 239 assertTrue($('create-profile-ok').disabled);
237 assertFalse($('supervised-user-import') == null); 240 assertFalse($('supervised-user-import-existing') == null);
238 241
239 // A profile which doesn't have an avatar yet. 242 // A profile which doesn't have an avatar yet.
240 nameField.value = 'Fritz'; 243 nameField.value = 'Fritz';
241 ManageProfileOverlay.getInstance().onNameChanged_('create'); 244 ManageProfileOverlay.getInstance().onNameChanged_('create');
242 return options.ManagedUserListData.getInstance().promise_; 245 return options.SupervisedUserListData.getInstance().promise_;
243 }).then(function() { 246 }).then(function() {
244 assertTrue($('create-profile-ok').disabled); 247 assertTrue($('create-profile-ok').disabled);
245 assertFalse($('supervised-user-import') == null); 248 assertFalse($('supervised-user-import-existing') == null);
246 249
247 // A profile which already exists on the device. 250 // A profile which already exists on the device.
248 nameField.value = 'Test'; 251 nameField.value = 'Test';
249 ManageProfileOverlay.getInstance().onNameChanged_('create'); 252 ManageProfileOverlay.getInstance().onNameChanged_('create');
250 return options.ManagedUserListData.getInstance().promise_; 253 return options.SupervisedUserListData.getInstance().promise_;
251 }).then(function() { 254 }).then(function() {
252 assertTrue($('create-profile-ok').disabled); 255 assertTrue($('create-profile-ok').disabled);
253 assertTrue($('supervised-user-import') == null); 256 assertTrue($('supervised-user-import-existing') == null);
254 257
255 // A profile which does not exist on the device, but there is a profile with 258 // A profile which does not exist on the device, but there is a profile with
256 // the same name already on the device. 259 // the same name already on the device.
257 nameField.value = 'SameName'; 260 nameField.value = 'SameName';
258 ManageProfileOverlay.getInstance().onNameChanged_('create'); 261 ManageProfileOverlay.getInstance().onNameChanged_('create');
259 return options.ManagedUserListData.getInstance().promise_; 262 return options.SupervisedUserListData.getInstance().promise_;
260 }).then(function() { 263 }).then(function() {
261 assertTrue($('create-profile-ok').disabled); 264 assertTrue($('create-profile-ok').disabled);
262 assertFalse($('supervised-user-import') == null); 265 assertFalse($('supervised-user-import-existing') == null);
263 266
264 // A profile which does not exist yet. 267 // A profile which does not exist yet.
265 nameField.value = 'NewProfileName'; 268 nameField.value = 'NewProfileName';
266 ManageProfileOverlay.getInstance().onNameChanged_('create'); 269 ManageProfileOverlay.getInstance().onNameChanged_('create');
267 return options.ManagedUserListData.getInstance().promise_; 270 return options.SupervisedUserListData.getInstance().promise_;
268 }).then(function() { 271 }).then(function() {
269 assertFalse($('create-profile-ok').disabled); 272 assertFalse($('create-profile-ok').disabled);
270 assertTrue($('supervised-user-import') == null); 273 assertTrue($('supervised-user-import-existing') == null);
271 testDone(); 274 testDone();
272 }); 275 });
273 }); 276 });
274 277
275 // Managed users should not be able to edit their profile names, and the initial 278 // Supervised users should not be able to edit their profile names, and the
276 // focus should be adjusted accordingly. 279 // initial focus should be adjusted accordingly.
277 TEST_F('ManageProfileUITest', 'EditManagedUserNameAllowed', function() { 280 TEST_F('ManageProfileUITest', 'EditSupervisedUserNameAllowed', function() {
278 var nameField = $('manage-profile-name'); 281 var nameField = $('manage-profile-name');
279 282
280 this.setProfileManaged_(false, 'manage'); 283 this.setProfileSupervised_(false, 'manage');
281 ManageProfileOverlay.showManageDialog(); 284 ManageProfileOverlay.showManageDialog();
282 expectFalse(nameField.disabled); 285 expectFalse(nameField.disabled);
283 expectEquals(nameField, document.activeElement); 286 expectEquals(nameField, document.activeElement);
284 287
285 OptionsPage.closeOverlay(); 288 OptionsPage.closeOverlay();
286 289
287 this.setProfileManaged_(true, 'manage'); 290 this.setProfileSupervised_(true, 'manage');
288 ManageProfileOverlay.showManageDialog(); 291 ManageProfileOverlay.showManageDialog();
289 expectTrue(nameField.disabled); 292 expectTrue(nameField.disabled);
290 expectEquals($('manage-profile-ok'), document.activeElement); 293 expectEquals($('manage-profile-ok'), document.activeElement);
291 }); 294 });
292 295
293 // Setting profile information should allow the confirmation to be shown. 296 // Setting profile information should allow the confirmation to be shown.
294 TEST_F('ManageProfileUITest', 'ShowCreateConfirmation', function() { 297 TEST_F('ManageProfileUITest', 'ShowCreateConfirmation', function() {
295 var testProfile = this.testProfileInfo_(true); 298 var testProfile = this.testProfileInfo_(true);
296 testProfile.custodianEmail = 'foo@bar.example.com'; 299 testProfile.custodianEmail = 'foo@bar.example.com';
297 ManagedUserCreateConfirmOverlay.setProfileInfo(testProfile); 300 SupervisedUserCreateConfirmOverlay.setProfileInfo(testProfile);
298 assertTrue(ManagedUserCreateConfirmOverlay.getInstance().canShowPage()); 301 assertTrue(SupervisedUserCreateConfirmOverlay.getInstance().canShowPage());
299 OptionsPage.showPageByName('managedUserCreateConfirm', false); 302 OptionsPage.showPageByName('supervisedUserCreateConfirm', false);
300 assertEquals('managedUserCreateConfirm', 303 assertEquals('supervisedUserCreateConfirm',
301 OptionsPage.getTopmostVisiblePage().name); 304 OptionsPage.getTopmostVisiblePage().name);
302 }); 305 });
303 306
304 // Trying to show a confirmation dialog with no profile information should fall 307 // Trying to show a confirmation dialog with no profile information should fall
305 // back to the default (main) settings page. 308 // back to the default (main) settings page.
306 TEST_F('ManageProfileUITest', 'NoEmptyConfirmation', function() { 309 TEST_F('ManageProfileUITest', 'NoEmptyConfirmation', function() {
307 assertEquals('manageProfile', OptionsPage.getTopmostVisiblePage().name); 310 assertEquals('manageProfile', OptionsPage.getTopmostVisiblePage().name);
308 assertFalse(ManagedUserCreateConfirmOverlay.getInstance().canShowPage()); 311 assertFalse(SupervisedUserCreateConfirmOverlay.getInstance().canShowPage());
309 OptionsPage.showPageByName('managedUserCreateConfirm', true); 312 OptionsPage.showPageByName('supervisedUserCreateConfirm', true);
310 assertEquals('settings', OptionsPage.getTopmostVisiblePage().name); 313 assertEquals('settings', OptionsPage.getTopmostVisiblePage().name);
311 }); 314 });
312 315
313 // A confirmation dialog should be shown after creating a new managed user. 316 // A confirmation dialog should be shown after creating a new supervised user.
314 TEST_F('ManageProfileUITest', 'ShowCreateConfirmationOnSuccess', function() { 317 TEST_F('ManageProfileUITest', 'ShowCreateConfirmationOnSuccess', function() {
315 OptionsPage.showPageByName('createProfile'); 318 OptionsPage.showPageByName('createProfile');
316 assertEquals('createProfile', OptionsPage.getTopmostVisiblePage().name); 319 assertEquals('createProfile', OptionsPage.getTopmostVisiblePage().name);
317 CreateProfileOverlay.onSuccess(this.testProfileInfo_(false)); 320 CreateProfileOverlay.onSuccess(this.testProfileInfo_(false));
318 assertEquals('settings', OptionsPage.getTopmostVisiblePage().name); 321 assertEquals('settings', OptionsPage.getTopmostVisiblePage().name);
319 322
320 OptionsPage.showPageByName('createProfile'); 323 OptionsPage.showPageByName('createProfile');
321 assertEquals('createProfile', OptionsPage.getTopmostVisiblePage().name); 324 assertEquals('createProfile', OptionsPage.getTopmostVisiblePage().name);
322 CreateProfileOverlay.onSuccess(this.testProfileInfo_(true)); 325 CreateProfileOverlay.onSuccess(this.testProfileInfo_(true));
323 assertEquals('managedUserCreateConfirm', 326 assertEquals('supervisedUserCreateConfirm',
324 OptionsPage.getTopmostVisiblePage().name); 327 OptionsPage.getTopmostVisiblePage().name);
325 expectEquals($('managed-user-created-switch'), document.activeElement); 328 expectEquals($('supervised-user-created-switch'), document.activeElement);
326 }); 329 });
327 330
328 // An error should be shown if creating a new managed user fails. 331 // An error should be shown if creating a new supervised user fails.
329 TEST_F('ManageProfileUITest', 'NoCreateConfirmationOnError', function() { 332 TEST_F('ManageProfileUITest', 'NoCreateConfirmationOnError', function() {
330 OptionsPage.showPageByName('createProfile'); 333 OptionsPage.showPageByName('createProfile');
331 assertEquals('createProfile', OptionsPage.getTopmostVisiblePage().name); 334 assertEquals('createProfile', OptionsPage.getTopmostVisiblePage().name);
332 var errorBubble = $('create-profile-error-bubble'); 335 var errorBubble = $('create-profile-error-bubble');
333 assertTrue(errorBubble.hidden); 336 assertTrue(errorBubble.hidden);
334 337
335 CreateProfileOverlay.onError('An Error Message!'); 338 CreateProfileOverlay.onError('An Error Message!');
336 assertEquals('createProfile', OptionsPage.getTopmostVisiblePage().name); 339 assertEquals('createProfile', OptionsPage.getTopmostVisiblePage().name);
337 assertFalse(errorBubble.hidden); 340 assertFalse(errorBubble.hidden);
338 }); 341 });
339 342
340 // The name and email should be inserted into the confirmation dialog. 343 // The name and email should be inserted into the confirmation dialog.
341 TEST_F('ManageProfileUITest', 'CreateConfirmationText', function() { 344 TEST_F('ManageProfileUITest', 'CreateConfirmationText', function() {
342 var self = this; 345 var self = this;
343 var custodianEmail = 'foo@example.com'; 346 var custodianEmail = 'foo@example.com';
344 347
345 // Checks the strings in the confirmation dialog. If |expectedNameText| is 348 // Checks the strings in the confirmation dialog. If |expectedNameText| is
346 // given, it should be present in the dialog's textContent; otherwise the name 349 // given, it should be present in the dialog's textContent; otherwise the name
347 // is expected. If |expectedNameHtml| is given, it should be present in the 350 // is expected. If |expectedNameHtml| is given, it should be present in the
348 // dialog's innerHTML; otherwise the expected text is expected in the HTML 351 // dialog's innerHTML; otherwise the expected text is expected in the HTML
349 // too. 352 // too.
350 function checkDialog(name, expectedNameText, expectedNameHtml) { 353 function checkDialog(name, expectedNameText, expectedNameHtml) {
351 var expectedText = expectedNameText || name; 354 var expectedText = expectedNameText || name;
352 var expectedHtml = expectedNameHtml || expectedText; 355 var expectedHtml = expectedNameHtml || expectedText;
353 356
354 // Configure the test profile and show the confirmation dialog. 357 // Configure the test profile and show the confirmation dialog.
355 var testProfile = self.testProfileInfo_(true); 358 var testProfile = self.testProfileInfo_(true);
356 testProfile.name = name; 359 testProfile.name = name;
357 CreateProfileOverlay.onSuccess(testProfile); 360 CreateProfileOverlay.onSuccess(testProfile);
358 assertEquals('managedUserCreateConfirm', 361 assertEquals('supervisedUserCreateConfirm',
359 OptionsPage.getTopmostVisiblePage().name); 362 OptionsPage.getTopmostVisiblePage().name);
360 363
361 // Check for the presence of the name and email in the UI, without depending 364 // Check for the presence of the name and email in the UI, without depending
362 // on the details of the messsages. 365 // on the details of the messages.
363 assertNotEquals(-1, 366 assertNotEquals(-1,
364 $('managed-user-created-title').textContent.indexOf(expectedText)); 367 $('supervised-user-created-title').textContent.indexOf(expectedText));
365 assertNotEquals(-1, 368 assertNotEquals(-1,
366 $('managed-user-created-switch').textContent.indexOf(expectedText)); 369 $('supervised-user-created-switch').textContent.indexOf(expectedText));
367 var message = $('managed-user-created-text'); 370 var message = $('supervised-user-created-text');
368 assertNotEquals(-1, message.textContent.indexOf(expectedText)); 371 assertNotEquals(-1, message.textContent.indexOf(expectedText));
369 assertNotEquals(-1, message.textContent.indexOf(custodianEmail)); 372 assertNotEquals(-1, message.textContent.indexOf(custodianEmail));
370 373
371 // The name should be properly HTML-escaped. 374 // The name should be properly HTML-escaped.
372 assertNotEquals(-1, message.innerHTML.indexOf(expectedHtml)); 375 assertNotEquals(-1, message.innerHTML.indexOf(expectedHtml));
373 376
374 OptionsPage.closeOverlay(); 377 OptionsPage.closeOverlay();
375 assertEquals('settings', OptionsPage.getTopmostVisiblePage().name, name); 378 assertEquals('settings', OptionsPage.getTopmostVisiblePage().name, name);
376 } 379 }
377 380
(...skipping 22 matching lines...) Expand all
400 403
401 // Test both elision and HTML escaping. The allowed string length is the 404 // Test both elision and HTML escaping. The allowed string length is the
402 // visible length, not the length including the entity names. 405 // visible length, not the length including the entity names.
403 name49Characters = name49Characters.replace('0', '&').replace('1', '>'); 406 name49Characters = name49Characters.replace('0', '&').replace('1', '>');
404 name60Characters = name60Characters.replace('0', '&').replace('1', '>'); 407 name60Characters = name60Characters.replace('0', '&').replace('1', '>');
405 var escaped = name49Characters.replace('&', '&').replace('>', '>'); 408 var escaped = name49Characters.replace('&', '&').replace('>', '>');
406 checkDialog( 409 checkDialog(
407 name60Characters, name49Characters + '\u2026', escaped + '\u2026'); 410 name60Characters, name49Characters + '\u2026', escaped + '\u2026');
408 }); 411 });
409 412
410 // An additional warning should be shown when deleting a managed user. 413 // An additional warning should be shown when deleting a supervised user.
411 TEST_F('ManageProfileUITest', 'DeleteManagedUserWarning', function() { 414 TEST_F('ManageProfileUITest', 'DeleteSupervisedUserWarning', function() {
412 var addendum = $('delete-managed-profile-addendum'); 415 var addendum = $('delete-supervised-profile-addendum');
413 416
414 ManageProfileOverlay.showDeleteDialog(this.testProfileInfo_(true)); 417 ManageProfileOverlay.showDeleteDialog(this.testProfileInfo_(true));
415 assertFalse(addendum.hidden); 418 assertFalse(addendum.hidden);
416 419
417 ManageProfileOverlay.showDeleteDialog(this.testProfileInfo_(false)); 420 ManageProfileOverlay.showDeleteDialog(this.testProfileInfo_(false));
418 assertTrue(addendum.hidden); 421 assertTrue(addendum.hidden);
419 }); 422 });
420 423
421 // The policy prohibiting managed users should update the UI dynamically. 424 // The policy prohibiting supervised users should update the UI dynamically.
422 TEST_F('ManageProfileUITest', 'PolicyDynamicRefresh', function() { 425 TEST_F('ManageProfileUITest', 'PolicyDynamicRefresh', function() {
423 ManageProfileOverlay.getInstance().initializePage(); 426 ManageProfileOverlay.getInstance().initializePage();
424 427
425 var custodianEmail = 'chrome.playpen.test@gmail.com'; 428 var custodianEmail = 'chrome.playpen.test@gmail.com';
426 CreateProfileOverlay.updateSignedInStatus(custodianEmail); 429 CreateProfileOverlay.updateSignedInStatus(custodianEmail);
427 CreateProfileOverlay.updateManagedUsersAllowed(true); 430 CreateProfileOverlay.updateSupervisedUsersAllowed(true);
428 var checkbox = $('create-profile-managed'); 431 var checkbox = $('create-profile-supervised');
429 var link = $('create-profile-managed-not-signed-in-link'); 432 var link = $('create-profile-supervised-not-signed-in-link');
430 var indicator = $('create-profile-managed-indicator'); 433 var indicator = $('create-profile-supervised-indicator');
431 434
432 assertFalse(checkbox.disabled, 'allowed and signed in'); 435 assertFalse(checkbox.disabled, 'allowed and signed in');
433 assertFalse(link.hidden, 'allowed and signed in'); 436 assertFalse(link.hidden, 'allowed and signed in');
434 assertEquals('none', window.getComputedStyle(indicator, null).display, 437 assertEquals('none', window.getComputedStyle(indicator, null).display,
435 'allowed and signed in'); 438 'allowed and signed in');
436 439
437 CreateProfileOverlay.updateSignedInStatus(''); 440 CreateProfileOverlay.updateSignedInStatus('');
438 CreateProfileOverlay.updateManagedUsersAllowed(true); 441 CreateProfileOverlay.updateSupervisedUsersAllowed(true);
439 assertTrue(checkbox.disabled, 'allowed, not signed in'); 442 assertTrue(checkbox.disabled, 'allowed, not signed in');
440 assertFalse(link.hidden, 'allowed, not signed in'); 443 assertFalse(link.hidden, 'allowed, not signed in');
441 assertEquals('none', window.getComputedStyle(indicator, null).display, 444 assertEquals('none', window.getComputedStyle(indicator, null).display,
442 'allowed, not signed in'); 445 'allowed, not signed in');
443 446
444 CreateProfileOverlay.updateSignedInStatus(''); 447 CreateProfileOverlay.updateSignedInStatus('');
445 CreateProfileOverlay.updateManagedUsersAllowed(false); 448 CreateProfileOverlay.updateSupervisedUsersAllowed(false);
446 assertTrue(checkbox.disabled, 'disallowed, not signed in'); 449 assertTrue(checkbox.disabled, 'disallowed, not signed in');
447 assertTrue(link.hidden, 'disallowed, not signed in'); 450 assertTrue(link.hidden, 'disallowed, not signed in');
448 assertEquals('inline-block', window.getComputedStyle(indicator, null).display, 451 assertEquals('inline-block', window.getComputedStyle(indicator, null).display,
449 'disallowed, not signed in'); 452 'disallowed, not signed in');
450 assertEquals('policy', indicator.getAttribute('controlled-by')); 453 assertEquals('policy', indicator.getAttribute('controlled-by'));
451 454
452 CreateProfileOverlay.updateSignedInStatus(custodianEmail); 455 CreateProfileOverlay.updateSignedInStatus(custodianEmail);
453 CreateProfileOverlay.updateManagedUsersAllowed(false); 456 CreateProfileOverlay.updateSupervisedUsersAllowed(false);
454 assertTrue(checkbox.disabled, 'disallowed, signed in'); 457 assertTrue(checkbox.disabled, 'disallowed, signed in');
455 assertTrue(link.hidden, 'disallowed, signed in'); 458 assertTrue(link.hidden, 'disallowed, signed in');
456 assertEquals('inline-block', window.getComputedStyle(indicator, null).display, 459 assertEquals('inline-block', window.getComputedStyle(indicator, null).display,
457 'disallowed, signed in'); 460 'disallowed, signed in');
458 assertEquals('policy', indicator.getAttribute('controlled-by')); 461 assertEquals('policy', indicator.getAttribute('controlled-by'));
459 462
460 CreateProfileOverlay.updateSignedInStatus(custodianEmail); 463 CreateProfileOverlay.updateSignedInStatus(custodianEmail);
461 CreateProfileOverlay.updateManagedUsersAllowed(true); 464 CreateProfileOverlay.updateSupervisedUsersAllowed(true);
462 assertFalse(checkbox.disabled, 're-allowed and signed in'); 465 assertFalse(checkbox.disabled, 're-allowed and signed in');
463 assertFalse(link.hidden, 're-allowed and signed in'); 466 assertFalse(link.hidden, 're-allowed and signed in');
464 assertEquals('none', window.getComputedStyle(indicator, null).display, 467 assertEquals('none', window.getComputedStyle(indicator, null).display,
465 're-allowed and signed in'); 468 're-allowed and signed in');
466 }); 469 });
467 470
468 // The managed user checkbox should correctly update its state during profile 471 // The supervised user checkbox should correctly update its state during profile
469 // creation and afterwards. 472 // creation and afterwards.
470 TEST_F('ManageProfileUITest', 'CreateInProgress', function() { 473 TEST_F('ManageProfileUITest', 'CreateInProgress', function() {
471 ManageProfileOverlay.getInstance().initializePage(); 474 ManageProfileOverlay.getInstance().initializePage();
472 475
473 var custodianEmail = 'chrome.playpen.test@gmail.com'; 476 var custodianEmail = 'chrome.playpen.test@gmail.com';
474 CreateProfileOverlay.updateSignedInStatus(custodianEmail); 477 CreateProfileOverlay.updateSignedInStatus(custodianEmail);
475 CreateProfileOverlay.updateManagedUsersAllowed(true); 478 CreateProfileOverlay.updateSupervisedUsersAllowed(true);
476 var checkbox = $('create-profile-managed'); 479 var checkbox = $('create-profile-supervised');
477 var link = $('create-profile-managed-not-signed-in-link'); 480 var link = $('create-profile-supervised-not-signed-in-link');
478 var indicator = $('create-profile-managed-indicator'); 481 var indicator = $('create-profile-supervised-indicator');
479 482
480 assertFalse(checkbox.disabled, 'allowed and signed in'); 483 assertFalse(checkbox.disabled, 'allowed and signed in');
481 assertFalse(link.hidden, 'allowed and signed in'); 484 assertFalse(link.hidden, 'allowed and signed in');
482 assertEquals('none', window.getComputedStyle(indicator, null).display, 485 assertEquals('none', window.getComputedStyle(indicator, null).display,
483 'allowed and signed in'); 486 'allowed and signed in');
484 assertFalse(indicator.hasAttribute('controlled-by')); 487 assertFalse(indicator.hasAttribute('controlled-by'));
485 488
486 CreateProfileOverlay.updateCreateInProgress(true); 489 CreateProfileOverlay.updateCreateInProgress(true);
487 assertTrue(checkbox.disabled, 'creation in progress'); 490 assertTrue(checkbox.disabled, 'creation in progress');
488 491
489 // A no-op update to the sign-in status should not change the UI. 492 // A no-op update to the sign-in status should not change the UI.
490 CreateProfileOverlay.updateSignedInStatus(custodianEmail); 493 CreateProfileOverlay.updateSignedInStatus(custodianEmail);
491 CreateProfileOverlay.updateManagedUsersAllowed(true); 494 CreateProfileOverlay.updateSupervisedUsersAllowed(true);
492 assertTrue(checkbox.disabled, 'creation in progress'); 495 assertTrue(checkbox.disabled, 'creation in progress');
493 496
494 CreateProfileOverlay.updateCreateInProgress(false); 497 CreateProfileOverlay.updateCreateInProgress(false);
495 assertFalse(checkbox.disabled, 'creation finished'); 498 assertFalse(checkbox.disabled, 'creation finished');
496 }); 499 });
497 500
498 // Managed users shouldn't be able to open the delete or create dialogs. 501 // Supervised users shouldn't be able to open the delete or create dialogs.
499 TEST_F('ManageProfileUITest', 'ManagedShowDeleteAndCreate', function() { 502 TEST_F('ManageProfileUITest', 'SupervisedShowDeleteAndCreate', function() {
500 this.setProfileManaged_(false, 'create'); 503 this.setProfileSupervised_(false, 'create');
501 504
502 ManageProfileOverlay.showCreateDialog(); 505 ManageProfileOverlay.showCreateDialog();
503 assertEquals('createProfile', OptionsPage.getTopmostVisiblePage().name); 506 assertEquals('createProfile', OptionsPage.getTopmostVisiblePage().name);
504 OptionsPage.closeOverlay(); 507 OptionsPage.closeOverlay();
505 assertEquals('settings', OptionsPage.getTopmostVisiblePage().name); 508 assertEquals('settings', OptionsPage.getTopmostVisiblePage().name);
506 ManageProfileOverlay.showDeleteDialog(this.testProfileInfo_(false)); 509 ManageProfileOverlay.showDeleteDialog(this.testProfileInfo_(false));
507 assertEquals('manageProfile', OptionsPage.getTopmostVisiblePage().name); 510 assertEquals('manageProfile', OptionsPage.getTopmostVisiblePage().name);
508 assertFalse($('manage-profile-overlay-delete').hidden); 511 assertFalse($('manage-profile-overlay-delete').hidden);
509 OptionsPage.closeOverlay(); 512 OptionsPage.closeOverlay();
510 assertEquals('settings', OptionsPage.getTopmostVisiblePage().name); 513 assertEquals('settings', OptionsPage.getTopmostVisiblePage().name);
511 514
512 this.setProfileManaged_(true, 'create'); 515 this.setProfileSupervised_(true, 'create');
513 ManageProfileOverlay.showCreateDialog(); 516 ManageProfileOverlay.showCreateDialog();
514 assertEquals('settings', OptionsPage.getTopmostVisiblePage().name); 517 assertEquals('settings', OptionsPage.getTopmostVisiblePage().name);
515 ManageProfileOverlay.showDeleteDialog(this.testProfileInfo_(false)); 518 ManageProfileOverlay.showDeleteDialog(this.testProfileInfo_(false));
516 assertEquals('settings', OptionsPage.getTopmostVisiblePage().name); 519 assertEquals('settings', OptionsPage.getTopmostVisiblePage().name);
517 }); 520 });
518 521
519 // Only non-managed users should be able to delete profiles. 522 // Only non-supervised users should be able to delete profiles.
520 TEST_F('ManageProfileUITest', 'ManagedDelete', function() { 523 TEST_F('ManageProfileUITest', 'SupervisedDelete', function() {
521 ManageProfileOverlay.showDeleteDialog(this.testProfileInfo_(false)); 524 ManageProfileOverlay.showDeleteDialog(this.testProfileInfo_(false));
522 assertEquals('manageProfile', OptionsPage.getTopmostVisiblePage().name); 525 assertEquals('manageProfile', OptionsPage.getTopmostVisiblePage().name);
523 assertFalse($('manage-profile-overlay-delete').hidden); 526 assertFalse($('manage-profile-overlay-delete').hidden);
524 527
525 // Clicks the "Delete" button, after overriding chrome.send to record what 528 // Clicks the "Delete" button, after overriding chrome.send to record what
526 // messages were sent. 529 // messages were sent.
527 function clickAndListen() { 530 function clickAndListen() {
528 var originalChromeSend = chrome.send; 531 var originalChromeSend = chrome.send;
529 var chromeSendMessages = []; 532 var chromeSendMessages = [];
530 chrome.send = function(message) { 533 chrome.send = function(message) {
531 chromeSendMessages.push(message); 534 chromeSendMessages.push(message);
532 }; 535 };
533 $('delete-profile-ok').onclick(); 536 $('delete-profile-ok').onclick();
534 // Restore the original function so the test framework can use it. 537 // Restore the original function so the test framework can use it.
535 chrome.send = originalChromeSend; 538 chrome.send = originalChromeSend;
536 return chromeSendMessages; 539 return chromeSendMessages;
537 } 540 }
538 541
539 this.setProfileManaged_(false, 'manage'); 542 this.setProfileSupervised_(false, 'manage');
540 var messages = clickAndListen(); 543 var messages = clickAndListen();
541 assertEquals(1, messages.length); 544 assertEquals(1, messages.length);
542 assertEquals('deleteProfile', messages[0]); 545 assertEquals('deleteProfile', messages[0]);
543 assertEquals('settings', OptionsPage.getTopmostVisiblePage().name); 546 assertEquals('settings', OptionsPage.getTopmostVisiblePage().name);
544 547
545 ManageProfileOverlay.showDeleteDialog(this.testProfileInfo_(false)); 548 ManageProfileOverlay.showDeleteDialog(this.testProfileInfo_(false));
546 this.setProfileManaged_(true, 'manage'); 549 this.setProfileSupervised_(true, 'manage');
547 messages = clickAndListen(); 550 messages = clickAndListen();
548 assertEquals(0, messages.length); 551 assertEquals(0, messages.length);
549 assertEquals('settings', OptionsPage.getTopmostVisiblePage().name); 552 assertEquals('settings', OptionsPage.getTopmostVisiblePage().name);
550 }); 553 });
551 554
552 // Selecting a different avatar image should update the suggested profile name. 555 // Selecting a different avatar image should update the suggested profile name.
553 TEST_F('ManageProfileUITest', 'Create_NameUpdateOnAvatarSelected', function() { 556 TEST_F('ManageProfileUITest', 'Create_NameUpdateOnAvatarSelected', function() {
554 var mode = 'create'; 557 var mode = 'create';
555 this.initDefaultProfiles_(mode); 558 this.initDefaultProfiles_(mode);
556 559
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
619 gridEl.selectedItem = this.defaultIconURLs[0]; 622 gridEl.selectedItem = this.defaultIconURLs[0];
620 expectEquals(oldName, nameEl.value); 623 expectEquals(oldName, nameEl.value);
621 624
622 OptionsPage.closeOverlay(); 625 OptionsPage.closeOverlay();
623 }); 626 });
624 627
625 // In the manage dialog, the name should never be updated on avatar selection. 628 // In the manage dialog, the name should never be updated on avatar selection.
626 TEST_F('ManageProfileUITest', 'Manage_NoNameUpdateOnAvatarSelected', 629 TEST_F('ManageProfileUITest', 'Manage_NoNameUpdateOnAvatarSelected',
627 function() { 630 function() {
628 var mode = 'manage'; 631 var mode = 'manage';
629 this.setProfileManaged_(false, mode); 632 this.setProfileSupervised_(false, mode);
630 OptionsPage.showPageByName(mode + 'Profile'); 633 OptionsPage.showPageByName(mode + 'Profile');
631 634
632 var testProfile = this.testProfileInfo_(false); 635 var testProfile = this.testProfileInfo_(false);
633 var iconURLs = [testProfile.iconURL, '/some/path', '/another/path']; 636 var iconURLs = [testProfile.iconURL, '/some/path', '/another/path'];
634 var names = [testProfile.name, 'Some Name', '']; 637 var names = [testProfile.name, 'Some Name', ''];
635 ManageProfileOverlay.receiveDefaultProfileIconsAndNames( 638 ManageProfileOverlay.receiveDefaultProfileIconsAndNames(
636 mode, iconURLs, names); 639 mode, iconURLs, names);
637 640
638 var gridEl = $(mode + '-profile-icon-grid'); 641 var gridEl = $(mode + '-profile-icon-grid');
639 var nameEl = $(mode + '-profile-name'); 642 var nameEl = $(mode + '-profile-name');
640 643
641 // Select another icon and check if the profile name was updated. 644 // Select another icon and check if the profile name was updated.
642 var oldName = nameEl.value; 645 var oldName = nameEl.value;
643 gridEl.selectedItem = iconURLs[1]; 646 gridEl.selectedItem = iconURLs[1];
644 expectEquals(oldName, nameEl.value); 647 expectEquals(oldName, nameEl.value);
645 648
646 OptionsPage.closeOverlay(); 649 OptionsPage.closeOverlay();
647 }); 650 });
648 651
649 GEN('#endif // OS_CHROMEOS'); 652 GEN('#endif // OS_CHROMEOS');
OLDNEW
« no previous file with comments | « chrome/browser/ui/webui/options/create_profile_handler.cc ('k') | chrome/browser/ui/webui/options/manage_profile_handler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698