OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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/views/message_popup_collection.h" | 5 #include "ui/message_center/views/message_popup_collection.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <list> | 9 #include <list> |
10 #include <utility> | 10 #include <utility> |
(...skipping 462 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
473 | 473 |
474 for (size_t i = 0; i < notifications_to_add - 1; ++i) { | 474 for (size_t i = 0; i < notifications_to_add - 1; ++i) { |
475 EXPECT_TRUE(IsToastShown(ids[i])) << "Should show the " << i << "th ID"; | 475 EXPECT_TRUE(IsToastShown(ids[i])) << "Should show the " << i << "th ID"; |
476 } | 476 } |
477 EXPECT_FALSE(IsToastShown(ids[notifications_to_add - 1])); | 477 EXPECT_FALSE(IsToastShown(ids[notifications_to_add - 1])); |
478 | 478 |
479 CloseAllToasts(); | 479 CloseAllToasts(); |
480 WaitForTransitionsDone(); | 480 WaitForTransitionsDone(); |
481 } | 481 } |
482 | 482 |
| 483 #if defined(OS_CHROMEOS) |
| 484 |
| 485 TEST_F(MessagePopupCollectionTest, CloseNonClosableNotifications) { |
| 486 const char* kNotificationId = "NOTIFICATION1"; |
| 487 |
| 488 scoped_ptr<Notification> notification(new Notification( |
| 489 NOTIFICATION_TYPE_BASE_FORMAT, kNotificationId, |
| 490 base::UTF8ToUTF16("test title"), |
| 491 base::UTF8ToUTF16("test message"), gfx::Image(), |
| 492 base::string16() /* display_source */, GURL(), |
| 493 NotifierId(NotifierId::APPLICATION, kNotificationId), |
| 494 message_center::RichNotificationData(), new NotificationDelegate())); |
| 495 notification->set_closable(false); |
| 496 |
| 497 // Add a non-closable notification. |
| 498 MessageCenter::Get()->AddNotification(std::move(notification)); |
| 499 WaitForTransitionsDone(); |
| 500 |
| 501 // Confirms that there is a toast. |
| 502 EXPECT_EQ(1u, GetToastCounts()); |
| 503 EXPECT_EQ(1u, MessageCenter::Get()->NotificationCount()); |
| 504 |
| 505 // Close the toast. |
| 506 views::WidgetDelegateView* toast1 = GetToast(kNotificationId); |
| 507 ASSERT_TRUE(toast1 != NULL); |
| 508 ui::MouseEvent event(ui::ET_MOUSE_MOVED, gfx::Point(), gfx::Point(), |
| 509 ui::EventTimeForNow(), 0, 0); |
| 510 toast1->OnMouseEntered(event); |
| 511 static_cast<MessageCenterObserver*>(collection())->OnNotificationRemoved( |
| 512 kNotificationId, true); |
| 513 WaitForTransitionsDone(); |
| 514 |
| 515 // Confirms that there is no toast. |
| 516 EXPECT_EQ(0u, GetToastCounts()); |
| 517 // But the notification still exists. |
| 518 EXPECT_EQ(1u, MessageCenter::Get()->NotificationCount()); |
| 519 } |
| 520 |
| 521 #endif // defined(OS_CHROMEOS) |
483 | 522 |
484 } // namespace test | 523 } // namespace test |
485 } // namespace message_center | 524 } // namespace message_center |
OLD | NEW |