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 28 matching lines...) Expand all Loading... |
563 UpdateItemInPersistentStore(&item)); | 559 UpdateItemInPersistentStore(&item)); |
564 EXPECT_CALL(item, GetState()) | 560 EXPECT_CALL(item, GetState()) |
565 .WillRepeatedly(Return(DownloadItem::CANCELLED)); | 561 .WillRepeatedly(Return(DownloadItem::CANCELLED)); |
566 EXPECT_CALL(item, GetDbHandle()) | 562 EXPECT_CALL(item, GetDbHandle()) |
567 .WillRepeatedly(Return(db_handle)); | 563 .WillRepeatedly(Return(db_handle)); |
568 | 564 |
569 EXPECT_CALL(item, OffThreadCancel(&GetMockDownloadFileManager())); | 565 EXPECT_CALL(item, OffThreadCancel(&GetMockDownloadFileManager())); |
570 download_manager_->DownloadStopped(&item); | 566 download_manager_->DownloadStopped(&item); |
571 EXPECT_EQ(NULL, GetActiveDownloadItem(download_id)); | 567 EXPECT_EQ(NULL, GetActiveDownloadItem(download_id)); |
572 } | 568 } |
OLD | NEW |