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

Unified Diff: content/browser/download/download_item_impl_unittest.cc

Issue 10837125: Revert 149794 - DownloadItem::Observer::OnDownloadDestroyed() replaces DownloadItem::REMOVING (Closed) Base URL: svn://svn.chromium.org/chrome/branches/1228/src/
Patch Set: Created 8 years, 4 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
« no previous file with comments | « content/browser/download/download_item_impl.cc ('k') | content/browser/download/download_manager_impl.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/browser/download/download_item_impl_unittest.cc
===================================================================
--- content/browser/download/download_item_impl_unittest.cc (revision 150095)
+++ content/browser/download/download_item_impl_unittest.cc (working copy)
@@ -131,43 +131,17 @@
public:
class MockObserver : public DownloadItem::Observer {
public:
- explicit MockObserver(DownloadItem* item)
- : item_(item),
- removed_(false),
- destroyed_(false),
- updated_(false) {
+ explicit MockObserver(DownloadItem* item) : item_(item), updated_(false) {
item_->AddObserver(this);
}
+ ~MockObserver() { item_->RemoveObserver(this); }
- virtual ~MockObserver() {
- if (item_) item_->RemoveObserver(this);
- }
-
- virtual void OnDownloadRemoved(DownloadItem* download) {
- removed_ = true;
- }
-
virtual void OnDownloadUpdated(DownloadItem* download) {
updated_ = true;
}
- virtual void OnDownloadOpened(DownloadItem* download) {
- }
+ virtual void OnDownloadOpened(DownloadItem* download) { }
- virtual void OnDownloadDestroyed(DownloadItem* download) {
- destroyed_ = true;
- item_->RemoveObserver(this);
- item_ = NULL;
- }
-
- bool CheckRemoved() {
- return removed_;
- }
-
- bool CheckDestroyed() {
- return destroyed_;
- }
-
bool CheckUpdated() {
bool was_updated = updated_;
updated_ = false;
@@ -176,8 +150,6 @@
private:
DownloadItem* item_;
- bool removed_;
- bool destroyed_;
bool updated_;
};
@@ -330,21 +302,12 @@
ASSERT_TRUE(observer.CheckUpdated());
}
-TEST_F(DownloadItemTest, NotificationAfterDestroyed) {
- DownloadItemImpl* item = CreateDownloadItem(DownloadItem::IN_PROGRESS);
- MockObserver observer(item);
-
- DestroyDownloadItem(item);
- ASSERT_TRUE(observer.CheckDestroyed());
-}
-
TEST_F(DownloadItemTest, NotificationAfterRemove) {
DownloadItemImpl* item = CreateDownloadItem(DownloadItem::IN_PROGRESS);
MockObserver observer(item);
item->Remove();
ASSERT_TRUE(observer.CheckUpdated());
- ASSERT_TRUE(observer.CheckRemoved());
}
TEST_F(DownloadItemTest, NotificationAfterOnContentCheckCompleted) {
« no previous file with comments | « content/browser/download/download_item_impl.cc ('k') | content/browser/download/download_manager_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698