| 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 495 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 506 download_manager_->RestartDownload(item.GetId()); | 506 download_manager_->RestartDownload(item.GetId()); |
| 507 } | 507 } |
| 508 | 508 |
| 509 // Do the results of an OnDownloadInterrupted get passed through properly | 509 // Do the results of an OnDownloadInterrupted get passed through properly |
| 510 // to the DownloadItem? | 510 // to the DownloadItem? |
| 511 TEST_F(DownloadManagerTest, OnDownloadInterrupted) { | 511 TEST_F(DownloadManagerTest, OnDownloadInterrupted) { |
| 512 // Put a mock we have a handle to on the download manager. | 512 // Put a mock we have a handle to on the download manager. |
| 513 content::MockDownloadItem& item(AddItemToManager()); | 513 content::MockDownloadItem& item(AddItemToManager()); |
| 514 int download_id = item.GetId(); | 514 int download_id = item.GetId(); |
| 515 | 515 |
| 516 int64 size = 0xdeadbeef; | |
| 517 const std::string hash_state("Undead beef"); | |
| 518 content::DownloadInterruptReason reason( | 516 content::DownloadInterruptReason reason( |
| 519 content::DOWNLOAD_INTERRUPT_REASON_FILE_FAILED); | 517 content::DOWNLOAD_INTERRUPT_REASON_FILE_FAILED); |
| 520 | 518 |
| 521 EXPECT_CALL(item, UpdateProgress(size, 0, hash_state)); | |
| 522 EXPECT_CALL(item, Interrupt(reason)); | 519 EXPECT_CALL(item, Interrupt(reason)); |
| 523 download_manager_->OnDownloadInterrupted( | 520 download_manager_->OnDownloadInterrupted(download_id, reason); |
| 524 download_id, size, hash_state, reason); | |
| 525 EXPECT_EQ(&item, GetActiveDownloadItem(download_id)); | 521 EXPECT_EQ(&item, GetActiveDownloadItem(download_id)); |
| 526 } | 522 } |
| 527 | 523 |
| 528 // Does DownloadStopped remove Download from appropriate queues? | 524 // Does DownloadStopped remove Download from appropriate queues? |
| 529 // This test tests non-persisted downloads. | 525 // This test tests non-persisted downloads. |
| 530 TEST_F(DownloadManagerTest, OnDownloadStopped_NonPersisted) { | 526 TEST_F(DownloadManagerTest, OnDownloadStopped_NonPersisted) { |
| 531 // Put a mock we have a handle to on the download manager. | 527 // Put a mock we have a handle to on the download manager. |
| 532 content::MockDownloadItem& item(AddItemToManager()); | 528 content::MockDownloadItem& item(AddItemToManager()); |
| 533 | 529 |
| 534 EXPECT_CALL(item, IsPersisted()) | 530 EXPECT_CALL(item, IsPersisted()) |
| (...skipping 26 matching lines...) Expand all Loading... |
| 561 UpdateItemInPersistentStore(&item)); | 557 UpdateItemInPersistentStore(&item)); |
| 562 EXPECT_CALL(item, GetState()) | 558 EXPECT_CALL(item, GetState()) |
| 563 .WillRepeatedly(Return(DownloadItem::CANCELLED)); | 559 .WillRepeatedly(Return(DownloadItem::CANCELLED)); |
| 564 EXPECT_CALL(item, GetDbHandle()) | 560 EXPECT_CALL(item, GetDbHandle()) |
| 565 .WillRepeatedly(Return(db_handle)); | 561 .WillRepeatedly(Return(db_handle)); |
| 566 | 562 |
| 567 EXPECT_CALL(item, OffThreadCancel(&GetMockDownloadFileManager())); | 563 EXPECT_CALL(item, OffThreadCancel(&GetMockDownloadFileManager())); |
| 568 download_manager_->DownloadStopped(&item); | 564 download_manager_->DownloadStopped(&item); |
| 569 EXPECT_EQ(NULL, GetActiveDownloadItem(download_id)); | 565 EXPECT_EQ(NULL, GetActiveDownloadItem(download_id)); |
| 570 } | 566 } |
| OLD | NEW |