| 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/message_center_tray.h" | 5 #include "ui/message_center/message_center_tray.h" |
| 6 | 6 |
| 7 #include <utility> |
| 8 |
| 7 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
| 8 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
| 9 #include "ui/base/models/menu_model.h" | 11 #include "ui/base/models/menu_model.h" |
| 10 #include "ui/message_center/message_center.h" | 12 #include "ui/message_center/message_center.h" |
| 11 #include "ui/message_center/notification.h" | 13 #include "ui/message_center/notification.h" |
| 12 #include "ui/message_center/notification_types.h" | 14 #include "ui/message_center/notification_types.h" |
| 13 | 15 |
| 14 using base::ASCIIToUTF16; | 16 using base::ASCIIToUTF16; |
| 15 | 17 |
| 16 namespace message_center { | 18 namespace message_center { |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 76 message_center_->EnableChangeQueueForTest(enabled); | 78 message_center_->EnableChangeQueueForTest(enabled); |
| 77 } | 79 } |
| 78 | 80 |
| 79 void AddNotification(const std::string& id, NotifierId notifier_id) { | 81 void AddNotification(const std::string& id, NotifierId notifier_id) { |
| 80 scoped_ptr<Notification> notification(new Notification( | 82 scoped_ptr<Notification> notification(new Notification( |
| 81 message_center::NOTIFICATION_TYPE_SIMPLE, id, | 83 message_center::NOTIFICATION_TYPE_SIMPLE, id, |
| 82 ASCIIToUTF16("Test Web Notification"), | 84 ASCIIToUTF16("Test Web Notification"), |
| 83 ASCIIToUTF16("Notification message body."), gfx::Image(), | 85 ASCIIToUTF16("Notification message body."), gfx::Image(), |
| 84 ASCIIToUTF16("www.test.org"), GURL(), notifier_id, | 86 ASCIIToUTF16("www.test.org"), GURL(), notifier_id, |
| 85 message_center::RichNotificationData(), NULL /* delegate */)); | 87 message_center::RichNotificationData(), NULL /* delegate */)); |
| 86 message_center_->AddNotification(notification.Pass()); | 88 message_center_->AddNotification(std::move(notification)); |
| 87 } | 89 } |
| 88 scoped_ptr<MockDelegate> delegate_; | 90 scoped_ptr<MockDelegate> delegate_; |
| 89 scoped_ptr<MessageCenterTray> message_center_tray_; | 91 scoped_ptr<MessageCenterTray> message_center_tray_; |
| 90 MessageCenter* message_center_; | 92 MessageCenter* message_center_; |
| 91 | 93 |
| 92 private: | 94 private: |
| 93 DISALLOW_COPY_AND_ASSIGN(MessageCenterTrayTest); | 95 DISALLOW_COPY_AND_ASSIGN(MessageCenterTrayTest); |
| 94 }; | 96 }; |
| 95 | 97 |
| 96 TEST_F(MessageCenterTrayTest, BasicMessageCenter) { | 98 TEST_F(MessageCenterTrayTest, BasicMessageCenter) { |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 219 ASSERT_FALSE(message_center_tray_->message_center_visible()); | 221 ASSERT_FALSE(message_center_tray_->message_center_visible()); |
| 220 | 222 |
| 221 scoped_ptr<Notification> notification(new Notification( | 223 scoped_ptr<Notification> notification(new Notification( |
| 222 message_center::NOTIFICATION_TYPE_SIMPLE, | 224 message_center::NOTIFICATION_TYPE_SIMPLE, |
| 223 "MessageCenterReopnPopupsForSystemPriority", | 225 "MessageCenterReopnPopupsForSystemPriority", |
| 224 ASCIIToUTF16("Test Web Notification"), | 226 ASCIIToUTF16("Test Web Notification"), |
| 225 ASCIIToUTF16("Notification message body."), gfx::Image(), | 227 ASCIIToUTF16("Notification message body."), gfx::Image(), |
| 226 ASCIIToUTF16("www.test.org"), GURL(), DummyNotifierId(), | 228 ASCIIToUTF16("www.test.org"), GURL(), DummyNotifierId(), |
| 227 message_center::RichNotificationData(), NULL /* delegate */)); | 229 message_center::RichNotificationData(), NULL /* delegate */)); |
| 228 notification->SetSystemPriority(); | 230 notification->SetSystemPriority(); |
| 229 message_center_->AddNotification(notification.Pass()); | 231 message_center_->AddNotification(std::move(notification)); |
| 230 | 232 |
| 231 ASSERT_TRUE(message_center_tray_->popups_visible()); | 233 ASSERT_TRUE(message_center_tray_->popups_visible()); |
| 232 ASSERT_FALSE(message_center_tray_->message_center_visible()); | 234 ASSERT_FALSE(message_center_tray_->message_center_visible()); |
| 233 | 235 |
| 234 bool shown = message_center_tray_->ShowMessageCenterBubble(); | 236 bool shown = message_center_tray_->ShowMessageCenterBubble(); |
| 235 EXPECT_TRUE(shown); | 237 EXPECT_TRUE(shown); |
| 236 | 238 |
| 237 ASSERT_FALSE(message_center_tray_->popups_visible()); | 239 ASSERT_FALSE(message_center_tray_->popups_visible()); |
| 238 ASSERT_TRUE(message_center_tray_->message_center_visible()); | 240 ASSERT_TRUE(message_center_tray_->message_center_visible()); |
| 239 | 241 |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 348 | 350 |
| 349 AddNotification(id1, notifier_id); | 351 AddNotification(id1, notifier_id); |
| 350 | 352 |
| 351 NotifierId notifier_id2(NotifierId::APPLICATION, "sample-app"); | 353 NotifierId notifier_id2(NotifierId::APPLICATION, "sample-app"); |
| 352 scoped_ptr<Notification> notification(new Notification( | 354 scoped_ptr<Notification> notification(new Notification( |
| 353 message_center::NOTIFICATION_TYPE_SIMPLE, id2, | 355 message_center::NOTIFICATION_TYPE_SIMPLE, id2, |
| 354 ASCIIToUTF16("Test Web Notification"), | 356 ASCIIToUTF16("Test Web Notification"), |
| 355 ASCIIToUTF16("Notification message body."), gfx::Image(), | 357 ASCIIToUTF16("Notification message body."), gfx::Image(), |
| 356 base::string16() /* empty display source */, GURL(), notifier_id2, | 358 base::string16() /* empty display source */, GURL(), notifier_id2, |
| 357 message_center::RichNotificationData(), NULL /* delegate */)); | 359 message_center::RichNotificationData(), NULL /* delegate */)); |
| 358 message_center_->AddNotification(notification.Pass()); | 360 message_center_->AddNotification(std::move(notification)); |
| 359 | 361 |
| 360 AddNotification(id3, notifier_id); | 362 AddNotification(id3, notifier_id); |
| 361 | 363 |
| 362 // The dummy notifier is SYSTEM_COMPONENT so no context menu is visible. | 364 // The dummy notifier is SYSTEM_COMPONENT so no context menu is visible. |
| 363 scoped_ptr<ui::MenuModel> model( | 365 scoped_ptr<ui::MenuModel> model( |
| 364 message_center_tray_->CreateNotificationMenuModel(DummyNotifierId(), | 366 message_center_tray_->CreateNotificationMenuModel(DummyNotifierId(), |
| 365 display_source)); | 367 display_source)); |
| 366 EXPECT_EQ(nullptr, model.get()); | 368 EXPECT_EQ(nullptr, model.get()); |
| 367 | 369 |
| 368 model = message_center_tray_->CreateNotificationMenuModel(notifier_id, | 370 model = message_center_tray_->CreateNotificationMenuModel(notifier_id, |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 407 EXPECT_EQ(1, model->GetItemCount()); | 409 EXPECT_EQ(1, model->GetItemCount()); |
| 408 #else | 410 #else |
| 409 EXPECT_EQ(2, model->GetItemCount()); | 411 EXPECT_EQ(2, model->GetItemCount()); |
| 410 EXPECT_FALSE(model->IsEnabledAt(1)); | 412 EXPECT_FALSE(model->IsEnabledAt(1)); |
| 411 #endif | 413 #endif |
| 412 | 414 |
| 413 EXPECT_FALSE(model->IsEnabledAt(0)); | 415 EXPECT_FALSE(model->IsEnabledAt(0)); |
| 414 } | 416 } |
| 415 | 417 |
| 416 } // namespace message_center | 418 } // namespace message_center |
| OLD | NEW |