summaryrefslogtreecommitdiffstats
path: root/ash
diff options
context:
space:
mode:
Diffstat (limited to 'ash')
-rw-r--r--ash/session_state_delegate.h13
-rw-r--r--ash/session_state_delegate_stub.cc5
-rw-r--r--ash/session_state_delegate_stub.h2
-rw-r--r--ash/system/user/tray_user.cc2
-rw-r--r--ash/system/user/tray_user_unittest.cc10
-rw-r--r--ash/test/test_session_state_delegate.cc30
-rw-r--r--ash/test/test_session_state_delegate.h4
7 files changed, 53 insertions, 13 deletions
diff --git a/ash/session_state_delegate.h b/ash/session_state_delegate.h
index 8c96747..7fac828 100644
--- a/ash/session_state_delegate.h
+++ b/ash/session_state_delegate.h
@@ -74,10 +74,17 @@ class ASH_EXPORT SessionStateDelegate {
virtual const base::string16 GetUserDisplayName(
MultiProfileIndex index) const = 0;
- // Gets the email address for the user with the given |index|.
+ // Gets the display email address for the user with the given |index|.
+ // The display email address might contains some periods in the email name
+ // as well as capitalized letters. For example: "Foo.Bar@mock.com".
// Note that |index| can at maximum be |NumberOfLoggedInUsers() - 1|.
virtual const std::string GetUserEmail(MultiProfileIndex index) const = 0;
+ // Gets the user id (sanitized email address) for the user with the given
+ // |index|. The function would return something like "foobar@mock.com".
+ // Note that |index| can at maximum be |NumberOfLoggedInUsers() - 1|.
+ virtual const std::string GetUserID(MultiProfileIndex index) const = 0;
+
// Gets the avatar image for the user with the given |index|.
// Note that |index| can at maximum be |NumberOfLoggedInUsers() - 1|.
virtual const gfx::ImageSkia& GetUserImage(MultiProfileIndex index) const = 0;
@@ -85,9 +92,9 @@ class ASH_EXPORT SessionStateDelegate {
// Returns a list of all logged in users.
virtual void GetLoggedInUsers(UserIdList* users) = 0;
- // Switches to another active user using the |user_email|
+ // Switches to another active user with |user_id|
// (if that user has already signed in).
- virtual void SwitchActiveUser(const std::string& user_email) = 0;
+ virtual void SwitchActiveUser(const std::string& user_id) = 0;
// Switches the active user to the next user, with the same ordering as
// GetLoggedInUsers.
diff --git a/ash/session_state_delegate_stub.cc b/ash/session_state_delegate_stub.cc
index 83efd73..91602b3 100644
--- a/ash/session_state_delegate_stub.cc
+++ b/ash/session_state_delegate_stub.cc
@@ -66,6 +66,11 @@ const std::string SessionStateDelegateStub::GetUserEmail(
return "stub-user@domain.com";
}
+const std::string SessionStateDelegateStub::GetUserID(
+ MultiProfileIndex index) const {
+ return GetUserEmail(index);
+}
+
const gfx::ImageSkia& SessionStateDelegateStub::GetUserImage(
MultiProfileIndex index) const {
return null_image_;
diff --git a/ash/session_state_delegate_stub.h b/ash/session_state_delegate_stub.h
index 96e8364..894759d 100644
--- a/ash/session_state_delegate_stub.h
+++ b/ash/session_state_delegate_stub.h
@@ -32,6 +32,8 @@ class SessionStateDelegateStub : public SessionStateDelegate {
ash::MultiProfileIndex index) const OVERRIDE;
virtual const std::string GetUserEmail(
ash::MultiProfileIndex index) const OVERRIDE;
+ virtual const std::string GetUserID(
+ ash::MultiProfileIndex index) const OVERRIDE;
virtual const gfx::ImageSkia& GetUserImage(
ash::MultiProfileIndex index) const OVERRIDE;
virtual void GetLoggedInUsers(UserIdList* users) OVERRIDE;
diff --git a/ash/system/user/tray_user.cc b/ash/system/user/tray_user.cc
index fe1439c..ba62612 100644
--- a/ash/system/user/tray_user.cc
+++ b/ash/system/user/tray_user.cc
@@ -123,7 +123,7 @@ void SwitchUser(ash::MultiProfileIndex user_index) {
ash::Shell::GetInstance()->session_state_delegate();
ash::MultiProfileUMA::RecordSwitchActiveUser(
ash::MultiProfileUMA::SWITCH_ACTIVE_USER_BY_TRAY);
- delegate->SwitchActiveUser(delegate->GetUserEmail(user_index));
+ delegate->SwitchActiveUser(delegate->GetUserID(user_index));
}
} // namespace
diff --git a/ash/system/user/tray_user_unittest.cc b/ash/system/user/tray_user_unittest.cc
index 5f4cbe1..f969344 100644
--- a/ash/system/user/tray_user_unittest.cc
+++ b/ash/system/user/tray_user_unittest.cc
@@ -229,10 +229,12 @@ TEST_F(TrayUserTest, MutiUserModeButtonClicks) {
aura::test::EventGenerator generator(Shell::GetPrimaryRootWindow());
ShowTrayMenu(&generator);
- // Switch to a new user.
+ // Switch to a new user - which has a capitalized name.
ClickUserItem(&generator, 1);
-
- EXPECT_EQ(delegate()->get_activated_user(), delegate()->GetUserEmail(1));
+ EXPECT_EQ(delegate()->get_activated_user(), delegate()->GetUserID(1));
+ // Since the name is capitalized, the email should be different then the
+ // user_id.
+ EXPECT_NE(delegate()->get_activated_user(), delegate()->GetUserEmail(1));
tray()->CloseSystemBubble();
}
@@ -285,7 +287,7 @@ TEST_F(TrayUserTest, CheckTrayUserItems) {
generator.MoveMouseTo(point.x(), point.y());
generator.ClickLeftButton();
- EXPECT_EQ(delegate()->get_activated_user(), delegate()->GetUserEmail(2));
+ EXPECT_EQ(delegate()->get_activated_user(), delegate()->GetUserID(2));
}
#endif
diff --git a/ash/test/test_session_state_delegate.cc b/ash/test/test_session_state_delegate.cc
index abed8e6..e18f7d1 100644
--- a/ash/test/test_session_state_delegate.cc
+++ b/ash/test/test_session_state_delegate.cc
@@ -4,10 +4,25 @@
#include "ash/test/test_session_state_delegate.h"
+#include <algorithm>
+#include <string>
+
#include "ash/shell.h"
#include "ash/system/user/login_status.h"
#include "base/strings/string16.h"
#include "base/strings/utf_string_conversions.h"
+#include "testing/gtest/include/gtest/gtest.h"
+
+namespace {
+
+// The the "canonicalized" user ID from a given |email| address.
+std::string GetUserIDFromEmail(const std::string& email) {
+ std::string user_id = email;
+ std::transform(user_id.begin(), user_id.end(), user_id.begin(), ::tolower);
+ return user_id;
+}
+
+} // namespace
namespace ash {
namespace test {
@@ -99,13 +114,18 @@ const base::string16 TestSessionStateDelegate::GetUserDisplayName(
const std::string TestSessionStateDelegate::GetUserEmail(
MultiProfileIndex index) const {
switch (index) {
- case 0: return "first@tray";
- case 1: return "second@tray";
+ case 0: return "First@tray"; // This is intended to be capitalized.
+ case 1: return "Second@tray"; // This is intended to be capitalized.
case 2: return "third@tray";
default: return "someone@tray";
}
}
+const std::string TestSessionStateDelegate::GetUserID(
+ MultiProfileIndex index) const {
+ return GetUserIDFromEmail(GetUserEmail(index));
+}
+
const gfx::ImageSkia& TestSessionStateDelegate::GetUserImage(
MultiProfileIndex index) const {
return null_image_;
@@ -114,8 +134,10 @@ const gfx::ImageSkia& TestSessionStateDelegate::GetUserImage(
void TestSessionStateDelegate::GetLoggedInUsers(UserIdList* users) {
}
-void TestSessionStateDelegate::SwitchActiveUser(const std::string& email) {
- activated_user_ = email;
+void TestSessionStateDelegate::SwitchActiveUser(const std::string& user_id) {
+ // Make sure this is a user id and not an email address.
+ EXPECT_EQ(user_id, GetUserIDFromEmail(user_id));
+ activated_user_ = user_id;
}
void TestSessionStateDelegate::SwitchActiveUserToNext() {
diff --git a/ash/test/test_session_state_delegate.h b/ash/test/test_session_state_delegate.h
index 585521c..105c0b1 100644
--- a/ash/test/test_session_state_delegate.h
+++ b/ash/test/test_session_state_delegate.h
@@ -35,10 +35,12 @@ class TestSessionStateDelegate : public SessionStateDelegate {
ash::MultiProfileIndex index) const OVERRIDE;
virtual const std::string GetUserEmail(
ash::MultiProfileIndex index) const OVERRIDE;
+ virtual const std::string GetUserID(
+ ash::MultiProfileIndex index) const OVERRIDE;
virtual const gfx::ImageSkia& GetUserImage(
ash::MultiProfileIndex index) const OVERRIDE;
virtual void GetLoggedInUsers(UserIdList* users) OVERRIDE;
- virtual void SwitchActiveUser(const std::string& email) OVERRIDE;
+ virtual void SwitchActiveUser(const std::string& user_id) OVERRIDE;
virtual void SwitchActiveUserToNext() OVERRIDE;
virtual void AddSessionStateObserver(
ash::SessionStateObserver* observer) OVERRIDE;