| 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 #include "chrome/browser/chromeos/login/login_manager_test.h" | 5 #include "chrome/browser/chromeos/login/login_manager_test.h" |
| 6 | 6 |
| 7 #include "base/prefs/scoped_user_pref_update.h" | 7 #include "base/prefs/scoped_user_pref_update.h" |
| 8 #include "chrome/browser/browser_process.h" | 8 #include "chrome/browser/browser_process.h" |
| 9 #include "chrome/browser/chrome_notification_types.h" | 9 #include "chrome/browser/chrome_notification_types.h" |
| 10 #include "chrome/browser/chromeos/login/auth/key.h" | 10 #include "chrome/browser/chromeos/login/auth/key.h" |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 60 users_pref->AppendIfNotPresent(new base::StringValue(user_id)); | 60 users_pref->AppendIfNotPresent(new base::StringValue(user_id)); |
| 61 } | 61 } |
| 62 | 62 |
| 63 void LoginManagerTest::SetExpectedCredentials(const UserContext& user_context) { | 63 void LoginManagerTest::SetExpectedCredentials(const UserContext& user_context) { |
| 64 login_utils().GetFakeLoginUtils()->SetExpectedCredentials(user_context); | 64 login_utils().GetFakeLoginUtils()->SetExpectedCredentials(user_context); |
| 65 } | 65 } |
| 66 | 66 |
| 67 bool LoginManagerTest::TryToLogin(const UserContext& user_context) { | 67 bool LoginManagerTest::TryToLogin(const UserContext& user_context) { |
| 68 if (!AddUserToSession(user_context)) | 68 if (!AddUserToSession(user_context)) |
| 69 return false; | 69 return false; |
| 70 if (const User* active_user = UserManager::Get()->GetActiveUser()) | 70 if (const User* active_user = GetUserManager()->GetActiveUser()) |
| 71 return active_user->email() == user_context.GetUserID(); | 71 return active_user->email() == user_context.GetUserID(); |
| 72 return false; | 72 return false; |
| 73 } | 73 } |
| 74 | 74 |
| 75 bool LoginManagerTest::AddUserToSession(const UserContext& user_context) { | 75 bool LoginManagerTest::AddUserToSession(const UserContext& user_context) { |
| 76 ExistingUserController* controller = | 76 ExistingUserController* controller = |
| 77 ExistingUserController::current_controller(); | 77 ExistingUserController::current_controller(); |
| 78 if (!controller) { | 78 if (!controller) { |
| 79 ADD_FAILURE(); | 79 ADD_FAILURE(); |
| 80 return false; | 80 return false; |
| 81 } | 81 } |
| 82 controller->Login(user_context, SigninSpecifics()); | 82 controller->Login(user_context, SigninSpecifics()); |
| 83 content::WindowedNotificationObserver( | 83 content::WindowedNotificationObserver( |
| 84 chrome::NOTIFICATION_SESSION_STARTED, | 84 chrome::NOTIFICATION_SESSION_STARTED, |
| 85 content::NotificationService::AllSources()).Wait(); | 85 content::NotificationService::AllSources()).Wait(); |
| 86 const UserList& logged_users = UserManager::Get()->GetLoggedInUsers(); | 86 const UserList& logged_users = GetUserManager()->GetLoggedInUsers(); |
| 87 for (UserList::const_iterator it = logged_users.begin(); | 87 for (UserList::const_iterator it = logged_users.begin(); |
| 88 it != logged_users.end(); ++it) { | 88 it != logged_users.end(); ++it) { |
| 89 if ((*it)->email() == user_context.GetUserID()) | 89 if ((*it)->email() == user_context.GetUserID()) |
| 90 return true; | 90 return true; |
| 91 } | 91 } |
| 92 return false; | 92 return false; |
| 93 } | 93 } |
| 94 | 94 |
| 95 void LoginManagerTest::LoginUser(const std::string& user_id) { | 95 void LoginManagerTest::LoginUser(const std::string& user_id) { |
| 96 UserContext user_context(user_id); | 96 UserContext user_context(user_id); |
| (...skipping 18 matching lines...) Expand all Loading... |
| 115 EXPECT_TRUE(host != NULL); | 115 EXPECT_TRUE(host != NULL); |
| 116 | 116 |
| 117 content::WebContents* web_contents = | 117 content::WebContents* web_contents = |
| 118 host->GetWebUILoginView()->GetWebContents(); | 118 host->GetWebUILoginView()->GetWebContents(); |
| 119 EXPECT_TRUE(web_contents != NULL); | 119 EXPECT_TRUE(web_contents != NULL); |
| 120 set_web_contents(web_contents); | 120 set_web_contents(web_contents); |
| 121 js_checker_.set_web_contents(web_contents); | 121 js_checker_.set_web_contents(web_contents); |
| 122 } | 122 } |
| 123 | 123 |
| 124 } // namespace chromeos | 124 } // namespace chromeos |
| OLD | NEW |