Index: content/browser/download/download_manager_impl_unittest.cc |
diff --git a/content/browser/download/download_manager_impl_unittest.cc b/content/browser/download/download_manager_impl_unittest.cc |
index 56bd819408e8a3f904cc450caaf4356aecedcd02..a4a0d365f873838fcd1d4ed1f61852088744f572 100644 |
--- a/content/browser/download/download_manager_impl_unittest.cc |
+++ b/content/browser/download/download_manager_impl_unittest.cc |
@@ -59,9 +59,19 @@ class MockDownloadItemImpl : public DownloadItemImpl { |
public: |
// Use history constructor for minimal base object. |
MockDownloadItemImpl(DownloadItemImplDelegate* delegate) |
- : DownloadItemImpl(delegate, content::DownloadId(), |
- content::DownloadPersistentStoreInfo(), |
- net::BoundNetLog()) {} |
+ : DownloadItemImpl( |
+ delegate, |
+ content::DownloadId(), |
+ FilePath(), |
+ GURL(), |
+ GURL(), |
+ base::Time(), |
+ base::Time(), |
+ 0, |
+ 0, |
+ DownloadItem::IN_PROGRESS, |
+ false, |
+ net::BoundNetLog()) {} |
virtual ~MockDownloadItemImpl() {} |
MOCK_METHOD4(OnDownloadTargetDetermined, |
@@ -122,10 +132,6 @@ class MockDownloadItemImpl : public DownloadItemImpl { |
MOCK_CONST_METHOD0(GetGlobalId, content::DownloadId()); |
MOCK_CONST_METHOD0(GetStartTime, base::Time()); |
MOCK_CONST_METHOD0(GetEndTime, base::Time()); |
- MOCK_METHOD0(SetIsPersisted, void()); |
- MOCK_CONST_METHOD0(IsPersisted, bool()); |
- MOCK_METHOD1(SetDbHandle, void(int64)); |
- MOCK_CONST_METHOD0(GetDbHandle, int64()); |
MOCK_METHOD0(GetDownloadManager, content::DownloadManager*()); |
MOCK_CONST_METHOD0(IsPaused, bool()); |
MOCK_CONST_METHOD0(GetOpenWhenComplete, bool()); |
@@ -146,8 +152,6 @@ class MockDownloadItemImpl : public DownloadItemImpl { |
MOCK_CONST_METHOD0(GetLastModifiedTime, const std::string&()); |
MOCK_CONST_METHOD0(GetETag, const std::string&()); |
MOCK_CONST_METHOD0(GetLastReason, DownloadInterruptReason()); |
- MOCK_CONST_METHOD0(GetPersistentStoreInfo, |
- content::DownloadPersistentStoreInfo()); |
MOCK_CONST_METHOD0(GetBrowserContext, content::BrowserContext*()); |
MOCK_CONST_METHOD0(GetWebContents, content::WebContents*()); |
MOCK_CONST_METHOD0(GetFileNameToReportUser, FilePath()); |
@@ -174,13 +178,6 @@ class MockDownloadManagerDelegate : public content::DownloadManagerDelegate { |
DownloadItem*, const base::Closure&)); |
MOCK_METHOD1(ShouldOpenDownload, bool(DownloadItem*)); |
MOCK_METHOD0(GenerateFileHash, bool()); |
- MOCK_METHOD1(AddItemToPersistentStore, void(DownloadItem*)); |
- MOCK_METHOD1(UpdateItemInPersistentStore, void(DownloadItem*)); |
- MOCK_METHOD2(UpdatePathForItemInPersistentStore, |
- void(DownloadItem*, const FilePath&)); |
- MOCK_METHOD1(RemoveItemFromPersistentStore, void(DownloadItem*)); |
- MOCK_METHOD2(RemoveItemsFromPersistentStoreBetween, void( |
- base::Time remove_begin, base::Time remove_end)); |
MOCK_METHOD4(GetSaveDir, void(WebContents*, FilePath*, FilePath*, bool*)); |
MOCK_METHOD5(ChooseSavePath, void( |
WebContents*, const FilePath&, const FilePath::StringType&, |
@@ -263,7 +260,15 @@ class MockDownloadItemFactory |
virtual DownloadItemImpl* CreatePersistedItem( |
DownloadItemImplDelegate* delegate, |
content::DownloadId download_id, |
- const content::DownloadPersistentStoreInfo& info, |
+ const FilePath& path, |
+ const GURL& url, |
+ const GURL& referrer_url, |
+ const base::Time& start_time, |
+ const base::Time& end_time, |
+ int64 received_bytes, |
+ int64 total_bytes, |
+ DownloadItem::DownloadState state, |
+ bool opened, |
const net::BoundNetLog& bound_net_log) OVERRIDE; |
virtual DownloadItemImpl* CreateActiveItem( |
DownloadItemImplDelegate* delegate, |
@@ -314,7 +319,15 @@ void MockDownloadItemFactory::RemoveItem(int id) { |
DownloadItemImpl* MockDownloadItemFactory::CreatePersistedItem( |
DownloadItemImplDelegate* delegate, |
content::DownloadId download_id, |
- const content::DownloadPersistentStoreInfo& info, |
+ const FilePath& path, |
+ const GURL& url, |
+ const GURL& referrer_url, |
+ const base::Time& start_time, |
+ const base::Time& end_time, |
+ int64 received_bytes, |
+ int64 total_bytes, |
+ DownloadItem::DownloadState state, |
+ bool opened, |
const net::BoundNetLog& bound_net_log) { |
int local_id = download_id.local(); |
DCHECK(items_.find(local_id) == items_.end()); |
@@ -518,35 +531,6 @@ class DownloadManagerTest : public testing::Test { |
download_manager_->DownloadStopped(item); |
} |
- void AddItemToHistory(MockDownloadItemImpl& item, int64 db_handle) { |
- // For DCHECK in AddDownloadItemToHistory. Don't want to use |
- // WillRepeatedly as it may have to return true after this. |
- if (DCHECK_IS_ON()) |
- EXPECT_CALL(item, IsPersisted()) |
- .WillRepeatedly(Return(false)); |
- |
- EXPECT_CALL(item, SetDbHandle(db_handle)); |
- EXPECT_CALL(item, SetIsPersisted()); |
- EXPECT_CALL(item, GetDbHandle()) |
- .WillRepeatedly(Return(db_handle)); |
- |
- // Null out ShowDownloadInBrowser |
- EXPECT_CALL(item, GetWebContents()) |
- .WillOnce(Return(static_cast<WebContents*>(NULL))); |
- EXPECT_CALL(GetMockDownloadManagerDelegate(), |
- GetAlternativeWebContentsToNotifyForDownload()) |
- .WillOnce(Return(static_cast<WebContents*>(NULL))); |
- |
- EXPECT_CALL(item, IsInProgress()) |
- .WillOnce(Return(true)); |
- |
- // Null out MaybeCompleteDownload |
- EXPECT_CALL(item, AllDataSaved()) |
- .WillOnce(Return(false)); |
- |
- download_manager_->OnItemAddedToPersistentStore(item.GetId(), db_handle); |
- } |
- |
protected: |
// Key test variable; we'll keep it available to sub-classes. |
scoped_refptr<DownloadManagerImpl> download_manager_; |
@@ -605,19 +589,14 @@ TEST_F(DownloadManagerTest, OnDownloadInterrupted) { |
} |
// Does DownloadStopped remove Download from appropriate queues? |
-// This test tests non-persisted downloads. |
-TEST_F(DownloadManagerTest, OnDownloadStopped_NonPersisted) { |
+TEST_F(DownloadManagerTest, OnDownloadStopped) { |
EXPECT_CALL(GetMockObserver(), OnDownloadCreated(download_manager_.get(), _)) |
.WillOnce(Return()); |
// Put a mock we have a handle to on the download manager. |
MockDownloadItemImpl& item(AddItemToManager()); |
- EXPECT_CALL(item, IsPersisted()) |
- .WillRepeatedly(Return(false)); |
EXPECT_CALL(item, GetState()) |
.WillRepeatedly(Return(DownloadItem::CANCELLED)); |
- EXPECT_CALL(item, GetDbHandle()) |
- .WillRepeatedly(Return(DownloadItem::kUninitializedHandle)); |
EXPECT_CALL(item, OffThreadCancel()); |
DownloadStopped(&item); |
@@ -626,30 +605,3 @@ TEST_F(DownloadManagerTest, OnDownloadStopped_NonPersisted) { |
// Currently, the item is left on the active list for rendez-vous with |
// the history system :-{. |
} |
- |
-// Does DownloadStopped remove Download from appropriate queues? |
-// This test tests persisted downloads. |
-TEST_F(DownloadManagerTest, OnDownloadStopped_Persisted) { |
- EXPECT_CALL(GetMockObserver(), OnDownloadCreated(download_manager_.get(), _)) |
- .WillOnce(Return()); |
- // Put a mock we have a handle to on the download manager. |
- MockDownloadItemImpl& item(AddItemToManager()); |
- int download_id = item.GetId(); |
- int64 db_handle = 0x7; |
- EXPECT_CALL(GetMockObserver(), ModelChanged(download_manager_.get())) |
- .WillOnce(Return()); |
- AddItemToHistory(item, db_handle); |
- |
- EXPECT_CALL(item, IsPersisted()) |
- .WillRepeatedly(Return(true)); |
- EXPECT_CALL(GetMockDownloadManagerDelegate(), |
- UpdateItemInPersistentStore(&item)); |
- EXPECT_CALL(item, GetState()) |
- .WillRepeatedly(Return(DownloadItem::CANCELLED)); |
- EXPECT_CALL(item, GetDbHandle()) |
- .WillRepeatedly(Return(db_handle)); |
- |
- EXPECT_CALL(item, OffThreadCancel()); |
- DownloadStopped(&item); |
- EXPECT_EQ(NULL, download_manager_->GetActiveDownloadItem(download_id)); |
-} |