OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 <string> | 5 #include <string> |
6 | 6 |
7 #include "base/message_loop/message_loop.h" | 7 #include "base/message_loop/message_loop.h" |
8 #include "base/prefs/pref_service.h" | 8 #include "base/prefs/pref_service.h" |
9 #include "base/strings/stringprintf.h" | 9 #include "base/strings/stringprintf.h" |
10 #include "base/synchronization/waitable_event.h" | 10 #include "base/synchronization/waitable_event.h" |
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
184 | 184 |
185 EXPECT_EQ(GetOAuthStatusFromLocalState(kTestAccountId), | 185 EXPECT_EQ(GetOAuthStatusFromLocalState(kTestAccountId), |
186 User::OAUTH2_TOKEN_STATUS_VALID); | 186 User::OAUTH2_TOKEN_STATUS_VALID); |
187 } | 187 } |
188 | 188 |
189 bool TryToLogin(const std::string& username, | 189 bool TryToLogin(const std::string& username, |
190 const std::string& password) { | 190 const std::string& password) { |
191 if (!AddUserToSession(username, password)) | 191 if (!AddUserToSession(username, password)) |
192 return false; | 192 return false; |
193 | 193 |
194 if (const User* active_user = UserManager::Get()->GetActiveUser()) | 194 if (const User* active_user = GetUserManager()->GetActiveUser()) |
195 return active_user->email() == username; | 195 return active_user->email() == username; |
196 | 196 |
197 return false; | 197 return false; |
198 } | 198 } |
199 | 199 |
200 User::OAuthTokenStatus GetOAuthStatusFromLocalState( | 200 User::OAuthTokenStatus GetOAuthStatusFromLocalState( |
201 const std::string& user_id) const { | 201 const std::string& user_id) const { |
202 PrefService* local_state = g_browser_process->local_state(); | 202 PrefService* local_state = g_browser_process->local_state(); |
203 const base::DictionaryValue* prefs_oauth_status = | 203 const base::DictionaryValue* prefs_oauth_status = |
204 local_state->GetDictionary("OAuthTokenStatus"); | 204 local_state->GetDictionary("OAuthTokenStatus"); |
205 int oauth_token_status = User::OAUTH_TOKEN_STATUS_UNKNOWN; | 205 int oauth_token_status = User::OAUTH_TOKEN_STATUS_UNKNOWN; |
206 if (prefs_oauth_status && | 206 if (prefs_oauth_status && |
207 prefs_oauth_status->GetIntegerWithoutPathExpansion( | 207 prefs_oauth_status->GetIntegerWithoutPathExpansion( |
208 user_id, &oauth_token_status)) { | 208 user_id, &oauth_token_status)) { |
209 User::OAuthTokenStatus result = | 209 User::OAuthTokenStatus result = |
210 static_cast<User::OAuthTokenStatus>(oauth_token_status); | 210 static_cast<User::OAuthTokenStatus>(oauth_token_status); |
211 return result; | 211 return result; |
212 } | 212 } |
213 return User::OAUTH_TOKEN_STATUS_UNKNOWN; | 213 return User::OAUTH_TOKEN_STATUS_UNKNOWN; |
214 } | 214 } |
215 | 215 |
216 protected: | 216 protected: |
217 // OobeBaseTest overrides. | 217 // OobeBaseTest overrides. |
218 virtual Profile* profile() OVERRIDE { | 218 virtual Profile* profile() OVERRIDE { |
219 if (UserManager::Get()->GetActiveUser()) | 219 if (GetUserManager()->GetActiveUser()) |
220 return ProfileManager::GetPrimaryUserProfile(); | 220 return ProfileManager::GetPrimaryUserProfile(); |
221 | 221 |
222 return OobeBaseTest::profile(); | 222 return OobeBaseTest::profile(); |
223 } | 223 } |
224 | 224 |
225 bool AddUserToSession(const std::string& username, | 225 bool AddUserToSession(const std::string& username, |
226 const std::string& password) { | 226 const std::string& password) { |
227 ExistingUserController* controller = | 227 ExistingUserController* controller = |
228 ExistingUserController::current_controller(); | 228 ExistingUserController::current_controller(); |
229 if (!controller) { | 229 if (!controller) { |
230 ADD_FAILURE(); | 230 ADD_FAILURE(); |
231 return false; | 231 return false; |
232 } | 232 } |
233 | 233 |
234 UserContext user_context(username); | 234 UserContext user_context(username); |
235 user_context.SetKey(Key(password)); | 235 user_context.SetKey(Key(password)); |
236 controller->Login(user_context, SigninSpecifics()); | 236 controller->Login(user_context, SigninSpecifics()); |
237 content::WindowedNotificationObserver( | 237 content::WindowedNotificationObserver( |
238 chrome::NOTIFICATION_SESSION_STARTED, | 238 chrome::NOTIFICATION_SESSION_STARTED, |
239 content::NotificationService::AllSources()).Wait(); | 239 content::NotificationService::AllSources()).Wait(); |
240 const UserList& logged_users = UserManager::Get()->GetLoggedInUsers(); | 240 const UserList& logged_users = GetUserManager()->GetLoggedInUsers(); |
241 for (UserList::const_iterator it = logged_users.begin(); | 241 for (UserList::const_iterator it = logged_users.begin(); |
242 it != logged_users.end(); ++it) { | 242 it != logged_users.end(); ++it) { |
243 if ((*it)->email() == username) | 243 if ((*it)->email() == username) |
244 return true; | 244 return true; |
245 } | 245 } |
246 return false; | 246 return false; |
247 } | 247 } |
248 | 248 |
249 void SetupGaiaServerWithAccessTokens() { | 249 void SetupGaiaServerWithAccessTokens() { |
250 // Configure OAuth authentication. | 250 // Configure OAuth authentication. |
(...skipping 525 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
776 | 776 |
777 if (!catcher.GetNextResult()) { | 777 if (!catcher.GetNextResult()) { |
778 std::string message = catcher.message(); | 778 std::string message = catcher.message(); |
779 ADD_FAILURE() << "Tests failed: " << message; | 779 ADD_FAILURE() << "Tests failed: " << message; |
780 } | 780 } |
781 | 781 |
782 EXPECT_TRUE(fake_google_.IsPageRequested()); | 782 EXPECT_TRUE(fake_google_.IsPageRequested()); |
783 } | 783 } |
784 | 784 |
785 } // namespace chromeos | 785 } // namespace chromeos |
OLD | NEW |