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

Side by Side Diff: ui/message_center/notification_list_unittest.cc

Issue 2018063002: Revert of Show message center on lock screen (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 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
« no previous file with comments | « ui/message_center/notification_list.cc ('k') | ui/message_center/views/message_center_view.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "ui/message_center/notification_list.h" 5 #include "ui/message_center/notification_list.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <utility> 9 #include <utility>
10 10
11 #include "base/i18n/time_formatting.h" 11 #include "base/i18n/time_formatting.h"
12 #include "base/macros.h" 12 #include "base/macros.h"
13 #include "base/strings/stringprintf.h" 13 #include "base/strings/stringprintf.h"
14 #include "base/strings/utf_string_conversions.h" 14 #include "base/strings/utf_string_conversions.h"
15 #include "base/values.h" 15 #include "base/values.h"
16 #include "testing/gtest/include/gtest/gtest.h" 16 #include "testing/gtest/include/gtest/gtest.h"
17 #include "ui/message_center/fake_message_center.h"
18 #include "ui/message_center/message_center_style.h" 17 #include "ui/message_center/message_center_style.h"
19 #include "ui/message_center/notification_blocker.h" 18 #include "ui/message_center/notification_blocker.h"
20 #include "ui/message_center/notification_types.h" 19 #include "ui/message_center/notification_types.h"
21 #include "ui/message_center/notifier_settings.h" 20 #include "ui/message_center/notifier_settings.h"
22 21
23 using base::UTF8ToUTF16; 22 using base::UTF8ToUTF16;
24 23
25 namespace message_center { 24 namespace message_center {
26 25
27 class NotificationListTest : public testing::Test { 26 class NotificationListTest : public testing::Test {
28 public: 27 public:
29 NotificationListTest() {} 28 NotificationListTest() {}
30 ~NotificationListTest() override {} 29 ~NotificationListTest() override {}
31 30
32 void SetUp() override { 31 void SetUp() override {
33 notification_list_.reset(new NotificationList(new FakeMessageCenter())); 32 notification_list_.reset(new NotificationList());
34 counter_ = 0; 33 counter_ = 0;
35 } 34 }
36 35
37 protected: 36 protected:
38 // Currently NotificationListTest doesn't care about some fields like title or 37 // Currently NotificationListTest doesn't care about some fields like title or
39 // message, so put a simple template on it. Returns the id of the new 38 // message, so put a simple template on it. Returns the id of the new
40 // notification. 39 // notification.
41 std::string AddNotification( 40 std::string AddNotification(
42 const message_center::RichNotificationData& optional_fields) { 41 const message_center::RichNotificationData& optional_fields) {
43 std::string new_id; 42 std::string new_id;
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
156 AddNotification(); 155 AddNotification();
157 EXPECT_EQ(2u, notification_list()->NotificationCount(blockers())); 156 EXPECT_EQ(2u, notification_list()->NotificationCount(blockers()));
158 } 157 }
159 158
160 TEST_F(NotificationListTest, MessageCenterVisible) { 159 TEST_F(NotificationListTest, MessageCenterVisible) {
161 AddNotification(); 160 AddNotification();
162 EXPECT_EQ(1u, notification_list()->NotificationCount(blockers())); 161 EXPECT_EQ(1u, notification_list()->NotificationCount(blockers()));
163 ASSERT_EQ(1u, notification_list()->UnreadCount(blockers())); 162 ASSERT_EQ(1u, notification_list()->UnreadCount(blockers()));
164 ASSERT_EQ(1u, GetPopupCounts()); 163 ASSERT_EQ(1u, GetPopupCounts());
165 164
166 // Resets the unread count and popup counts. 165 // Make the message center visible. It resets the unread count and popup
167 notification_list()->SetNotificationsShown(blockers(), NULL); 166 // counts.
167 notification_list()->SetMessageCenterVisible(true, NULL);
168 ASSERT_EQ(0u, notification_list()->UnreadCount(blockers())); 168 ASSERT_EQ(0u, notification_list()->UnreadCount(blockers()));
169 ASSERT_EQ(0u, GetPopupCounts()); 169 ASSERT_EQ(0u, GetPopupCounts());
170 } 170 }
171 171
172 TEST_F(NotificationListTest, UnreadCount) { 172 TEST_F(NotificationListTest, UnreadCount) {
173 std::string id0 = AddNotification(); 173 std::string id0 = AddNotification();
174 std::string id1 = AddNotification(); 174 std::string id1 = AddNotification();
175 ASSERT_EQ(2u, notification_list()->UnreadCount(blockers())); 175 ASSERT_EQ(2u, notification_list()->UnreadCount(blockers()));
176 176
177 notification_list()->MarkSinglePopupAsDisplayed(id0); 177 notification_list()->MarkSinglePopupAsDisplayed(id0);
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
302 ASSERT_EQ(0u, notification_list()->UnreadCount(blockers())); 302 ASSERT_EQ(0u, notification_list()->UnreadCount(blockers()));
303 303
304 // Default priority has the limit on the number of the popups. 304 // Default priority has the limit on the number of the popups.
305 for (size_t i = 0; i <= kMaxVisiblePopupNotifications; ++i) 305 for (size_t i = 0; i <= kMaxVisiblePopupNotifications; ++i)
306 AddNotification(); 306 AddNotification();
307 EXPECT_EQ(kMaxVisiblePopupNotifications + 1, 307 EXPECT_EQ(kMaxVisiblePopupNotifications + 1,
308 notification_list()->NotificationCount(blockers())); 308 notification_list()->NotificationCount(blockers()));
309 EXPECT_EQ(kMaxVisiblePopupNotifications, GetPopupCounts()); 309 EXPECT_EQ(kMaxVisiblePopupNotifications, GetPopupCounts());
310 310
311 // Low priority: not visible to popups. 311 // Low priority: not visible to popups.
312 notification_list()->SetNotificationsShown(blockers(), NULL); 312 notification_list()->SetMessageCenterVisible(true, NULL);
313 notification_list()->SetMessageCenterVisible(false, NULL);
313 EXPECT_EQ(0u, notification_list()->UnreadCount(blockers())); 314 EXPECT_EQ(0u, notification_list()->UnreadCount(blockers()));
314 AddPriorityNotification(LOW_PRIORITY); 315 AddPriorityNotification(LOW_PRIORITY);
315 EXPECT_EQ(kMaxVisiblePopupNotifications + 2, 316 EXPECT_EQ(kMaxVisiblePopupNotifications + 2,
316 notification_list()->NotificationCount(blockers())); 317 notification_list()->NotificationCount(blockers()));
317 EXPECT_EQ(1u, notification_list()->UnreadCount(blockers())); 318 EXPECT_EQ(1u, notification_list()->UnreadCount(blockers()));
318 EXPECT_EQ(0u, GetPopupCounts()); 319 EXPECT_EQ(0u, GetPopupCounts());
319 320
320 // Minimum priority: doesn't update the unread count. 321 // Minimum priority: doesn't update the unread count.
321 AddPriorityNotification(MIN_PRIORITY); 322 AddPriorityNotification(MIN_PRIORITY);
322 EXPECT_EQ(kMaxVisiblePopupNotifications + 3, 323 EXPECT_EQ(kMaxVisiblePopupNotifications + 3,
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
360 GetNotification(system_id)->SetSystemPriority(); 361 GetNotification(system_id)->SetSystemPriority();
361 362
362 EXPECT_EQ(2u, GetPopupCounts()); 363 EXPECT_EQ(2u, GetPopupCounts());
363 364
364 notification_list()->MarkSinglePopupAsDisplayed(normal_id); 365 notification_list()->MarkSinglePopupAsDisplayed(normal_id);
365 notification_list()->MarkSinglePopupAsDisplayed(system_id); 366 notification_list()->MarkSinglePopupAsDisplayed(system_id);
366 367
367 notification_list()->MarkSinglePopupAsShown(normal_id, false); 368 notification_list()->MarkSinglePopupAsShown(normal_id, false);
368 notification_list()->MarkSinglePopupAsShown(system_id, false); 369 notification_list()->MarkSinglePopupAsShown(system_id, false);
369 370
370 notification_list()->SetNotificationsShown(blockers(), NULL); 371 notification_list()->SetMessageCenterVisible(true, NULL);
372 notification_list()->SetMessageCenterVisible(false, NULL);
371 EXPECT_EQ(1u, GetPopupCounts()); 373 EXPECT_EQ(1u, GetPopupCounts());
372 374
373 // Mark as read -- emulation of mouse click. 375 // Mark as read -- emulation of mouse click.
374 notification_list()->MarkSinglePopupAsShown(system_id, true); 376 notification_list()->MarkSinglePopupAsShown(system_id, true);
375 EXPECT_EQ(0u, GetPopupCounts()); 377 EXPECT_EQ(0u, GetPopupCounts());
376 } 378 }
377 379
378 TEST_F(NotificationListTest, PriorityPromotion) { 380 TEST_F(NotificationListTest, PriorityPromotion) {
379 std::string id0 = AddPriorityNotification(LOW_PRIORITY); 381 std::string id0 = AddPriorityNotification(LOW_PRIORITY);
380 std::string replaced = id0 + "_replaced"; 382 std::string replaced = id0 + "_replaced";
(...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after
660 NotifierId(), RichNotificationData(), NULL)); 662 NotifierId(), RichNotificationData(), NULL));
661 notification_list()->AddNotification(std::move(updated_notification)); 663 notification_list()->AddNotification(std::move(updated_notification));
662 664
663 EXPECT_FALSE(notification_list()->HasNotificationOfType( 665 EXPECT_FALSE(notification_list()->HasNotificationOfType(
664 id, message_center::NOTIFICATION_TYPE_SIMPLE)); 666 id, message_center::NOTIFICATION_TYPE_SIMPLE));
665 EXPECT_TRUE(notification_list()->HasNotificationOfType( 667 EXPECT_TRUE(notification_list()->HasNotificationOfType(
666 id, message_center::NOTIFICATION_TYPE_PROGRESS)); 668 id, message_center::NOTIFICATION_TYPE_PROGRESS));
667 } 669 }
668 670
669 } // namespace message_center 671 } // namespace message_center
OLDNEW
« no previous file with comments | « ui/message_center/notification_list.cc ('k') | ui/message_center/views/message_center_view.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698