diff options
author | yoshiki <yoshiki@chromium.org> | 2015-10-28 18:05:14 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-10-29 01:05:54 +0000 |
commit | 2f1533a6dca1fa0a0be4f550363f4df64df0e29b (patch) | |
tree | 261aa48d6ea3cab1cd15fa0902c9a540c4a6da36 | |
parent | 7de7140fee31af3b23cf445ffda771f820bd1708 (diff) | |
download | chromium_src-2f1533a6dca1fa0a0be4f550363f4df64df0e29b.zip chromium_src-2f1533a6dca1fa0a0be4f550363f4df64df0e29b.tar.gz chromium_src-2f1533a6dca1fa0a0be4f550363f4df64df0e29b.tar.bz2 |
[Download Notification] Add a test to check updates of notification
This patch adds the check if the notification is updated correctly after the download data is updated.
In other words, this patch tests the following fix.
https://crrev.com/795243b38d321e1e9d1f32d814265461194d74b0
BUG=541633
TEST=trybot passes
Review URL: https://codereview.chromium.org/1396883003
Cr-Commit-Position: refs/heads/master@{#356715}
-rw-r--r-- | chrome/browser/download/notification/download_item_notification_unittest.cc | 10 | ||||
-rw-r--r-- | chrome/browser/notifications/notification_test_util.cc | 16 |
2 files changed, 26 insertions, 0 deletions
diff --git a/chrome/browser/download/notification/download_item_notification_unittest.cc b/chrome/browser/download/notification/download_item_notification_unittest.cc index 30a497b..e664891 100644 --- a/chrome/browser/download/notification/download_item_notification_unittest.cc +++ b/chrome/browser/download/notification/download_item_notification_unittest.cc @@ -284,7 +284,17 @@ TEST_F(DownloadItemNotificationTest, DisablePopup) { EXPECT_EQ(message_center::DEFAULT_PRIORITY, notification()->priority()); download_item_notification_->DisablePopup(); + // Priority is low. EXPECT_EQ(message_center::LOW_PRIORITY, notification()->priority()); + + // Downloading is completed. + EXPECT_CALL(*download_item_, GetState()) + .WillRepeatedly(Return(content::DownloadItem::COMPLETE)); + EXPECT_CALL(*download_item_, IsDone()).WillRepeatedly(Return(true)); + download_item_->NotifyObserversDownloadUpdated(); + + // Priority is updated back to normal. + EXPECT_EQ(message_center::DEFAULT_PRIORITY, notification()->priority()); } } // namespace test diff --git a/chrome/browser/notifications/notification_test_util.cc b/chrome/browser/notifications/notification_test_util.cc index e5a5670..41cf521 100644 --- a/chrome/browser/notifications/notification_test_util.cc +++ b/chrome/browser/notifications/notification_test_util.cc @@ -48,6 +48,22 @@ void StubNotificationUIManager::Add(const Notification& notification, bool StubNotificationUIManager::Update(const Notification& notification, Profile* profile) { + const ProfileID profile_id = NotificationUIManager::GetProfileID(profile); + if (notification.tag().empty()) + return false; + + auto iter = notifications_.begin(); + for (; iter != notifications_.end(); ++iter) { + const Notification& old_notification = iter->first; + if (old_notification.tag() == notification.tag() && + old_notification.origin_url() == notification.origin_url() && + iter->second == profile_id) { + notifications_.erase(iter); + notifications_.push_back(std::make_pair(notification, profile_id)); + return true; + } + } + return false; } |