Index: ash/common/session/session_controller_unittest.cc |
diff --git a/ash/common/session/session_controller_unittest.cc b/ash/common/session/session_controller_unittest.cc |
index d6a986a6833d412ffb68fd7bca53b327c9a78655..9da35fd1f4d7dba6f6e6e55364448720ac04b508 100644 |
--- a/ash/common/session/session_controller_unittest.cc |
+++ b/ash/common/session/session_controller_unittest.cc |
@@ -123,6 +123,7 @@ TEST_F(SessionControllerTest, SimpleSessionInfo) { |
mojom::SessionInfo info; |
FillDefaultSessionInfo(&info); |
SetSessionInfo(info); |
+ UpdateSession(1u, "user1@test.com"); |
EXPECT_EQ(session_manager::kMaxmiumNumberOfUserSessions, |
controller()->GetMaximumNumberOfLoggedInUsers()); |
@@ -140,6 +141,22 @@ TEST_F(SessionControllerTest, SimpleSessionInfo) { |
EXPECT_FALSE(controller()->ShouldLockScreenAutomatically()); |
} |
+// Tests that the CanLockScreen is only true with an active user session. |
+TEST_F(SessionControllerTest, CanLockScreen) { |
+ mojom::SessionInfo info; |
+ FillDefaultSessionInfo(&info); |
+ ASSERT_TRUE(info.can_lock_screen); // Check can_lock_screen default to true. |
+ SetSessionInfo(info); |
+ |
+ // Cannot lock screen when there is no active user session. |
+ EXPECT_FALSE(controller()->IsActiveUserSessionStarted()); |
+ EXPECT_FALSE(controller()->CanLockScreen()); |
+ |
+ UpdateSession(1u, "user1@test.com"); |
+ EXPECT_TRUE(controller()->IsActiveUserSessionStarted()); |
+ EXPECT_TRUE(controller()->CanLockScreen()); |
+} |
+ |
// Tests that AddUserSessionPolicy is set properly. |
TEST_F(SessionControllerTest, AddUserPolicy) { |
const AddUserSessionPolicy kTestCases[] = { |