Chromium Code Reviews| 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/macros.h" | 9 #include "base/macros.h" |
| 10 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
| 11 #include "base/run_loop.h" | 11 #include "base/run_loop.h" |
| 12 #include "chrome/browser/chromeos/login/session/user_session_manager.h" | 12 #include "chrome/browser/chromeos/login/session/user_session_manager.h" |
| 13 #include "chrome/browser/chromeos/login/session/user_session_manager_test_api.h" | 13 #include "chrome/browser/chromeos/login/session/user_session_manager_test_api.h" |
| 14 #include "chrome/test/base/in_process_browser_test.h" | 14 #include "chrome/test/base/in_process_browser_test.h" |
| 15 #include "chromeos/chromeos_switches.h" | 15 #include "chromeos/chromeos_switches.h" |
| 16 #include "chromeos/cryptohome/cryptohome_parameters.h" | 16 #include "chromeos/cryptohome/cryptohome_parameters.h" |
| 17 #include "chromeos/dbus/cryptohome_client.h" | 17 #include "chromeos/dbus/cryptohome_client.h" |
| 18 #include "chromeos/dbus/dbus_thread_manager.h" | 18 #include "chromeos/dbus/dbus_thread_manager.h" |
| 19 #include "chromeos/dbus/fake_session_manager_client.h" | 19 #include "chromeos/dbus/fake_session_manager_client.h" |
| 20 #include "chromeos/dbus/session_manager_client.h" | 20 #include "chromeos/dbus/session_manager_client.h" |
| 21 #include "components/session_manager/core/session_manager.h" | |
| 21 #include "components/user_manager/user.h" | 22 #include "components/user_manager/user.h" |
| 22 #include "components/user_manager/user_manager.h" | 23 #include "components/user_manager/user_manager.h" |
| 23 #include "content/public/test/test_utils.h" | 24 #include "content/public/test/test_utils.h" |
| 24 #include "testing/gmock/include/gmock/gmock.h" | 25 #include "testing/gmock/include/gmock/gmock.h" |
| 25 #include "third_party/cros_system_api/dbus/service_constants.h" | 26 #include "third_party/cros_system_api/dbus/service_constants.h" |
| 26 | 27 |
| 27 namespace chromeos { | 28 namespace chromeos { |
| 28 | 29 |
| 29 namespace { | 30 namespace { |
| 30 | 31 |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 68 }; | 69 }; |
| 69 | 70 |
| 70 IN_PROC_BROWSER_TEST_F(CrashRestoreSimpleTest, RestoreSessionForOneUser) { | 71 IN_PROC_BROWSER_TEST_F(CrashRestoreSimpleTest, RestoreSessionForOneUser) { |
| 71 user_manager::UserManager* user_manager = user_manager::UserManager::Get(); | 72 user_manager::UserManager* user_manager = user_manager::UserManager::Get(); |
| 72 user_manager::User* user = user_manager->GetActiveUser(); | 73 user_manager::User* user = user_manager->GetActiveUser(); |
| 73 ASSERT_TRUE(user); | 74 ASSERT_TRUE(user); |
| 74 EXPECT_EQ(account_id1_, user->GetAccountId()); | 75 EXPECT_EQ(account_id1_, user->GetAccountId()); |
| 75 EXPECT_EQ(CryptohomeClient::GetStubSanitizedUsername(cryptohome_id1_), | 76 EXPECT_EQ(CryptohomeClient::GetStubSanitizedUsername(cryptohome_id1_), |
| 76 user->username_hash()); | 77 user->username_hash()); |
| 77 EXPECT_EQ(1UL, user_manager->GetLoggedInUsers().size()); | 78 EXPECT_EQ(1UL, user_manager->GetLoggedInUsers().size()); |
| 79 | |
| 80 session_manager::SessionManager* session_manager = | |
|
achuithb
2016/10/31 21:55:56
I think auto* is ok here since the type is clear?
xiyuan
2016/10/31 22:29:45
Done.
| |
| 81 session_manager::SessionManager::Get(); | |
| 82 EXPECT_EQ(session_manager::SessionState::ACTIVE, | |
| 83 session_manager->session_state()); | |
| 84 EXPECT_EQ(1u, session_manager->sessions().size()); | |
| 78 } | 85 } |
| 79 | 86 |
| 80 // Observer that keeps track of user sessions restore event. | 87 // Observer that keeps track of user sessions restore event. |
| 81 class UserSessionRestoreObserver : public UserSessionStateObserver { | 88 class UserSessionRestoreObserver : public UserSessionStateObserver { |
| 82 public: | 89 public: |
| 83 UserSessionRestoreObserver() | 90 UserSessionRestoreObserver() |
| 84 : running_loop_(false), | 91 : running_loop_(false), |
| 85 user_sessions_restored_( | 92 user_sessions_restored_( |
| 86 UserSessionManager::GetInstance()->UserSessionsRestored()) { | 93 UserSessionManager::GetInstance()->UserSessionsRestored()) { |
| 87 if (!user_sessions_restored_) | 94 if (!user_sessions_restored_) |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 157 // User that becomes active moves to the beginning of the list. | 164 // User that becomes active moves to the beginning of the list. |
| 158 EXPECT_EQ(account_id3_, users[0]->GetAccountId()); | 165 EXPECT_EQ(account_id3_, users[0]->GetAccountId()); |
| 159 EXPECT_EQ(CryptohomeClient::GetStubSanitizedUsername(cryptohome_id3_), | 166 EXPECT_EQ(CryptohomeClient::GetStubSanitizedUsername(cryptohome_id3_), |
| 160 users[0]->username_hash()); | 167 users[0]->username_hash()); |
| 161 EXPECT_EQ(account_id2_, users[1]->GetAccountId()); | 168 EXPECT_EQ(account_id2_, users[1]->GetAccountId()); |
| 162 EXPECT_EQ(CryptohomeClient::GetStubSanitizedUsername(cryptohome_id2_), | 169 EXPECT_EQ(CryptohomeClient::GetStubSanitizedUsername(cryptohome_id2_), |
| 163 users[1]->username_hash()); | 170 users[1]->username_hash()); |
| 164 EXPECT_EQ(account_id1_, users[2]->GetAccountId()); | 171 EXPECT_EQ(account_id1_, users[2]->GetAccountId()); |
| 165 EXPECT_EQ(CryptohomeClient::GetStubSanitizedUsername(cryptohome_id1_), | 172 EXPECT_EQ(CryptohomeClient::GetStubSanitizedUsername(cryptohome_id1_), |
| 166 users[2]->username_hash()); | 173 users[2]->username_hash()); |
| 174 | |
| 175 session_manager::SessionManager* session_manager = | |
|
achuithb
2016/10/31 21:55:56
ditto
xiyuan
2016/10/31 22:29:45
Done.
| |
| 176 session_manager::SessionManager::Get(); | |
| 177 EXPECT_EQ(session_manager::SessionState::ACTIVE, | |
| 178 session_manager->session_state()); | |
| 179 EXPECT_EQ(3u, session_manager->sessions().size()); | |
| 180 EXPECT_EQ(session_manager->sessions()[0].user_account_id, account_id1_); | |
| 181 EXPECT_EQ(session_manager->sessions()[1].user_account_id, account_id2_); | |
| 182 EXPECT_EQ(session_manager->sessions()[2].user_account_id, account_id3_); | |
| 167 } | 183 } |
| 168 | 184 |
| 169 } // namespace chromeos | 185 } // namespace chromeos |
| OLD | NEW |