| 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..d34a83e1631a08c10cd01f6e7f623b4bb50c823a 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);
|
| @@ -257,7 +256,8 @@ TEST_F(SyncedNotificationTest, ShowTest) {
|
| return;
|
|
|
| // Call the method under test using the pre-populated data.
|
| - notification1_->Show(notification_manager(), NULL, NULL);
|
| + notification1_->set_notification_manager(notification_manager());
|
| + notification1_->Show(NULL);
|
|
|
| const Notification notification = notification_manager()->notification();
|
|
|
| @@ -277,24 +277,25 @@ TEST_F(SyncedNotificationTest, DismissTest) {
|
| if (!UseRichNotifications())
|
| return;
|
|
|
| + notification4_->set_notification_manager(notification_manager());
|
| // Call the method under test using a dismissed notification.
|
| - notification4_->Show(notification_manager(), NULL, NULL);
|
| + notification4_->Show(NULL);
|
|
|
| EXPECT_EQ(std::string(kKey1), notification_manager()->dismissed_id());
|
| }
|
|
|
| -TEST_F(SyncedNotificationTest, AddBitmapToFetchQueueTest) {
|
| +TEST_F(SyncedNotificationTest, CreateBitmapFetcherTest) {
|
| scoped_ptr<SyncedNotification> notification6;
|
| notification6.reset(new SyncedNotification(sync_data1_));
|
|
|
| // Add two bitmaps to the queue.
|
| - notification6->AddBitmapToFetchQueue(GURL(kIconUrl1));
|
| - notification6->AddBitmapToFetchQueue(GURL(kIconUrl2));
|
| + notification6->CreateBitmapFetcher(GURL(kIconUrl1));
|
| + notification6->CreateBitmapFetcher(GURL(kIconUrl2));
|
|
|
| EXPECT_EQ(GURL(kIconUrl1), notification6->fetchers_[0]->url());
|
| EXPECT_EQ(GURL(kIconUrl2), notification6->fetchers_[1]->url());
|
|
|
| - notification6->AddBitmapToFetchQueue(GURL(kIconUrl2));
|
| + notification6->CreateBitmapFetcher(GURL(kIconUrl2));
|
| }
|
|
|
| TEST_F(SyncedNotificationTest, OnFetchCompleteTest) {
|
| @@ -305,10 +306,10 @@ TEST_F(SyncedNotificationTest, OnFetchCompleteTest) {
|
| notification1_->notification_manager_ = notification_manager();
|
|
|
| // Add the bitmaps to the queue for us to match up.
|
| - notification1_->AddBitmapToFetchQueue(GURL(kIconUrl1));
|
| - notification1_->AddBitmapToFetchQueue(GURL(kImageUrl1));
|
| - notification1_->AddBitmapToFetchQueue(GURL(kButtonOneIconUrl));
|
| - notification1_->AddBitmapToFetchQueue(GURL(kButtonTwoIconUrl));
|
| + notification1_->CreateBitmapFetcher(GURL(kIconUrl1));
|
| + notification1_->CreateBitmapFetcher(GURL(kImageUrl1));
|
| + notification1_->CreateBitmapFetcher(GURL(kButtonOneIconUrl));
|
| + notification1_->CreateBitmapFetcher(GURL(kButtonTwoIconUrl));
|
|
|
| // Put some realistic looking bitmap data into the url_fetcher.
|
| SkBitmap bitmap;
|
| @@ -349,7 +350,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;
|
| @@ -358,10 +359,10 @@ TEST_F(SyncedNotificationTest, EmptyBitmapTest) {
|
| notification1_->notification_manager_ = notification_manager();
|
|
|
| // Add the bitmaps to the queue for us to match up.
|
| - notification1_->AddBitmapToFetchQueue(GURL(kIconUrl1));
|
| - notification1_->AddBitmapToFetchQueue(GURL(kImageUrl1));
|
| - notification1_->AddBitmapToFetchQueue(GURL(kButtonOneIconUrl));
|
| - notification1_->AddBitmapToFetchQueue(GURL(kButtonTwoIconUrl));
|
| + notification1_->CreateBitmapFetcher(GURL(kIconUrl1));
|
| + notification1_->CreateBitmapFetcher(GURL(kImageUrl1));
|
| + notification1_->CreateBitmapFetcher(GURL(kButtonOneIconUrl));
|
| + notification1_->CreateBitmapFetcher(GURL(kButtonTwoIconUrl));
|
|
|
| // Put some realistic looking bitmap data into the url_fetcher.
|
| SkBitmap bitmap;
|
| @@ -399,6 +400,53 @@ TEST_F(SyncedNotificationTest, EmptyBitmapTest) {
|
| base::UTF16ToUTF8(notification_manager()->notification().message()));
|
| }
|
|
|
| +TEST_F(SyncedNotificationTest, ShowIfNewlyEnabledTest) {
|
| + if (!UseRichNotifications())
|
| + return;
|
| +
|
| + notification1_->set_notification_manager(notification_manager());
|
| +
|
| + // Call the method using the wrong app id, nothing should get shown.
|
| + notification1_->ShowAllForAppId(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_->ShowAllForAppId(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_->set_notification_manager(notification_manager());
|
| + notification1_->Show(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_->HideAllForAppId(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
|
|
|