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"); |
516 content::DownloadInterruptReason reason( | 518 content::DownloadInterruptReason reason( |
517 content::DOWNLOAD_INTERRUPT_REASON_FILE_FAILED); | 519 content::DOWNLOAD_INTERRUPT_REASON_FILE_FAILED); |
518 | 520 |
| 521 EXPECT_CALL(item, UpdateProgress(size, 0, hash_state)); |
519 EXPECT_CALL(item, Interrupt(reason)); | 522 EXPECT_CALL(item, Interrupt(reason)); |
520 download_manager_->OnDownloadInterrupted(download_id, reason); | 523 download_manager_->OnDownloadInterrupted( |
| 524 download_id, size, hash_state, reason); |
521 EXPECT_EQ(&item, GetActiveDownloadItem(download_id)); | 525 EXPECT_EQ(&item, GetActiveDownloadItem(download_id)); |
522 } | 526 } |
523 | 527 |
524 // Does DownloadStopped remove Download from appropriate queues? | 528 // Does DownloadStopped remove Download from appropriate queues? |
525 // This test tests non-persisted downloads. | 529 // This test tests non-persisted downloads. |
526 TEST_F(DownloadManagerTest, OnDownloadStopped_NonPersisted) { | 530 TEST_F(DownloadManagerTest, OnDownloadStopped_NonPersisted) { |
527 // Put a mock we have a handle to on the download manager. | 531 // Put a mock we have a handle to on the download manager. |
528 content::MockDownloadItem& item(AddItemToManager()); | 532 content::MockDownloadItem& item(AddItemToManager()); |
529 | 533 |
530 EXPECT_CALL(item, IsPersisted()) | 534 EXPECT_CALL(item, IsPersisted()) |
(...skipping 28 matching lines...) Expand all Loading... |
559 UpdateItemInPersistentStore(&item)); | 563 UpdateItemInPersistentStore(&item)); |
560 EXPECT_CALL(item, GetState()) | 564 EXPECT_CALL(item, GetState()) |
561 .WillRepeatedly(Return(DownloadItem::CANCELLED)); | 565 .WillRepeatedly(Return(DownloadItem::CANCELLED)); |
562 EXPECT_CALL(item, GetDbHandle()) | 566 EXPECT_CALL(item, GetDbHandle()) |
563 .WillRepeatedly(Return(db_handle)); | 567 .WillRepeatedly(Return(db_handle)); |
564 | 568 |
565 EXPECT_CALL(item, OffThreadCancel(&GetMockDownloadFileManager())); | 569 EXPECT_CALL(item, OffThreadCancel(&GetMockDownloadFileManager())); |
566 download_manager_->DownloadStopped(&item); | 570 download_manager_->DownloadStopped(&item); |
567 EXPECT_EQ(NULL, GetActiveDownloadItem(download_id)); | 571 EXPECT_EQ(NULL, GetActiveDownloadItem(download_id)); |
568 } | 572 } |
OLD | NEW |