| Index: ui/message_center/message_center_tray_unittest.cc
|
| diff --git a/ui/message_center/message_center_tray_unittest.cc b/ui/message_center/message_center_tray_unittest.cc
|
| index 1562156695a486d5afcfd08c034e400f24943640..e12bd094c3fb7d91ce0380e61e06b1a11a22c124 100644
|
| --- a/ui/message_center/message_center_tray_unittest.cc
|
| +++ b/ui/message_center/message_center_tray_unittest.cc
|
| @@ -69,11 +69,15 @@ class MessageCenterTrayTest : public testing::Test {
|
| }
|
|
|
| void AddNotification(const std::string& id) {
|
| + AddNotification(id, DummyNotifierId());
|
| + }
|
| +
|
| + void AddNotification(const std::string& id, NotifierId notifier_id) {
|
| scoped_ptr<Notification> notification(new Notification(
|
| message_center::NOTIFICATION_TYPE_SIMPLE, id,
|
| ASCIIToUTF16("Test Web Notification"),
|
| ASCIIToUTF16("Notification message body."), gfx::Image(),
|
| - ASCIIToUTF16("www.test.org"), GURL(), DummyNotifierId(),
|
| + ASCIIToUTF16("www.test.org"), GURL(), notifier_id,
|
| message_center::RichNotificationData(), NULL /* delegate */));
|
| message_center_->AddNotification(notification.Pass());
|
| }
|
| @@ -100,12 +104,12 @@ TEST_F(MessageCenterTrayTest, BasicMessageCenter) {
|
| ASSERT_FALSE(message_center_tray_->popups_visible());
|
| ASSERT_FALSE(message_center_tray_->message_center_visible());
|
|
|
| - message_center_tray_->ToggleMessageCenterBubble();
|
| + message_center_tray_->ShowMessageCenterBubble();
|
|
|
| ASSERT_FALSE(message_center_tray_->popups_visible());
|
| ASSERT_TRUE(message_center_tray_->message_center_visible());
|
|
|
| - message_center_tray_->ToggleMessageCenterBubble();
|
| + message_center_tray_->HideMessageCenterBubble();
|
|
|
| ASSERT_FALSE(message_center_tray_->popups_visible());
|
| ASSERT_FALSE(message_center_tray_->message_center_visible());
|
| @@ -221,7 +225,7 @@ TEST_F(MessageCenterTrayTest, ShowBubbleFails) {
|
| ASSERT_FALSE(message_center_tray_->popups_visible());
|
| ASSERT_FALSE(message_center_tray_->message_center_visible());
|
|
|
| - message_center_tray_->ToggleMessageCenterBubble();
|
| + message_center_tray_->ShowMessageCenterBubble();
|
|
|
| ASSERT_FALSE(message_center_tray_->popups_visible());
|
| ASSERT_FALSE(message_center_tray_->message_center_visible());
|
| @@ -232,7 +236,8 @@ TEST_F(MessageCenterTrayTest, ShowBubbleFails) {
|
| ASSERT_FALSE(message_center_tray_->message_center_visible());
|
| }
|
|
|
| -TEST_F(MessageCenterTrayTest, ContextMenuTest) {
|
| +#ifdef OS_CHROMEOS
|
| +TEST_F(MessageCenterTrayTest, ContextMenuTestWithMessageCenter) {
|
| const std::string id1 = "id1";
|
| const std::string id2 = "id2";
|
| const std::string id3 = "id3";
|
| @@ -288,4 +293,80 @@ TEST_F(MessageCenterTrayTest, ContextMenuTest) {
|
| EXPECT_FALSE(model->IsEnabledAt(0));
|
| }
|
|
|
| +#else
|
| +TEST_F(MessageCenterTrayTest, ContextMenuTestPopupsOnly) {
|
| + const std::string id1 = "id1";
|
| + const std::string id2 = "id2";
|
| + const std::string id3 = "id3";
|
| +
|
| + base::string16 display_source = ASCIIToUTF16("https://www.test.org");
|
| + NotifierId notifier_id(GURL("https://www.test.org"));
|
| +
|
| + AddNotification(id1, notifier_id);
|
| +
|
| + NotifierId notifier_id2(NotifierId::APPLICATION, "sample-app");
|
| + scoped_ptr<Notification> notification(new Notification(
|
| + message_center::NOTIFICATION_TYPE_SIMPLE, id2,
|
| + ASCIIToUTF16("Test Web Notification"),
|
| + ASCIIToUTF16("Notification message body."), gfx::Image(),
|
| + base::string16() /* empty display source */, GURL(), notifier_id2,
|
| + message_center::RichNotificationData(), NULL /* delegate */));
|
| + message_center_->AddNotification(notification.Pass());
|
| +
|
| + AddNotification(id3, notifier_id);
|
| +
|
| + // The dummy notifier is SYSTEM_COMPONENT so no context menu is visible.
|
| + scoped_ptr<ui::MenuModel> model(
|
| + message_center_tray_->CreateNotificationMenuModel(DummyNotifierId(),
|
| + display_source));
|
| + EXPECT_EQ(nullptr, model.get());
|
| +
|
| + model = message_center_tray_->CreateNotificationMenuModel(notifier_id,
|
| + display_source);
|
| + EXPECT_EQ(1, model->GetItemCount());
|
| +
|
| + // The first item is to disable notifications from the notifier id. It also
|
| + // removes all notifications from the same notifier, i.e. id1 and id3.
|
| + EXPECT_TRUE(model->IsEnabledAt(0));
|
| + model->ActivatedAt(0);
|
| +
|
| + NotificationList::Notifications notifications =
|
| + message_center_->GetVisibleNotifications();
|
| + EXPECT_EQ(1u, notifications.size());
|
| + EXPECT_EQ(id2, (*notifications.begin())->id());
|
| +
|
| + // Disables the context menu.
|
| + delegate_->enable_context_menu_ = false;
|
| +
|
| + // id2 doesn't have the display source, so it don't have the menu item for
|
| + // disabling notifications.
|
| + EXPECT_EQ(nullptr, message_center_tray_->CreateNotificationMenuModel(
|
| + notifier_id2, base::string16()));
|
| +}
|
| +#endif
|
| +
|
| +TEST_F(MessageCenterTrayTest, DelegateDisabledContextMenu) {
|
| + const std::string id1 = "id1";
|
| + base::string16 display_source = ASCIIToUTF16("www.test.org");
|
| + AddNotification(id1);
|
| + NotifierId notifier_id(GURL("www.test.org"));
|
| +
|
| + delegate_->enable_context_menu_ = false;
|
| + // id2 doesn't have the display source, so it don't have the menu item for
|
| + // disabling notifications.
|
| + scoped_ptr<ui::MenuModel> model(
|
| + message_center_tray_->CreateNotificationMenuModel(notifier_id,
|
| + display_source));
|
| +
|
| +// The commands are disabled because delegate disables context menu.
|
| +#ifndef OS_CHROMEOS
|
| + EXPECT_EQ(1, model->GetItemCount());
|
| +#else
|
| + EXPECT_EQ(2, model->GetItemCount());
|
| + EXPECT_FALSE(model->IsEnabledAt(1));
|
| +#endif
|
| +
|
| + EXPECT_FALSE(model->IsEnabledAt(0));
|
| +}
|
| +
|
| } // namespace message_center
|
|
|