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 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
132 MOCK_METHOD1(SetOpenWhenComplete, void(bool)); | 132 MOCK_METHOD1(SetOpenWhenComplete, void(bool)); |
133 MOCK_CONST_METHOD0(GetFileExternallyRemoved, bool()); | 133 MOCK_CONST_METHOD0(GetFileExternallyRemoved, bool()); |
134 MOCK_CONST_METHOD0(GetSafetyState, SafetyState()); | 134 MOCK_CONST_METHOD0(GetSafetyState, SafetyState()); |
135 MOCK_CONST_METHOD0(GetDangerType, content::DownloadDangerType()); | 135 MOCK_CONST_METHOD0(GetDangerType, content::DownloadDangerType()); |
136 MOCK_CONST_METHOD0(IsDangerous, bool()); | 136 MOCK_CONST_METHOD0(IsDangerous, bool()); |
137 MOCK_METHOD0(GetAutoOpened, bool()); | 137 MOCK_METHOD0(GetAutoOpened, bool()); |
138 MOCK_CONST_METHOD0(GetTargetName, FilePath()); | 138 MOCK_CONST_METHOD0(GetTargetName, FilePath()); |
139 MOCK_CONST_METHOD0(GetForcedFilePath, const FilePath&()); | 139 MOCK_CONST_METHOD0(GetForcedFilePath, const FilePath&()); |
140 MOCK_CONST_METHOD0(HasUserGesture, bool()); | 140 MOCK_CONST_METHOD0(HasUserGesture, bool()); |
141 MOCK_CONST_METHOD0(GetTransitionType, content::PageTransition()); | 141 MOCK_CONST_METHOD0(GetTransitionType, content::PageTransition()); |
142 MOCK_CONST_METHOD0(IsOtr, bool()); | |
143 MOCK_CONST_METHOD0(IsTemporary, bool()); | 142 MOCK_CONST_METHOD0(IsTemporary, bool()); |
144 MOCK_METHOD1(SetIsTemporary, void(bool)); | 143 MOCK_METHOD1(SetIsTemporary, void(bool)); |
145 MOCK_METHOD1(SetOpened, void(bool)); | 144 MOCK_METHOD1(SetOpened, void(bool)); |
146 MOCK_CONST_METHOD0(GetOpened, bool()); | 145 MOCK_CONST_METHOD0(GetOpened, bool()); |
147 MOCK_CONST_METHOD0(GetLastModifiedTime, const std::string&()); | 146 MOCK_CONST_METHOD0(GetLastModifiedTime, const std::string&()); |
148 MOCK_CONST_METHOD0(GetETag, const std::string&()); | 147 MOCK_CONST_METHOD0(GetETag, const std::string&()); |
149 MOCK_CONST_METHOD0(GetLastReason, DownloadInterruptReason()); | 148 MOCK_CONST_METHOD0(GetLastReason, DownloadInterruptReason()); |
150 MOCK_CONST_METHOD0(GetPersistentStoreInfo, | 149 MOCK_CONST_METHOD0(GetPersistentStoreInfo, |
151 content::DownloadPersistentStoreInfo()); | 150 content::DownloadPersistentStoreInfo()); |
152 MOCK_CONST_METHOD0(GetBrowserContext, content::BrowserContext*()); | 151 MOCK_CONST_METHOD0(GetBrowserContext, content::BrowserContext*()); |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
263 // Overridden methods from DownloadItemFactory. | 262 // Overridden methods from DownloadItemFactory. |
264 virtual DownloadItemImpl* CreatePersistedItem( | 263 virtual DownloadItemImpl* CreatePersistedItem( |
265 DownloadItemImplDelegate* delegate, | 264 DownloadItemImplDelegate* delegate, |
266 content::DownloadId download_id, | 265 content::DownloadId download_id, |
267 const content::DownloadPersistentStoreInfo& info, | 266 const content::DownloadPersistentStoreInfo& info, |
268 const net::BoundNetLog& bound_net_log) OVERRIDE; | 267 const net::BoundNetLog& bound_net_log) OVERRIDE; |
269 virtual DownloadItemImpl* CreateActiveItem( | 268 virtual DownloadItemImpl* CreateActiveItem( |
270 DownloadItemImplDelegate* delegate, | 269 DownloadItemImplDelegate* delegate, |
271 const DownloadCreateInfo& info, | 270 const DownloadCreateInfo& info, |
272 scoped_ptr<DownloadRequestHandleInterface> request_handle, | 271 scoped_ptr<DownloadRequestHandleInterface> request_handle, |
273 bool is_otr, | |
274 const net::BoundNetLog& bound_net_log) OVERRIDE; | 272 const net::BoundNetLog& bound_net_log) OVERRIDE; |
275 virtual DownloadItemImpl* CreateSavePageItem( | 273 virtual DownloadItemImpl* CreateSavePageItem( |
276 DownloadItemImplDelegate* delegate, | 274 DownloadItemImplDelegate* delegate, |
277 const FilePath& path, | 275 const FilePath& path, |
278 const GURL& url, | 276 const GURL& url, |
279 bool is_otr, | |
280 content::DownloadId download_id, | 277 content::DownloadId download_id, |
281 const std::string& mime_type, | 278 const std::string& mime_type, |
282 const net::BoundNetLog& bound_net_log) OVERRIDE; | 279 const net::BoundNetLog& bound_net_log) OVERRIDE; |
283 | 280 |
284 private: | 281 private: |
285 std::map<int32, MockDownloadItemImpl*> items_; | 282 std::map<int32, MockDownloadItemImpl*> items_; |
286 DownloadItemImplDelegate item_delegate_; | 283 DownloadItemImplDelegate item_delegate_; |
287 | 284 |
288 DISALLOW_COPY_AND_ASSIGN(MockDownloadItemFactory); | 285 DISALLOW_COPY_AND_ASSIGN(MockDownloadItemFactory); |
289 }; | 286 }; |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
328 .WillRepeatedly(Return(local_id)); | 325 .WillRepeatedly(Return(local_id)); |
329 items_[local_id] = result; | 326 items_[local_id] = result; |
330 | 327 |
331 return result; | 328 return result; |
332 } | 329 } |
333 | 330 |
334 DownloadItemImpl* MockDownloadItemFactory::CreateActiveItem( | 331 DownloadItemImpl* MockDownloadItemFactory::CreateActiveItem( |
335 DownloadItemImplDelegate* delegate, | 332 DownloadItemImplDelegate* delegate, |
336 const DownloadCreateInfo& info, | 333 const DownloadCreateInfo& info, |
337 scoped_ptr<DownloadRequestHandleInterface> request_handle, | 334 scoped_ptr<DownloadRequestHandleInterface> request_handle, |
338 bool is_otr, | |
339 const net::BoundNetLog& bound_net_log) { | 335 const net::BoundNetLog& bound_net_log) { |
340 int local_id = info.download_id.local(); | 336 int local_id = info.download_id.local(); |
341 DCHECK(items_.find(local_id) == items_.end()); | 337 DCHECK(items_.find(local_id) == items_.end()); |
342 | 338 |
343 MockDownloadItemImpl* result = | 339 MockDownloadItemImpl* result = |
344 new StrictMock<MockDownloadItemImpl>(&item_delegate_); | 340 new StrictMock<MockDownloadItemImpl>(&item_delegate_); |
345 EXPECT_CALL(*result, GetId()) | 341 EXPECT_CALL(*result, GetId()) |
346 .WillRepeatedly(Return(local_id)); | 342 .WillRepeatedly(Return(local_id)); |
347 items_[local_id] = result; | 343 items_[local_id] = result; |
348 | 344 |
349 return result; | 345 return result; |
350 } | 346 } |
351 | 347 |
352 DownloadItemImpl* MockDownloadItemFactory::CreateSavePageItem( | 348 DownloadItemImpl* MockDownloadItemFactory::CreateSavePageItem( |
353 DownloadItemImplDelegate* delegate, | 349 DownloadItemImplDelegate* delegate, |
354 const FilePath& path, | 350 const FilePath& path, |
355 const GURL& url, | 351 const GURL& url, |
356 bool is_otr, | |
357 content::DownloadId download_id, | 352 content::DownloadId download_id, |
358 const std::string& mime_type, | 353 const std::string& mime_type, |
359 const net::BoundNetLog& bound_net_log) { | 354 const net::BoundNetLog& bound_net_log) { |
360 int local_id = download_id.local(); | 355 int local_id = download_id.local(); |
361 DCHECK(items_.find(local_id) == items_.end()); | 356 DCHECK(items_.find(local_id) == items_.end()); |
362 | 357 |
363 MockDownloadItemImpl* result = | 358 MockDownloadItemImpl* result = |
364 new StrictMock<MockDownloadItemImpl>(&item_delegate_); | 359 new StrictMock<MockDownloadItemImpl>(&item_delegate_); |
365 EXPECT_CALL(*result, GetId()) | 360 EXPECT_CALL(*result, GetId()) |
366 .WillRepeatedly(Return(local_id)); | 361 .WillRepeatedly(Return(local_id)); |
(...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
648 UpdateItemInPersistentStore(&item)); | 643 UpdateItemInPersistentStore(&item)); |
649 EXPECT_CALL(item, GetState()) | 644 EXPECT_CALL(item, GetState()) |
650 .WillRepeatedly(Return(DownloadItem::CANCELLED)); | 645 .WillRepeatedly(Return(DownloadItem::CANCELLED)); |
651 EXPECT_CALL(item, GetDbHandle()) | 646 EXPECT_CALL(item, GetDbHandle()) |
652 .WillRepeatedly(Return(db_handle)); | 647 .WillRepeatedly(Return(db_handle)); |
653 | 648 |
654 EXPECT_CALL(item, OffThreadCancel()); | 649 EXPECT_CALL(item, OffThreadCancel()); |
655 DownloadStopped(&item); | 650 DownloadStopped(&item); |
656 EXPECT_EQ(NULL, download_manager_->GetActiveDownloadItem(download_id)); | 651 EXPECT_EQ(NULL, download_manager_->GetActiveDownloadItem(download_id)); |
657 } | 652 } |
OLD | NEW |