| Index: chrome/browser/notifications/notification_test_util.cc
|
| diff --git a/chrome/browser/notifications/notification_test_util.cc b/chrome/browser/notifications/notification_test_util.cc
|
| index 41cf5217a7bf368cd1f88332f5d62c1b9684bf31..98df721147a5d881bdd93e341ce35c2f51efe112 100644
|
| --- a/chrome/browser/notifications/notification_test_util.cc
|
| +++ b/chrome/browser/notifications/notification_test_util.cc
|
| @@ -4,6 +4,10 @@
|
|
|
| #include "chrome/browser/notifications/notification_test_util.h"
|
|
|
| +#include "base/strings/utf_string_conversions.h"
|
| +#include "third_party/skia/include/core/SkBitmap.h"
|
| +#include "url/gurl.h"
|
| +
|
| MockNotificationDelegate::MockNotificationDelegate(const std::string& id)
|
| : id_(id) {}
|
|
|
| @@ -135,3 +139,62 @@ void StubNotificationUIManager::CancelAll() {
|
| pair.first.delegate()->Close(false /* by_user */);
|
| notifications_.clear();
|
| }
|
| +
|
| +std::unique_ptr<Notification> NotificationGenerator::CreateNotification(
|
| + message_center::NotificationType type) {
|
| + return NotificationGenerator::CreateNotification(
|
| + "Title", "This is a message.", "I am a context message.", "Button 1",
|
| + "Button 2", type);
|
| +}
|
| +
|
| +// static
|
| +std::unique_ptr<Notification> NotificationGenerator::CreateNotification(
|
| + const std::string& title,
|
| + const std::string& subtitle,
|
| + const std::string& context,
|
| + const std::string& button1,
|
| + const std::string& button2,
|
| + message_center::NotificationType type) {
|
| + message_center::RichNotificationData optional_fields;
|
| + optional_fields.priority = 1;
|
| + optional_fields.context_message = base::UTF8ToUTF16(context);
|
| + optional_fields.timestamp = base::Time::FromDoubleT(12345678.9);
|
| + if (!button1.empty()) {
|
| + optional_fields.buttons.push_back(
|
| + message_center::ButtonInfo(base::UTF8ToUTF16(button1)));
|
| + if (!button2.empty()) {
|
| + optional_fields.buttons.push_back(
|
| + message_center::ButtonInfo(base::UTF8ToUTF16(button2)));
|
| + }
|
| + }
|
| + optional_fields.clickable = false;
|
| +
|
| + if (type == message_center::NOTIFICATION_TYPE_IMAGE)
|
| + optional_fields.image = gfx::Image();
|
| + if (type == message_center::NOTIFICATION_TYPE_MULTIPLE) {
|
| + optional_fields.items.push_back(
|
| + message_center::NotificationItem(base::UTF8ToUTF16("Item 1 Title"),
|
| + base::UTF8ToUTF16("Item 1 Message")));
|
| + optional_fields.items.push_back(
|
| + message_center::NotificationItem(base::UTF8ToUTF16("Item 2 Title"),
|
| + base::UTF8ToUTF16("Item 2 Message")));
|
| + }
|
| + if (type == message_center::NOTIFICATION_TYPE_PROGRESS)
|
| + optional_fields.progress = 50;
|
| +
|
| + NotificationDelegate* delegate(new MockNotificationDelegate("id1"));
|
| +
|
| + SkBitmap bitmap;
|
| + bitmap.allocN32Pixels(1, 1);
|
| + bitmap.eraseColor(SkColorSetRGB(1, 2, 3));
|
| + gfx::Image icon = gfx::Image::CreateFrom1xBitmap(bitmap);
|
| +
|
| + std::unique_ptr<Notification> notification(new Notification(
|
| + type, base::UTF8ToUTF16(title), base::UTF8ToUTF16(subtitle), icon,
|
| + message_center::NotifierId(message_center::NotifierId::APPLICATION,
|
| + "Notifier 1"),
|
| + base::UTF8ToUTF16("Notifier's Name"), GURL(), "id1", optional_fields,
|
| + delegate));
|
| +
|
| + return notification;
|
| +}
|
|
|