| OLD | NEW |
| 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 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 54 | 54 |
| 55 private: | 55 private: |
| 56 session_manager::SessionState state_ = session_manager::SessionState::UNKNOWN; | 56 session_manager::SessionState state_ = session_manager::SessionState::UNKNOWN; |
| 57 AccountId active_account_id_; | 57 AccountId active_account_id_; |
| 58 std::vector<AccountId> user_session_account_ids_; | 58 std::vector<AccountId> user_session_account_ids_; |
| 59 | 59 |
| 60 DISALLOW_COPY_AND_ASSIGN(TestSessionStateObserver); | 60 DISALLOW_COPY_AND_ASSIGN(TestSessionStateObserver); |
| 61 }; | 61 }; |
| 62 | 62 |
| 63 void FillDefaultSessionInfo(mojom::SessionInfo* info) { | 63 void FillDefaultSessionInfo(mojom::SessionInfo* info) { |
| 64 info->max_users = 123; | |
| 65 info->can_lock_screen = true; | 64 info->can_lock_screen = true; |
| 66 info->should_lock_screen_automatically = true; | 65 info->should_lock_screen_automatically = true; |
| 67 info->add_user_session_policy = AddUserSessionPolicy::ALLOWED; | 66 info->add_user_session_policy = AddUserSessionPolicy::ALLOWED; |
| 68 info->state = session_manager::SessionState::LOGIN_PRIMARY; | 67 info->state = session_manager::SessionState::LOGIN_PRIMARY; |
| 69 } | 68 } |
| 70 | 69 |
| 71 class SessionControllerTest : public testing::Test { | 70 class SessionControllerTest : public testing::Test { |
| 72 public: | 71 public: |
| 73 SessionControllerTest() {} | 72 SessionControllerTest() {} |
| 74 ~SessionControllerTest() override {} | 73 ~SessionControllerTest() override {} |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 117 | 116 |
| 118 DISALLOW_COPY_AND_ASSIGN(SessionControllerTest); | 117 DISALLOW_COPY_AND_ASSIGN(SessionControllerTest); |
| 119 }; | 118 }; |
| 120 | 119 |
| 121 // Tests that the simple session info is reflected properly. | 120 // Tests that the simple session info is reflected properly. |
| 122 TEST_F(SessionControllerTest, SimpleSessionInfo) { | 121 TEST_F(SessionControllerTest, SimpleSessionInfo) { |
| 123 mojom::SessionInfo info; | 122 mojom::SessionInfo info; |
| 124 FillDefaultSessionInfo(&info); | 123 FillDefaultSessionInfo(&info); |
| 125 SetSessionInfo(info); | 124 SetSessionInfo(info); |
| 126 | 125 |
| 127 EXPECT_EQ(123, controller()->GetMaximumNumberOfLoggedInUsers()); | 126 EXPECT_EQ(session_manager::kMaxmiumNumberOfUserSessions, |
| 127 controller()->GetMaximumNumberOfLoggedInUsers()); |
| 128 EXPECT_TRUE(controller()->CanLockScreen()); | 128 EXPECT_TRUE(controller()->CanLockScreen()); |
| 129 EXPECT_TRUE(controller()->ShouldLockScreenAutomatically()); | 129 EXPECT_TRUE(controller()->ShouldLockScreenAutomatically()); |
| 130 | 130 |
| 131 info.can_lock_screen = false; | 131 info.can_lock_screen = false; |
| 132 SetSessionInfo(info); | 132 SetSessionInfo(info); |
| 133 EXPECT_FALSE(controller()->CanLockScreen()); | 133 EXPECT_FALSE(controller()->CanLockScreen()); |
| 134 EXPECT_TRUE(controller()->ShouldLockScreenAutomatically()); | 134 EXPECT_TRUE(controller()->ShouldLockScreenAutomatically()); |
| 135 | 135 |
| 136 info.should_lock_screen_automatically = false; | 136 info.should_lock_screen_automatically = false; |
| 137 SetSessionInfo(info); | 137 SetSessionInfo(info); |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 227 EXPECT_EQ("user2@test.com", observer()->active_account_id().GetUserEmail()); | 227 EXPECT_EQ("user2@test.com", observer()->active_account_id().GetUserEmail()); |
| 228 | 228 |
| 229 order = {1u, 2u}; | 229 order = {1u, 2u}; |
| 230 controller()->SetUserSessionOrder(order); | 230 controller()->SetUserSessionOrder(order); |
| 231 EXPECT_EQ("user1@test.com,user2@test.com,", GetUserSessionEmails()); | 231 EXPECT_EQ("user1@test.com,user2@test.com,", GetUserSessionEmails()); |
| 232 EXPECT_EQ("user1@test.com", observer()->active_account_id().GetUserEmail()); | 232 EXPECT_EQ("user1@test.com", observer()->active_account_id().GetUserEmail()); |
| 233 } | 233 } |
| 234 | 234 |
| 235 } // namespace | 235 } // namespace |
| 236 } // namespace ash | 236 } // namespace ash |
| OLD | NEW |