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

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

Issue 132013002: Replace own callback handling with Promises. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Change tests to async. Created 6 years, 11 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 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
11 /** 11 /**
12 * TestFixture for ManageProfileOverlay and CreateProfileOverlay WebUI testing. 12 * TestFixture for ManageProfileOverlay and CreateProfileOverlay WebUI testing.
13 * @extends {testing.Test} 13 * @extends {testing.Test}
14 * @constructor 14 * @constructor
15 */ 15 */
16 function ManageProfileUITest() {} 16 function ManageProfileUITest() {}
17 17
18 ManageProfileUITest.prototype = { 18 ManageProfileUITest.prototype = {
19 __proto__: testing.Test.prototype, 19 __proto__: testing.Test.prototype,
20 20
21 /** @override */ 21 /** @override */
22 browsePreload: 'chrome://settings-frame/manageProfile', 22 browsePreload: 'chrome://settings-frame/manageProfile',
23 23
24 isAsync: true,
25
24 /** 26 /**
25 * No need to run these for every OptionsPage test, since they'll cover the 27 * No need to run these for every OptionsPage test, since they'll cover the
26 * whole consolidated page each time. 28 * whole consolidated page each time.
27 * @override 29 * @override
28 */ 30 */
29 runAccessibilityChecks: false, 31 runAccessibilityChecks: false,
30 32
31 /** @override */ 33 /** @override */
32 testGenPreamble: function() { 34 testGenPreamble: function() {
33 GEN('CommandLine::ForCurrentProcess()->' + 35 GEN('CommandLine::ForCurrentProcess()->' +
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
89 $('manage-profile-cancel')); 91 $('manage-profile-cancel'));
90 checkFocus('createProfile', 92 checkFocus('createProfile',
91 $('create-profile-name'), 93 $('create-profile-name'),
92 $('create-profile-cancel')); 94 $('create-profile-cancel'));
93 checkFocus('managedUserLearnMore', 95 checkFocus('managedUserLearnMore',
94 $('managed-user-learn-more-done'), 96 $('managed-user-learn-more-done'),
95 $('managed-user-learn-more-done')); 97 $('managed-user-learn-more-done'));
96 checkFocus('managedUserLearnMore', 98 checkFocus('managedUserLearnMore',
97 document.querySelector('#managed-user-learn-more-text a'), 99 document.querySelector('#managed-user-learn-more-text a'),
98 document.querySelector('#managed-user-learn-more-text a')); 100 document.querySelector('#managed-user-learn-more-text a'));
101 testDone();
Bernhard Bauer 2014/01/13 17:18:47 Alternatively, you could make a subclass for the a
Adrian Kuegel 2014/01/15 14:15:35 Ok, this seems to be the better solution, since we
99 }); 102 });
100 103
101 // The default options should be reset each time the creation overlay is shown. 104 // The default options should be reset each time the creation overlay is shown.
102 TEST_F('ManageProfileUITest', 'DefaultCreateOptions', function() { 105 TEST_F('ManageProfileUITest', 'DefaultCreateOptions', function() {
103 OptionsPage.showPageByName('createProfile'); 106 OptionsPage.showPageByName('createProfile');
104 var shortcutsAllowed = loadTimeData.getBoolean('profileShortcutsEnabled'); 107 var shortcutsAllowed = loadTimeData.getBoolean('profileShortcutsEnabled');
105 var createShortcut = $('create-shortcut'); 108 var createShortcut = $('create-shortcut');
106 var createManaged = $('create-profile-managed'); 109 var createManaged = $('create-profile-managed');
107 assertEquals(shortcutsAllowed, createShortcut.checked); 110 assertEquals(shortcutsAllowed, createShortcut.checked);
108 assertFalse(createManaged.checked); 111 assertFalse(createManaged.checked);
109 112
110 createShortcut.checked = !shortcutsAllowed; 113 createShortcut.checked = !shortcutsAllowed;
111 createManaged.checked = true; 114 createManaged.checked = true;
112 OptionsPage.closeOverlay(); 115 OptionsPage.closeOverlay();
113 OptionsPage.showPageByName('createProfile'); 116 OptionsPage.showPageByName('createProfile');
114 assertEquals(shortcutsAllowed, createShortcut.checked); 117 assertEquals(shortcutsAllowed, createShortcut.checked);
115 assertFalse(createManaged.checked); 118 assertFalse(createManaged.checked);
119 testDone();
116 }); 120 });
117 121
118 // The checkbox label should change depending on whether the user is signed in. 122 // The checkbox label should change depending on whether the user is signed in.
119 TEST_F('ManageProfileUITest', 'CreateManagedUserText', function() { 123 TEST_F('ManageProfileUITest', 'CreateManagedUserText', function() {
120 var signedInText = $('create-profile-managed-signed-in'); 124 var signedInText = $('create-profile-managed-signed-in');
121 var notSignedInText = $('create-profile-managed-not-signed-in'); 125 var notSignedInText = $('create-profile-managed-not-signed-in');
122 126
123 ManageProfileOverlay.getInstance().initializePage(); 127 ManageProfileOverlay.getInstance().initializePage();
124 128
125 var custodianEmail = 'chrome.playpen.test@gmail.com'; 129 var custodianEmail = 'chrome.playpen.test@gmail.com';
126 CreateProfileOverlay.updateSignedInStatus(custodianEmail); 130 CreateProfileOverlay.updateSignedInStatus(custodianEmail);
127 assertEquals(custodianEmail, 131 assertEquals(custodianEmail,
128 CreateProfileOverlay.getInstance().signedInEmail_); 132 CreateProfileOverlay.getInstance().signedInEmail_);
129 assertFalse(signedInText.hidden); 133 assertFalse(signedInText.hidden);
130 assertTrue(notSignedInText.hidden); 134 assertTrue(notSignedInText.hidden);
131 // Make sure the email is in the string somewhere, without depending on the 135 // Make sure the email is in the string somewhere, without depending on the
132 // exact details of the message. 136 // exact details of the message.
133 assertNotEquals(-1, signedInText.textContent.indexOf(custodianEmail)); 137 assertNotEquals(-1, signedInText.textContent.indexOf(custodianEmail));
134 138
135 CreateProfileOverlay.updateSignedInStatus(''); 139 CreateProfileOverlay.updateSignedInStatus('');
136 assertEquals('', CreateProfileOverlay.getInstance().signedInEmail_); 140 assertEquals('', CreateProfileOverlay.getInstance().signedInEmail_);
137 assertTrue(signedInText.hidden); 141 assertTrue(signedInText.hidden);
138 assertFalse(notSignedInText.hidden); 142 assertFalse(notSignedInText.hidden);
139 assertFalse($('create-profile-managed').checked); 143 assertFalse($('create-profile-managed').checked);
140 assertTrue($('create-profile-managed').disabled); 144 assertTrue($('create-profile-managed').disabled);
145 testDone();
141 }); 146 });
142 147
143 // The import link should show up if the user tries to create a profile with the 148 // 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. 149 // same name as an existing managed user profile.
145 TEST_F('ManageProfileUITest', 'CreateExistingManagedUser', function() { 150 TEST_F('ManageProfileUITest', 'CreateExistingManagedUser', function() {
146 ManageProfileOverlay.getInstance().initializePage(); 151 ManageProfileOverlay.getInstance().initializePage();
147 var custodianEmail = 'chrome.playpen.test@gmail.com'; 152 var custodianEmail = 'chrome.playpen.test@gmail.com';
148 CreateProfileOverlay.updateSignedInStatus(custodianEmail); 153 CreateProfileOverlay.updateSignedInStatus(custodianEmail);
149 assertEquals(custodianEmail, 154 assertEquals(custodianEmail,
150 CreateProfileOverlay.getInstance().signedInEmail_); 155 CreateProfileOverlay.getInstance().signedInEmail_);
151 this.setProfileManaged_(false, 'create'); 156 this.setProfileManaged_(false, 'create');
152 157
153 // Initialize the list of existing managed users. 158 // Initialize the list of existing managed users.
154 var managedUserListData = options.ManagedUserListData.getInstance(); 159 var managedUsers = [
155 managedUserListData.managedUsers_ = [
156 { 160 {
157 id: 'managedUser1', 161 id: 'managedUser1',
158 name: 'Rosalie', 162 name: 'Rosalie',
159 iconURL: 'chrome://path/to/icon/image', 163 iconURL: 'chrome://path/to/icon/image',
160 onCurrentDevice: false, 164 onCurrentDevice: false,
165 nameConflict: false,
161 needAvatar: false 166 needAvatar: false
162 }, 167 },
163 { 168 {
164 id: 'managedUser2', 169 id: 'managedUser2',
165 name: 'Fritz', 170 name: 'Fritz',
166 iconURL: 'chrome://path/to/icon/image', 171 iconURL: 'chrome://path/to/icon/image',
167 onCurrentDevice: false, 172 onCurrentDevice: false,
173 nameConflict: false,
168 needAvatar: true 174 needAvatar: true
169 }, 175 },
170 { 176 {
171 id: 'managedUser3', 177 id: 'managedUser3',
172 name: 'Test', 178 name: 'Test',
173 iconURL: 'chrome://path/to/icon/image', 179 iconURL: 'chrome://path/to/icon/image',
174 onCurrentDevice: true, 180 onCurrentDevice: true,
181 nameConflict: true,
175 needAvatar: false 182 needAvatar: false
176 }]; 183 }];
184 var promise = Promise.resolve(managedUsers);
185 options.ManagedUserListData.getInstance().promise_ = promise;
177 // Also add the name 'Test' to |profileNames_| to simulate that the profile 186 // Also add the name 'Test' to |profileNames_| to simulate that the profile
178 // exists on the device. 187 // exists on the device.
179 ManageProfileOverlay.getInstance().profileNames_.Test = true; 188 ManageProfileOverlay.getInstance().profileNames_.Test = true;
180 189
181 // Initially, the ok button should be enabled and the import link should not 190 // Initially, the ok button should be enabled and the import link should not
182 // exist. 191 // exist.
183 assertFalse($('create-profile-ok').disabled); 192 assertFalse($('create-profile-ok').disabled);
184 assertTrue($('supervised-user-import') == null); 193 assertTrue($('supervised-user-import') == null);
185 194
186 // Now try to create profiles with the names of existing supervised users. 195 // Now try to create profiles with the names of existing supervised users.
187 $('create-profile-managed').checked = true; 196 $('create-profile-managed').checked = true;
188 var nameField = $('create-profile-name'); 197 var nameField = $('create-profile-name');
189 // A profile which already has an avatar. 198 // A profile which already has an avatar.
190 nameField.value = 'Rosalie'; 199 nameField.value = 'Rosalie';
191 ManageProfileOverlay.getInstance().onNameChanged_('create'); 200 ManageProfileOverlay.getInstance().onNameChanged_('create');
192 assertTrue($('create-profile-ok').disabled); 201 // Need to wait until the promise resolves.
193 assertFalse($('supervised-user-import') == null); 202 promise.then(function() {
194 // A profile which doesn't have an avatar yet. 203 assertTrue($('create-profile-ok').disabled);
195 nameField.value = 'Fritz'; 204 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 205
205 // A profile which does not exist yet. 206 // A profile which doesn't have an avatar yet.
206 nameField.value = 'NewProfileName'; 207 nameField.value = 'Fritz';
207 ManageProfileOverlay.getInstance().onNameChanged_('create'); 208 ManageProfileOverlay.getInstance().onNameChanged_('create');
208 assertFalse($('create-profile-ok').disabled); 209 promise.then(function() {
Bernhard Bauer 2014/01/13 17:18:47 You're waiting on the same promise, which is alrea
Adrian Kuegel 2014/01/15 14:15:35 You are right, in a normal execution it could have
209 assertTrue($('supervised-user-import') == null); 210 assertTrue($('create-profile-ok').disabled);
211 assertFalse($('supervised-user-import') == null);
212
213 // A profile which already exists on the device.
214 nameField.value = 'Test';
215 ManageProfileOverlay.getInstance().onNameChanged_('create');
216 promise.then(function() {
217 assertTrue($('create-profile-ok').disabled);
218 assertTrue($('supervised-user-import') == null);
219
220 // A profile which does not exist yet.
221 nameField.value = 'NewProfileName';
222 ManageProfileOverlay.getInstance().onNameChanged_('create');
223 promise.then(function() {
224 assertFalse($('create-profile-ok').disabled);
225 assertTrue($('supervised-user-import') == null);
226 testDone();
227 });
228 });
229 });
230 });
210 }); 231 });
211 232
212 // Managed users should not be able to edit their profile names, and the initial 233 // Managed users should not be able to edit their profile names, and the initial
213 // focus should be adjusted accordingly. 234 // focus should be adjusted accordingly.
214 TEST_F('ManageProfileUITest', 'EditManagedUserNameAllowed', function() { 235 TEST_F('ManageProfileUITest', 'EditManagedUserNameAllowed', function() {
215 var nameField = $('manage-profile-name'); 236 var nameField = $('manage-profile-name');
216 237
217 this.setProfileManaged_(false, 'manage'); 238 this.setProfileManaged_(false, 'manage');
218 ManageProfileOverlay.showManageDialog(); 239 ManageProfileOverlay.showManageDialog();
219 expectFalse(nameField.disabled); 240 expectFalse(nameField.disabled);
220 expectEquals(nameField, document.activeElement); 241 expectEquals(nameField, document.activeElement);
221 242
222 OptionsPage.closeOverlay(); 243 OptionsPage.closeOverlay();
223 244
224 this.setProfileManaged_(true, 'manage'); 245 this.setProfileManaged_(true, 'manage');
225 ManageProfileOverlay.showManageDialog(); 246 ManageProfileOverlay.showManageDialog();
226 expectTrue(nameField.disabled); 247 expectTrue(nameField.disabled);
227 expectEquals($('manage-profile-ok'), document.activeElement); 248 expectEquals($('manage-profile-ok'), document.activeElement);
249 testDone();
228 }); 250 });
229 251
230 // Setting profile information should allow the confirmation to be shown. 252 // Setting profile information should allow the confirmation to be shown.
231 TEST_F('ManageProfileUITest', 'ShowCreateConfirmation', function() { 253 TEST_F('ManageProfileUITest', 'ShowCreateConfirmation', function() {
232 var testProfile = this.testProfileInfo_(true); 254 var testProfile = this.testProfileInfo_(true);
233 testProfile.custodianEmail = 'foo@bar.example.com'; 255 testProfile.custodianEmail = 'foo@bar.example.com';
234 ManagedUserCreateConfirmOverlay.setProfileInfo(testProfile); 256 ManagedUserCreateConfirmOverlay.setProfileInfo(testProfile);
235 assertTrue(ManagedUserCreateConfirmOverlay.getInstance().canShowPage()); 257 assertTrue(ManagedUserCreateConfirmOverlay.getInstance().canShowPage());
236 OptionsPage.showPageByName('managedUserCreateConfirm', false); 258 OptionsPage.showPageByName('managedUserCreateConfirm', false);
237 assertEquals('managedUserCreateConfirm', 259 assertEquals('managedUserCreateConfirm',
238 OptionsPage.getTopmostVisiblePage().name); 260 OptionsPage.getTopmostVisiblePage().name);
261 testDone();
239 }); 262 });
240 263
241 // Trying to show a confirmation dialog with no profile information should fall 264 // Trying to show a confirmation dialog with no profile information should fall
242 // back to the default (main) settings page. 265 // back to the default (main) settings page.
243 TEST_F('ManageProfileUITest', 'NoEmptyConfirmation', function() { 266 TEST_F('ManageProfileUITest', 'NoEmptyConfirmation', function() {
244 assertEquals('manageProfile', OptionsPage.getTopmostVisiblePage().name); 267 assertEquals('manageProfile', OptionsPage.getTopmostVisiblePage().name);
245 assertFalse(ManagedUserCreateConfirmOverlay.getInstance().canShowPage()); 268 assertFalse(ManagedUserCreateConfirmOverlay.getInstance().canShowPage());
246 OptionsPage.showPageByName('managedUserCreateConfirm', true); 269 OptionsPage.showPageByName('managedUserCreateConfirm', true);
247 assertEquals('settings', OptionsPage.getTopmostVisiblePage().name); 270 assertEquals('settings', OptionsPage.getTopmostVisiblePage().name);
271 testDone();
248 }); 272 });
249 273
250 // A confirmation dialog should be shown after creating a new managed user. 274 // A confirmation dialog should be shown after creating a new managed user.
251 TEST_F('ManageProfileUITest', 'ShowCreateConfirmationOnSuccess', function() { 275 TEST_F('ManageProfileUITest', 'ShowCreateConfirmationOnSuccess', function() {
252 OptionsPage.showPageByName('createProfile'); 276 OptionsPage.showPageByName('createProfile');
253 assertEquals('createProfile', OptionsPage.getTopmostVisiblePage().name); 277 assertEquals('createProfile', OptionsPage.getTopmostVisiblePage().name);
254 CreateProfileOverlay.onSuccess(this.testProfileInfo_(false)); 278 CreateProfileOverlay.onSuccess(this.testProfileInfo_(false));
255 assertEquals('settings', OptionsPage.getTopmostVisiblePage().name); 279 assertEquals('settings', OptionsPage.getTopmostVisiblePage().name);
256 280
257 OptionsPage.showPageByName('createProfile'); 281 OptionsPage.showPageByName('createProfile');
258 assertEquals('createProfile', OptionsPage.getTopmostVisiblePage().name); 282 assertEquals('createProfile', OptionsPage.getTopmostVisiblePage().name);
259 CreateProfileOverlay.onSuccess(this.testProfileInfo_(true)); 283 CreateProfileOverlay.onSuccess(this.testProfileInfo_(true));
260 assertEquals('managedUserCreateConfirm', 284 assertEquals('managedUserCreateConfirm',
261 OptionsPage.getTopmostVisiblePage().name); 285 OptionsPage.getTopmostVisiblePage().name);
262 expectEquals($('managed-user-created-switch'), document.activeElement); 286 expectEquals($('managed-user-created-switch'), document.activeElement);
287 testDone();
263 }); 288 });
264 289
265 // An error should be shown if creating a new managed user fails. 290 // An error should be shown if creating a new managed user fails.
266 TEST_F('ManageProfileUITest', 'NoCreateConfirmationOnError', function() { 291 TEST_F('ManageProfileUITest', 'NoCreateConfirmationOnError', function() {
267 OptionsPage.showPageByName('createProfile'); 292 OptionsPage.showPageByName('createProfile');
268 assertEquals('createProfile', OptionsPage.getTopmostVisiblePage().name); 293 assertEquals('createProfile', OptionsPage.getTopmostVisiblePage().name);
269 var errorBubble = $('create-profile-error-bubble'); 294 var errorBubble = $('create-profile-error-bubble');
270 assertTrue(errorBubble.hidden); 295 assertTrue(errorBubble.hidden);
271 296
272 CreateProfileOverlay.onError('An Error Message!'); 297 CreateProfileOverlay.onError('An Error Message!');
273 assertEquals('createProfile', OptionsPage.getTopmostVisiblePage().name); 298 assertEquals('createProfile', OptionsPage.getTopmostVisiblePage().name);
274 assertFalse(errorBubble.hidden); 299 assertFalse(errorBubble.hidden);
300 testDone();
275 }); 301 });
276 302
277 // The name and email sould be inserted into the confirmation dialog. 303 // The name and email sould be inserted into the confirmation dialog.
278 TEST_F('ManageProfileUITest', 'CreateConfirmationText', function () { 304 TEST_F('ManageProfileUITest', 'CreateConfirmationText', function () {
279 var self = this; 305 var self = this;
280 var custodianEmail = 'foo@example.com'; 306 var custodianEmail = 'foo@example.com';
281 307
282 // Checks the strings in the confirmation dialog. If |expectedNameText| is 308 // Checks the strings in the confirmation dialog. If |expectedNameText| is
283 // given, it should be present in the dialog's textContent; otherwise the name 309 // given, it should be present in the dialog's textContent; otherwise the name
284 // is expected. If |expectedNameHtml| is given, it should be present in the 310 // is expected. If |expectedNameHtml| is given, it should be present in the
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
318 assertEquals('createProfile', OptionsPage.getTopmostVisiblePage().name); 344 assertEquals('createProfile', OptionsPage.getTopmostVisiblePage().name);
319 345
320 checkDialog('OneWord'); 346 checkDialog('OneWord');
321 checkDialog('Multiple Words'); 347 checkDialog('Multiple Words');
322 checkDialog('It\'s "<HTML> injection" & more!', 348 checkDialog('It\'s "<HTML> injection" & more!',
323 'It\'s "<HTML> injection" & more!', 349 'It\'s "<HTML> injection" & more!',
324 // The innerHTML getter doesn't escape quotation marks, 350 // The innerHTML getter doesn't escape quotation marks,
325 // independent of whether they were escaped in the setter. 351 // independent of whether they were escaped in the setter.
326 'It\'s "&lt;HTML&gt; injection" &amp; more!'); 352 'It\'s "&lt;HTML&gt; injection" &amp; more!');
327 353
328 // Test elision. MAX_LENGTH = 50, minus 3 for the ellipsis. 354 // Test elision. MAX_LENGTH = 50, minus 1 for the ellipsis.
329 var name47Characters = '01234567890123456789012345678901234567890123456'; 355 var name49Characters = '0123456789012345678901234567890123456789012345678';
330 var name60Characters = name47Characters + '0123456789012'; 356 var name50Characters = name49Characters + '9';
331 checkDialog(name60Characters, name47Characters + '...'); 357 var name51Characters = name50Characters + '0';
358 var name60Characters = name51Characters + '123456789';
359 checkDialog(name49Characters, name49Characters);
360 checkDialog(name50Characters, name50Characters);
361 checkDialog(name51Characters, name49Characters + '\u2026');
362 checkDialog(name60Characters, name49Characters + '\u2026');
332 363
333 // Test both elision and HTML escaping. The allowed string length is the 364 // Test both elision and HTML escaping. The allowed string length is the
334 // visible length, not the length including the entity names. 365 // visible length, not the length including the entity names.
335 name47Characters = name47Characters.replace('0', '&').replace('1', '>'); 366 name49Characters = name49Characters.replace('0', '&').replace('1', '>');
336 name60Characters = name60Characters.replace('0', '&').replace('1', '>'); 367 name60Characters = name60Characters.replace('0', '&').replace('1', '>');
337 var escaped = name47Characters.replace('&', '&amp;').replace('>', '&gt;'); 368 var escaped = name49Characters.replace('&', '&amp;').replace('>', '&gt;');
338 checkDialog(name60Characters, name47Characters + '...', escaped + '...'); 369 checkDialog(
370 name60Characters, name49Characters + '\u2026', escaped + '\u2026');
371 testDone();
339 }); 372 });
340 373
341 // An additional warning should be shown when deleting a managed user. 374 // An additional warning should be shown when deleting a managed user.
342 TEST_F('ManageProfileUITest', 'DeleteManagedUserWarning', function() { 375 TEST_F('ManageProfileUITest', 'DeleteManagedUserWarning', function() {
343 var addendum = $('delete-managed-profile-addendum'); 376 var addendum = $('delete-managed-profile-addendum');
344 377
345 ManageProfileOverlay.showDeleteDialog(this.testProfileInfo_(true)); 378 ManageProfileOverlay.showDeleteDialog(this.testProfileInfo_(true));
346 assertFalse(addendum.hidden); 379 assertFalse(addendum.hidden);
347 380
348 ManageProfileOverlay.showDeleteDialog(this.testProfileInfo_(false)); 381 ManageProfileOverlay.showDeleteDialog(this.testProfileInfo_(false));
349 assertTrue(addendum.hidden); 382 assertTrue(addendum.hidden);
383 testDone();
350 }); 384 });
351 385
352 // The policy prohibiting managed users should update the UI dynamically. 386 // The policy prohibiting managed users should update the UI dynamically.
353 TEST_F('ManageProfileUITest', 'PolicyDynamicRefresh', function() { 387 TEST_F('ManageProfileUITest', 'PolicyDynamicRefresh', function() {
354 ManageProfileOverlay.getInstance().initializePage(); 388 ManageProfileOverlay.getInstance().initializePage();
355 389
356 var custodianEmail = 'chrome.playpen.test@gmail.com'; 390 var custodianEmail = 'chrome.playpen.test@gmail.com';
357 CreateProfileOverlay.updateSignedInStatus(custodianEmail); 391 CreateProfileOverlay.updateSignedInStatus(custodianEmail);
358 CreateProfileOverlay.updateManagedUsersAllowed(true); 392 CreateProfileOverlay.updateManagedUsersAllowed(true);
359 var checkbox = $('create-profile-managed'); 393 var checkbox = $('create-profile-managed');
(...skipping 27 matching lines...) Expand all
387 assertEquals('inline-block', window.getComputedStyle(indicator, null).display, 421 assertEquals('inline-block', window.getComputedStyle(indicator, null).display,
388 'disallowed, signed in'); 422 'disallowed, signed in');
389 assertEquals('policy', indicator.getAttribute('controlled-by')); 423 assertEquals('policy', indicator.getAttribute('controlled-by'));
390 424
391 CreateProfileOverlay.updateSignedInStatus(custodianEmail); 425 CreateProfileOverlay.updateSignedInStatus(custodianEmail);
392 CreateProfileOverlay.updateManagedUsersAllowed(true); 426 CreateProfileOverlay.updateManagedUsersAllowed(true);
393 assertFalse(checkbox.disabled, 're-allowed and signed in'); 427 assertFalse(checkbox.disabled, 're-allowed and signed in');
394 assertFalse(link.hidden, 're-allowed and signed in'); 428 assertFalse(link.hidden, 're-allowed and signed in');
395 assertEquals('none', window.getComputedStyle(indicator, null).display, 429 assertEquals('none', window.getComputedStyle(indicator, null).display,
396 're-allowed and signed in'); 430 're-allowed and signed in');
431 testDone();
397 }); 432 });
398 433
399 // The managed user checkbox should correctly update its state during profile 434 // The managed user checkbox should correctly update its state during profile
400 // creation and afterwards. 435 // creation and afterwards.
401 TEST_F('ManageProfileUITest', 'CreateInProgress', function() { 436 TEST_F('ManageProfileUITest', 'CreateInProgress', function() {
402 ManageProfileOverlay.getInstance().initializePage(); 437 ManageProfileOverlay.getInstance().initializePage();
403 438
404 var custodianEmail = 'chrome.playpen.test@gmail.com'; 439 var custodianEmail = 'chrome.playpen.test@gmail.com';
405 CreateProfileOverlay.updateSignedInStatus(custodianEmail); 440 CreateProfileOverlay.updateSignedInStatus(custodianEmail);
406 CreateProfileOverlay.updateManagedUsersAllowed(true); 441 CreateProfileOverlay.updateManagedUsersAllowed(true);
(...skipping 10 matching lines...) Expand all
417 CreateProfileOverlay.updateCreateInProgress(true); 452 CreateProfileOverlay.updateCreateInProgress(true);
418 assertTrue(checkbox.disabled, 'creation in progress'); 453 assertTrue(checkbox.disabled, 'creation in progress');
419 454
420 // A no-op update to the sign-in status should not change the UI. 455 // A no-op update to the sign-in status should not change the UI.
421 CreateProfileOverlay.updateSignedInStatus(custodianEmail); 456 CreateProfileOverlay.updateSignedInStatus(custodianEmail);
422 CreateProfileOverlay.updateManagedUsersAllowed(true); 457 CreateProfileOverlay.updateManagedUsersAllowed(true);
423 assertTrue(checkbox.disabled, 'creation in progress'); 458 assertTrue(checkbox.disabled, 'creation in progress');
424 459
425 CreateProfileOverlay.updateCreateInProgress(false); 460 CreateProfileOverlay.updateCreateInProgress(false);
426 assertFalse(checkbox.disabled, 'creation finished'); 461 assertFalse(checkbox.disabled, 'creation finished');
462 testDone();
427 }); 463 });
428 464
429 // Managed users shouldn't be able to open the delete or create dialogs. 465 // Managed users shouldn't be able to open the delete or create dialogs.
430 TEST_F('ManageProfileUITest', 'ManagedShowDeleteAndCreate', function() { 466 TEST_F('ManageProfileUITest', 'ManagedShowDeleteAndCreate', function() {
431 this.setProfileManaged_(false, 'create'); 467 this.setProfileManaged_(false, 'create');
432 468
433 ManageProfileOverlay.showCreateDialog(); 469 ManageProfileOverlay.showCreateDialog();
434 assertEquals('createProfile', OptionsPage.getTopmostVisiblePage().name); 470 assertEquals('createProfile', OptionsPage.getTopmostVisiblePage().name);
435 OptionsPage.closeOverlay(); 471 OptionsPage.closeOverlay();
436 assertEquals('settings', OptionsPage.getTopmostVisiblePage().name); 472 assertEquals('settings', OptionsPage.getTopmostVisiblePage().name);
437 ManageProfileOverlay.showDeleteDialog(this.testProfileInfo_(false)); 473 ManageProfileOverlay.showDeleteDialog(this.testProfileInfo_(false));
438 assertEquals('manageProfile', OptionsPage.getTopmostVisiblePage().name); 474 assertEquals('manageProfile', OptionsPage.getTopmostVisiblePage().name);
439 assertFalse($('manage-profile-overlay-delete').hidden); 475 assertFalse($('manage-profile-overlay-delete').hidden);
440 OptionsPage.closeOverlay(); 476 OptionsPage.closeOverlay();
441 assertEquals('settings', OptionsPage.getTopmostVisiblePage().name); 477 assertEquals('settings', OptionsPage.getTopmostVisiblePage().name);
442 478
443 this.setProfileManaged_(true, 'create'); 479 this.setProfileManaged_(true, 'create');
444 ManageProfileOverlay.showCreateDialog(); 480 ManageProfileOverlay.showCreateDialog();
445 assertEquals('settings', OptionsPage.getTopmostVisiblePage().name); 481 assertEquals('settings', OptionsPage.getTopmostVisiblePage().name);
446 ManageProfileOverlay.showDeleteDialog(this.testProfileInfo_(false)); 482 ManageProfileOverlay.showDeleteDialog(this.testProfileInfo_(false));
447 assertEquals('settings', OptionsPage.getTopmostVisiblePage().name); 483 assertEquals('settings', OptionsPage.getTopmostVisiblePage().name);
484 testDone();
448 }); 485 });
449 486
450 // Only non-managed users should be able to delete profiles. 487 // Only non-managed users should be able to delete profiles.
451 TEST_F('ManageProfileUITest', 'ManagedDelete', function() { 488 TEST_F('ManageProfileUITest', 'ManagedDelete', function() {
452 ManageProfileOverlay.showDeleteDialog(this.testProfileInfo_(false)); 489 ManageProfileOverlay.showDeleteDialog(this.testProfileInfo_(false));
453 assertEquals('manageProfile', OptionsPage.getTopmostVisiblePage().name); 490 assertEquals('manageProfile', OptionsPage.getTopmostVisiblePage().name);
454 assertFalse($('manage-profile-overlay-delete').hidden); 491 assertFalse($('manage-profile-overlay-delete').hidden);
455 492
456 // Clicks the "Delete" button, after overriding chrome.send to record what 493 // Clicks the "Delete" button, after overriding chrome.send to record what
457 // messages were sent. 494 // messages were sent.
458 function clickAndListen() { 495 function clickAndListen() {
459 var originalChromeSend = chrome.send; 496 var originalChromeSend = chrome.send;
460 var chromeSendMessages = []; 497 var chromeSendMessages = [];
461 chrome.send = function(message) { 498 chrome.send = function(message) {
462 chromeSendMessages.push(message); 499 chromeSendMessages.push(message);
463 }; 500 };
464 $('delete-profile-ok').onclick(); 501 $('delete-profile-ok').onclick();
465 // Restore the original function so the test framework can use it. 502 // Restore the original function so the test framework can use it.
466 chrome.send = originalChromeSend; 503 chrome.send = originalChromeSend;
467 return chromeSendMessages; 504 return chromeSendMessages;
468 } 505 }
469 506
470 this.setProfileManaged_(false, 'manage'); 507 this.setProfileManaged_(false, 'manage');
471 var messages = clickAndListen(); 508 var messages = clickAndListen();
472 assertEquals(2, messages.length); 509 assertEquals(1, messages.length);
473 assertEquals('deleteProfile', messages[0]); 510 assertEquals('deleteProfile', messages[0]);
474 assertEquals('requestManagedUserImportUpdate', messages[1]);
475 assertEquals('settings', OptionsPage.getTopmostVisiblePage().name); 511 assertEquals('settings', OptionsPage.getTopmostVisiblePage().name);
476 512
477 ManageProfileOverlay.showDeleteDialog(this.testProfileInfo_(false)); 513 ManageProfileOverlay.showDeleteDialog(this.testProfileInfo_(false));
478 this.setProfileManaged_(true, 'manage'); 514 this.setProfileManaged_(true, 'manage');
479 messages = clickAndListen(); 515 messages = clickAndListen();
480 assertEquals(0, messages.length); 516 assertEquals(0, messages.length);
481 assertEquals('settings', OptionsPage.getTopmostVisiblePage().name); 517 assertEquals('settings', OptionsPage.getTopmostVisiblePage().name);
518 testDone();
482 }); 519 });
483 520
484 GEN('#endif // OS_CHROMEOS'); 521 GEN('#endif // OS_CHROMEOS');
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698