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

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

Issue 11827010: Fixes the policy to choose the notifications for popups. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 11 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 | Annotate | Revision Log
« no previous file with comments | « ui/message_center/notification_list.cc ('k') | no next file » | 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 "base/basictypes.h" 7 #include "base/basictypes.h"
8 #include "base/i18n/time_formatting.h" 8 #include "base/i18n/time_formatting.h"
9 #include "base/stringprintf.h" 9 #include "base/stringprintf.h"
10 #include "base/utf_string_conversions.h" 10 #include "base/utf_string_conversions.h"
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after
205 notification_list()->AddNotification( 205 notification_list()->AddNotification(
206 ui::notifications::NOTIFICATION_TYPE_SIMPLE, "id3", UTF8ToUTF16("title1"), 206 ui::notifications::NOTIFICATION_TYPE_SIMPLE, "id3", UTF8ToUTF16("title1"),
207 UTF8ToUTF16("message1"), UTF8ToUTF16("source2"), "ext1", NULL); 207 UTF8ToUTF16("message1"), UTF8ToUTF16("source2"), "ext1", NULL);
208 208
209 notification_list()->SendRemoveNotificationsBySource("id0"); 209 notification_list()->SendRemoveNotificationsBySource("id0");
210 EXPECT_EQ(2u, delegate()->GetSendRemoveCountAndReset()); 210 EXPECT_EQ(2u, delegate()->GetSendRemoveCountAndReset());
211 notification_list()->SendRemoveNotificationsByExtension("id0"); 211 notification_list()->SendRemoveNotificationsByExtension("id0");
212 EXPECT_EQ(3u, delegate()->GetSendRemoveCountAndReset()); 212 EXPECT_EQ(3u, delegate()->GetSendRemoveCountAndReset());
213 } 213 }
214 214
215 TEST_F(NotificationListTest, OldPopupShouldNotBeHidden) {
216 std::vector<std::string> ids;
217 for (size_t i = 0; i <= NotificationList::kMaxVisiblePopupNotifications;
218 i++) {
219 ids.push_back(AddNotification(NULL));
220 }
221
222 NotificationList::Notifications popups;
223 notification_list()->GetPopupNotifications(&popups);
224 // The popup should contain the oldest kMaxVisiblePopupNotifications. Newer
225 // one should come earlier in the popup list. It means, the last element
226 // of |popups| should be the firstly added one, and so on.
227 EXPECT_EQ(NotificationList::kMaxVisiblePopupNotifications, popups.size());
228 NotificationList::Notifications::const_reverse_iterator iter =
229 popups.rbegin();
230 for (size_t i = 0; i < NotificationList::kMaxVisiblePopupNotifications;
231 ++i, ++iter) {
232 EXPECT_EQ(ids[i], iter->id) << i;
233 }
234
235 notification_list()->MarkPopupsAsShown(ui::notifications::DEFAULT_PRIORITY);
236 popups.clear();
237 notification_list()->GetPopupNotifications(&popups);
238 EXPECT_EQ(1u, popups.size());
239 EXPECT_EQ(ids[ids.size() - 1], popups.begin()->id);
240 }
241
215 TEST_F(NotificationListTest, Priority) { 242 TEST_F(NotificationListTest, Priority) {
216 ASSERT_EQ(0u, notification_list()->NotificationCount()); 243 ASSERT_EQ(0u, notification_list()->NotificationCount());
217 ASSERT_EQ(0u, notification_list()->unread_count()); 244 ASSERT_EQ(0u, notification_list()->unread_count());
218 245
219 // Default priority has the limit on the number of the popups. 246 // Default priority has the limit on the number of the popups.
220 for (size_t i = 0; i <= NotificationList::kMaxVisiblePopupNotifications; 247 for (size_t i = 0; i <= NotificationList::kMaxVisiblePopupNotifications;
221 ++i) { 248 ++i) {
222 AddNotification(NULL); 249 AddNotification(NULL);
223 } 250 }
224 EXPECT_EQ(NotificationList::kMaxVisiblePopupNotifications + 1, 251 EXPECT_EQ(NotificationList::kMaxVisiblePopupNotifications + 1,
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
330 357
331 notification_list()->SetQuietMode(false); 358 notification_list()->SetQuietMode(false);
332 AddNotification(NULL); 359 AddNotification(NULL);
333 EXPECT_EQ(4u, notification_list()->NotificationCount()); 360 EXPECT_EQ(4u, notification_list()->NotificationCount());
334 EXPECT_EQ(1u, GetPopupCounts()); 361 EXPECT_EQ(1u, GetPopupCounts());
335 362
336 // TODO(mukai): Add test of quiet mode with expiration. 363 // TODO(mukai): Add test of quiet mode with expiration.
337 } 364 }
338 365
339 } // namespace message_center 366 } // namespace message_center
OLDNEW
« no previous file with comments | « ui/message_center/notification_list.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698