Get foreground tab on Android
[chromium-blink-merge.git] / ui / message_center / message_center_impl_unittest.cc
blobe54f14b88de6799da62db3fee18aeb1fc8133123
1 // Copyright 2013 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.
5 #include "ui/message_center/message_center_impl.h"
7 #include "base/bind.h"
8 #include "base/message_loop/message_loop.h"
9 #include "base/run_loop.h"
10 #include "base/strings/utf_string_conversions.h"
11 #include "testing/gtest/include/gtest/gtest.h"
12 #include "ui/gfx/canvas.h"
13 #include "ui/gfx/size.h"
14 #include "ui/message_center/message_center.h"
15 #include "ui/message_center/message_center_types.h"
16 #include "ui/message_center/notification_blocker.h"
17 #include "ui/message_center/notification_types.h"
19 namespace message_center {
20 namespace {
22 class MessageCenterImplTest : public testing::Test,
23 public MessageCenterObserver {
24 public:
25 MessageCenterImplTest() {}
27 virtual void SetUp() OVERRIDE {
28 MessageCenter::Initialize();
29 message_center_ = MessageCenter::Get();
30 loop_.reset(new base::MessageLoop(base::MessageLoop::TYPE_DEFAULT));
31 run_loop_.reset(new base::RunLoop());
32 closure_ = run_loop_->QuitClosure();
35 virtual void TearDown() OVERRIDE {
36 run_loop_.reset();
37 loop_.reset();
38 message_center_ = NULL;
39 MessageCenter::Shutdown();
42 MessageCenter* message_center() const { return message_center_; }
43 base::RunLoop* run_loop() const { return run_loop_.get(); }
44 base::Closure closure() const { return closure_; }
46 protected:
47 Notification* CreateSimpleNotification(const std::string& id) {
48 return CreateNotification(id, NOTIFICATION_TYPE_SIMPLE);
51 Notification* CreateNotification(const std::string& id,
52 message_center::NotificationType type) {
53 RichNotificationData optional_fields;
54 optional_fields.buttons.push_back(ButtonInfo(UTF8ToUTF16("foo")));
55 optional_fields.buttons.push_back(ButtonInfo(UTF8ToUTF16("foo")));
56 return new Notification(type,
57 id,
58 UTF8ToUTF16("title"),
59 UTF8ToUTF16(id),
60 gfx::Image() /* icon */,
61 base::string16() /* display_source */,
62 NotifierId(NotifierId::APPLICATION, "app1"),
63 optional_fields,
64 NULL);
67 private:
68 MessageCenter* message_center_;
69 scoped_ptr<base::MessageLoop> loop_;
70 scoped_ptr<base::RunLoop> run_loop_;
71 base::Closure closure_;
73 DISALLOW_COPY_AND_ASSIGN(MessageCenterImplTest);
76 class ToggledNotificationBlocker : public NotificationBlocker {
77 public:
78 explicit ToggledNotificationBlocker(MessageCenter* message_center)
79 : NotificationBlocker(message_center),
80 notifications_enabled_(true) {}
81 virtual ~ToggledNotificationBlocker() {}
83 void SetNotificationsEnabled(bool enabled) {
84 if (notifications_enabled_ != enabled) {
85 notifications_enabled_ = enabled;
86 FOR_EACH_OBSERVER(
87 NotificationBlocker::Observer, observers(), OnBlockingStateChanged());
91 // NotificationBlocker overrides:
92 virtual bool ShouldShowNotificationAsPopup(
93 const message_center::NotifierId& notifier_id) const OVERRIDE {
94 return notifications_enabled_;
97 private:
98 bool notifications_enabled_;
100 DISALLOW_COPY_AND_ASSIGN(ToggledNotificationBlocker);
103 class PopupNotificationBlocker : public ToggledNotificationBlocker {
104 public:
105 PopupNotificationBlocker(MessageCenter* message_center,
106 const NotifierId& allowed_notifier)
107 : ToggledNotificationBlocker(message_center),
108 allowed_notifier_(allowed_notifier) {}
109 virtual ~PopupNotificationBlocker() {}
111 // NotificationBlocker overrides:
112 virtual bool ShouldShowNotificationAsPopup(
113 const NotifierId& notifier_id) const OVERRIDE {
114 return (notifier_id == allowed_notifier_) ||
115 ToggledNotificationBlocker::ShouldShowNotificationAsPopup(notifier_id);
118 private:
119 NotifierId allowed_notifier_;
121 DISALLOW_COPY_AND_ASSIGN(PopupNotificationBlocker);
124 bool PopupNotificationsContain(
125 const NotificationList::PopupNotifications& popups,
126 const std::string& id) {
127 for (NotificationList::PopupNotifications::const_iterator iter =
128 popups.begin(); iter != popups.end(); ++iter) {
129 if ((*iter)->id() == id)
130 return true;
132 return false;
135 } // namespace
137 namespace internal {
139 class MockPopupTimersController : public PopupTimersController {
140 public:
141 MockPopupTimersController(MessageCenter* message_center,
142 base::Closure quit_closure)
143 : PopupTimersController(message_center),
144 timer_finished_(false),
145 quit_closure_(quit_closure) {}
146 virtual ~MockPopupTimersController() {}
148 virtual void TimerFinished(const std::string& id) OVERRIDE {
149 base::MessageLoop::current()->PostTask(FROM_HERE, quit_closure_);
150 timer_finished_ = true;
151 last_id_ = id;
154 bool timer_finished() const { return timer_finished_; }
155 const std::string& last_id() const { return last_id_; }
157 private:
158 bool timer_finished_;
159 std::string last_id_;
160 base::Closure quit_closure_;
163 TEST_F(MessageCenterImplTest, PopupTimersEmptyController) {
164 scoped_ptr<PopupTimersController> popup_timers_controller =
165 make_scoped_ptr(new PopupTimersController(message_center()));
167 // Test that all functions succed without any timers created.
168 popup_timers_controller->PauseAll();
169 popup_timers_controller->StartAll();
170 popup_timers_controller->CancelAll();
171 popup_timers_controller->TimerFinished("unknown");
172 popup_timers_controller->PauseTimer("unknown");
173 popup_timers_controller->CancelTimer("unknown");
176 TEST_F(MessageCenterImplTest, PopupTimersControllerStartTimer) {
177 scoped_ptr<MockPopupTimersController> popup_timers_controller =
178 make_scoped_ptr(
179 new MockPopupTimersController(message_center(), closure()));
180 popup_timers_controller->StartTimer("test",
181 base::TimeDelta::FromMilliseconds(1));
182 run_loop()->Run();
183 EXPECT_TRUE(popup_timers_controller->timer_finished());
186 TEST_F(MessageCenterImplTest, PopupTimersControllerPauseTimer) {
187 scoped_ptr<MockPopupTimersController> popup_timers_controller =
188 make_scoped_ptr(
189 new MockPopupTimersController(message_center(), closure()));
190 popup_timers_controller->StartTimer("test",
191 base::TimeDelta::FromMilliseconds(1));
192 popup_timers_controller->PauseTimer("test");
193 run_loop()->RunUntilIdle();
195 EXPECT_FALSE(popup_timers_controller->timer_finished());
198 TEST_F(MessageCenterImplTest, PopupTimersControllerCancelTimer) {
199 scoped_ptr<MockPopupTimersController> popup_timers_controller =
200 make_scoped_ptr(
201 new MockPopupTimersController(message_center(), closure()));
202 popup_timers_controller->StartTimer("test",
203 base::TimeDelta::FromMilliseconds(1));
204 popup_timers_controller->CancelTimer("test");
205 run_loop()->RunUntilIdle();
207 EXPECT_FALSE(popup_timers_controller->timer_finished());
210 TEST_F(MessageCenterImplTest, PopupTimersControllerPauseAllTimers) {
211 scoped_ptr<MockPopupTimersController> popup_timers_controller =
212 make_scoped_ptr(
213 new MockPopupTimersController(message_center(), closure()));
214 popup_timers_controller->StartTimer("test",
215 base::TimeDelta::FromMilliseconds(1));
216 popup_timers_controller->PauseAll();
217 run_loop()->RunUntilIdle();
219 EXPECT_FALSE(popup_timers_controller->timer_finished());
222 TEST_F(MessageCenterImplTest, PopupTimersControllerStartAllTimers) {
223 scoped_ptr<MockPopupTimersController> popup_timers_controller =
224 make_scoped_ptr(
225 new MockPopupTimersController(message_center(), closure()));
226 popup_timers_controller->StartTimer("test",
227 base::TimeDelta::FromMilliseconds(1));
228 popup_timers_controller->PauseAll();
229 popup_timers_controller->StartAll();
230 run_loop()->Run();
232 EXPECT_TRUE(popup_timers_controller->timer_finished());
235 TEST_F(MessageCenterImplTest, PopupTimersControllerStartMultipleTimers) {
236 scoped_ptr<MockPopupTimersController> popup_timers_controller =
237 make_scoped_ptr(
238 new MockPopupTimersController(message_center(), closure()));
239 popup_timers_controller->StartTimer("test",
240 base::TimeDelta::FromMilliseconds(5));
241 popup_timers_controller->StartTimer("test2",
242 base::TimeDelta::FromMilliseconds(1));
243 popup_timers_controller->StartTimer("test3",
244 base::TimeDelta::FromMilliseconds(3));
245 popup_timers_controller->PauseAll();
246 popup_timers_controller->StartAll();
247 run_loop()->Run();
249 EXPECT_EQ(popup_timers_controller->last_id(), "test2");
250 EXPECT_TRUE(popup_timers_controller->timer_finished());
253 TEST_F(MessageCenterImplTest, PopupTimersControllerStartMultipleTimersPause) {
254 scoped_ptr<MockPopupTimersController> popup_timers_controller =
255 make_scoped_ptr(
256 new MockPopupTimersController(message_center(), closure()));
257 popup_timers_controller->StartTimer("test",
258 base::TimeDelta::FromMilliseconds(5));
259 popup_timers_controller->StartTimer("test2",
260 base::TimeDelta::FromMilliseconds(1));
261 popup_timers_controller->StartTimer("test3",
262 base::TimeDelta::FromMilliseconds(3));
263 popup_timers_controller->PauseTimer("test2");
265 run_loop()->Run();
267 EXPECT_EQ(popup_timers_controller->last_id(), "test3");
268 EXPECT_TRUE(popup_timers_controller->timer_finished());
271 TEST_F(MessageCenterImplTest, PopupTimersControllerResetTimer) {
272 scoped_ptr<MockPopupTimersController> popup_timers_controller =
273 make_scoped_ptr(
274 new MockPopupTimersController(message_center(), closure()));
275 popup_timers_controller->StartTimer("test",
276 base::TimeDelta::FromMilliseconds(5));
277 popup_timers_controller->StartTimer("test2",
278 base::TimeDelta::FromMilliseconds(1));
279 popup_timers_controller->StartTimer("test3",
280 base::TimeDelta::FromMilliseconds(3));
281 popup_timers_controller->PauseTimer("test2");
282 popup_timers_controller->ResetTimer("test",
283 base::TimeDelta::FromMilliseconds(2));
285 run_loop()->Run();
287 EXPECT_EQ(popup_timers_controller->last_id(), "test");
288 EXPECT_TRUE(popup_timers_controller->timer_finished());
291 TEST_F(MessageCenterImplTest, NotificationBlocker) {
292 NotifierId notifier_id(NotifierId::APPLICATION, "app1");
293 // Multiple blockers to verify the case that one blocker blocks but another
294 // doesn't.
295 ToggledNotificationBlocker blocker1(message_center());
296 ToggledNotificationBlocker blocker2(message_center());
298 message_center()->AddNotification(scoped_ptr<Notification>(new Notification(
299 NOTIFICATION_TYPE_SIMPLE,
300 "id1",
301 UTF8ToUTF16("title"),
302 UTF8ToUTF16("message"),
303 gfx::Image() /* icon */,
304 base::string16() /* display_source */,
305 notifier_id,
306 RichNotificationData(),
307 NULL)));
308 message_center()->AddNotification(scoped_ptr<Notification>(new Notification(
309 NOTIFICATION_TYPE_SIMPLE,
310 "id2",
311 UTF8ToUTF16("title"),
312 UTF8ToUTF16("message"),
313 gfx::Image() /* icon */,
314 base::string16() /* display_source */,
315 notifier_id,
316 RichNotificationData(),
317 NULL)));
318 EXPECT_EQ(2u, message_center()->GetPopupNotifications().size());
319 EXPECT_EQ(2u, message_center()->GetVisibleNotifications().size());
321 // Block all notifications. All popups are gone and message center should be
322 // hidden.
323 blocker1.SetNotificationsEnabled(false);
324 EXPECT_TRUE(message_center()->GetPopupNotifications().empty());
325 EXPECT_EQ(2u, message_center()->GetVisibleNotifications().size());
327 // Updates |blocker2| state, which doesn't affect the global state.
328 blocker2.SetNotificationsEnabled(false);
329 EXPECT_TRUE(message_center()->GetPopupNotifications().empty());
330 EXPECT_EQ(2u, message_center()->GetVisibleNotifications().size());
332 blocker2.SetNotificationsEnabled(true);
333 EXPECT_TRUE(message_center()->GetPopupNotifications().empty());
334 EXPECT_EQ(2u, message_center()->GetVisibleNotifications().size());
336 // If |blocker2| blocks, then unblocking blocker1 doesn't change the global
337 // state.
338 blocker2.SetNotificationsEnabled(false);
339 blocker1.SetNotificationsEnabled(true);
340 EXPECT_TRUE(message_center()->GetPopupNotifications().empty());
341 EXPECT_EQ(2u, message_center()->GetVisibleNotifications().size());
343 // Unblock both blockers, which recovers the global state, but the popups
344 // aren't shown.
345 blocker2.SetNotificationsEnabled(true);
346 EXPECT_TRUE(message_center()->GetPopupNotifications().empty());
347 EXPECT_EQ(2u, message_center()->GetVisibleNotifications().size());
350 TEST_F(MessageCenterImplTest, NotificationsDuringBlocked) {
351 NotifierId notifier_id(NotifierId::APPLICATION, "app1");
352 ToggledNotificationBlocker blocker(message_center());
354 message_center()->AddNotification(scoped_ptr<Notification>(new Notification(
355 NOTIFICATION_TYPE_SIMPLE,
356 "id1",
357 UTF8ToUTF16("title"),
358 UTF8ToUTF16("message"),
359 gfx::Image() /* icon */,
360 base::string16() /* display_source */,
361 notifier_id,
362 RichNotificationData(),
363 NULL)));
364 EXPECT_EQ(1u, message_center()->GetPopupNotifications().size());
365 EXPECT_EQ(1u, message_center()->GetVisibleNotifications().size());
367 // Create a notification during blocked. Still no popups.
368 blocker.SetNotificationsEnabled(false);
369 message_center()->AddNotification(scoped_ptr<Notification>(new Notification(
370 NOTIFICATION_TYPE_SIMPLE,
371 "id2",
372 UTF8ToUTF16("title"),
373 UTF8ToUTF16("message"),
374 gfx::Image() /* icon */,
375 base::string16() /* display_source */,
376 notifier_id,
377 RichNotificationData(),
378 NULL)));
379 EXPECT_TRUE(message_center()->GetPopupNotifications().empty());
380 EXPECT_EQ(2u, message_center()->GetVisibleNotifications().size());
382 // Unblock notifications, the id1 should appear as a popup.
383 blocker.SetNotificationsEnabled(true);
384 NotificationList::PopupNotifications popups =
385 message_center()->GetPopupNotifications();
386 EXPECT_EQ(1u, popups.size());
387 EXPECT_TRUE(PopupNotificationsContain(popups, "id2"));
388 EXPECT_EQ(2u, message_center()->GetVisibleNotifications().size());
391 // Similar to other blocker cases but this test case allows |notifier_id2| even
392 // in blocked.
393 TEST_F(MessageCenterImplTest, NotificationBlockerAllowsPopups) {
394 NotifierId notifier_id1(NotifierId::APPLICATION, "app1");
395 NotifierId notifier_id2(NotifierId::APPLICATION, "app2");
396 PopupNotificationBlocker blocker(message_center(), notifier_id2);
398 message_center()->AddNotification(scoped_ptr<Notification>(new Notification(
399 NOTIFICATION_TYPE_SIMPLE,
400 "id1",
401 UTF8ToUTF16("title"),
402 UTF8ToUTF16("message"),
403 gfx::Image() /* icon */,
404 base::string16() /* display_source */,
405 notifier_id1,
406 RichNotificationData(),
407 NULL)));
408 message_center()->AddNotification(scoped_ptr<Notification>(new Notification(
409 NOTIFICATION_TYPE_SIMPLE,
410 "id2",
411 UTF8ToUTF16("title"),
412 UTF8ToUTF16("message"),
413 gfx::Image() /* icon */,
414 base::string16() /* display_source */,
415 notifier_id2,
416 RichNotificationData(),
417 NULL)));
419 // "id1" is closed but "id2" is still visible as a popup.
420 blocker.SetNotificationsEnabled(false);
421 NotificationList::PopupNotifications popups =
422 message_center()->GetPopupNotifications();
423 EXPECT_EQ(1u, popups.size());
424 EXPECT_TRUE(PopupNotificationsContain(popups, "id2"));
425 EXPECT_EQ(2u, message_center()->GetVisibleNotifications().size());
427 message_center()->AddNotification(scoped_ptr<Notification>(new Notification(
428 NOTIFICATION_TYPE_SIMPLE,
429 "id3",
430 UTF8ToUTF16("title"),
431 UTF8ToUTF16("message"),
432 gfx::Image() /* icon */,
433 base::string16() /* display_source */,
434 notifier_id1,
435 RichNotificationData(),
436 NULL)));
437 message_center()->AddNotification(scoped_ptr<Notification>(new Notification(
438 NOTIFICATION_TYPE_SIMPLE,
439 "id4",
440 UTF8ToUTF16("title"),
441 UTF8ToUTF16("message"),
442 gfx::Image() /* icon */,
443 base::string16() /* display_source */,
444 notifier_id2,
445 RichNotificationData(),
446 NULL)));
447 popups = message_center()->GetPopupNotifications();
448 EXPECT_EQ(2u, popups.size());
449 EXPECT_TRUE(PopupNotificationsContain(popups, "id2"));
450 EXPECT_TRUE(PopupNotificationsContain(popups, "id4"));
451 EXPECT_EQ(4u, message_center()->GetVisibleNotifications().size());
453 blocker.SetNotificationsEnabled(true);
454 popups = message_center()->GetPopupNotifications();
455 EXPECT_EQ(3u, popups.size());
456 EXPECT_TRUE(PopupNotificationsContain(popups, "id2"));
457 EXPECT_TRUE(PopupNotificationsContain(popups, "id3"));
458 EXPECT_TRUE(PopupNotificationsContain(popups, "id4"));
459 EXPECT_EQ(4u, message_center()->GetVisibleNotifications().size());
462 TEST_F(MessageCenterImplTest, QueueUpdatesWithCenterVisible) {
463 std::string id("id1");
464 std::string id2("id2");
465 NotifierId notifier_id1(NotifierId::APPLICATION, "app1");
467 // First, add and update a notification to ensure updates happen
468 // normally.
469 scoped_ptr<Notification> notification(CreateSimpleNotification(id));
470 message_center()->AddNotification(notification.Pass());
471 notification.reset(CreateSimpleNotification(id2));
472 message_center()->UpdateNotification(id, notification.Pass());
473 EXPECT_TRUE(message_center()->HasNotification(id2));
474 EXPECT_FALSE(message_center()->HasNotification(id));
476 // Then open the message center.
477 message_center()->SetVisibility(VISIBILITY_MESSAGE_CENTER);
479 // Then update a notification; nothing should have happened.
480 notification.reset(CreateSimpleNotification(id));
481 message_center()->UpdateNotification(id2, notification.Pass());
482 EXPECT_TRUE(message_center()->HasNotification(id2));
483 EXPECT_FALSE(message_center()->HasNotification(id));
485 // Close the message center; then the update should have propagated.
486 message_center()->SetVisibility(VISIBILITY_TRANSIENT);
487 EXPECT_FALSE(message_center()->HasNotification(id2));
488 EXPECT_TRUE(message_center()->HasNotification(id));
491 TEST_F(MessageCenterImplTest, ComplexQueueing) {
492 std::string ids[5] = {"0", "1", "2", "3", "4p"};
493 NotifierId notifier_id1(NotifierId::APPLICATION, "app1");
495 scoped_ptr<Notification> notification;
496 // Add some notifications
497 int i = 0;
498 for (; i < 3; i++) {
499 notification.reset(CreateSimpleNotification(ids[i]));
500 message_center()->AddNotification(notification.Pass());
502 for (i = 0; i < 3; i++) {
503 EXPECT_TRUE(message_center()->HasNotification(ids[i]));
505 for (; i < 5; i++) {
506 EXPECT_FALSE(message_center()->HasNotification(ids[i]));
509 notification.reset(CreateNotification(ids[4], NOTIFICATION_TYPE_PROGRESS));
510 message_center()->AddNotification(notification.Pass());
512 // Now start queueing.
513 // NL: ["0", "1", "2", "4p"]
514 message_center()->SetVisibility(VISIBILITY_MESSAGE_CENTER);
516 // This should update notification "1" to have id "3".
517 notification.reset(CreateSimpleNotification(ids[3]));
518 message_center()->UpdateNotification(ids[1], notification.Pass());
520 notification.reset(CreateSimpleNotification(ids[4]));
521 message_center()->UpdateNotification(ids[4], notification.Pass());
523 notification.reset(CreateNotification(ids[4], NOTIFICATION_TYPE_PROGRESS));
524 message_center()->UpdateNotification(ids[4], notification.Pass());
526 // This should update notification "3" to a new ID after we go TRANSIENT.
527 notification.reset(CreateSimpleNotification("New id"));
528 message_center()->UpdateNotification(ids[3], notification.Pass());
530 // This should create a new "3", that doesn't overwrite the update to 3
531 // before.
532 notification.reset(CreateSimpleNotification(ids[3]));
533 message_center()->AddNotification(notification.Pass());
535 // The NL should still be the same: ["0", "1", "2", "4p"]
536 EXPECT_TRUE(message_center()->HasNotification(ids[0]));
537 EXPECT_TRUE(message_center()->HasNotification(ids[1]));
538 EXPECT_TRUE(message_center()->HasNotification(ids[2]));
539 EXPECT_FALSE(message_center()->HasNotification(ids[3]));
540 EXPECT_TRUE(message_center()->HasNotification(ids[4]));
541 EXPECT_EQ(message_center()->GetVisibleNotifications().size(), 4u);
542 message_center()->SetVisibility(VISIBILITY_TRANSIENT);
544 EXPECT_TRUE(message_center()->HasNotification(ids[0]));
545 EXPECT_FALSE(message_center()->HasNotification(ids[1]));
546 EXPECT_TRUE(message_center()->HasNotification(ids[2]));
547 EXPECT_TRUE(message_center()->HasNotification(ids[3]));
548 EXPECT_TRUE(message_center()->HasNotification(ids[4]));
549 EXPECT_TRUE(message_center()->HasNotification("New id"));
550 EXPECT_EQ(message_center()->GetVisibleNotifications().size(), 5u);
553 TEST_F(MessageCenterImplTest, QueuedDirectUpdates) {
554 std::string id("id1");
555 std::string id2("id2");
556 NotifierId notifier_id1(NotifierId::APPLICATION, "app1");
558 gfx::Size original_size(0, 0);
559 // Open the message center to prevent adding notifications
560 message_center()->SetVisibility(VISIBILITY_MESSAGE_CENTER);
562 // Create new notification to be added to the queue; images all have the same
563 // original size.
564 scoped_ptr<Notification> notification(CreateSimpleNotification(id));
566 // Double-check that sizes all match.
567 const std::vector<ButtonInfo>& original_buttons = notification->buttons();
568 ASSERT_EQ(2u, original_buttons.size());
570 EXPECT_EQ(original_size, notification->icon().Size());
571 EXPECT_EQ(original_size, notification->image().Size());
572 EXPECT_EQ(original_size, original_buttons[0].icon.Size());
573 EXPECT_EQ(original_size, original_buttons[1].icon.Size());
575 message_center()->AddNotification(notification.Pass());
577 // The notification should be in the queue.
578 EXPECT_FALSE(message_center()->HasNotification(id));
580 // Now try setting the icon to a different size.
581 gfx::Size new_size(16, 16);
582 EXPECT_NE(original_size, new_size);
584 gfx::Canvas canvas(new_size, 1.0f, true);
585 canvas.DrawColor(SK_ColorBLUE);
586 gfx::Image testImage(gfx::Image(gfx::ImageSkia(canvas.ExtractImageRep())));
587 message_center()->SetNotificationIcon(id, testImage);
588 message_center()->SetNotificationImage(id, testImage);
589 message_center()->SetNotificationButtonIcon(id, 0, testImage);
590 message_center()->SetNotificationButtonIcon(id, 1, testImage);
592 // The notification should be in the queue.
593 EXPECT_FALSE(message_center()->HasNotification(id));
595 // Close the message center; then the update should have propagated.
596 message_center()->SetVisibility(VISIBILITY_TRANSIENT);
597 // The notification should no longer be in the queue.
598 EXPECT_TRUE(message_center()->HasNotification(id));
600 Notification* mc_notification =
601 *(message_center()->GetVisibleNotifications().begin());
602 const std::vector<ButtonInfo>& buttons = mc_notification->buttons();
603 ASSERT_EQ(2u, buttons.size());
605 EXPECT_EQ(new_size, mc_notification->icon().Size());
606 EXPECT_EQ(new_size, mc_notification->image().Size());
607 EXPECT_EQ(new_size, buttons[0].icon.Size());
608 EXPECT_EQ(new_size, buttons[1].icon.Size());
611 } // namespace internal
612 } // namespace message_center