Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3288)

Unified Diff: chrome/browser/download/notification/download_item_notification_unittest.cc

Issue 1389273004: Update first download notification correctly if there are multiple notifications (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/download/notification/download_item_notification_unittest.cc
diff --git a/chrome/browser/download/notification/download_item_notification_unittest.cc b/chrome/browser/download/notification/download_item_notification_unittest.cc
index 52c885a2f79cf125015d45e8a322af5e2707e1ef..30a497b0e52eaeafa06f51ac066e66b3c85ece9e 100644
--- a/chrome/browser/download/notification/download_item_notification_unittest.cc
+++ b/chrome/browser/download/notification/download_item_notification_unittest.cc
@@ -35,6 +35,26 @@ const base::FilePath::CharType kDownloadItemTargetPathString[] =
namespace test {
+class MockMessageCenter : public message_center::FakeMessageCenter {
+ public:
+ MockMessageCenter() {}
+ ~MockMessageCenter() override {}
+
+ void AddVisibleNotification(message_center::Notification* notification) {
+ visible_notifications_.insert(notification);
+ }
+
+ const message_center::NotificationList::Notifications&
+ GetVisibleNotifications() override {
+ return visible_notifications_;
+ }
+
+ private:
+ message_center::NotificationList::Notifications visible_notifications_;
+
+ DISALLOW_COPY_AND_ASSIGN(MockMessageCenter);
+};
+
class DownloadItemNotificationTest : public testing::Test {
public:
DownloadItemNotificationTest()
@@ -57,6 +77,10 @@ class DownloadItemNotificationTest : public testing::Test {
download_notification_manager_.reset(
new DownloadNotificationManagerForProfile(profile_, nullptr));
+ message_center_.reset(new MockMessageCenter());
+ download_notification_manager_->OverrideMessageCenterForTest(
+ message_center_.get());
+
base::FilePath download_item_target_path(kDownloadItemTargetPathString);
download_item_.reset(new NiceMock<content::MockDownloadItem>());
ON_CALL(*download_item_, GetId()).WillByDefault(Return(12345));
@@ -135,6 +159,8 @@ class DownloadItemNotificationTest : public testing::Test {
download_notification_manager_->OnNewDownloadReady(download_item_.get());
download_item_notification_ =
download_notification_manager_->items_[download_item_.get()];
+ message_center_->AddVisibleNotification(
+ download_item_notification_->notification_.get());
}
base::MessageLoopForUI message_loop_;
@@ -146,6 +172,7 @@ class DownloadItemNotificationTest : public testing::Test {
scoped_ptr<NiceMock<content::MockDownloadItem>> download_item_;
scoped_ptr<DownloadNotificationManagerForProfile>
download_notification_manager_;
+ scoped_ptr<MockMessageCenter> message_center_;
DownloadItemNotification* download_item_notification_;
};

Powered by Google App Engine
This is Rietveld 408576698