Index: chrome/browser/notifications/sync_notifier/synced_notification_unittest.cc |
diff --git a/chrome/browser/notifications/sync_notifier/synced_notification_unittest.cc b/chrome/browser/notifications/sync_notifier/synced_notification_unittest.cc |
index 6dd09901ac92eed4877747b91443e6e759cedfe7..ca3d9f49eff88833b26a13659c683c3f71328f5e 100644 |
--- a/chrome/browser/notifications/sync_notifier/synced_notification_unittest.cc |
+++ b/chrome/browser/notifications/sync_notifier/synced_notification_unittest.cc |
@@ -153,7 +153,6 @@ TEST_F(SyncedNotificationTest, GetImageURLTest) { |
EXPECT_EQ(expected_image_url, found_image_url); |
} |
-// TODO(petewil): test with a multi-line message |
TEST_F(SyncedNotificationTest, GetTextTest) { |
std::string found_text = notification1_->GetText(); |
std::string expected_text(kText1); |
@@ -349,7 +348,7 @@ TEST_F(SyncedNotificationTest, OnFetchCompleteTest) { |
// image, notification1_->GetAppIconBitmap())); |
} |
- |
+// TODO(petewil): Empty bitmap should count as a successful fetch. |
TEST_F(SyncedNotificationTest, EmptyBitmapTest) { |
if (!UseRichNotifications()) |
return; |
@@ -399,6 +398,53 @@ TEST_F(SyncedNotificationTest, EmptyBitmapTest) { |
base::UTF16ToUTF8(notification_manager()->notification().message())); |
} |
+TEST_F(SyncedNotificationTest, ShowIfNewlyEnabledTest) { |
+ if (!UseRichNotifications()) |
+ return; |
+ |
+ // Call the method using the wrong app id, nothing should get shown. |
+ notification1_->ShowIfNewlyEnabled( |
+ notification_manager(), NULL, NULL, kAppId2); |
+ |
+ // Ensure no notification was generated and shown. |
+ const Notification notification1 = notification_manager()->notification(); |
+ EXPECT_EQ(std::string(), base::UTF16ToUTF8(notification1.replace_id())); |
+ |
+ // Call the method under test using the pre-populated data. |
+ notification1_->ShowIfNewlyEnabled( |
+ notification_manager(), NULL, NULL, kAppId1); |
+ |
+ const Notification notification2 = notification_manager()->notification(); |
+ |
+ // Check the base fields of the notification. |
+ EXPECT_EQ(message_center::NOTIFICATION_TYPE_IMAGE, notification2.type()); |
+ EXPECT_EQ(std::string(kTitle1), base::UTF16ToUTF8(notification2.title())); |
+ EXPECT_EQ(std::string(kText1), base::UTF16ToUTF8(notification2.message())); |
+ EXPECT_EQ(std::string(kExpectedOriginUrl), notification2.origin_url().spec()); |
+ EXPECT_EQ(std::string(kKey1), base::UTF16ToUTF8(notification2.replace_id())); |
+ |
+ EXPECT_EQ(kFakeCreationTime, notification2.timestamp().ToDoubleT()); |
+ EXPECT_EQ(kNotificationPriority, notification2.priority()); |
+} |
+ |
+TEST_F(SyncedNotificationTest, HideIfNewlyRemovedTest) { |
+ if (!UseRichNotifications()) |
+ return; |
+ |
+ // Add the notification to the notification manger, so it exists before we |
+ // we remove it. |
+ notification1_->Show(notification_manager(), NULL, NULL); |
+ const Notification* found1 = notification_manager()->FindById(kKey1); |
+ EXPECT_NE(reinterpret_cast<Notification*>(NULL), found1); |
+ |
+ // Call the method under test using the pre-populated data. |
+ notification1_->HideIfNewlyRemoved( |
+ notification_manager(), NULL, NULL, kAppId1); |
+ |
+ // Ensure the notification was removed from the notification manager |
+ EXPECT_EQ(std::string(kKey1), notification_manager()->dismissed_id()); |
+} |
+ |
// TODO(petewil): Add a test for a notification being read and or deleted. |
} // namespace notifier |