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

Unified Diff: ash/system/supervised/tray_supervised_user_unittest.cc

Issue 2829813002: cros: Move IsUserSupervised and IsUserChild off SystemTrayDelegate (Closed)
Patch Set: review 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ash/system/supervised/tray_supervised_user.cc ('k') | ash/system/tiles/tray_tiles_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..37c96c9643477a06981aa42bb6360f7cfa500e9f 100644
--- a/ash/system/supervised/tray_supervised_user_unittest.cc
+++ b/ash/system/supervised/tray_supervised_user_unittest.cc
@@ -5,7 +5,10 @@
#include "ash/system/supervised/tray_supervised_user.h"
#include "ash/login_status.h"
-#include "ash/test/ash_test.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 +19,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 +44,19 @@ 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);
+ SessionController* session = Shell::Get()->session_controller();
+ ASSERT_EQ(LoginStatus::NOT_LOGGED_IN, session->login_status());
+ ASSERT_FALSE(session->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();
+ client->AddUserSession("user1@test.com", user_manager::USER_TYPE_SUPERVISED);
+ 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),
« no previous file with comments | « ash/system/supervised/tray_supervised_user.cc ('k') | ash/system/tiles/tray_tiles_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698