| 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 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 116 TestSessionStateObserver observer_; | 116 TestSessionStateObserver observer_; |
| 117 | 117 |
| 118 DISALLOW_COPY_AND_ASSIGN(SessionControllerTest); | 118 DISALLOW_COPY_AND_ASSIGN(SessionControllerTest); |
| 119 }; | 119 }; |
| 120 | 120 |
| 121 // Tests that the simple session info is reflected properly. | 121 // Tests that the simple session info is reflected properly. |
| 122 TEST_F(SessionControllerTest, SimpleSessionInfo) { | 122 TEST_F(SessionControllerTest, SimpleSessionInfo) { |
| 123 mojom::SessionInfo info; | 123 mojom::SessionInfo info; |
| 124 FillDefaultSessionInfo(&info); | 124 FillDefaultSessionInfo(&info); |
| 125 SetSessionInfo(info); | 125 SetSessionInfo(info); |
| 126 UpdateSession(1u, "user1@test.com"); |
| 126 | 127 |
| 127 EXPECT_EQ(session_manager::kMaxmiumNumberOfUserSessions, | 128 EXPECT_EQ(session_manager::kMaxmiumNumberOfUserSessions, |
| 128 controller()->GetMaximumNumberOfLoggedInUsers()); | 129 controller()->GetMaximumNumberOfLoggedInUsers()); |
| 129 EXPECT_TRUE(controller()->CanLockScreen()); | 130 EXPECT_TRUE(controller()->CanLockScreen()); |
| 130 EXPECT_TRUE(controller()->ShouldLockScreenAutomatically()); | 131 EXPECT_TRUE(controller()->ShouldLockScreenAutomatically()); |
| 131 | 132 |
| 132 info.can_lock_screen = false; | 133 info.can_lock_screen = false; |
| 133 SetSessionInfo(info); | 134 SetSessionInfo(info); |
| 134 EXPECT_FALSE(controller()->CanLockScreen()); | 135 EXPECT_FALSE(controller()->CanLockScreen()); |
| 135 EXPECT_TRUE(controller()->ShouldLockScreenAutomatically()); | 136 EXPECT_TRUE(controller()->ShouldLockScreenAutomatically()); |
| 136 | 137 |
| 137 info.should_lock_screen_automatically = false; | 138 info.should_lock_screen_automatically = false; |
| 138 SetSessionInfo(info); | 139 SetSessionInfo(info); |
| 139 EXPECT_FALSE(controller()->CanLockScreen()); | 140 EXPECT_FALSE(controller()->CanLockScreen()); |
| 140 EXPECT_FALSE(controller()->ShouldLockScreenAutomatically()); | 141 EXPECT_FALSE(controller()->ShouldLockScreenAutomatically()); |
| 141 } | 142 } |
| 142 | 143 |
| 144 // Tests that the CanLockScreen is only true with an active user session. |
| 145 TEST_F(SessionControllerTest, CanLockScreen) { |
| 146 mojom::SessionInfo info; |
| 147 FillDefaultSessionInfo(&info); |
| 148 ASSERT_TRUE(info.can_lock_screen); // Check can_lock_screen default to true. |
| 149 SetSessionInfo(info); |
| 150 |
| 151 // Cannot lock screen when there is no active user session. |
| 152 EXPECT_FALSE(controller()->IsActiveUserSessionStarted()); |
| 153 EXPECT_FALSE(controller()->CanLockScreen()); |
| 154 |
| 155 UpdateSession(1u, "user1@test.com"); |
| 156 EXPECT_TRUE(controller()->IsActiveUserSessionStarted()); |
| 157 EXPECT_TRUE(controller()->CanLockScreen()); |
| 158 } |
| 159 |
| 143 // Tests that AddUserSessionPolicy is set properly. | 160 // Tests that AddUserSessionPolicy is set properly. |
| 144 TEST_F(SessionControllerTest, AddUserPolicy) { | 161 TEST_F(SessionControllerTest, AddUserPolicy) { |
| 145 const AddUserSessionPolicy kTestCases[] = { | 162 const AddUserSessionPolicy kTestCases[] = { |
| 146 AddUserSessionPolicy::ALLOWED, | 163 AddUserSessionPolicy::ALLOWED, |
| 147 AddUserSessionPolicy::ERROR_NOT_ALLOWED_PRIMARY_USER, | 164 AddUserSessionPolicy::ERROR_NOT_ALLOWED_PRIMARY_USER, |
| 148 AddUserSessionPolicy::ERROR_NO_ELIGIBLE_USERS, | 165 AddUserSessionPolicy::ERROR_NO_ELIGIBLE_USERS, |
| 149 AddUserSessionPolicy::ERROR_MAXIMUM_USERS_REACHED, | 166 AddUserSessionPolicy::ERROR_MAXIMUM_USERS_REACHED, |
| 150 }; | 167 }; |
| 151 | 168 |
| 152 mojom::SessionInfo info; | 169 mojom::SessionInfo info; |
| (...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 290 EXPECT_EQ("user2@test.com", observer()->active_account_id().GetUserEmail()); | 307 EXPECT_EQ("user2@test.com", observer()->active_account_id().GetUserEmail()); |
| 291 | 308 |
| 292 order = {1u, 2u}; | 309 order = {1u, 2u}; |
| 293 controller()->SetUserSessionOrder(order); | 310 controller()->SetUserSessionOrder(order); |
| 294 EXPECT_EQ("user1@test.com,user2@test.com,", GetUserSessionEmails()); | 311 EXPECT_EQ("user1@test.com,user2@test.com,", GetUserSessionEmails()); |
| 295 EXPECT_EQ("user1@test.com", observer()->active_account_id().GetUserEmail()); | 312 EXPECT_EQ("user1@test.com", observer()->active_account_id().GetUserEmail()); |
| 296 } | 313 } |
| 297 | 314 |
| 298 } // namespace | 315 } // namespace |
| 299 } // namespace ash | 316 } // namespace ash |
| OLD | NEW |