| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 // None of these tests is relevant for Chrome OS. | 5 // None of these tests is relevant for Chrome OS. |
| 6 GEN('#if !defined(OS_CHROMEOS)'); | 6 GEN('#if !defined(OS_CHROMEOS)'); |
| 7 | 7 |
| 8 /** | 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 483 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 494 | 494 |
| 495 // A no-op update to the sign-in status should not change the UI. | 495 // A no-op update to the sign-in status should not change the UI. |
| 496 CreateProfileOverlay.updateSignedInStatus(custodianEmail); | 496 CreateProfileOverlay.updateSignedInStatus(custodianEmail); |
| 497 CreateProfileOverlay.updateSupervisedUsersAllowed(true); | 497 CreateProfileOverlay.updateSupervisedUsersAllowed(true); |
| 498 assertTrue(checkbox.disabled, 'creation in progress'); | 498 assertTrue(checkbox.disabled, 'creation in progress'); |
| 499 | 499 |
| 500 CreateProfileOverlay.updateCreateInProgress(false); | 500 CreateProfileOverlay.updateCreateInProgress(false); |
| 501 assertFalse(checkbox.disabled, 'creation finished'); | 501 assertFalse(checkbox.disabled, 'creation finished'); |
| 502 }); | 502 }); |
| 503 | 503 |
| 504 // Supervised users shouldn't be able to open the delete or create dialogs. | 504 // Supervised users should be able to open the delete dialog, but not the |
| 505 TEST_F('ManageProfileUITest', 'SupervisedShowDeleteAndCreate', function() { | 505 // create dialog. |
| 506 TEST_F('ManageProfileUITest', 'SupervisedShowCreate', function() { |
| 506 this.setProfileSupervised_(false, 'create'); | 507 this.setProfileSupervised_(false, 'create'); |
| 507 | 508 |
| 508 ManageProfileOverlay.showCreateDialog(); | 509 ManageProfileOverlay.showCreateDialog(); |
| 509 assertEquals('createProfile', PageManager.getTopmostVisiblePage().name); | 510 assertEquals('createProfile', PageManager.getTopmostVisiblePage().name); |
| 510 PageManager.closeOverlay(); | 511 PageManager.closeOverlay(); |
| 511 assertEquals('settings', PageManager.getTopmostVisiblePage().name); | 512 assertEquals('settings', PageManager.getTopmostVisiblePage().name); |
| 512 ManageProfileOverlay.showDeleteDialog(this.testProfileInfo_(false)); | 513 ManageProfileOverlay.showDeleteDialog(this.testProfileInfo_(false)); |
| 513 assertEquals('manageProfile', PageManager.getTopmostVisiblePage().name); | 514 assertEquals('manageProfile', PageManager.getTopmostVisiblePage().name); |
| 514 assertFalse($('manage-profile-overlay-delete').hidden); | 515 assertFalse($('manage-profile-overlay-delete').hidden); |
| 515 PageManager.closeOverlay(); | 516 PageManager.closeOverlay(); |
| 516 assertEquals('settings', PageManager.getTopmostVisiblePage().name); | 517 assertEquals('settings', PageManager.getTopmostVisiblePage().name); |
| 517 | 518 |
| 518 this.setProfileSupervised_(true, 'create'); | 519 this.setProfileSupervised_(true, 'create'); |
| 519 ManageProfileOverlay.showCreateDialog(); | 520 ManageProfileOverlay.showCreateDialog(); |
| 520 assertEquals('settings', PageManager.getTopmostVisiblePage().name); | 521 assertEquals('settings', PageManager.getTopmostVisiblePage().name); |
| 521 ManageProfileOverlay.showDeleteDialog(this.testProfileInfo_(false)); | 522 ManageProfileOverlay.showDeleteDialog(this.testProfileInfo_(false)); |
| 522 assertEquals('settings', PageManager.getTopmostVisiblePage().name); | |
| 523 }); | |
| 524 | |
| 525 // Only non-supervised users should be able to delete profiles. | |
| 526 TEST_F('ManageProfileUITest', 'SupervisedDelete', function() { | |
| 527 ManageProfileOverlay.showDeleteDialog(this.testProfileInfo_(false)); | |
| 528 assertEquals('manageProfile', PageManager.getTopmostVisiblePage().name); | 523 assertEquals('manageProfile', PageManager.getTopmostVisiblePage().name); |
| 529 assertFalse($('manage-profile-overlay-delete').hidden); | |
| 530 | |
| 531 // Clicks the "Delete" button, after overriding chrome.send to record what | |
| 532 // messages were sent. | |
| 533 function clickAndListen() { | |
| 534 var originalChromeSend = chrome.send; | |
| 535 var chromeSendMessages = []; | |
| 536 chrome.send = function(message) { | |
| 537 chromeSendMessages.push(message); | |
| 538 }; | |
| 539 $('delete-profile-ok').onclick(); | |
| 540 // Restore the original function so the test framework can use it. | |
| 541 chrome.send = originalChromeSend; | |
| 542 return chromeSendMessages; | |
| 543 } | |
| 544 | |
| 545 this.setProfileSupervised_(false, 'manage'); | |
| 546 var messages = clickAndListen(); | |
| 547 assertEquals(1, messages.length); | |
| 548 assertEquals('deleteProfile', messages[0]); | |
| 549 assertEquals('settings', PageManager.getTopmostVisiblePage().name); | |
| 550 | |
| 551 ManageProfileOverlay.showDeleteDialog(this.testProfileInfo_(false)); | |
| 552 this.setProfileSupervised_(true, 'manage'); | |
| 553 messages = clickAndListen(); | |
| 554 assertEquals(0, messages.length); | |
| 555 assertEquals('settings', PageManager.getTopmostVisiblePage().name); | |
| 556 }); | 524 }); |
| 557 | 525 |
| 558 // Selecting a different avatar image should update the suggested profile name. | 526 // Selecting a different avatar image should update the suggested profile name. |
| 559 TEST_F('ManageProfileUITest', 'Create_NameUpdateOnAvatarSelected', function() { | 527 TEST_F('ManageProfileUITest', 'Create_NameUpdateOnAvatarSelected', function() { |
| 560 var mode = 'create'; | 528 var mode = 'create'; |
| 561 this.initDefaultProfiles_(mode); | 529 this.initDefaultProfiles_(mode); |
| 562 | 530 |
| 563 var gridEl = $(mode + '-profile-icon-grid'); | 531 var gridEl = $(mode + '-profile-icon-grid'); |
| 564 var nameEl = $(mode + '-profile-name'); | 532 var nameEl = $(mode + '-profile-name'); |
| 565 | 533 |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 646 | 614 |
| 647 // Select another icon and check if the profile name was updated. | 615 // Select another icon and check if the profile name was updated. |
| 648 var oldName = nameEl.value; | 616 var oldName = nameEl.value; |
| 649 gridEl.selectedItem = iconURLs[1]; | 617 gridEl.selectedItem = iconURLs[1]; |
| 650 expectEquals(oldName, nameEl.value); | 618 expectEquals(oldName, nameEl.value); |
| 651 | 619 |
| 652 PageManager.closeOverlay(); | 620 PageManager.closeOverlay(); |
| 653 }); | 621 }); |
| 654 | 622 |
| 655 GEN('#endif // OS_CHROMEOS'); | 623 GEN('#endif // OS_CHROMEOS'); |
| OLD | NEW |