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 <string> | 5 #include <string> |
6 #include <vector> | 6 #include <vector> |
7 | 7 |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "base/memory/ref_counted.h" | 9 #include "base/memory/ref_counted.h" |
10 #include "base/run_loop.h" | 10 #include "base/run_loop.h" |
11 #include "chrome/browser/chromeos/login/session/user_session_manager.h" | 11 #include "chrome/browser/chromeos/login/session/user_session_manager.h" |
12 #include "chrome/browser/chromeos/login/users/user_manager.h" | |
13 #include "chrome/test/base/in_process_browser_test.h" | 12 #include "chrome/test/base/in_process_browser_test.h" |
14 #include "chromeos/chromeos_switches.h" | 13 #include "chromeos/chromeos_switches.h" |
15 #include "chromeos/dbus/cryptohome_client.h" | 14 #include "chromeos/dbus/cryptohome_client.h" |
16 #include "chromeos/dbus/fake_dbus_thread_manager.h" | 15 #include "chromeos/dbus/fake_dbus_thread_manager.h" |
17 #include "chromeos/dbus/fake_session_manager_client.h" | 16 #include "chromeos/dbus/fake_session_manager_client.h" |
18 #include "chromeos/dbus/session_manager_client.h" | 17 #include "chromeos/dbus/session_manager_client.h" |
19 #include "components/user_manager/user.h" | 18 #include "components/user_manager/user.h" |
| 19 #include "components/user_manager/user_manager.h" |
20 #include "content/public/test/test_utils.h" | 20 #include "content/public/test/test_utils.h" |
21 #include "testing/gmock/include/gmock/gmock.h" | 21 #include "testing/gmock/include/gmock/gmock.h" |
22 #include "third_party/cros_system_api/dbus/service_constants.h" | 22 #include "third_party/cros_system_api/dbus/service_constants.h" |
23 | 23 |
24 namespace chromeos { | 24 namespace chromeos { |
25 | 25 |
26 namespace { | 26 namespace { |
27 | 27 |
28 const char kUserId1[] = "user1@example.com"; | 28 const char kUserId1[] = "user1@example.com"; |
29 const char kUserId2[] = "user2@example.com"; | 29 const char kUserId2[] = "user2@example.com"; |
(...skipping 22 matching lines...) Expand all Loading... |
52 dbus_thread_manager->SetSessionManagerClient( | 52 dbus_thread_manager->SetSessionManagerClient( |
53 scoped_ptr<SessionManagerClient>(session_manager_client_)); | 53 scoped_ptr<SessionManagerClient>(session_manager_client_)); |
54 DBusThreadManager::SetInstanceForTesting(dbus_thread_manager); | 54 DBusThreadManager::SetInstanceForTesting(dbus_thread_manager); |
55 session_manager_client_->StartSession(kUserId1); | 55 session_manager_client_->StartSession(kUserId1); |
56 } | 56 } |
57 | 57 |
58 FakeSessionManagerClient* session_manager_client_; | 58 FakeSessionManagerClient* session_manager_client_; |
59 }; | 59 }; |
60 | 60 |
61 IN_PROC_BROWSER_TEST_F(CrashRestoreSimpleTest, RestoreSessionForOneUser) { | 61 IN_PROC_BROWSER_TEST_F(CrashRestoreSimpleTest, RestoreSessionForOneUser) { |
62 UserManager* user_manager = UserManager::Get(); | 62 user_manager::UserManager* user_manager = user_manager::UserManager::Get(); |
63 user_manager::User* user = user_manager->GetActiveUser(); | 63 user_manager::User* user = user_manager->GetActiveUser(); |
64 ASSERT_TRUE(user); | 64 ASSERT_TRUE(user); |
65 EXPECT_EQ(kUserId1, user->email()); | 65 EXPECT_EQ(kUserId1, user->email()); |
66 EXPECT_EQ(CryptohomeClient::GetStubSanitizedUsername(kUserId1), | 66 EXPECT_EQ(CryptohomeClient::GetStubSanitizedUsername(kUserId1), |
67 user->username_hash()); | 67 user->username_hash()); |
68 EXPECT_EQ(1UL, user_manager->GetLoggedInUsers().size()); | 68 EXPECT_EQ(1UL, user_manager->GetLoggedInUsers().size()); |
69 } | 69 } |
70 | 70 |
71 // Observer that keeps track of user sessions restore event. | 71 // Observer that keeps track of user sessions restore event. |
72 class UserSessionRestoreObserver : public UserSessionStateObserver { | 72 class UserSessionRestoreObserver : public UserSessionStateObserver { |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
125 IN_PROC_BROWSER_TEST_F(CrashRestoreComplexTest, RestoreSessionForThreeUsers) { | 125 IN_PROC_BROWSER_TEST_F(CrashRestoreComplexTest, RestoreSessionForThreeUsers) { |
126 { | 126 { |
127 UserSessionRestoreObserver restore_observer; | 127 UserSessionRestoreObserver restore_observer; |
128 restore_observer.Wait(); | 128 restore_observer.Wait(); |
129 } | 129 } |
130 | 130 |
131 DCHECK(UserSessionManager::GetInstance()->UserSessionsRestored()); | 131 DCHECK(UserSessionManager::GetInstance()->UserSessionsRestored()); |
132 | 132 |
133 // User that is last in the user sessions map becomes active. This behavior | 133 // User that is last in the user sessions map becomes active. This behavior |
134 // will become better defined once each user gets a separate user desktop. | 134 // will become better defined once each user gets a separate user desktop. |
135 UserManager* user_manager = UserManager::Get(); | 135 user_manager::UserManager* user_manager = user_manager::UserManager::Get(); |
136 user_manager::User* user = user_manager->GetActiveUser(); | 136 user_manager::User* user = user_manager->GetActiveUser(); |
137 ASSERT_TRUE(user); | 137 ASSERT_TRUE(user); |
138 EXPECT_EQ(kUserId3, user->email()); | 138 EXPECT_EQ(kUserId3, user->email()); |
139 EXPECT_EQ(CryptohomeClient::GetStubSanitizedUsername(kUserId3), | 139 EXPECT_EQ(CryptohomeClient::GetStubSanitizedUsername(kUserId3), |
140 user->username_hash()); | 140 user->username_hash()); |
141 const user_manager::UserList& users = user_manager->GetLoggedInUsers(); | 141 const user_manager::UserList& users = user_manager->GetLoggedInUsers(); |
142 ASSERT_EQ(3UL, users.size()); | 142 ASSERT_EQ(3UL, users.size()); |
143 | 143 |
144 // User that becomes active moves to the beginning of the list. | 144 // User that becomes active moves to the beginning of the list. |
145 EXPECT_EQ(kUserId3, users[0]->email()); | 145 EXPECT_EQ(kUserId3, users[0]->email()); |
146 EXPECT_EQ(CryptohomeClient::GetStubSanitizedUsername(kUserId3), | 146 EXPECT_EQ(CryptohomeClient::GetStubSanitizedUsername(kUserId3), |
147 users[0]->username_hash()); | 147 users[0]->username_hash()); |
148 EXPECT_EQ(kUserId2, users[1]->email()); | 148 EXPECT_EQ(kUserId2, users[1]->email()); |
149 EXPECT_EQ(CryptohomeClient::GetStubSanitizedUsername(kUserId2), | 149 EXPECT_EQ(CryptohomeClient::GetStubSanitizedUsername(kUserId2), |
150 users[1]->username_hash()); | 150 users[1]->username_hash()); |
151 EXPECT_EQ(kUserId1, users[2]->email()); | 151 EXPECT_EQ(kUserId1, users[2]->email()); |
152 EXPECT_EQ(CryptohomeClient::GetStubSanitizedUsername(kUserId1), | 152 EXPECT_EQ(CryptohomeClient::GetStubSanitizedUsername(kUserId1), |
153 users[2]->username_hash()); | 153 users[2]->username_hash()); |
154 } | 154 } |
155 | 155 |
156 } // namespace chromeos | 156 } // namespace chromeos |
OLD | NEW |