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 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
150 MOCK_CONST_METHOD0(GetPersistentStoreInfo, | 150 MOCK_CONST_METHOD0(GetPersistentStoreInfo, |
151 content::DownloadPersistentStoreInfo()); | 151 content::DownloadPersistentStoreInfo()); |
152 MOCK_CONST_METHOD0(GetBrowserContext, content::BrowserContext*()); | 152 MOCK_CONST_METHOD0(GetBrowserContext, content::BrowserContext*()); |
153 MOCK_CONST_METHOD0(GetWebContents, content::WebContents*()); | 153 MOCK_CONST_METHOD0(GetWebContents, content::WebContents*()); |
154 MOCK_CONST_METHOD0(GetFileNameToReportUser, FilePath()); | 154 MOCK_CONST_METHOD0(GetFileNameToReportUser, FilePath()); |
155 MOCK_METHOD1(SetDisplayName, void(const FilePath&)); | 155 MOCK_METHOD1(SetDisplayName, void(const FilePath&)); |
156 MOCK_CONST_METHOD0(GetUserVerifiedFilePath, FilePath()); | 156 MOCK_CONST_METHOD0(GetUserVerifiedFilePath, FilePath()); |
157 MOCK_METHOD0(OffThreadCancel, void()); | 157 MOCK_METHOD0(OffThreadCancel, void()); |
158 MOCK_CONST_METHOD1(DebugString, std::string(bool)); | 158 MOCK_CONST_METHOD1(DebugString, std::string(bool)); |
159 MOCK_METHOD0(MockDownloadOpenForTesting, void()); | 159 MOCK_METHOD0(MockDownloadOpenForTesting, void()); |
160 MOCK_METHOD1(GetExternalData, ExternalData*(const void*)); | |
161 MOCK_CONST_METHOD1(GetExternalData, const ExternalData*(const void*)); | |
162 MOCK_METHOD2(SetExternalData, void(const void*, ExternalData*)); | |
163 }; | 160 }; |
164 | 161 |
165 class MockDownloadManagerDelegate : public content::DownloadManagerDelegate { | 162 class MockDownloadManagerDelegate : public content::DownloadManagerDelegate { |
166 public: | 163 public: |
167 MockDownloadManagerDelegate(); | 164 MockDownloadManagerDelegate(); |
168 virtual ~MockDownloadManagerDelegate(); | 165 virtual ~MockDownloadManagerDelegate(); |
169 | 166 |
170 MOCK_METHOD0(Shutdown, void()); | 167 MOCK_METHOD0(Shutdown, void()); |
171 MOCK_METHOD0(GetNextId, content::DownloadId()); | 168 MOCK_METHOD0(GetNextId, content::DownloadId()); |
172 MOCK_METHOD2(DetermineDownloadTarget, | 169 MOCK_METHOD2(DetermineDownloadTarget, |
(...skipping 461 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
634 | 631 |
635 // Does DownloadStopped remove Download from appropriate queues? | 632 // Does DownloadStopped remove Download from appropriate queues? |
636 // This test tests persisted downloads. | 633 // This test tests persisted downloads. |
637 TEST_F(DownloadManagerTest, OnDownloadStopped_Persisted) { | 634 TEST_F(DownloadManagerTest, OnDownloadStopped_Persisted) { |
638 EXPECT_CALL(GetMockObserver(), OnDownloadCreated(download_manager_.get(), _)) | 635 EXPECT_CALL(GetMockObserver(), OnDownloadCreated(download_manager_.get(), _)) |
639 .WillOnce(Return()); | 636 .WillOnce(Return()); |
640 // Put a mock we have a handle to on the download manager. | 637 // Put a mock we have a handle to on the download manager. |
641 MockDownloadItemImpl& item(AddItemToManager()); | 638 MockDownloadItemImpl& item(AddItemToManager()); |
642 int download_id = item.GetId(); | 639 int download_id = item.GetId(); |
643 int64 db_handle = 0x7; | 640 int64 db_handle = 0x7; |
644 EXPECT_CALL(item, GetExternalData(_)) | |
645 .WillOnce(Return(static_cast<DownloadItem::ExternalData*>(NULL))); | |
646 EXPECT_CALL(GetMockObserver(), ModelChanged(download_manager_.get())) | 641 EXPECT_CALL(GetMockObserver(), ModelChanged(download_manager_.get())) |
647 .WillOnce(Return()); | 642 .WillOnce(Return()); |
648 AddItemToHistory(item, db_handle); | 643 AddItemToHistory(item, db_handle); |
649 | 644 |
650 EXPECT_CALL(item, IsPersisted()) | 645 EXPECT_CALL(item, IsPersisted()) |
651 .WillRepeatedly(Return(true)); | 646 .WillRepeatedly(Return(true)); |
652 EXPECT_CALL(GetMockDownloadManagerDelegate(), | 647 EXPECT_CALL(GetMockDownloadManagerDelegate(), |
653 UpdateItemInPersistentStore(&item)); | 648 UpdateItemInPersistentStore(&item)); |
654 EXPECT_CALL(item, GetState()) | 649 EXPECT_CALL(item, GetState()) |
655 .WillRepeatedly(Return(DownloadItem::CANCELLED)); | 650 .WillRepeatedly(Return(DownloadItem::CANCELLED)); |
656 EXPECT_CALL(item, GetDbHandle()) | 651 EXPECT_CALL(item, GetDbHandle()) |
657 .WillRepeatedly(Return(db_handle)); | 652 .WillRepeatedly(Return(db_handle)); |
658 | 653 |
659 EXPECT_CALL(item, OffThreadCancel()); | 654 EXPECT_CALL(item, OffThreadCancel()); |
660 DownloadStopped(&item); | 655 DownloadStopped(&item); |
661 EXPECT_EQ(NULL, download_manager_->GetActiveDownloadItem(download_id)); | 656 EXPECT_EQ(NULL, download_manager_->GetActiveDownloadItem(download_id)); |
662 } | 657 } |
OLD | NEW |