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

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

Issue 410293004: Split OptionsPage into Page and PageManager (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Addressed feedback 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 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
61 // Set the profile info in the overlay. 61 // Set the profile info in the overlay.
62 ManageProfileOverlay.setProfileInfo(this.testProfileInfo_(managed), mode); 62 ManageProfileOverlay.setProfileInfo(this.testProfileInfo_(managed), mode);
63 }, 63 },
64 64
65 /** 65 /**
66 * Set some default profile infos (icon URLs and names). 66 * Set some default profile infos (icon URLs and names).
67 * @param {boolean} managed Whether the test profile should be marked managed. 67 * @param {boolean} managed Whether the test profile should be marked managed.
68 * @param {string} mode The mode of the overlay (either 'manage' or 'create'). 68 * @param {string} mode The mode of the overlay (either 'manage' or 'create').
69 */ 69 */
70 initDefaultProfiles_: function(mode) { 70 initDefaultProfiles_: function(mode) {
71 OptionsPage.showPageByName(mode + 'Profile'); 71 PageManager.showPageByName(mode + 'Profile');
72 72
73 var defaultProfile = { 73 var defaultProfile = {
74 name: 'Default Name', 74 name: 'Default Name',
75 iconURL: '/default/path', 75 iconURL: '/default/path',
76 }; 76 };
77 this.defaultIconURLs = ['/some/path', 77 this.defaultIconURLs = ['/some/path',
78 defaultProfile.iconURL, 78 defaultProfile.iconURL,
79 '/another/path', 79 '/another/path',
80 '/one/more/path']; 80 '/one/more/path'];
81 this.defaultNames = ['Some Name', defaultProfile.name, '', 'Another Name']; 81 this.defaultNames = ['Some Name', defaultProfile.name, '', 'Another Name'];
82 ManageProfileOverlay.receiveDefaultProfileIconsAndNames( 82 ManageProfileOverlay.receiveDefaultProfileIconsAndNames(
83 mode, this.defaultIconURLs, this.defaultNames); 83 mode, this.defaultIconURLs, this.defaultNames);
84 ManageProfileOverlay.receiveNewProfileDefaults(defaultProfile); 84 ManageProfileOverlay.receiveNewProfileDefaults(defaultProfile);
85 85
86 // Make sure the correct item in the icon grid was selected. 86 // Make sure the correct item in the icon grid was selected.
87 var gridEl = $(mode + '-profile-icon-grid'); 87 var gridEl = $(mode + '-profile-icon-grid');
88 expectEquals(defaultProfile.iconURL, gridEl.selectedItem); 88 expectEquals(defaultProfile.iconURL, gridEl.selectedItem);
89 }, 89 },
90 }; 90 };
91 91
92 // Receiving the new profile defaults in the manage-user overlay shouldn't mess 92 // Receiving the new profile defaults in the manage-user overlay shouldn't mess
93 // up the focus in a visible higher-level overlay. 93 // up the focus in a visible higher-level overlay.
94 TEST_F('ManageProfileUITest', 'NewProfileDefaultsFocus', function() { 94 TEST_F('ManageProfileUITest', 'NewProfileDefaultsFocus', function() {
95 var self = this; 95 var self = this;
96 96
97 function checkFocus(pageName, expectedFocus, initialFocus) { 97 function checkFocus(pageName, expectedFocus, initialFocus) {
98 OptionsPage.showPageByName(pageName); 98 PageManager.showPageByName(pageName);
99 initialFocus.focus(); 99 initialFocus.focus();
100 expectEquals(initialFocus, document.activeElement, pageName); 100 expectEquals(initialFocus, document.activeElement, pageName);
101 101
102 ManageProfileOverlay.receiveNewProfileDefaults( 102 ManageProfileOverlay.receiveNewProfileDefaults(
103 self.testProfileInfo_(false)); 103 self.testProfileInfo_(false));
104 expectEquals(expectedFocus, document.activeElement, pageName); 104 expectEquals(expectedFocus, document.activeElement, pageName);
105 OptionsPage.closeOverlay(); 105 PageManager.closeOverlay();
106 } 106 }
107 107
108 // Receiving new profile defaults sets focus to the name field if the create 108 // 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. 109 // overlay is open, and should not change focus at all otherwise.
110 checkFocus('manageProfile', 110 checkFocus('manageProfile',
111 $('manage-profile-cancel'), 111 $('manage-profile-cancel'),
112 $('manage-profile-cancel')); 112 $('manage-profile-cancel'));
113 checkFocus('createProfile', 113 checkFocus('createProfile',
114 $('create-profile-name'), 114 $('create-profile-name'),
115 $('create-profile-cancel')); 115 $('create-profile-cancel'));
116 checkFocus('managedUserLearnMore', 116 checkFocus('managedUserLearnMore',
117 $('managed-user-learn-more-done'), 117 $('managed-user-learn-more-done'),
118 $('managed-user-learn-more-done')); 118 $('managed-user-learn-more-done'));
119 checkFocus('managedUserLearnMore', 119 checkFocus('managedUserLearnMore',
120 document.querySelector('#managed-user-learn-more-text a'), 120 document.querySelector('#managed-user-learn-more-text a'),
121 document.querySelector('#managed-user-learn-more-text a')); 121 document.querySelector('#managed-user-learn-more-text a'));
122 }); 122 });
123 123
124 // The default options should be reset each time the creation overlay is shown. 124 // The default options should be reset each time the creation overlay is shown.
125 TEST_F('ManageProfileUITest', 'DefaultCreateOptions', function() { 125 TEST_F('ManageProfileUITest', 'DefaultCreateOptions', function() {
126 OptionsPage.showPageByName('createProfile'); 126 PageManager.showPageByName('createProfile');
127 var shortcutsAllowed = loadTimeData.getBoolean('profileShortcutsEnabled'); 127 var shortcutsAllowed = loadTimeData.getBoolean('profileShortcutsEnabled');
128 var createShortcut = $('create-shortcut'); 128 var createShortcut = $('create-shortcut');
129 var createManaged = $('create-profile-managed'); 129 var createManaged = $('create-profile-managed');
130 assertEquals(shortcutsAllowed, createShortcut.checked); 130 assertEquals(shortcutsAllowed, createShortcut.checked);
131 assertFalse(createManaged.checked); 131 assertFalse(createManaged.checked);
132 132
133 createShortcut.checked = !shortcutsAllowed; 133 createShortcut.checked = !shortcutsAllowed;
134 createManaged.checked = true; 134 createManaged.checked = true;
135 OptionsPage.closeOverlay(); 135 PageManager.closeOverlay();
136 OptionsPage.showPageByName('createProfile'); 136 PageManager.showPageByName('createProfile');
137 assertEquals(shortcutsAllowed, createShortcut.checked); 137 assertEquals(shortcutsAllowed, createShortcut.checked);
138 assertFalse(createManaged.checked); 138 assertFalse(createManaged.checked);
139 }); 139 });
140 140
141 // The checkbox label should change depending on whether the user is signed in. 141 // The checkbox label should change depending on whether the user is signed in.
142 TEST_F('ManageProfileUITest', 'CreateManagedUserText', function() { 142 TEST_F('ManageProfileUITest', 'CreateManagedUserText', function() {
143 var signedInText = $('create-profile-managed-signed-in'); 143 var signedInText = $('create-profile-managed-signed-in');
144 var notSignedInText = $('create-profile-managed-not-signed-in'); 144 var notSignedInText = $('create-profile-managed-not-signed-in');
145 145
146 ManageProfileOverlay.getInstance().initializePage(); 146 ManageProfileOverlay.getInstance().initializePage();
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
275 // Managed users should not be able to edit their profile names, and the initial 275 // Managed users should not be able to edit their profile names, and the initial
276 // focus should be adjusted accordingly. 276 // focus should be adjusted accordingly.
277 TEST_F('ManageProfileUITest', 'EditManagedUserNameAllowed', function() { 277 TEST_F('ManageProfileUITest', 'EditManagedUserNameAllowed', function() {
278 var nameField = $('manage-profile-name'); 278 var nameField = $('manage-profile-name');
279 279
280 this.setProfileManaged_(false, 'manage'); 280 this.setProfileManaged_(false, 'manage');
281 ManageProfileOverlay.showManageDialog(); 281 ManageProfileOverlay.showManageDialog();
282 expectFalse(nameField.disabled); 282 expectFalse(nameField.disabled);
283 expectEquals(nameField, document.activeElement); 283 expectEquals(nameField, document.activeElement);
284 284
285 OptionsPage.closeOverlay(); 285 PageManager.closeOverlay();
286 286
287 this.setProfileManaged_(true, 'manage'); 287 this.setProfileManaged_(true, 'manage');
288 ManageProfileOverlay.showManageDialog(); 288 ManageProfileOverlay.showManageDialog();
289 expectTrue(nameField.disabled); 289 expectTrue(nameField.disabled);
290 expectEquals($('manage-profile-ok'), document.activeElement); 290 expectEquals($('manage-profile-ok'), document.activeElement);
291 }); 291 });
292 292
293 // Setting profile information should allow the confirmation to be shown. 293 // Setting profile information should allow the confirmation to be shown.
294 TEST_F('ManageProfileUITest', 'ShowCreateConfirmation', function() { 294 TEST_F('ManageProfileUITest', 'ShowCreateConfirmation', function() {
295 var testProfile = this.testProfileInfo_(true); 295 var testProfile = this.testProfileInfo_(true);
296 testProfile.custodianEmail = 'foo@bar.example.com'; 296 testProfile.custodianEmail = 'foo@bar.example.com';
297 ManagedUserCreateConfirmOverlay.setProfileInfo(testProfile); 297 ManagedUserCreateConfirmOverlay.setProfileInfo(testProfile);
298 assertTrue(ManagedUserCreateConfirmOverlay.getInstance().canShowPage()); 298 assertTrue(ManagedUserCreateConfirmOverlay.getInstance().canShowPage());
299 OptionsPage.showPageByName('managedUserCreateConfirm', false); 299 PageManager.showPageByName('managedUserCreateConfirm', false);
300 assertEquals('managedUserCreateConfirm', 300 assertEquals('managedUserCreateConfirm',
301 OptionsPage.getTopmostVisiblePage().name); 301 PageManager.getTopmostVisiblePage().name);
302 }); 302 });
303 303
304 // Trying to show a confirmation dialog with no profile information should fall 304 // Trying to show a confirmation dialog with no profile information should fall
305 // back to the default (main) settings page. 305 // back to the default (main) settings page.
306 TEST_F('ManageProfileUITest', 'NoEmptyConfirmation', function() { 306 TEST_F('ManageProfileUITest', 'NoEmptyConfirmation', function() {
307 assertEquals('manageProfile', OptionsPage.getTopmostVisiblePage().name); 307 assertEquals('manageProfile', PageManager.getTopmostVisiblePage().name);
308 assertFalse(ManagedUserCreateConfirmOverlay.getInstance().canShowPage()); 308 assertFalse(ManagedUserCreateConfirmOverlay.getInstance().canShowPage());
309 OptionsPage.showPageByName('managedUserCreateConfirm', true); 309 PageManager.showPageByName('managedUserCreateConfirm', true);
310 assertEquals('settings', OptionsPage.getTopmostVisiblePage().name); 310 assertEquals('settings', PageManager.getTopmostVisiblePage().name);
311 }); 311 });
312 312
313 // A confirmation dialog should be shown after creating a new managed user. 313 // A confirmation dialog should be shown after creating a new managed user.
314 TEST_F('ManageProfileUITest', 'ShowCreateConfirmationOnSuccess', function() { 314 TEST_F('ManageProfileUITest', 'ShowCreateConfirmationOnSuccess', function() {
315 OptionsPage.showPageByName('createProfile'); 315 PageManager.showPageByName('createProfile');
316 assertEquals('createProfile', OptionsPage.getTopmostVisiblePage().name); 316 assertEquals('createProfile', PageManager.getTopmostVisiblePage().name);
317 CreateProfileOverlay.onSuccess(this.testProfileInfo_(false)); 317 CreateProfileOverlay.onSuccess(this.testProfileInfo_(false));
318 assertEquals('settings', OptionsPage.getTopmostVisiblePage().name); 318 assertEquals('settings', PageManager.getTopmostVisiblePage().name);
319 319
320 OptionsPage.showPageByName('createProfile'); 320 PageManager.showPageByName('createProfile');
321 assertEquals('createProfile', OptionsPage.getTopmostVisiblePage().name); 321 assertEquals('createProfile', PageManager.getTopmostVisiblePage().name);
322 CreateProfileOverlay.onSuccess(this.testProfileInfo_(true)); 322 CreateProfileOverlay.onSuccess(this.testProfileInfo_(true));
323 assertEquals('managedUserCreateConfirm', 323 assertEquals('managedUserCreateConfirm',
324 OptionsPage.getTopmostVisiblePage().name); 324 PageManager.getTopmostVisiblePage().name);
325 expectEquals($('managed-user-created-switch'), document.activeElement); 325 expectEquals($('managed-user-created-switch'), document.activeElement);
326 }); 326 });
327 327
328 // An error should be shown if creating a new managed user fails. 328 // An error should be shown if creating a new managed user fails.
329 TEST_F('ManageProfileUITest', 'NoCreateConfirmationOnError', function() { 329 TEST_F('ManageProfileUITest', 'NoCreateConfirmationOnError', function() {
330 OptionsPage.showPageByName('createProfile'); 330 PageManager.showPageByName('createProfile');
331 assertEquals('createProfile', OptionsPage.getTopmostVisiblePage().name); 331 assertEquals('createProfile', PageManager.getTopmostVisiblePage().name);
332 var errorBubble = $('create-profile-error-bubble'); 332 var errorBubble = $('create-profile-error-bubble');
333 assertTrue(errorBubble.hidden); 333 assertTrue(errorBubble.hidden);
334 334
335 CreateProfileOverlay.onError('An Error Message!'); 335 CreateProfileOverlay.onError('An Error Message!');
336 assertEquals('createProfile', OptionsPage.getTopmostVisiblePage().name); 336 assertEquals('createProfile', PageManager.getTopmostVisiblePage().name);
337 assertFalse(errorBubble.hidden); 337 assertFalse(errorBubble.hidden);
338 }); 338 });
339 339
340 // The name and email should be inserted into the confirmation dialog. 340 // The name and email should be inserted into the confirmation dialog.
341 TEST_F('ManageProfileUITest', 'CreateConfirmationText', function() { 341 TEST_F('ManageProfileUITest', 'CreateConfirmationText', function() {
342 var self = this; 342 var self = this;
343 var custodianEmail = 'foo@example.com'; 343 var custodianEmail = 'foo@example.com';
344 344
345 // Checks the strings in the confirmation dialog. If |expectedNameText| is 345 // Checks the strings in the confirmation dialog. If |expectedNameText| is
346 // given, it should be present in the dialog's textContent; otherwise the name 346 // 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 347 // 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 348 // dialog's innerHTML; otherwise the expected text is expected in the HTML
349 // too. 349 // too.
350 function checkDialog(name, expectedNameText, expectedNameHtml) { 350 function checkDialog(name, expectedNameText, expectedNameHtml) {
351 var expectedText = expectedNameText || name; 351 var expectedText = expectedNameText || name;
352 var expectedHtml = expectedNameHtml || expectedText; 352 var expectedHtml = expectedNameHtml || expectedText;
353 353
354 // Configure the test profile and show the confirmation dialog. 354 // Configure the test profile and show the confirmation dialog.
355 var testProfile = self.testProfileInfo_(true); 355 var testProfile = self.testProfileInfo_(true);
356 testProfile.name = name; 356 testProfile.name = name;
357 CreateProfileOverlay.onSuccess(testProfile); 357 CreateProfileOverlay.onSuccess(testProfile);
358 assertEquals('managedUserCreateConfirm', 358 assertEquals('managedUserCreateConfirm',
359 OptionsPage.getTopmostVisiblePage().name); 359 PageManager.getTopmostVisiblePage().name);
360 360
361 // Check for the presence of the name and email in the UI, without depending 361 // Check for the presence of the name and email in the UI, without depending
362 // on the details of the messsages. 362 // on the details of the messsages.
363 assertNotEquals(-1, 363 assertNotEquals(-1,
364 $('managed-user-created-title').textContent.indexOf(expectedText)); 364 $('managed-user-created-title').textContent.indexOf(expectedText));
365 assertNotEquals(-1, 365 assertNotEquals(-1,
366 $('managed-user-created-switch').textContent.indexOf(expectedText)); 366 $('managed-user-created-switch').textContent.indexOf(expectedText));
367 var message = $('managed-user-created-text'); 367 var message = $('managed-user-created-text');
368 assertNotEquals(-1, message.textContent.indexOf(expectedText)); 368 assertNotEquals(-1, message.textContent.indexOf(expectedText));
369 assertNotEquals(-1, message.textContent.indexOf(custodianEmail)); 369 assertNotEquals(-1, message.textContent.indexOf(custodianEmail));
370 370
371 // The name should be properly HTML-escaped. 371 // The name should be properly HTML-escaped.
372 assertNotEquals(-1, message.innerHTML.indexOf(expectedHtml)); 372 assertNotEquals(-1, message.innerHTML.indexOf(expectedHtml));
373 373
374 OptionsPage.closeOverlay(); 374 PageManager.closeOverlay();
375 assertEquals('settings', OptionsPage.getTopmostVisiblePage().name, name); 375 assertEquals('settings', PageManager.getTopmostVisiblePage().name, name);
376 } 376 }
377 377
378 // Show and configure the create-profile dialog. 378 // Show and configure the create-profile dialog.
379 OptionsPage.showPageByName('createProfile'); 379 PageManager.showPageByName('createProfile');
380 CreateProfileOverlay.updateSignedInStatus(custodianEmail); 380 CreateProfileOverlay.updateSignedInStatus(custodianEmail);
381 assertEquals('createProfile', OptionsPage.getTopmostVisiblePage().name); 381 assertEquals('createProfile', PageManager.getTopmostVisiblePage().name);
382 382
383 checkDialog('OneWord'); 383 checkDialog('OneWord');
384 checkDialog('Multiple Words'); 384 checkDialog('Multiple Words');
385 checkDialog('It\'s "<HTML> injection" & more!', 385 checkDialog('It\'s "<HTML> injection" & more!',
386 'It\'s "<HTML> injection" & more!', 386 'It\'s "<HTML> injection" & more!',
387 // The innerHTML getter doesn't escape quotation marks, 387 // The innerHTML getter doesn't escape quotation marks,
388 // independent of whether they were escaped in the setter. 388 // independent of whether they were escaped in the setter.
389 'It\'s "&lt;HTML&gt; injection" &amp; more!'); 389 'It\'s "&lt;HTML&gt; injection" &amp; more!');
390 390
391 // Test elision. MAX_LENGTH = 50, minus 1 for the ellipsis. 391 // Test elision. MAX_LENGTH = 50, minus 1 for the ellipsis.
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
493 493
494 CreateProfileOverlay.updateCreateInProgress(false); 494 CreateProfileOverlay.updateCreateInProgress(false);
495 assertFalse(checkbox.disabled, 'creation finished'); 495 assertFalse(checkbox.disabled, 'creation finished');
496 }); 496 });
497 497
498 // Managed users shouldn't be able to open the delete or create dialogs. 498 // Managed users shouldn't be able to open the delete or create dialogs.
499 TEST_F('ManageProfileUITest', 'ManagedShowDeleteAndCreate', function() { 499 TEST_F('ManageProfileUITest', 'ManagedShowDeleteAndCreate', function() {
500 this.setProfileManaged_(false, 'create'); 500 this.setProfileManaged_(false, 'create');
501 501
502 ManageProfileOverlay.showCreateDialog(); 502 ManageProfileOverlay.showCreateDialog();
503 assertEquals('createProfile', OptionsPage.getTopmostVisiblePage().name); 503 assertEquals('createProfile', PageManager.getTopmostVisiblePage().name);
504 OptionsPage.closeOverlay(); 504 PageManager.closeOverlay();
505 assertEquals('settings', OptionsPage.getTopmostVisiblePage().name); 505 assertEquals('settings', PageManager.getTopmostVisiblePage().name);
506 ManageProfileOverlay.showDeleteDialog(this.testProfileInfo_(false)); 506 ManageProfileOverlay.showDeleteDialog(this.testProfileInfo_(false));
507 assertEquals('manageProfile', OptionsPage.getTopmostVisiblePage().name); 507 assertEquals('manageProfile', PageManager.getTopmostVisiblePage().name);
508 assertFalse($('manage-profile-overlay-delete').hidden); 508 assertFalse($('manage-profile-overlay-delete').hidden);
509 OptionsPage.closeOverlay(); 509 PageManager.closeOverlay();
510 assertEquals('settings', OptionsPage.getTopmostVisiblePage().name); 510 assertEquals('settings', PageManager.getTopmostVisiblePage().name);
511 511
512 this.setProfileManaged_(true, 'create'); 512 this.setProfileManaged_(true, 'create');
513 ManageProfileOverlay.showCreateDialog(); 513 ManageProfileOverlay.showCreateDialog();
514 assertEquals('settings', OptionsPage.getTopmostVisiblePage().name); 514 assertEquals('settings', PageManager.getTopmostVisiblePage().name);
515 ManageProfileOverlay.showDeleteDialog(this.testProfileInfo_(false)); 515 ManageProfileOverlay.showDeleteDialog(this.testProfileInfo_(false));
516 assertEquals('settings', OptionsPage.getTopmostVisiblePage().name); 516 assertEquals('settings', PageManager.getTopmostVisiblePage().name);
517 }); 517 });
518 518
519 // Only non-managed users should be able to delete profiles. 519 // Only non-managed users should be able to delete profiles.
520 TEST_F('ManageProfileUITest', 'ManagedDelete', function() { 520 TEST_F('ManageProfileUITest', 'ManagedDelete', function() {
521 ManageProfileOverlay.showDeleteDialog(this.testProfileInfo_(false)); 521 ManageProfileOverlay.showDeleteDialog(this.testProfileInfo_(false));
522 assertEquals('manageProfile', OptionsPage.getTopmostVisiblePage().name); 522 assertEquals('manageProfile', PageManager.getTopmostVisiblePage().name);
523 assertFalse($('manage-profile-overlay-delete').hidden); 523 assertFalse($('manage-profile-overlay-delete').hidden);
524 524
525 // Clicks the "Delete" button, after overriding chrome.send to record what 525 // Clicks the "Delete" button, after overriding chrome.send to record what
526 // messages were sent. 526 // messages were sent.
527 function clickAndListen() { 527 function clickAndListen() {
528 var originalChromeSend = chrome.send; 528 var originalChromeSend = chrome.send;
529 var chromeSendMessages = []; 529 var chromeSendMessages = [];
530 chrome.send = function(message) { 530 chrome.send = function(message) {
531 chromeSendMessages.push(message); 531 chromeSendMessages.push(message);
532 }; 532 };
533 $('delete-profile-ok').onclick(); 533 $('delete-profile-ok').onclick();
534 // Restore the original function so the test framework can use it. 534 // Restore the original function so the test framework can use it.
535 chrome.send = originalChromeSend; 535 chrome.send = originalChromeSend;
536 return chromeSendMessages; 536 return chromeSendMessages;
537 } 537 }
538 538
539 this.setProfileManaged_(false, 'manage'); 539 this.setProfileManaged_(false, 'manage');
540 var messages = clickAndListen(); 540 var messages = clickAndListen();
541 assertEquals(1, messages.length); 541 assertEquals(1, messages.length);
542 assertEquals('deleteProfile', messages[0]); 542 assertEquals('deleteProfile', messages[0]);
543 assertEquals('settings', OptionsPage.getTopmostVisiblePage().name); 543 assertEquals('settings', PageManager.getTopmostVisiblePage().name);
544 544
545 ManageProfileOverlay.showDeleteDialog(this.testProfileInfo_(false)); 545 ManageProfileOverlay.showDeleteDialog(this.testProfileInfo_(false));
546 this.setProfileManaged_(true, 'manage'); 546 this.setProfileManaged_(true, 'manage');
547 messages = clickAndListen(); 547 messages = clickAndListen();
548 assertEquals(0, messages.length); 548 assertEquals(0, messages.length);
549 assertEquals('settings', OptionsPage.getTopmostVisiblePage().name); 549 assertEquals('settings', PageManager.getTopmostVisiblePage().name);
550 }); 550 });
551 551
552 // Selecting a different avatar image should update the suggested profile name. 552 // Selecting a different avatar image should update the suggested profile name.
553 TEST_F('ManageProfileUITest', 'Create_NameUpdateOnAvatarSelected', function() { 553 TEST_F('ManageProfileUITest', 'Create_NameUpdateOnAvatarSelected', function() {
554 var mode = 'create'; 554 var mode = 'create';
555 this.initDefaultProfiles_(mode); 555 this.initDefaultProfiles_(mode);
556 556
557 var gridEl = $(mode + '-profile-icon-grid'); 557 var gridEl = $(mode + '-profile-icon-grid');
558 var nameEl = $(mode + '-profile-name'); 558 var nameEl = $(mode + '-profile-name');
559 559
560 // Select another icon and check that the profile name was updated. 560 // Select another icon and check that the profile name was updated.
561 assertNotEquals(gridEl.selectedItem, this.defaultIconURLs[0]); 561 assertNotEquals(gridEl.selectedItem, this.defaultIconURLs[0]);
562 gridEl.selectedItem = this.defaultIconURLs[0]; 562 gridEl.selectedItem = this.defaultIconURLs[0];
563 expectEquals(this.defaultNames[0], nameEl.value); 563 expectEquals(this.defaultNames[0], nameEl.value);
564 564
565 // Select icon without an associated name; the profile name shouldn't change. 565 // Select icon without an associated name; the profile name shouldn't change.
566 var oldName = nameEl.value; 566 var oldName = nameEl.value;
567 assertEquals('', this.defaultNames[2]); 567 assertEquals('', this.defaultNames[2]);
568 gridEl.selectedItem = this.defaultIconURLs[2]; 568 gridEl.selectedItem = this.defaultIconURLs[2];
569 expectEquals(oldName, nameEl.value); 569 expectEquals(oldName, nameEl.value);
570 570
571 // Select another icon with a name and check that the name is updated again. 571 // Select another icon with a name and check that the name is updated again.
572 assertNotEquals('', this.defaultNames[1]); 572 assertNotEquals('', this.defaultNames[1]);
573 gridEl.selectedItem = this.defaultIconURLs[1]; 573 gridEl.selectedItem = this.defaultIconURLs[1];
574 expectEquals(this.defaultNames[1], nameEl.value); 574 expectEquals(this.defaultNames[1], nameEl.value);
575 575
576 OptionsPage.closeOverlay(); 576 PageManager.closeOverlay();
577 }); 577 });
578 578
579 // After the user edited the profile name, selecting a different avatar image 579 // After the user edited the profile name, selecting a different avatar image
580 // should not update the suggested name anymore. 580 // should not update the suggested name anymore.
581 TEST_F('ManageProfileUITest', 'Create_NoNameUpdateOnAvatarSelectedAfterEdit', 581 TEST_F('ManageProfileUITest', 'Create_NoNameUpdateOnAvatarSelectedAfterEdit',
582 function() { 582 function() {
583 var mode = 'create'; 583 var mode = 'create';
584 this.initDefaultProfiles_(mode); 584 this.initDefaultProfiles_(mode);
585 585
586 var gridEl = $(mode + '-profile-icon-grid'); 586 var gridEl = $(mode + '-profile-icon-grid');
587 var nameEl = $(mode + '-profile-name'); 587 var nameEl = $(mode + '-profile-name');
588 588
589 // After the user manually entered a name, it should not be changed anymore 589 // After the user manually entered a name, it should not be changed anymore
590 // (even if the entered name is another default name). 590 // (even if the entered name is another default name).
591 nameEl.value = this.defaultNames[3]; 591 nameEl.value = this.defaultNames[3];
592 nameEl.oninput(); 592 nameEl.oninput();
593 gridEl.selectedItem = this.defaultIconURLs[0]; 593 gridEl.selectedItem = this.defaultIconURLs[0];
594 expectEquals(this.defaultNames[3], nameEl.value); 594 expectEquals(this.defaultNames[3], nameEl.value);
595 595
596 OptionsPage.closeOverlay(); 596 PageManager.closeOverlay();
597 }); 597 });
598 598
599 // After the user edited the profile name, selecting a different avatar image 599 // After the user edited the profile name, selecting a different avatar image
600 // should not update the suggested name anymore even if the original suggestion 600 // should not update the suggested name anymore even if the original suggestion
601 // is entered again. 601 // is entered again.
602 TEST_F('ManageProfileUITest', 'Create_NoNameUpdateOnAvatarSelectedAfterRevert', 602 TEST_F('ManageProfileUITest', 'Create_NoNameUpdateOnAvatarSelectedAfterRevert',
603 function() { 603 function() {
604 var mode = 'create'; 604 var mode = 'create';
605 this.initDefaultProfiles_(mode); 605 this.initDefaultProfiles_(mode);
606 606
607 var gridEl = $(mode + '-profile-icon-grid'); 607 var gridEl = $(mode + '-profile-icon-grid');
608 var nameEl = $(mode + '-profile-name'); 608 var nameEl = $(mode + '-profile-name');
609 609
610 // After the user manually entered a name, it should not be changed anymore, 610 // After the user manually entered a name, it should not be changed anymore,
611 // even if the user then reverts to the original suggestion. 611 // even if the user then reverts to the original suggestion.
612 var oldName = nameEl.value; 612 var oldName = nameEl.value;
613 nameEl.value = 'Custom Name'; 613 nameEl.value = 'Custom Name';
614 nameEl.oninput(); 614 nameEl.oninput();
615 nameEl.value = oldName; 615 nameEl.value = oldName;
616 nameEl.oninput(); 616 nameEl.oninput();
617 // Now select another avatar and check that the name remained the same. 617 // Now select another avatar and check that the name remained the same.
618 assertNotEquals(gridEl.selectedItem, this.defaultIconURLs[0]); 618 assertNotEquals(gridEl.selectedItem, this.defaultIconURLs[0]);
619 gridEl.selectedItem = this.defaultIconURLs[0]; 619 gridEl.selectedItem = this.defaultIconURLs[0];
620 expectEquals(oldName, nameEl.value); 620 expectEquals(oldName, nameEl.value);
621 621
622 OptionsPage.closeOverlay(); 622 PageManager.closeOverlay();
623 }); 623 });
624 624
625 // In the manage dialog, the name should never be updated on avatar selection. 625 // In the manage dialog, the name should never be updated on avatar selection.
626 TEST_F('ManageProfileUITest', 'Manage_NoNameUpdateOnAvatarSelected', 626 TEST_F('ManageProfileUITest', 'Manage_NoNameUpdateOnAvatarSelected',
627 function() { 627 function() {
628 var mode = 'manage'; 628 var mode = 'manage';
629 this.setProfileManaged_(false, mode); 629 this.setProfileManaged_(false, mode);
630 OptionsPage.showPageByName(mode + 'Profile'); 630 PageManager.showPageByName(mode + 'Profile');
631 631
632 var testProfile = this.testProfileInfo_(false); 632 var testProfile = this.testProfileInfo_(false);
633 var iconURLs = [testProfile.iconURL, '/some/path', '/another/path']; 633 var iconURLs = [testProfile.iconURL, '/some/path', '/another/path'];
634 var names = [testProfile.name, 'Some Name', '']; 634 var names = [testProfile.name, 'Some Name', ''];
635 ManageProfileOverlay.receiveDefaultProfileIconsAndNames( 635 ManageProfileOverlay.receiveDefaultProfileIconsAndNames(
636 mode, iconURLs, names); 636 mode, iconURLs, names);
637 637
638 var gridEl = $(mode + '-profile-icon-grid'); 638 var gridEl = $(mode + '-profile-icon-grid');
639 var nameEl = $(mode + '-profile-name'); 639 var nameEl = $(mode + '-profile-name');
640 640
641 // Select another icon and check if the profile name was updated. 641 // Select another icon and check if the profile name was updated.
642 var oldName = nameEl.value; 642 var oldName = nameEl.value;
643 gridEl.selectedItem = iconURLs[1]; 643 gridEl.selectedItem = iconURLs[1];
644 expectEquals(oldName, nameEl.value); 644 expectEquals(oldName, nameEl.value);
645 645
646 OptionsPage.closeOverlay(); 646 PageManager.closeOverlay();
647 }); 647 });
648 648
649 GEN('#endif // OS_CHROMEOS'); 649 GEN('#endif // OS_CHROMEOS');
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698