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

Unified Diff: chrome/browser/ui/webui/options/manage_profile_browsertest.js

Issue 209393009: In the "create user" overlay, associate avatars with their default names (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: More review comments. Created 6 years, 9 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ui/webui/options/manage_profile_browsertest.js
diff --git a/chrome/browser/ui/webui/options/manage_profile_browsertest.js b/chrome/browser/ui/webui/options/manage_profile_browsertest.js
index 950d1b8e21d7d28e5aad305d051acacca03155a7..24d595bb649d71eb93fe35518901cd2558673df7 100644
--- a/chrome/browser/ui/webui/options/manage_profile_browsertest.js
+++ b/chrome/browser/ui/webui/options/manage_profile_browsertest.js
@@ -26,6 +26,12 @@ ManageProfileUITest.prototype = {
runAccessibilityChecks: false,
/**
+ * Some default profile infos.
+ */
+ defaultIconURLs: [],
+ defaultNames: [],
+
+ /**
* Returns a test profile-info object with configurable "managed" status.
* @param {boolean} managed If true, the test profile will be marked as
* managed.
@@ -55,6 +61,32 @@ ManageProfileUITest.prototype = {
// Set the profile info in the overlay.
ManageProfileOverlay.setProfileInfo(this.testProfileInfo_(managed), mode);
},
+
+ /**
+ * Set some default profile infos (icon URLs and names).
+ * @param {boolean} managed Whether the test profile should be marked managed.
+ * @param {string} mode The mode of the overlay (either 'manage' or 'create').
+ */
+ initDefaultProfiles_: function(mode) {
+ OptionsPage.showPageByName(mode + 'Profile');
+
+ var defaultProfile = {
+ name: "Default Name",
+ iconURL: "/default/path",
+ };
+ this.defaultIconURLs = ['/some/path',
+ defaultProfile.iconURL,
+ '/another/path',
+ '/one/more/path'];
+ this.defaultNames = ['Some Name', defaultProfile.name, '', 'Another Name'];
+ ManageProfileOverlay.receiveDefaultProfileIconsAndNames(
+ mode, this.defaultIconURLs, this.defaultNames);
+ ManageProfileOverlay.receiveNewProfileDefaults(defaultProfile);
+
+ // Make sure the correct item in the icon grid was selected.
+ var gridEl = $(mode + '-profile-icon-grid');
+ expectEquals(defaultProfile.iconURL, gridEl.selectedItem);
+ },
};
// Receiving the new profile defaults in the manage-user overlay shouldn't mess
@@ -183,10 +215,10 @@ TEST_F('ManageProfileUITestAsync', 'CreateExistingManagedUser', function() {
CreateProfileOverlay.getInstance().signedInEmail_);
this.setProfileManaged_(false, 'create');
- // Also add the names 'Test' and 'Test2' to |profileNames_| to simulate that
- // profiles with those names exist on the device.
- ManageProfileOverlay.getInstance().profileNames_.Test = true;
- ManageProfileOverlay.getInstance().profileNames_.SameName = true;
+ // Also add the names 'Test' and 'SameName' to |existingProfileNames_| to
+ // simulate that profiles with those names exist on the device.
+ ManageProfileOverlay.getInstance().existingProfileNames_.Test = true;
+ ManageProfileOverlay.getInstance().existingProfileNames_.SameName = true;
// Initially, the ok button should be enabled and the import link should not
// exist.
@@ -305,7 +337,7 @@ TEST_F('ManageProfileUITest', 'NoCreateConfirmationOnError', function() {
assertFalse(errorBubble.hidden);
});
-// The name and email sould be inserted into the confirmation dialog.
+// The name and email should be inserted into the confirmation dialog.
TEST_F('ManageProfileUITest', 'CreateConfirmationText', function () {
var self = this;
var custodianEmail = 'foo@example.com';
@@ -517,4 +549,101 @@ TEST_F('ManageProfileUITest', 'ManagedDelete', function() {
assertEquals('settings', OptionsPage.getTopmostVisiblePage().name);
});
+// Selecting a different avatar image should update the suggested profile name.
+TEST_F('ManageProfileUITest', 'Create_NameUpdateOnAvatarSelected', function() {
+ var mode = 'create';
+ this.initDefaultProfiles_(mode);
+
+ var gridEl = $(mode + '-profile-icon-grid');
+ var nameEl = $(mode + '-profile-name');
+
+ // Select another icon and check that the profile name was updated.
+ assertNotEquals(gridEl.selectedItem, this.defaultIconURLs[0]);
+ gridEl.selectedItem = this.defaultIconURLs[0];
+ expectEquals(this.defaultNames[0], nameEl.value);
+
+ // Select icon without an associated name; the profile name shouldn't change.
+ var oldName = nameEl.value;
+ assertEquals('', this.defaultNames[2]);
Pam (message me for reviews) 2014/04/02 10:43:24 This isn't really necessary. If the test data is c
+ gridEl.selectedItem = this.defaultIconURLs[2];
+ expectEquals(oldName, nameEl.value);
+
+ // Select another icon with a name and check that the name is updated again.
+ assertNotEquals('', this.defaultNames[1]);
Pam (message me for reviews) 2014/04/02 10:43:24 Same here.
+ gridEl.selectedItem = this.defaultIconURLs[1];
+ expectEquals(this.defaultNames[1], nameEl.value);
+
+ OptionsPage.closeOverlay();
+});
+
+// After the user edited the profile name, selecting a different avatar image
+// should not update the suggested name anymore.
+TEST_F('ManageProfileUITest', 'Create_NoNameUpdateOnAvatarSelectedAfterEdit',
+ function() {
+ var mode = 'create';
+ this.initDefaultProfiles_(mode);
+
+ var gridEl = $(mode + '-profile-icon-grid');
+ var nameEl = $(mode + '-profile-name');
+
+ // After the user manually entered a name, it should not be changed anymore
+ // (even if the entered name is another default name).
+ nameEl.value = this.defaultNames[3];
+ nameEl.oninput();
+ gridEl.selectedItem = this.defaultIconURLs[0];
+ expectEquals(this.defaultNames[3], nameEl.value);
+
+ OptionsPage.closeOverlay();
+});
+
+// After the user edited the profile name, selecting a different avatar image
+// should not update the suggested name anymore even if the original suggestion
+// is entered again.
+TEST_F('ManageProfileUITest', 'Create_NoNameUpdateOnAvatarSelectedAfterRevert',
+ function() {
+ var mode = 'create';
+ this.initDefaultProfiles_(mode);
+
+ var gridEl = $(mode + '-profile-icon-grid');
+ var nameEl = $(mode + '-profile-name');
+
+ // After the user manually entered a name, it should not be changed anymore,
+ // even if the user then reverts to the original suggestion.
+ var oldName = nameEl.value;
+ nameEl.value = 'Custom Name';
+ nameEl.oninput();
+ nameEl.value = oldName;
+ nameEl.oninput();
+ // Now select another avatar and check that the name remained the same.
+ assertNotEquals(gridEl.selectedItem, this.defaultIconURLs[0]);
+ gridEl.selectedItem = this.defaultIconURLs[0];
+ expectEquals(oldName, nameEl.value);
+
+ OptionsPage.closeOverlay();
+});
+
+// In the manage dialog, the name should never be updated on avatar selection.
+TEST_F('ManageProfileUITest', 'Manage_NoNameUpdateOnAvatarSelected',
+ function() {
+ var mode = 'manage';
+ this.setProfileManaged_(false, mode);
+ OptionsPage.showPageByName(mode + 'Profile');
+
+ var testProfile = this.testProfileInfo_(false);
+ var iconURLs = [testProfile.iconURL, '/some/path', '/another/path'];
+ var names = [testProfile.name, 'Some Name', ''];
+ ManageProfileOverlay.receiveDefaultProfileIconsAndNames(
+ mode, iconURLs, names);
+
+ var gridEl = $(mode + '-profile-icon-grid');
+ var nameEl = $(mode + '-profile-name');
+
+ // Select another icon and check if the profile name was updated.
+ var oldName = nameEl.value;
+ gridEl.selectedItem = iconURLs[1];
+ expectEquals(oldName, nameEl.value);
+
+ OptionsPage.closeOverlay();
+});
+
GEN('#endif // OS_CHROMEOS');
« no previous file with comments | « chrome/browser/resources/options/manage_profile_overlay.js ('k') | chrome/browser/ui/webui/options/manage_profile_handler.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698