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

Side by Side Diff: ash/common/system/chromeos/supervised/tray_supervised_user_unittest.cc

Issue 2734653002: chromeos: Move files in //ash/common to //ash (Closed)
Patch Set: fix a11y tests, fix docs Created 3 years, 9 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "ash/common/system/chromeos/supervised/tray_supervised_user.h"
6
7 #include "ash/common/login_status.h"
8 #include "ash/common/test/ash_test.h"
9 #include "ash/common/test/test_system_tray_delegate.h"
10 #include "ui/message_center/message_center.h"
11 #include "ui/message_center/notification.h"
12 #include "ui/message_center/notification_list.h"
13 #include "ui/message_center/notification_types.h"
14
15 using message_center::NotificationList;
16
17 namespace ash {
18
19 class TraySupervisedUserTest : public AshTest {
20 public:
21 TraySupervisedUserTest() {}
22 ~TraySupervisedUserTest() override {}
23
24 protected:
25 message_center::Notification* GetPopup();
26
27 private:
28 DISALLOW_COPY_AND_ASSIGN(TraySupervisedUserTest);
29 };
30
31 message_center::Notification* TraySupervisedUserTest::GetPopup() {
32 NotificationList::PopupNotifications popups =
33 message_center::MessageCenter::Get()->GetPopupNotifications();
34 for (NotificationList::PopupNotifications::const_iterator iter =
35 popups.begin();
36 iter != popups.end(); ++iter) {
37 if ((*iter)->id() == TraySupervisedUser::kNotificationId)
38 return *iter;
39 }
40 return NULL;
41 }
42
43 class TraySupervisedUserInitialTest : public TraySupervisedUserTest {
44 public:
45 // Set the initial login status to supervised-user before AshTest::SetUp()
46 // constructs the system tray.
47 TraySupervisedUserInitialTest()
48 : scoped_initial_login_status_(LoginStatus::SUPERVISED) {}
49 ~TraySupervisedUserInitialTest() override {}
50
51 private:
52 test::ScopedInitialLoginStatus scoped_initial_login_status_;
53
54 DISALLOW_COPY_AND_ASSIGN(TraySupervisedUserInitialTest);
55 };
56
57 TEST_F(TraySupervisedUserTest, SupervisedUserHasNotification) {
58 test::TestSystemTrayDelegate* delegate = GetSystemTrayDelegate();
59 delegate->SetLoginStatus(LoginStatus::SUPERVISED);
60
61 message_center::Notification* notification = GetPopup();
62 ASSERT_NE(static_cast<message_center::Notification*>(NULL), notification);
63 EXPECT_EQ(static_cast<int>(message_center::SYSTEM_PRIORITY),
64 notification->rich_notification_data().priority);
65 }
66
67 TEST_F(TraySupervisedUserInitialTest, SupervisedUserNoCrash) {
68 // Initial login status is already SUPERVISED, which should create
69 // the notification and should not cause crashes.
70 message_center::Notification* notification = GetPopup();
71 ASSERT_NE(static_cast<message_center::Notification*>(NULL), notification);
72 EXPECT_EQ(static_cast<int>(message_center::SYSTEM_PRIORITY),
73 notification->rich_notification_data().priority);
74 }
75
76 } // namespace ash
OLDNEW
« no previous file with comments | « ash/common/system/chromeos/supervised/tray_supervised_user.cc ('k') | ash/common/system/chromeos/system_clock_observer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698