Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(396)

Side by Side Diff: chrome/browser/chromeos/login/crash_restore_browsertest.cc

Issue 2468483002: session_manager: Tracks user sessions (Closed)
Patch Set: replace func overload with better names Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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 auto* session_manager = session_manager::SessionManager::Get();
81 EXPECT_EQ(session_manager::SessionState::ACTIVE,
82 session_manager->session_state());
83 EXPECT_EQ(1u, session_manager->sessions().size());
78 } 84 }
79 85
80 // Observer that keeps track of user sessions restore event. 86 // Observer that keeps track of user sessions restore event.
81 class UserSessionRestoreObserver : public UserSessionStateObserver { 87 class UserSessionRestoreObserver : public UserSessionStateObserver {
82 public: 88 public:
83 UserSessionRestoreObserver() 89 UserSessionRestoreObserver()
84 : running_loop_(false), 90 : running_loop_(false),
85 user_sessions_restored_( 91 user_sessions_restored_(
86 UserSessionManager::GetInstance()->UserSessionsRestored()) { 92 UserSessionManager::GetInstance()->UserSessionsRestored()) {
87 if (!user_sessions_restored_) 93 if (!user_sessions_restored_)
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
157 // User that becomes active moves to the beginning of the list. 163 // User that becomes active moves to the beginning of the list.
158 EXPECT_EQ(account_id3_, users[0]->GetAccountId()); 164 EXPECT_EQ(account_id3_, users[0]->GetAccountId());
159 EXPECT_EQ(CryptohomeClient::GetStubSanitizedUsername(cryptohome_id3_), 165 EXPECT_EQ(CryptohomeClient::GetStubSanitizedUsername(cryptohome_id3_),
160 users[0]->username_hash()); 166 users[0]->username_hash());
161 EXPECT_EQ(account_id2_, users[1]->GetAccountId()); 167 EXPECT_EQ(account_id2_, users[1]->GetAccountId());
162 EXPECT_EQ(CryptohomeClient::GetStubSanitizedUsername(cryptohome_id2_), 168 EXPECT_EQ(CryptohomeClient::GetStubSanitizedUsername(cryptohome_id2_),
163 users[1]->username_hash()); 169 users[1]->username_hash());
164 EXPECT_EQ(account_id1_, users[2]->GetAccountId()); 170 EXPECT_EQ(account_id1_, users[2]->GetAccountId());
165 EXPECT_EQ(CryptohomeClient::GetStubSanitizedUsername(cryptohome_id1_), 171 EXPECT_EQ(CryptohomeClient::GetStubSanitizedUsername(cryptohome_id1_),
166 users[2]->username_hash()); 172 users[2]->username_hash());
173
174 auto* session_manager = session_manager::SessionManager::Get();
175 EXPECT_EQ(session_manager::SessionState::ACTIVE,
176 session_manager->session_state());
177 EXPECT_EQ(3u, session_manager->sessions().size());
178 EXPECT_EQ(session_manager->sessions()[0].user_account_id, account_id1_);
179 EXPECT_EQ(session_manager->sessions()[1].user_account_id, account_id2_);
180 EXPECT_EQ(session_manager->sessions()[2].user_account_id, account_id3_);
167 } 181 }
168 182
169 } // namespace chromeos 183 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698