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

Side by Side Diff: ash/common/session/session_controller_unittest.cc

Issue 2797743002: ash: Merge LoginStatus update code path (Closed)
Patch Set: for #2 comments Created 3 years, 8 months 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
« no previous file with comments | « ash/common/session/session_controller.cc ('k') | ash/common/session/session_state_observer.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 "ash/common/session/session_controller.h" 5 #include "ash/common/session/session_controller.h"
6 6
7 #include <memory> 7 #include <memory>
8 #include <string> 8 #include <string>
9 #include <utility> 9 #include <utility>
10 #include <vector> 10 #include <vector>
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after
224 {SessionState::LOGGED_IN_NOT_ACTIVE, LoginStatus::NOT_LOGGED_IN}, 224 {SessionState::LOGGED_IN_NOT_ACTIVE, LoginStatus::NOT_LOGGED_IN},
225 {SessionState::LOCKED, LoginStatus::LOCKED}, 225 {SessionState::LOCKED, LoginStatus::LOCKED},
226 // TODO: Add LOGIN_SECONDARY if we added a status for it. 226 // TODO: Add LOGIN_SECONDARY if we added a status for it.
227 }; 227 };
228 228
229 mojom::SessionInfo info; 229 mojom::SessionInfo info;
230 FillDefaultSessionInfo(&info); 230 FillDefaultSessionInfo(&info);
231 for (const auto& test_case : kTestCases) { 231 for (const auto& test_case : kTestCases) {
232 info.state = test_case.state; 232 info.state = test_case.state;
233 SetSessionInfo(info); 233 SetSessionInfo(info);
234 EXPECT_EQ(test_case.expected_status, controller()->GetLoginStatus()) 234 EXPECT_EQ(test_case.expected_status, controller()->login_status())
235 << "Test case state=" << static_cast<int>(test_case.state); 235 << "Test case state=" << static_cast<int>(test_case.state);
236 } 236 }
237 } 237 }
238 238
239 // Tests that LoginStatus is computed correctly for active sessions. 239 // Tests that LoginStatus is computed correctly for active sessions.
240 TEST_F(SessionControllerTest, GetLoginStateForActiveSession) { 240 TEST_F(SessionControllerTest, GetLoginStateForActiveSession) {
241 // Simulate an active user session. 241 // Simulate an active user session.
242 mojom::SessionInfo info; 242 mojom::SessionInfo info;
243 FillDefaultSessionInfo(&info); 243 FillDefaultSessionInfo(&info);
244 info.state = session_manager::SessionState::ACTIVE; 244 info.state = session_manager::SessionState::ACTIVE;
(...skipping 15 matching lines...) Expand all
260 260
261 for (const auto& test_case : kTestCases) { 261 for (const auto& test_case : kTestCases) {
262 mojom::UserSessionPtr session = mojom::UserSession::New(); 262 mojom::UserSessionPtr session = mojom::UserSession::New();
263 session->session_id = 1u; 263 session->session_id = 1u;
264 session->type = test_case.user_type; 264 session->type = test_case.user_type;
265 session->account_id = AccountId::FromUserEmail("user1@test.com"); 265 session->account_id = AccountId::FromUserEmail("user1@test.com");
266 session->display_name = "User 1"; 266 session->display_name = "User 1";
267 session->display_email = "user1@test.com"; 267 session->display_email = "user1@test.com";
268 controller()->UpdateUserSession(std::move(session)); 268 controller()->UpdateUserSession(std::move(session));
269 269
270 EXPECT_EQ(test_case.expected_status, controller()->GetLoginStatus()) 270 EXPECT_EQ(test_case.expected_status, controller()->login_status())
271 << "Test case user_type=" << static_cast<int>(test_case.user_type); 271 << "Test case user_type=" << static_cast<int>(test_case.user_type);
272 } 272 }
273 } 273 }
274 274
275 // Tests that user sessions can be set and updated. 275 // Tests that user sessions can be set and updated.
276 TEST_F(SessionControllerTest, UserSessions) { 276 TEST_F(SessionControllerTest, UserSessions) {
277 EXPECT_FALSE(controller()->IsActiveUserSessionStarted()); 277 EXPECT_FALSE(controller()->IsActiveUserSessionStarted());
278 278
279 UpdateSession(1u, "user1@test.com"); 279 UpdateSession(1u, "user1@test.com");
280 EXPECT_TRUE(controller()->IsActiveUserSessionStarted()); 280 EXPECT_TRUE(controller()->IsActiveUserSessionStarted());
(...skipping 26 matching lines...) Expand all
307 EXPECT_EQ("user2@test.com", observer()->active_account_id().GetUserEmail()); 307 EXPECT_EQ("user2@test.com", observer()->active_account_id().GetUserEmail());
308 308
309 order = {1u, 2u}; 309 order = {1u, 2u};
310 controller()->SetUserSessionOrder(order); 310 controller()->SetUserSessionOrder(order);
311 EXPECT_EQ("user1@test.com,user2@test.com,", GetUserSessionEmails()); 311 EXPECT_EQ("user1@test.com,user2@test.com,", GetUserSessionEmails());
312 EXPECT_EQ("user1@test.com", observer()->active_account_id().GetUserEmail()); 312 EXPECT_EQ("user1@test.com", observer()->active_account_id().GetUserEmail());
313 } 313 }
314 314
315 } // namespace 315 } // namespace
316 } // namespace ash 316 } // namespace ash
OLDNEW
« no previous file with comments | « ash/common/session/session_controller.cc ('k') | ash/common/session/session_state_observer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698