Chromium Code Reviews| Index: ash/system/supervised/tray_supervised_user_unittest.cc |
| diff --git a/ash/system/supervised/tray_supervised_user_unittest.cc b/ash/system/supervised/tray_supervised_user_unittest.cc |
| index 61d3d48393b192db1945bb04ad49ee41497a6922..1de4b247797261cfbadb900e133df69e7de285f9 100644 |
| --- a/ash/system/supervised/tray_supervised_user_unittest.cc |
| +++ b/ash/system/supervised/tray_supervised_user_unittest.cc |
| @@ -5,7 +5,11 @@ |
| #include "ash/system/supervised/tray_supervised_user.h" |
| #include "ash/login_status.h" |
| -#include "ash/test/ash_test.h" |
| +#include "ash/public/interfaces/session_controller.mojom.h" |
| +#include "ash/session/session_controller.h" |
| +#include "ash/shell.h" |
| +#include "ash/test/ash_test_base.h" |
| +#include "ash/test/test_session_controller_client.h" |
| #include "ash/test/test_system_tray_delegate.h" |
| #include "ui/message_center/message_center.h" |
| #include "ui/message_center/notification.h" |
| @@ -16,7 +20,8 @@ using message_center::NotificationList; |
| namespace ash { |
| -class TraySupervisedUserTest : public AshTest { |
| +// Tests handle creating their own sessions. |
| +class TraySupervisedUserTest : public test::NoSessionAshTestBase { |
| public: |
| TraySupervisedUserTest() {} |
| ~TraySupervisedUserTest() override {} |
| @@ -40,33 +45,23 @@ message_center::Notification* TraySupervisedUserTest::GetPopup() { |
| return NULL; |
| } |
| -class TraySupervisedUserInitialTest : public TraySupervisedUserTest { |
| - public: |
| - // Set the initial login status to supervised-user before AshTest::SetUp() |
| - // constructs the system tray. |
| - TraySupervisedUserInitialTest() |
| - : scoped_initial_login_status_(LoginStatus::SUPERVISED) {} |
| - ~TraySupervisedUserInitialTest() override {} |
| - |
| - private: |
| - test::ScopedInitialLoginStatus scoped_initial_login_status_; |
| - |
| - DISALLOW_COPY_AND_ASSIGN(TraySupervisedUserInitialTest); |
| -}; |
| - |
| +// Verifies that when a supervised user logs in that a warning notification is |
| +// shown and ash does not crash. |
| TEST_F(TraySupervisedUserTest, SupervisedUserHasNotification) { |
| - test::TestSystemTrayDelegate* delegate = GetSystemTrayDelegate(); |
| - delegate->SetLoginStatus(LoginStatus::SUPERVISED); |
| + ASSERT_EQ(LoginStatus::NOT_LOGGED_IN, |
| + GetSystemTrayDelegate()->GetUserLoginStatus()); |
|
xiyuan
2017/04/19 20:58:00
I would vote to merge GetUserLoginStatus with the
James Cook
2017/04/19 22:16:37
I think that's a good idea, but we need to elimina
|
| + ASSERT_FALSE( |
| + Shell::Get()->session_controller()->IsActiveUserSessionStarted()); |
| - message_center::Notification* notification = GetPopup(); |
| - ASSERT_NE(static_cast<message_center::Notification*>(NULL), notification); |
| - EXPECT_EQ(static_cast<int>(message_center::SYSTEM_PRIORITY), |
| - notification->rich_notification_data().priority); |
| -} |
| + // Simulate a supervised user logging in. |
| + test::TestSessionControllerClient* client = GetSessionControllerClient(); |
| + client->Reset(); |
| + mojom::UserSessionPtr session = mojom::UserSession::New(); |
| + session->session_id = 1; |
| + session->type = user_manager::USER_TYPE_SUPERVISED; |
| + Shell::Get()->session_controller()->UpdateUserSession(std::move(session)); |
|
xiyuan
2017/04/19 20:58:00
Make TestSessionControllerClient::AddUserSession t
James Cook
2017/04/19 22:16:37
Done.
|
| + client->SetSessionState(session_manager::SessionState::ACTIVE); |
| -TEST_F(TraySupervisedUserInitialTest, SupervisedUserNoCrash) { |
| - // Initial login status is already SUPERVISED, which should create |
| - // the notification and should not cause crashes. |
| message_center::Notification* notification = GetPopup(); |
| ASSERT_NE(static_cast<message_center::Notification*>(NULL), notification); |
| EXPECT_EQ(static_cast<int>(message_center::SYSTEM_PRIORITY), |