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

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

Issue 14631005: Enable users of NotificationUIManager to specify binary images. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase for relanding. Created 7 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/notification_types.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 "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 14 matching lines...) Expand all
25 notification_list_.reset(new NotificationList()); 25 notification_list_.reset(new NotificationList());
26 counter_ = 0; 26 counter_ = 0;
27 } 27 }
28 28
29 protected: 29 protected:
30 // Currently NotificationListTest doesn't care about some fields like title or 30 // Currently NotificationListTest doesn't care about some fields like title or
31 // message, so put a simple template on it. Returns the id of the new 31 // message, so put a simple template on it. Returns the id of the new
32 // notification. 32 // notification.
33 std::string AddNotification(const base::DictionaryValue* optional_fields) { 33 std::string AddNotification(const base::DictionaryValue* optional_fields) {
34 std::string new_id = base::StringPrintf(kIdFormat, counter_); 34 std::string new_id = base::StringPrintf(kIdFormat, counter_);
35 notification_list_->AddNotification( 35 scoped_ptr<Notification> notification(new Notification(
36 message_center::NOTIFICATION_TYPE_SIMPLE, 36 message_center::NOTIFICATION_TYPE_SIMPLE,
37 new_id, 37 new_id,
38 UTF8ToUTF16(base::StringPrintf(kTitleFormat, counter_)), 38 UTF8ToUTF16(base::StringPrintf(kTitleFormat, counter_)),
39 UTF8ToUTF16(base::StringPrintf(kMessageFormat, counter_)), 39 UTF8ToUTF16(base::StringPrintf(kMessageFormat, counter_)),
40 gfx::Image(),
40 UTF8ToUTF16(kDisplaySource), 41 UTF8ToUTF16(kDisplaySource),
41 kExtensionId, 42 kExtensionId,
42 optional_fields, 43 optional_fields,
43 NULL); 44 NULL));
45 notification_list_->AddNotification(notification.Pass());
44 counter_++; 46 counter_++;
45 return new_id; 47 return new_id;
46 } 48 }
47 49
48 // Utility methods of AddNotification. 50 // Utility methods of AddNotification.
49 std::string AddPriorityNotification(NotificationPriority priority) { 51 std::string AddPriorityNotification(NotificationPriority priority) {
50 base::DictionaryValue optional; 52 base::DictionaryValue optional;
51 optional.SetInteger(message_center::kPriorityKey, 53 optional.SetInteger(message_center::kPriorityKey,
52 static_cast<int>(priority)); 54 static_cast<int>(priority));
53 return AddNotification(&optional); 55 return AddNotification(&optional);
(...skipping 11 matching lines...) Expand all
65 Notification* GetNotification(const std::string& id) { 67 Notification* GetNotification(const std::string& id) {
66 NotificationList::Notifications::iterator iter = 68 NotificationList::Notifications::iterator iter =
67 notification_list()->GetNotification(id); 69 notification_list()->GetNotification(id);
68 if (iter == notification_list()->GetNotifications().end()) 70 if (iter == notification_list()->GetNotifications().end())
69 return NULL; 71 return NULL;
70 return *iter; 72 return *iter;
71 } 73 }
72 74
73 NotificationList* notification_list() { return notification_list_.get(); } 75 NotificationList* notification_list() { return notification_list_.get(); }
74 76
75 private:
76 static const char kIdFormat[]; 77 static const char kIdFormat[];
77 static const char kTitleFormat[]; 78 static const char kTitleFormat[];
78 static const char kMessageFormat[]; 79 static const char kMessageFormat[];
79 static const char kDisplaySource[]; 80 static const char kDisplaySource[];
80 static const char kExtensionId[]; 81 static const char kExtensionId[];
81 82
83 private:
82 scoped_ptr<NotificationList> notification_list_; 84 scoped_ptr<NotificationList> notification_list_;
83 size_t counter_; 85 size_t counter_;
84 86
85 DISALLOW_COPY_AND_ASSIGN(NotificationListTest); 87 DISALLOW_COPY_AND_ASSIGN(NotificationListTest);
86 }; 88 };
87 89
88 bool IsInNotifications(const NotificationList::Notifications& notifications, 90 bool IsInNotifications(const NotificationList::Notifications& notifications,
89 const std::string& id) { 91 const std::string& id) {
90 for (NotificationList::Notifications::const_iterator iter = 92 for (NotificationList::Notifications::const_iterator iter =
91 notifications.begin(); iter != notifications.end(); ++iter) { 93 notifications.begin(); iter != notifications.end(); ++iter) {
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
157 notification_list()->MarkSinglePopupAsDisplayed(id0); 159 notification_list()->MarkSinglePopupAsDisplayed(id0);
158 EXPECT_EQ(1u, notification_list()->unread_count()); 160 EXPECT_EQ(1u, notification_list()->unread_count());
159 notification_list()->MarkSinglePopupAsDisplayed(id1); 161 notification_list()->MarkSinglePopupAsDisplayed(id1);
160 EXPECT_EQ(0u, notification_list()->unread_count()); 162 EXPECT_EQ(0u, notification_list()->unread_count());
161 } 163 }
162 164
163 TEST_F(NotificationListTest, UpdateNotification) { 165 TEST_F(NotificationListTest, UpdateNotification) {
164 std::string id0 = AddNotification(NULL); 166 std::string id0 = AddNotification(NULL);
165 std::string replaced = id0 + "_replaced"; 167 std::string replaced = id0 + "_replaced";
166 EXPECT_EQ(1u, notification_list()->NotificationCount()); 168 EXPECT_EQ(1u, notification_list()->NotificationCount());
167 notification_list()->UpdateNotificationMessage(id0, 169 scoped_ptr<Notification> notification(
168 replaced, 170 new Notification(message_center::NOTIFICATION_TYPE_SIMPLE,
169 UTF8ToUTF16("newtitle"), 171 replaced,
170 UTF8ToUTF16("newbody"), 172 UTF8ToUTF16("newtitle"),
171 NULL, 173 UTF8ToUTF16("newbody"),
172 NULL); 174 gfx::Image(),
175 UTF8ToUTF16(kDisplaySource),
176 kExtensionId,
177 NULL,
178 NULL));
179 notification_list()->UpdateNotificationMessage(id0, notification.Pass());
173 EXPECT_EQ(1u, notification_list()->NotificationCount()); 180 EXPECT_EQ(1u, notification_list()->NotificationCount());
174 const NotificationList::Notifications& notifications = 181 const NotificationList::Notifications& notifications =
175 notification_list()->GetNotifications(); 182 notification_list()->GetNotifications();
176 EXPECT_EQ(replaced, (*notifications.begin())->id()); 183 EXPECT_EQ(replaced, (*notifications.begin())->id());
177 EXPECT_EQ(UTF8ToUTF16("newtitle"), (*notifications.begin())->title()); 184 EXPECT_EQ(UTF8ToUTF16("newtitle"), (*notifications.begin())->title());
178 EXPECT_EQ(UTF8ToUTF16("newbody"), (*notifications.begin())->message()); 185 EXPECT_EQ(UTF8ToUTF16("newbody"), (*notifications.begin())->message());
179 } 186 }
180 187
181 TEST_F(NotificationListTest, GetNotificationsBySourceOrExtensions) { 188 TEST_F(NotificationListTest, GetNotificationsBySourceOrExtensions) {
182 notification_list()->AddNotification(message_center::NOTIFICATION_TYPE_SIMPLE, 189 scoped_ptr<Notification> notification(
183 "id0", 190 new Notification(message_center::NOTIFICATION_TYPE_SIMPLE,
184 UTF8ToUTF16("title0"), 191 "id0",
185 UTF8ToUTF16("message0"), 192 UTF8ToUTF16("title0"),
186 UTF8ToUTF16("source0"), 193 UTF8ToUTF16("message0"),
187 "ext0", 194 gfx::Image(),
188 NULL, 195 UTF8ToUTF16("source0"),
189 NULL); 196 "ext0",
190 notification_list()->AddNotification(message_center::NOTIFICATION_TYPE_SIMPLE, 197 NULL,
191 "id1", 198 NULL));
192 UTF8ToUTF16("title1"), 199 notification_list()->AddNotification(notification.Pass());
193 UTF8ToUTF16("message1"), 200 notification.reset(new Notification(message_center::NOTIFICATION_TYPE_SIMPLE,
194 UTF8ToUTF16("source0"), 201 "id1",
195 "ext0", 202 UTF8ToUTF16("title1"),
196 NULL, 203 UTF8ToUTF16("message1"),
197 NULL); 204 gfx::Image(),
198 notification_list()->AddNotification(message_center::NOTIFICATION_TYPE_SIMPLE, 205 UTF8ToUTF16("source0"),
199 "id2", 206 "ext0",
200 UTF8ToUTF16("title1"), 207 NULL,
201 UTF8ToUTF16("message1"), 208 NULL));
202 UTF8ToUTF16("source1"), 209 notification_list()->AddNotification(notification.Pass());
203 "ext0", 210 notification.reset(new Notification(message_center::NOTIFICATION_TYPE_SIMPLE,
204 NULL, 211 "id2",
205 NULL); 212 UTF8ToUTF16("title1"),
206 notification_list()->AddNotification(message_center::NOTIFICATION_TYPE_SIMPLE, 213 UTF8ToUTF16("message1"),
207 "id3", 214 gfx::Image(),
208 UTF8ToUTF16("title1"), 215 UTF8ToUTF16("source1"),
209 UTF8ToUTF16("message1"), 216 "ext0",
210 UTF8ToUTF16("source2"), 217 NULL,
211 "ext1", 218 NULL));
212 NULL, 219 notification_list()->AddNotification(notification.Pass());
213 NULL); 220 notification.reset(new Notification(message_center::NOTIFICATION_TYPE_SIMPLE,
221 "id3",
222 UTF8ToUTF16("title1"),
223 UTF8ToUTF16("message1"),
224 gfx::Image(),
225 UTF8ToUTF16("source2"),
226 "ext1",
227 NULL,
228 NULL));
229 notification_list()->AddNotification(notification.Pass());
214 230
215 NotificationList::Notifications by_source = 231 NotificationList::Notifications by_source =
216 notification_list()->GetNotificationsBySource("id0"); 232 notification_list()->GetNotificationsBySource("id0");
217 EXPECT_TRUE(IsInNotifications(by_source, "id0")); 233 EXPECT_TRUE(IsInNotifications(by_source, "id0"));
218 EXPECT_TRUE(IsInNotifications(by_source, "id1")); 234 EXPECT_TRUE(IsInNotifications(by_source, "id1"));
219 EXPECT_FALSE(IsInNotifications(by_source, "id2")); 235 EXPECT_FALSE(IsInNotifications(by_source, "id2"));
220 EXPECT_FALSE(IsInNotifications(by_source, "id3")); 236 EXPECT_FALSE(IsInNotifications(by_source, "id3"));
221 237
222 NotificationList::Notifications by_extension = 238 NotificationList::Notifications by_extension =
223 notification_list()->GetNotificationsByExtension("id0"); 239 notification_list()->GetNotificationsByExtension("id0");
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
301 EXPECT_EQ(1u, GetPopupCounts()); 317 EXPECT_EQ(1u, GetPopupCounts());
302 } 318 }
303 319
304 TEST_F(NotificationListTest, PriorityPromotion) { 320 TEST_F(NotificationListTest, PriorityPromotion) {
305 std::string id0 = AddPriorityNotification(LOW_PRIORITY); 321 std::string id0 = AddPriorityNotification(LOW_PRIORITY);
306 std::string replaced = id0 + "_replaced"; 322 std::string replaced = id0 + "_replaced";
307 EXPECT_EQ(1u, notification_list()->NotificationCount()); 323 EXPECT_EQ(1u, notification_list()->NotificationCount());
308 EXPECT_EQ(0u, GetPopupCounts()); 324 EXPECT_EQ(0u, GetPopupCounts());
309 base::DictionaryValue optional; 325 base::DictionaryValue optional;
310 optional.SetInteger(message_center::kPriorityKey, 1); 326 optional.SetInteger(message_center::kPriorityKey, 1);
311 notification_list()->UpdateNotificationMessage(id0, 327 scoped_ptr<Notification> notification(
312 replaced, 328 new Notification(message_center::NOTIFICATION_TYPE_SIMPLE,
313 UTF8ToUTF16("newtitle"), 329 replaced,
314 UTF8ToUTF16("newbody"), 330 UTF8ToUTF16("newtitle"),
315 &optional, 331 UTF8ToUTF16("newbody"),
316 NULL); 332 gfx::Image(),
333 UTF8ToUTF16(kDisplaySource),
334 kExtensionId,
335 &optional,
336 NULL));
337 notification_list()->UpdateNotificationMessage(id0, notification.Pass());
317 EXPECT_EQ(1u, notification_list()->NotificationCount()); 338 EXPECT_EQ(1u, notification_list()->NotificationCount());
318 EXPECT_EQ(1u, GetPopupCounts()); 339 EXPECT_EQ(1u, GetPopupCounts());
319 const NotificationList::Notifications& notifications = 340 const NotificationList::Notifications& notifications =
320 notification_list()->GetNotifications(); 341 notification_list()->GetNotifications();
321 EXPECT_EQ(replaced, (*notifications.begin())->id()); 342 EXPECT_EQ(replaced, (*notifications.begin())->id());
322 EXPECT_EQ(UTF8ToUTF16("newtitle"), (*notifications.begin())->title()); 343 EXPECT_EQ(UTF8ToUTF16("newtitle"), (*notifications.begin())->title());
323 EXPECT_EQ(UTF8ToUTF16("newbody"), (*notifications.begin())->message()); 344 EXPECT_EQ(UTF8ToUTF16("newbody"), (*notifications.begin())->message());
324 EXPECT_EQ(1, (*notifications.begin())->priority()); 345 EXPECT_EQ(1, (*notifications.begin())->priority());
325 } 346 }
326 347
327 TEST_F(NotificationListTest, PriorityPromotionWithPopups) { 348 TEST_F(NotificationListTest, PriorityPromotionWithPopups) {
328 std::string id0 = AddPriorityNotification(LOW_PRIORITY); 349 std::string id0 = AddPriorityNotification(LOW_PRIORITY);
329 std::string id1 = AddPriorityNotification(DEFAULT_PRIORITY); 350 std::string id1 = AddPriorityNotification(DEFAULT_PRIORITY);
330 EXPECT_EQ(1u, GetPopupCounts()); 351 EXPECT_EQ(1u, GetPopupCounts());
331 notification_list()->MarkSinglePopupAsShown(id1, true); 352 notification_list()->MarkSinglePopupAsShown(id1, true);
332 EXPECT_EQ(0u, GetPopupCounts()); 353 EXPECT_EQ(0u, GetPopupCounts());
333 354
334 // id0 promoted to LOW->DEFAULT, it'll appear as toast (popup). 355 // id0 promoted to LOW->DEFAULT, it'll appear as toast (popup).
335 base::DictionaryValue priority_default; 356 base::DictionaryValue priority_default;
336 priority_default.SetInteger(message_center::kPriorityKey, 357 priority_default.SetInteger(message_center::kPriorityKey,
337 static_cast<int>(DEFAULT_PRIORITY)); 358 static_cast<int>(DEFAULT_PRIORITY));
338 notification_list()->UpdateNotificationMessage(id0, 359 scoped_ptr<Notification> notification(
339 id0, 360 new Notification(message_center::NOTIFICATION_TYPE_SIMPLE,
340 UTF8ToUTF16("newtitle"), 361 id0,
341 UTF8ToUTF16("newbody"), 362 UTF8ToUTF16("newtitle"),
342 &priority_default, 363 UTF8ToUTF16("newbody"),
343 NULL); 364 gfx::Image(),
365 UTF8ToUTF16(kDisplaySource),
366 kExtensionId,
367 &priority_default,
368 NULL));
369 notification_list()->UpdateNotificationMessage(id0, notification.Pass());
344 EXPECT_EQ(1u, GetPopupCounts()); 370 EXPECT_EQ(1u, GetPopupCounts());
345 notification_list()->MarkSinglePopupAsShown(id0, true); 371 notification_list()->MarkSinglePopupAsShown(id0, true);
346 EXPECT_EQ(0u, GetPopupCounts()); 372 EXPECT_EQ(0u, GetPopupCounts());
347 373
348 // update with no promotion change for id0, it won't appear as a toast. 374 // update with no promotion change for id0, it won't appear as a toast.
349 notification_list()->UpdateNotificationMessage( 375 notification.reset(new Notification(message_center::NOTIFICATION_TYPE_SIMPLE,
350 id0, id0, UTF8ToUTF16("newtitle2"), UTF8ToUTF16("newbody2"), NULL, NULL); 376 id0,
377 UTF8ToUTF16("newtitle2"),
378 UTF8ToUTF16("newbody2"),
379 gfx::Image(),
380 UTF8ToUTF16(kDisplaySource),
381 kExtensionId,
382 NULL,
383 NULL));
384 notification_list()->UpdateNotificationMessage(id0, notification.Pass());
351 EXPECT_EQ(0u, GetPopupCounts()); 385 EXPECT_EQ(0u, GetPopupCounts());
352 386
353 // id1 promoted to DEFAULT->HIGH, it'll appear as toast (popup). 387 // id1 promoted to DEFAULT->HIGH, it'll appear as toast (popup).
354 base::DictionaryValue priority_high; 388 base::DictionaryValue priority_high;
355 priority_high.SetInteger(message_center::kPriorityKey, 389 priority_high.SetInteger(message_center::kPriorityKey,
356 static_cast<int>(HIGH_PRIORITY)); 390 static_cast<int>(HIGH_PRIORITY));
357 notification_list()->UpdateNotificationMessage(id1, 391 notification.reset(new Notification(message_center::NOTIFICATION_TYPE_SIMPLE,
358 id1, 392 id1,
359 UTF8ToUTF16("newtitle"), 393 UTF8ToUTF16("newtitle"),
360 UTF8ToUTF16("newbody"), 394 UTF8ToUTF16("newbody"),
361 &priority_high, 395 gfx::Image(),
362 NULL); 396 UTF8ToUTF16(kDisplaySource),
397 kExtensionId,
398 &priority_high,
399 NULL));
400 notification_list()->UpdateNotificationMessage(id1, notification.Pass());
363 EXPECT_EQ(1u, GetPopupCounts()); 401 EXPECT_EQ(1u, GetPopupCounts());
364 notification_list()->MarkSinglePopupAsShown(id1, true); 402 notification_list()->MarkSinglePopupAsShown(id1, true);
365 EXPECT_EQ(0u, GetPopupCounts()); 403 EXPECT_EQ(0u, GetPopupCounts());
366 404
367 // id1 promoted to HIGH->MAX, it'll appear as toast again. 405 // id1 promoted to HIGH->MAX, it'll appear as toast again.
368 base::DictionaryValue priority_max; 406 base::DictionaryValue priority_max;
369 priority_max.SetInteger(message_center::kPriorityKey, 407 priority_max.SetInteger(message_center::kPriorityKey,
370 static_cast<int>(MAX_PRIORITY)); 408 static_cast<int>(MAX_PRIORITY));
371 notification_list()->UpdateNotificationMessage(id1, 409 notification.reset(new Notification(message_center::NOTIFICATION_TYPE_SIMPLE,
372 id1, 410 id1,
373 UTF8ToUTF16("newtitle2"), 411 UTF8ToUTF16("newtitle2"),
374 UTF8ToUTF16("newbody2"), 412 UTF8ToUTF16("newbody2"),
375 &priority_max, 413 gfx::Image(),
376 NULL); 414 UTF8ToUTF16(kDisplaySource),
415 kExtensionId,
416 &priority_max,
417 NULL));
418 notification_list()->UpdateNotificationMessage(id1, notification.Pass());
377 EXPECT_EQ(1u, GetPopupCounts()); 419 EXPECT_EQ(1u, GetPopupCounts());
378 notification_list()->MarkSinglePopupAsShown(id1, true); 420 notification_list()->MarkSinglePopupAsShown(id1, true);
379 EXPECT_EQ(0u, GetPopupCounts()); 421 EXPECT_EQ(0u, GetPopupCounts());
380 422
381 // id1 demoted to MAX->DEFAULT, no appearing as toast. 423 // id1 demoted to MAX->DEFAULT, no appearing as toast.
382 notification_list()->UpdateNotificationMessage(id1, 424 notification.reset(new Notification(message_center::NOTIFICATION_TYPE_SIMPLE,
383 id1, 425 id1,
384 UTF8ToUTF16("newtitle3"), 426 UTF8ToUTF16("newtitle3"),
385 UTF8ToUTF16("newbody3"), 427 UTF8ToUTF16("newbody3"),
386 &priority_default, 428 gfx::Image(),
387 NULL); 429 UTF8ToUTF16(kDisplaySource),
430 kExtensionId,
431 &priority_default,
432 NULL));
433 notification_list()->UpdateNotificationMessage(id1, notification.Pass());
388 EXPECT_EQ(0u, GetPopupCounts()); 434 EXPECT_EQ(0u, GetPopupCounts());
389 } 435 }
390 436
391 TEST_F(NotificationListTest, NotificationOrderAndPriority) { 437 TEST_F(NotificationListTest, NotificationOrderAndPriority) {
392 base::Time now = base::Time::Now(); 438 base::Time now = base::Time::Now();
393 base::DictionaryValue optional; 439 base::DictionaryValue optional;
394 SetupTimestampKey(now, &optional); 440 SetupTimestampKey(now, &optional);
395 optional.SetInteger(message_center::kPriorityKey, 2); 441 optional.SetInteger(message_center::kPriorityKey, 2);
396 std::string max_id = AddNotification(&optional); 442 std::string max_id = AddNotification(&optional);
397 now += base::TimeDelta::FromSeconds(1); 443 now += base::TimeDelta::FromSeconds(1);
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
506 EXPECT_FALSE(n1->shown_as_popup()); 552 EXPECT_FALSE(n1->shown_as_popup());
507 EXPECT_TRUE(n1->is_read()); 553 EXPECT_TRUE(n1->is_read());
508 554
509 notification_list()->MarkSinglePopupAsShown(id1, true); 555 notification_list()->MarkSinglePopupAsShown(id1, true);
510 556
511 n1 = GetNotification(id1); 557 n1 = GetNotification(id1);
512 EXPECT_TRUE(n1->shown_as_popup()); 558 EXPECT_TRUE(n1->shown_as_popup());
513 EXPECT_TRUE(n1->is_read()); 559 EXPECT_TRUE(n1->is_read());
514 560
515 const std::string replaced("test-replaced-id"); 561 const std::string replaced("test-replaced-id");
516 notification_list()->UpdateNotificationMessage(id1, 562 scoped_ptr<Notification> notification(
517 replaced, 563 new Notification(message_center::NOTIFICATION_TYPE_SIMPLE,
518 UTF8ToUTF16("newtitle"), 564 replaced,
519 UTF8ToUTF16("newbody"), 565 UTF8ToUTF16("newtitle"),
520 NULL, 566 UTF8ToUTF16("newbody"),
521 NULL); 567 gfx::Image(),
568 UTF8ToUTF16(kDisplaySource),
569 kExtensionId,
570 NULL,
571 NULL));
572 notification_list()->UpdateNotificationMessage(id1, notification.Pass());
522 n1 = GetNotification(id1); 573 n1 = GetNotification(id1);
523 EXPECT_TRUE(n1 == NULL); 574 EXPECT_TRUE(n1 == NULL);
524 const Notification* nr = GetNotification(replaced); 575 const Notification* nr = GetNotification(replaced);
525 EXPECT_TRUE(nr->shown_as_popup()); 576 EXPECT_TRUE(nr->shown_as_popup());
526 EXPECT_TRUE(nr->is_read()); 577 EXPECT_TRUE(nr->is_read());
527 } 578 }
528 579
529 TEST_F(NotificationListTest, QuietMode) { 580 TEST_F(NotificationListTest, QuietMode) {
530 notification_list()->SetQuietMode(true); 581 notification_list()->SetQuietMode(true);
531 AddNotification(NULL); 582 AddNotification(NULL);
532 AddPriorityNotification(HIGH_PRIORITY); 583 AddPriorityNotification(HIGH_PRIORITY);
533 AddPriorityNotification(MAX_PRIORITY); 584 AddPriorityNotification(MAX_PRIORITY);
534 EXPECT_EQ(3u, notification_list()->NotificationCount()); 585 EXPECT_EQ(3u, notification_list()->NotificationCount());
535 EXPECT_EQ(0u, GetPopupCounts()); 586 EXPECT_EQ(0u, GetPopupCounts());
536 // TODO(mukai): fix here when notification_list distinguish dismiss by quiet 587 // TODO(mukai): fix here when notification_list distinguish dismiss by quiet
537 // mode and by user operation. 588 // mode and by user operation.
538 EXPECT_EQ(0u, notification_list()->unread_count()); 589 EXPECT_EQ(0u, notification_list()->unread_count());
539 590
540 notification_list()->SetQuietMode(false); 591 notification_list()->SetQuietMode(false);
541 AddNotification(NULL); 592 AddNotification(NULL);
542 EXPECT_EQ(4u, notification_list()->NotificationCount()); 593 EXPECT_EQ(4u, notification_list()->NotificationCount());
543 EXPECT_EQ(1u, GetPopupCounts()); 594 EXPECT_EQ(1u, GetPopupCounts());
544 595
545 // TODO(mukai): Add test of quiet mode with expiration. 596 // TODO(mukai): Add test of quiet mode with expiration.
546 } 597 }
547 598
548 } // namespace test 599 } // namespace test
549 } // namespace message_center 600 } // namespace message_center
OLDNEW
« no previous file with comments | « ui/message_center/notification_list.cc ('k') | ui/message_center/notification_types.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698