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

Unified Diff: content/public/test/mock_download_item.h

Issue 248713004: [Downloads] Add real observers to MockDownloadItem. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Merge with r268551 Created 6 years, 7 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: content/public/test/mock_download_item.h
diff --git a/content/public/test/mock_download_item.h b/content/public/test/mock_download_item.h
index 6a365f52b432a719fff97fe11cb880040b7bf0ef..d9e390817f6dc8fc9be377ed83128e2eb4586ba3 100644
--- a/content/public/test/mock_download_item.h
+++ b/content/public/test/mock_download_item.h
@@ -6,6 +6,7 @@
#define CONTENT_PUBLIC_TEST_MOCK_DOWNLOAD_ITEM_H_
#include "base/callback.h"
+#include "base/observer_list.h"
#include "base/time/time.h"
#include "content/public/browser/download_interrupt_reasons.h"
#include "content/public/browser/download_item.h"
@@ -19,8 +20,20 @@ class MockDownloadItem : public DownloadItem {
public:
MockDownloadItem();
virtual ~MockDownloadItem();
- MOCK_METHOD1(AddObserver, void(DownloadItem::Observer*));
- MOCK_METHOD1(RemoveObserver, void(DownloadItem::Observer*));
+
+ // Management of observer lists is common in tests. So Add/RemoveObserver
+ // methods are not mocks. In addition, any registered observers will receive a
+ // OnDownloadDestroyed() notification when the mock is destroyed.
+ virtual void AddObserver(Observer* observer) OVERRIDE;
+ virtual void RemoveObserver(Observer* observer) OVERRIDE;
+
+ // Dispatches an OnDownloadOpened() notification to observers.
+ void NotifyObserversDownloadOpened();
+ // Dispatches an OnDownloadRemoved() notification to observers.
+ void NotifyObserversDownloadRemoved();
+ // Dispatches an OnDownloadUpdated() notification to observers.
+ void NotifyObserversDownloadUpdated();
+
MOCK_METHOD0(UpdateObservers, void());
MOCK_METHOD0(ValidateDangerousDownload, void());
MOCK_METHOD1(StealDangerousDownload, void(const AcquireFileCallback&));
@@ -87,6 +100,9 @@ class MockDownloadItem : public DownloadItem {
MOCK_METHOD1(SetOpened, void(bool));
MOCK_METHOD1(SetDisplayName, void(const base::FilePath&));
MOCK_CONST_METHOD1(DebugString, std::string(bool));
+
+ private:
+ ObserverList<Observer> observers_;
};
} // namespace content
« no previous file with comments | « chrome/browser/safe_browsing/download_protection_service_unittest.cc ('k') | content/public/test/mock_download_item.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698