Index: chrome/browser/chromeos/login/login_manager_test.cc |
diff --git a/chrome/browser/chromeos/login/login_manager_test.cc b/chrome/browser/chromeos/login/login_manager_test.cc |
index c9eb1bf7e045003aea2c364c2ea272d45f2f483a..c5238276b86a537a8f89c170c80795bd484eea3f 100644 |
--- a/chrome/browser/chromeos/login/login_manager_test.cc |
+++ b/chrome/browser/chromeos/login/login_manager_test.cc |
@@ -7,6 +7,7 @@ |
#include "base/prefs/scoped_user_pref_update.h" |
#include "chrome/browser/browser_process.h" |
#include "chrome/browser/chrome_notification_types.h" |
+#include "chrome/browser/chromeos/login/auth/key.h" |
#include "chrome/browser/chromeos/login/auth/user_context.h" |
#include "chrome/browser/chromeos/login/existing_user_controller.h" |
#include "chrome/browser/chromeos/login/ui/login_display_host_impl.h" |
@@ -54,35 +55,30 @@ void LoginManagerTest::SetUpOnMainThread() { |
InitializeWebContents(); |
} |
-void LoginManagerTest::RegisterUser(const std::string& username) { |
+void LoginManagerTest::RegisterUser(const std::string& user_id) { |
ListPrefUpdate users_pref(g_browser_process->local_state(), "LoggedInUsers"); |
- users_pref->AppendIfNotPresent(new base::StringValue(username)); |
+ users_pref->AppendIfNotPresent(new base::StringValue(user_id)); |
} |
-void LoginManagerTest::SetExpectedCredentials(const std::string& username, |
- const std::string& password) { |
- login_utils().GetFakeLoginUtils()->SetExpectedCredentials(username, password); |
+void LoginManagerTest::SetExpectedCredentials(const UserContext& user_context) { |
+ login_utils().GetFakeLoginUtils()->SetExpectedCredentials(user_context); |
} |
-bool LoginManagerTest::TryToLogin(const std::string& username, |
- const std::string& password) { |
- if (!AddUserToSession(username, password)) |
+bool LoginManagerTest::TryToLogin(const UserContext& user_context) { |
+ if (!AddUserToSession(user_context)) |
return false; |
if (const User* active_user = UserManager::Get()->GetActiveUser()) |
- return active_user->email() == username; |
+ return active_user->email() == user_context.GetUserID(); |
return false; |
} |
-bool LoginManagerTest::AddUserToSession(const std::string& username, |
- const std::string& password) { |
+bool LoginManagerTest::AddUserToSession(const UserContext& user_context) { |
ExistingUserController* controller = |
ExistingUserController::current_controller(); |
if (!controller) { |
ADD_FAILURE(); |
return false; |
} |
- UserContext user_context(username); |
- user_context.SetPassword(password); |
controller->Login(user_context); |
content::WindowedNotificationObserver( |
chrome::NOTIFICATION_SESSION_STARTED, |
@@ -90,20 +86,24 @@ bool LoginManagerTest::AddUserToSession(const std::string& username, |
const UserList& logged_users = UserManager::Get()->GetLoggedInUsers(); |
for (UserList::const_iterator it = logged_users.begin(); |
it != logged_users.end(); ++it) { |
- if ((*it)->email() == username) |
+ if ((*it)->email() == user_context.GetUserID()) |
return true; |
} |
return false; |
} |
-void LoginManagerTest::LoginUser(const std::string& username) { |
- SetExpectedCredentials(username, "password"); |
- EXPECT_TRUE(TryToLogin(username, "password")); |
+void LoginManagerTest::LoginUser(const std::string& user_id) { |
+ UserContext user_context(user_id); |
+ user_context.SetKey(Key("password")); |
+ SetExpectedCredentials(user_context); |
+ EXPECT_TRUE(TryToLogin(user_context)); |
} |
-void LoginManagerTest::AddUser(const std::string& username) { |
- SetExpectedCredentials(username, "password"); |
- EXPECT_TRUE(AddUserToSession(username, "password")); |
+void LoginManagerTest::AddUser(const std::string& user_id) { |
+ UserContext user_context(user_id); |
+ user_context.SetKey(Key("password")); |
+ SetExpectedCredentials(user_context); |
+ EXPECT_TRUE(AddUserToSession(user_context)); |
} |
void LoginManagerTest::JSExpect(const std::string& expression) { |