OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include <set> | 5 #include <set> |
6 #include <string> | 6 #include <string> |
7 | 7 |
8 #include "base/bind.h" | 8 #include "base/bind.h" |
9 #include "base/file_util.h" | 9 #include "base/file_util.h" |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
52 namespace content { | 52 namespace content { |
53 class ByteStreamReader; | 53 class ByteStreamReader; |
54 } | 54 } |
55 | 55 |
56 namespace { | 56 namespace { |
57 | 57 |
58 class MockDownloadItemImpl : public DownloadItemImpl { | 58 class MockDownloadItemImpl : public DownloadItemImpl { |
59 public: | 59 public: |
60 // Use history constructor for minimal base object. | 60 // Use history constructor for minimal base object. |
61 MockDownloadItemImpl(DownloadItemImplDelegate* delegate) | 61 MockDownloadItemImpl(DownloadItemImplDelegate* delegate) |
62 : DownloadItemImpl(delegate, content::DownloadId(), | 62 : DownloadItemImpl( |
63 content::DownloadPersistentStoreInfo(), | 63 delegate, |
64 net::BoundNetLog()) {} | 64 content::DownloadId(), |
| 65 FilePath(), |
| 66 GURL(), |
| 67 GURL(), |
| 68 base::Time(), |
| 69 base::Time(), |
| 70 0, |
| 71 0, |
| 72 DownloadItem::IN_PROGRESS, |
| 73 false, |
| 74 net::BoundNetLog()) {} |
65 virtual ~MockDownloadItemImpl() {} | 75 virtual ~MockDownloadItemImpl() {} |
66 | 76 |
67 MOCK_METHOD4(OnDownloadTargetDetermined, | 77 MOCK_METHOD4(OnDownloadTargetDetermined, |
68 void(const FilePath&, TargetDisposition, | 78 void(const FilePath&, TargetDisposition, |
69 content::DownloadDangerType, const FilePath&)); | 79 content::DownloadDangerType, const FilePath&)); |
70 MOCK_METHOD1(AddObserver, void(content::DownloadItem::Observer*)); | 80 MOCK_METHOD1(AddObserver, void(content::DownloadItem::Observer*)); |
71 MOCK_METHOD1(RemoveObserver, void(content::DownloadItem::Observer*)); | 81 MOCK_METHOD1(RemoveObserver, void(content::DownloadItem::Observer*)); |
72 MOCK_METHOD0(UpdateObservers, void()); | 82 MOCK_METHOD0(UpdateObservers, void()); |
73 MOCK_METHOD0(CanShowInFolder, bool()); | 83 MOCK_METHOD0(CanShowInFolder, bool()); |
74 MOCK_METHOD0(CanOpenDownload, bool()); | 84 MOCK_METHOD0(CanOpenDownload, bool()); |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
115 MOCK_CONST_METHOD0(GetReferrerCharset, std::string()); | 125 MOCK_CONST_METHOD0(GetReferrerCharset, std::string()); |
116 MOCK_CONST_METHOD0(GetRemoteAddress, std::string()); | 126 MOCK_CONST_METHOD0(GetRemoteAddress, std::string()); |
117 MOCK_CONST_METHOD0(GetTotalBytes, int64()); | 127 MOCK_CONST_METHOD0(GetTotalBytes, int64()); |
118 MOCK_CONST_METHOD0(GetReceivedBytes, int64()); | 128 MOCK_CONST_METHOD0(GetReceivedBytes, int64()); |
119 MOCK_CONST_METHOD0(GetHashState, const std::string&()); | 129 MOCK_CONST_METHOD0(GetHashState, const std::string&()); |
120 MOCK_CONST_METHOD0(GetHash, const std::string&()); | 130 MOCK_CONST_METHOD0(GetHash, const std::string&()); |
121 MOCK_CONST_METHOD0(GetId, int32()); | 131 MOCK_CONST_METHOD0(GetId, int32()); |
122 MOCK_CONST_METHOD0(GetGlobalId, content::DownloadId()); | 132 MOCK_CONST_METHOD0(GetGlobalId, content::DownloadId()); |
123 MOCK_CONST_METHOD0(GetStartTime, base::Time()); | 133 MOCK_CONST_METHOD0(GetStartTime, base::Time()); |
124 MOCK_CONST_METHOD0(GetEndTime, base::Time()); | 134 MOCK_CONST_METHOD0(GetEndTime, base::Time()); |
125 MOCK_METHOD0(SetIsPersisted, void()); | |
126 MOCK_CONST_METHOD0(IsPersisted, bool()); | |
127 MOCK_METHOD1(SetDbHandle, void(int64)); | |
128 MOCK_CONST_METHOD0(GetDbHandle, int64()); | |
129 MOCK_METHOD0(GetDownloadManager, content::DownloadManager*()); | 135 MOCK_METHOD0(GetDownloadManager, content::DownloadManager*()); |
130 MOCK_CONST_METHOD0(IsPaused, bool()); | 136 MOCK_CONST_METHOD0(IsPaused, bool()); |
131 MOCK_CONST_METHOD0(GetOpenWhenComplete, bool()); | 137 MOCK_CONST_METHOD0(GetOpenWhenComplete, bool()); |
132 MOCK_METHOD1(SetOpenWhenComplete, void(bool)); | 138 MOCK_METHOD1(SetOpenWhenComplete, void(bool)); |
133 MOCK_CONST_METHOD0(GetFileExternallyRemoved, bool()); | 139 MOCK_CONST_METHOD0(GetFileExternallyRemoved, bool()); |
134 MOCK_CONST_METHOD0(GetSafetyState, SafetyState()); | 140 MOCK_CONST_METHOD0(GetSafetyState, SafetyState()); |
135 MOCK_CONST_METHOD0(GetDangerType, content::DownloadDangerType()); | 141 MOCK_CONST_METHOD0(GetDangerType, content::DownloadDangerType()); |
136 MOCK_CONST_METHOD0(IsDangerous, bool()); | 142 MOCK_CONST_METHOD0(IsDangerous, bool()); |
137 MOCK_METHOD0(GetAutoOpened, bool()); | 143 MOCK_METHOD0(GetAutoOpened, bool()); |
138 MOCK_CONST_METHOD0(GetTargetName, FilePath()); | 144 MOCK_CONST_METHOD0(GetTargetName, FilePath()); |
139 MOCK_CONST_METHOD0(GetForcedFilePath, const FilePath&()); | 145 MOCK_CONST_METHOD0(GetForcedFilePath, const FilePath&()); |
140 MOCK_CONST_METHOD0(HasUserGesture, bool()); | 146 MOCK_CONST_METHOD0(HasUserGesture, bool()); |
141 MOCK_CONST_METHOD0(GetTransitionType, content::PageTransition()); | 147 MOCK_CONST_METHOD0(GetTransitionType, content::PageTransition()); |
142 MOCK_CONST_METHOD0(IsTemporary, bool()); | 148 MOCK_CONST_METHOD0(IsTemporary, bool()); |
143 MOCK_METHOD1(SetIsTemporary, void(bool)); | 149 MOCK_METHOD1(SetIsTemporary, void(bool)); |
144 MOCK_METHOD1(SetOpened, void(bool)); | 150 MOCK_METHOD1(SetOpened, void(bool)); |
145 MOCK_CONST_METHOD0(GetOpened, bool()); | 151 MOCK_CONST_METHOD0(GetOpened, bool()); |
146 MOCK_CONST_METHOD0(GetLastModifiedTime, const std::string&()); | 152 MOCK_CONST_METHOD0(GetLastModifiedTime, const std::string&()); |
147 MOCK_CONST_METHOD0(GetETag, const std::string&()); | 153 MOCK_CONST_METHOD0(GetETag, const std::string&()); |
148 MOCK_CONST_METHOD0(GetLastReason, DownloadInterruptReason()); | 154 MOCK_CONST_METHOD0(GetLastReason, DownloadInterruptReason()); |
149 MOCK_CONST_METHOD0(GetPersistentStoreInfo, | |
150 content::DownloadPersistentStoreInfo()); | |
151 MOCK_CONST_METHOD0(GetBrowserContext, content::BrowserContext*()); | 155 MOCK_CONST_METHOD0(GetBrowserContext, content::BrowserContext*()); |
152 MOCK_CONST_METHOD0(GetWebContents, content::WebContents*()); | 156 MOCK_CONST_METHOD0(GetWebContents, content::WebContents*()); |
153 MOCK_CONST_METHOD0(GetFileNameToReportUser, FilePath()); | 157 MOCK_CONST_METHOD0(GetFileNameToReportUser, FilePath()); |
154 MOCK_METHOD1(SetDisplayName, void(const FilePath&)); | 158 MOCK_METHOD1(SetDisplayName, void(const FilePath&)); |
155 MOCK_CONST_METHOD0(GetUserVerifiedFilePath, FilePath()); | 159 MOCK_CONST_METHOD0(GetUserVerifiedFilePath, FilePath()); |
156 MOCK_METHOD0(OffThreadCancel, void()); | 160 MOCK_METHOD0(OffThreadCancel, void()); |
157 MOCK_CONST_METHOD1(DebugString, std::string(bool)); | 161 MOCK_CONST_METHOD1(DebugString, std::string(bool)); |
158 MOCK_METHOD0(MockDownloadOpenForTesting, void()); | 162 MOCK_METHOD0(MockDownloadOpenForTesting, void()); |
159 }; | 163 }; |
160 | 164 |
161 class MockDownloadManagerDelegate : public content::DownloadManagerDelegate { | 165 class MockDownloadManagerDelegate : public content::DownloadManagerDelegate { |
162 public: | 166 public: |
163 MockDownloadManagerDelegate(); | 167 MockDownloadManagerDelegate(); |
164 virtual ~MockDownloadManagerDelegate(); | 168 virtual ~MockDownloadManagerDelegate(); |
165 | 169 |
166 MOCK_METHOD0(Shutdown, void()); | 170 MOCK_METHOD0(Shutdown, void()); |
167 MOCK_METHOD0(GetNextId, content::DownloadId()); | 171 MOCK_METHOD0(GetNextId, content::DownloadId()); |
168 MOCK_METHOD2(DetermineDownloadTarget, | 172 MOCK_METHOD2(DetermineDownloadTarget, |
169 bool(DownloadItem* item, | 173 bool(DownloadItem* item, |
170 const content::DownloadTargetCallback&)); | 174 const content::DownloadTargetCallback&)); |
171 MOCK_METHOD0(GetAlternativeWebContentsToNotifyForDownload, WebContents*()); | 175 MOCK_METHOD0(GetAlternativeWebContentsToNotifyForDownload, WebContents*()); |
172 MOCK_METHOD1(ShouldOpenFileBasedOnExtension, bool(const FilePath&)); | 176 MOCK_METHOD1(ShouldOpenFileBasedOnExtension, bool(const FilePath&)); |
173 MOCK_METHOD2(ShouldCompleteDownload, bool( | 177 MOCK_METHOD2(ShouldCompleteDownload, bool( |
174 DownloadItem*, const base::Closure&)); | 178 DownloadItem*, const base::Closure&)); |
175 MOCK_METHOD1(ShouldOpenDownload, bool(DownloadItem*)); | 179 MOCK_METHOD1(ShouldOpenDownload, bool(DownloadItem*)); |
176 MOCK_METHOD0(GenerateFileHash, bool()); | 180 MOCK_METHOD0(GenerateFileHash, bool()); |
177 MOCK_METHOD1(AddItemToPersistentStore, void(DownloadItem*)); | |
178 MOCK_METHOD1(UpdateItemInPersistentStore, void(DownloadItem*)); | |
179 MOCK_METHOD2(UpdatePathForItemInPersistentStore, | |
180 void(DownloadItem*, const FilePath&)); | |
181 MOCK_METHOD1(RemoveItemFromPersistentStore, void(DownloadItem*)); | |
182 MOCK_METHOD2(RemoveItemsFromPersistentStoreBetween, void( | |
183 base::Time remove_begin, base::Time remove_end)); | |
184 MOCK_METHOD4(GetSaveDir, void(WebContents*, FilePath*, FilePath*, bool*)); | 181 MOCK_METHOD4(GetSaveDir, void(WebContents*, FilePath*, FilePath*, bool*)); |
185 MOCK_METHOD5(ChooseSavePath, void( | 182 MOCK_METHOD5(ChooseSavePath, void( |
186 WebContents*, const FilePath&, const FilePath::StringType&, | 183 WebContents*, const FilePath&, const FilePath::StringType&, |
187 bool, const content::SavePackagePathPickedCallback&)); | 184 bool, const content::SavePackagePathPickedCallback&)); |
188 }; | 185 }; |
189 | 186 |
190 MockDownloadManagerDelegate::MockDownloadManagerDelegate() {} | 187 MockDownloadManagerDelegate::MockDownloadManagerDelegate() {} |
191 | 188 |
192 MockDownloadManagerDelegate::~MockDownloadManagerDelegate() {} | 189 MockDownloadManagerDelegate::~MockDownloadManagerDelegate() {} |
193 | 190 |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
256 MockDownloadItemImpl* PopItem(); | 253 MockDownloadItemImpl* PopItem(); |
257 | 254 |
258 // Should be called when the item of this id is removed so that | 255 // Should be called when the item of this id is removed so that |
259 // we don't keep dangling pointers. | 256 // we don't keep dangling pointers. |
260 void RemoveItem(int id); | 257 void RemoveItem(int id); |
261 | 258 |
262 // Overridden methods from DownloadItemFactory. | 259 // Overridden methods from DownloadItemFactory. |
263 virtual DownloadItemImpl* CreatePersistedItem( | 260 virtual DownloadItemImpl* CreatePersistedItem( |
264 DownloadItemImplDelegate* delegate, | 261 DownloadItemImplDelegate* delegate, |
265 content::DownloadId download_id, | 262 content::DownloadId download_id, |
266 const content::DownloadPersistentStoreInfo& info, | 263 const FilePath& path, |
| 264 const GURL& url, |
| 265 const GURL& referrer_url, |
| 266 const base::Time& start_time, |
| 267 const base::Time& end_time, |
| 268 int64 received_bytes, |
| 269 int64 total_bytes, |
| 270 DownloadItem::DownloadState state, |
| 271 bool opened, |
267 const net::BoundNetLog& bound_net_log) OVERRIDE; | 272 const net::BoundNetLog& bound_net_log) OVERRIDE; |
268 virtual DownloadItemImpl* CreateActiveItem( | 273 virtual DownloadItemImpl* CreateActiveItem( |
269 DownloadItemImplDelegate* delegate, | 274 DownloadItemImplDelegate* delegate, |
270 const DownloadCreateInfo& info, | 275 const DownloadCreateInfo& info, |
271 scoped_ptr<DownloadRequestHandleInterface> request_handle, | 276 scoped_ptr<DownloadRequestHandleInterface> request_handle, |
272 const net::BoundNetLog& bound_net_log) OVERRIDE; | 277 const net::BoundNetLog& bound_net_log) OVERRIDE; |
273 virtual DownloadItemImpl* CreateSavePageItem( | 278 virtual DownloadItemImpl* CreateSavePageItem( |
274 DownloadItemImplDelegate* delegate, | 279 DownloadItemImplDelegate* delegate, |
275 const FilePath& path, | 280 const FilePath& path, |
276 const GURL& url, | 281 const GURL& url, |
(...skipping 30 matching lines...) Expand all Loading... |
307 } | 312 } |
308 | 313 |
309 void MockDownloadItemFactory::RemoveItem(int id) { | 314 void MockDownloadItemFactory::RemoveItem(int id) { |
310 DCHECK(items_.find(id) != items_.end()); | 315 DCHECK(items_.find(id) != items_.end()); |
311 items_.erase(id); | 316 items_.erase(id); |
312 } | 317 } |
313 | 318 |
314 DownloadItemImpl* MockDownloadItemFactory::CreatePersistedItem( | 319 DownloadItemImpl* MockDownloadItemFactory::CreatePersistedItem( |
315 DownloadItemImplDelegate* delegate, | 320 DownloadItemImplDelegate* delegate, |
316 content::DownloadId download_id, | 321 content::DownloadId download_id, |
317 const content::DownloadPersistentStoreInfo& info, | 322 const FilePath& path, |
| 323 const GURL& url, |
| 324 const GURL& referrer_url, |
| 325 const base::Time& start_time, |
| 326 const base::Time& end_time, |
| 327 int64 received_bytes, |
| 328 int64 total_bytes, |
| 329 DownloadItem::DownloadState state, |
| 330 bool opened, |
318 const net::BoundNetLog& bound_net_log) { | 331 const net::BoundNetLog& bound_net_log) { |
319 int local_id = download_id.local(); | 332 int local_id = download_id.local(); |
320 DCHECK(items_.find(local_id) == items_.end()); | 333 DCHECK(items_.find(local_id) == items_.end()); |
321 | 334 |
322 MockDownloadItemImpl* result = | 335 MockDownloadItemImpl* result = |
323 new StrictMock<MockDownloadItemImpl>(&item_delegate_); | 336 new StrictMock<MockDownloadItemImpl>(&item_delegate_); |
324 EXPECT_CALL(*result, GetId()) | 337 EXPECT_CALL(*result, GetId()) |
325 .WillRepeatedly(Return(local_id)); | 338 .WillRepeatedly(Return(local_id)); |
326 items_[local_id] = result; | 339 items_[local_id] = result; |
327 | 340 |
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
511 | 524 |
512 MockDownloadManagerObserver& GetMockObserver() { | 525 MockDownloadManagerObserver& GetMockObserver() { |
513 return *observer_; | 526 return *observer_; |
514 } | 527 } |
515 | 528 |
516 // Probe at private internals. | 529 // Probe at private internals. |
517 void DownloadStopped(DownloadItemImpl* item) { | 530 void DownloadStopped(DownloadItemImpl* item) { |
518 download_manager_->DownloadStopped(item); | 531 download_manager_->DownloadStopped(item); |
519 } | 532 } |
520 | 533 |
521 void AddItemToHistory(MockDownloadItemImpl& item, int64 db_handle) { | |
522 // For DCHECK in AddDownloadItemToHistory. Don't want to use | |
523 // WillRepeatedly as it may have to return true after this. | |
524 if (DCHECK_IS_ON()) | |
525 EXPECT_CALL(item, IsPersisted()) | |
526 .WillRepeatedly(Return(false)); | |
527 | |
528 EXPECT_CALL(item, SetDbHandle(db_handle)); | |
529 EXPECT_CALL(item, SetIsPersisted()); | |
530 EXPECT_CALL(item, GetDbHandle()) | |
531 .WillRepeatedly(Return(db_handle)); | |
532 | |
533 // Null out ShowDownloadInBrowser | |
534 EXPECT_CALL(item, GetWebContents()) | |
535 .WillOnce(Return(static_cast<WebContents*>(NULL))); | |
536 EXPECT_CALL(GetMockDownloadManagerDelegate(), | |
537 GetAlternativeWebContentsToNotifyForDownload()) | |
538 .WillOnce(Return(static_cast<WebContents*>(NULL))); | |
539 | |
540 EXPECT_CALL(item, IsInProgress()) | |
541 .WillOnce(Return(true)); | |
542 | |
543 // Null out MaybeCompleteDownload | |
544 EXPECT_CALL(item, AllDataSaved()) | |
545 .WillOnce(Return(false)); | |
546 | |
547 download_manager_->OnItemAddedToPersistentStore(item.GetId(), db_handle); | |
548 } | |
549 | |
550 protected: | 534 protected: |
551 // Key test variable; we'll keep it available to sub-classes. | 535 // Key test variable; we'll keep it available to sub-classes. |
552 scoped_refptr<DownloadManagerImpl> download_manager_; | 536 scoped_refptr<DownloadManagerImpl> download_manager_; |
553 | 537 |
554 private: | 538 private: |
555 MessageLoopForUI message_loop_; | 539 MessageLoopForUI message_loop_; |
556 content::TestBrowserThread ui_thread_; | 540 content::TestBrowserThread ui_thread_; |
557 content::TestBrowserThread file_thread_; | 541 content::TestBrowserThread file_thread_; |
558 base::WeakPtr<MockDownloadItemFactory> mock_download_item_factory_; | 542 base::WeakPtr<MockDownloadItemFactory> mock_download_item_factory_; |
559 scoped_ptr<MockDownloadManagerDelegate> mock_download_manager_delegate_; | 543 scoped_ptr<MockDownloadManagerDelegate> mock_download_manager_delegate_; |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
598 | 582 |
599 content::DownloadInterruptReason reason( | 583 content::DownloadInterruptReason reason( |
600 content::DOWNLOAD_INTERRUPT_REASON_FILE_FAILED); | 584 content::DOWNLOAD_INTERRUPT_REASON_FILE_FAILED); |
601 | 585 |
602 EXPECT_CALL(item, Interrupt(reason)); | 586 EXPECT_CALL(item, Interrupt(reason)); |
603 download_manager_->OnDownloadInterrupted(download_id, reason); | 587 download_manager_->OnDownloadInterrupted(download_id, reason); |
604 EXPECT_EQ(&item, download_manager_->GetActiveDownloadItem(download_id)); | 588 EXPECT_EQ(&item, download_manager_->GetActiveDownloadItem(download_id)); |
605 } | 589 } |
606 | 590 |
607 // Does DownloadStopped remove Download from appropriate queues? | 591 // Does DownloadStopped remove Download from appropriate queues? |
608 // This test tests non-persisted downloads. | 592 TEST_F(DownloadManagerTest, OnDownloadStopped) { |
609 TEST_F(DownloadManagerTest, OnDownloadStopped_NonPersisted) { | |
610 EXPECT_CALL(GetMockObserver(), OnDownloadCreated(download_manager_.get(), _)) | 593 EXPECT_CALL(GetMockObserver(), OnDownloadCreated(download_manager_.get(), _)) |
611 .WillOnce(Return()); | 594 .WillOnce(Return()); |
612 // Put a mock we have a handle to on the download manager. | 595 // Put a mock we have a handle to on the download manager. |
613 MockDownloadItemImpl& item(AddItemToManager()); | 596 MockDownloadItemImpl& item(AddItemToManager()); |
614 | 597 |
615 EXPECT_CALL(item, IsPersisted()) | |
616 .WillRepeatedly(Return(false)); | |
617 EXPECT_CALL(item, GetState()) | 598 EXPECT_CALL(item, GetState()) |
618 .WillRepeatedly(Return(DownloadItem::CANCELLED)); | 599 .WillRepeatedly(Return(DownloadItem::CANCELLED)); |
619 EXPECT_CALL(item, GetDbHandle()) | |
620 .WillRepeatedly(Return(DownloadItem::kUninitializedHandle)); | |
621 | 600 |
622 EXPECT_CALL(item, OffThreadCancel()); | 601 EXPECT_CALL(item, OffThreadCancel()); |
623 DownloadStopped(&item); | 602 DownloadStopped(&item); |
624 // TODO(rdsmith): Confirm that the download item is no longer on the | 603 // TODO(rdsmith): Confirm that the download item is no longer on the |
625 // active list by calling download_manager_->GetActiveDownloadItem(id). | 604 // active list by calling download_manager_->GetActiveDownloadItem(id). |
626 // Currently, the item is left on the active list for rendez-vous with | 605 // Currently, the item is left on the active list for rendez-vous with |
627 // the history system :-{. | 606 // the history system :-{. |
628 } | 607 } |
629 | |
630 // Does DownloadStopped remove Download from appropriate queues? | |
631 // This test tests persisted downloads. | |
632 TEST_F(DownloadManagerTest, OnDownloadStopped_Persisted) { | |
633 EXPECT_CALL(GetMockObserver(), OnDownloadCreated(download_manager_.get(), _)) | |
634 .WillOnce(Return()); | |
635 // Put a mock we have a handle to on the download manager. | |
636 MockDownloadItemImpl& item(AddItemToManager()); | |
637 int download_id = item.GetId(); | |
638 int64 db_handle = 0x7; | |
639 EXPECT_CALL(GetMockObserver(), ModelChanged(download_manager_.get())) | |
640 .WillOnce(Return()); | |
641 AddItemToHistory(item, db_handle); | |
642 | |
643 EXPECT_CALL(item, IsPersisted()) | |
644 .WillRepeatedly(Return(true)); | |
645 EXPECT_CALL(GetMockDownloadManagerDelegate(), | |
646 UpdateItemInPersistentStore(&item)); | |
647 EXPECT_CALL(item, GetState()) | |
648 .WillRepeatedly(Return(DownloadItem::CANCELLED)); | |
649 EXPECT_CALL(item, GetDbHandle()) | |
650 .WillRepeatedly(Return(db_handle)); | |
651 | |
652 EXPECT_CALL(item, OffThreadCancel()); | |
653 DownloadStopped(&item); | |
654 EXPECT_EQ(NULL, download_manager_->GetActiveDownloadItem(download_id)); | |
655 } | |
OLD | NEW |