OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 <string> | 5 #include <string> |
6 #include <set> | 6 #include <set> |
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/i18n/number_formatting.h" | 10 #include "base/i18n/number_formatting.h" |
(...skipping 11 matching lines...) Expand all Loading... |
22 #include "chrome/browser/prefs/pref_service.h" | 22 #include "chrome/browser/prefs/pref_service.h" |
23 #include "chrome/common/pref_names.h" | 23 #include "chrome/common/pref_names.h" |
24 #include "chrome/test/base/testing_profile.h" | 24 #include "chrome/test/base/testing_profile.h" |
25 #include "content/browser/browser_thread.h" | 25 #include "content/browser/browser_thread.h" |
26 #include "content/browser/download/download_buffer.h" | 26 #include "content/browser/download/download_buffer.h" |
27 #include "content/browser/download/download_create_info.h" | 27 #include "content/browser/download/download_create_info.h" |
28 #include "content/browser/download/download_file.h" | 28 #include "content/browser/download/download_file.h" |
29 #include "content/browser/download/download_file_manager.h" | 29 #include "content/browser/download/download_file_manager.h" |
30 #include "content/browser/download/download_item.h" | 30 #include "content/browser/download/download_item.h" |
31 #include "content/browser/download/download_manager.h" | 31 #include "content/browser/download/download_manager.h" |
| 32 #include "content/browser/download/download_request_handle.h" |
32 #include "content/browser/download/download_status_updater.h" | 33 #include "content/browser/download/download_status_updater.h" |
33 #include "content/browser/download/interrupt_reasons.h" | 34 #include "content/browser/download/interrupt_reasons.h" |
34 #include "content/browser/download/mock_download_manager.h" | 35 #include "content/browser/download/mock_download_manager.h" |
35 #include "grit/generated_resources.h" | 36 #include "grit/generated_resources.h" |
36 #include "net/base/io_buffer.h" | 37 #include "net/base/io_buffer.h" |
37 #include "net/base/mock_file_stream.h" | 38 #include "net/base/mock_file_stream.h" |
38 #include "testing/gmock/include/gmock/gmock.h" | 39 #include "testing/gmock/include/gmock/gmock.h" |
39 #include "testing/gmock_mutant.h" | 40 #include "testing/gmock_mutant.h" |
40 #include "testing/gtest/include/gtest/gtest.h" | 41 #include "testing/gtest/include/gtest/gtest.h" |
41 #include "ui/base/l10n/l10n_util.h" | 42 #include "ui/base/l10n/l10n_util.h" |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
168 | 169 |
169 protected: | 170 protected: |
170 // This version creates a |MockFileStream| instead of a |FileStream|. | 171 // This version creates a |MockFileStream| instead of a |FileStream|. |
171 virtual void CreateFileStream() OVERRIDE; | 172 virtual void CreateFileStream() OVERRIDE; |
172 }; | 173 }; |
173 | 174 |
174 DownloadFileWithMockStream::DownloadFileWithMockStream( | 175 DownloadFileWithMockStream::DownloadFileWithMockStream( |
175 DownloadCreateInfo* info, | 176 DownloadCreateInfo* info, |
176 DownloadManager* manager, | 177 DownloadManager* manager, |
177 net::testing::MockFileStream* stream) | 178 net::testing::MockFileStream* stream) |
178 : DownloadFile(info, manager) { | 179 : DownloadFile(info, DownloadRequestHandle(), manager) { |
179 DCHECK(file_stream_ == NULL); | 180 DCHECK(file_stream_ == NULL); |
180 file_stream_.reset(stream); | 181 file_stream_.reset(stream); |
181 } | 182 } |
182 | 183 |
183 void DownloadFileWithMockStream::SetForcedError(int error) | 184 void DownloadFileWithMockStream::SetForcedError(int error) |
184 { | 185 { |
185 // |file_stream_| can only be set in the constructor and in | 186 // |file_stream_| can only be set in the constructor and in |
186 // CreateFileStream(), both of which insure that it is a |MockFileStream|. | 187 // CreateFileStream(), both of which insure that it is a |MockFileStream|. |
187 net::testing::MockFileStream* mock_stream = | 188 net::testing::MockFileStream* mock_stream = |
188 static_cast<net::testing::MockFileStream *>(file_stream_.get()); | 189 static_cast<net::testing::MockFileStream *>(file_stream_.get()); |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
266 // Dangerous download, download finishes AFTER file name determined. | 267 // Dangerous download, download finishes AFTER file name determined. |
267 // Needs to be renamed only once. | 268 // Needs to be renamed only once. |
268 { FILE_PATH_LITERAL("Unconfirmed xxx.crdownload"), true, false, false, 1, }, | 269 { FILE_PATH_LITERAL("Unconfirmed xxx.crdownload"), true, false, false, 1, }, |
269 { FILE_PATH_LITERAL("Unconfirmed xxx.crdownload"), false, true, false, 1, }, | 270 { FILE_PATH_LITERAL("Unconfirmed xxx.crdownload"), false, true, false, 1, }, |
270 { FILE_PATH_LITERAL("Unconfirmed xxx.crdownload"), true, true, false, 1, }, | 271 { FILE_PATH_LITERAL("Unconfirmed xxx.crdownload"), true, true, false, 1, }, |
271 }; | 272 }; |
272 | 273 |
273 class MockDownloadFile : public DownloadFile { | 274 class MockDownloadFile : public DownloadFile { |
274 public: | 275 public: |
275 MockDownloadFile(DownloadCreateInfo* info, DownloadManager* manager) | 276 MockDownloadFile(DownloadCreateInfo* info, DownloadManager* manager) |
276 : DownloadFile(info, manager), renamed_count_(0) { } | 277 : DownloadFile(info, DownloadRequestHandle(), manager), |
| 278 renamed_count_(0) { } |
277 virtual ~MockDownloadFile() { Destructed(); } | 279 virtual ~MockDownloadFile() { Destructed(); } |
278 MOCK_METHOD1(Rename, net::Error(const FilePath&)); | 280 MOCK_METHOD1(Rename, net::Error(const FilePath&)); |
279 MOCK_METHOD0(Destructed, void()); | 281 MOCK_METHOD0(Destructed, void()); |
280 | 282 |
281 net::Error TestMultipleRename( | 283 net::Error TestMultipleRename( |
282 int expected_count, const FilePath& expected, | 284 int expected_count, const FilePath& expected, |
283 const FilePath& path) { | 285 const FilePath& path) { |
284 ++renamed_count_; | 286 ++renamed_count_; |
285 EXPECT_EQ(expected_count, renamed_count_); | 287 EXPECT_EQ(expected_count, renamed_count_); |
286 EXPECT_EQ(expected.value(), path.value()); | 288 EXPECT_EQ(expected.value(), path.value()); |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
378 | 380 |
379 SelectFileObserver observer(download_manager_); | 381 SelectFileObserver observer(download_manager_); |
380 // Normally, the download system takes ownership of info, and is | 382 // Normally, the download system takes ownership of info, and is |
381 // responsible for deleting it. In these unit tests, however, we | 383 // responsible for deleting it. In these unit tests, however, we |
382 // don't call the function that deletes it, so we do so ourselves. | 384 // don't call the function that deletes it, so we do so ourselves. |
383 scoped_ptr<DownloadCreateInfo> info(new DownloadCreateInfo); | 385 scoped_ptr<DownloadCreateInfo> info(new DownloadCreateInfo); |
384 info->download_id = static_cast<int>(i); | 386 info->download_id = static_cast<int>(i); |
385 info->prompt_user_for_save_location = kStartDownloadCases[i].save_as; | 387 info->prompt_user_for_save_location = kStartDownloadCases[i].save_as; |
386 info->url_chain.push_back(GURL(kStartDownloadCases[i].url)); | 388 info->url_chain.push_back(GURL(kStartDownloadCases[i].url)); |
387 info->mime_type = kStartDownloadCases[i].mime_type; | 389 info->mime_type = kStartDownloadCases[i].mime_type; |
388 download_manager_->CreateDownloadItem(info.get()); | 390 download_manager_->CreateDownloadItem(info.get(), DownloadRequestHandle()); |
389 | 391 |
390 DownloadFile* download_file( | 392 DownloadFile* download_file( |
391 new DownloadFile(info.get(), download_manager_)); | 393 new DownloadFile(info.get(), DownloadRequestHandle(), |
| 394 download_manager_)); |
392 AddDownloadToFileManager(info->download_id, download_file); | 395 AddDownloadToFileManager(info->download_id, download_file); |
393 download_file->Initialize(false); | 396 download_file->Initialize(false); |
394 download_manager_->StartDownload(info->download_id); | 397 download_manager_->StartDownload(info->download_id); |
395 message_loop_.RunAllPending(); | 398 message_loop_.RunAllPending(); |
396 | 399 |
397 // SelectFileObserver will have recorded any attempt to open the | 400 // SelectFileObserver will have recorded any attempt to open the |
398 // select file dialog. | 401 // select file dialog. |
399 // Note that DownloadManager::FileSelectionCanceled() is never called. | 402 // Note that DownloadManager::FileSelectionCanceled() is never called. |
400 EXPECT_EQ(kStartDownloadCases[i].expected_save_as, | 403 EXPECT_EQ(kStartDownloadCases[i].expected_save_as, |
401 observer.ShowedFileDialogForId(i)); | 404 observer.ShowedFileDialogForId(i)); |
(...skipping 30 matching lines...) Expand all Loading... |
432 ASSERT_EQ(2, kDownloadRenameCases[i].expected_rename_count); | 435 ASSERT_EQ(2, kDownloadRenameCases[i].expected_rename_count); |
433 FilePath crdownload(download_util::GetCrDownloadPath(new_path)); | 436 FilePath crdownload(download_util::GetCrDownloadPath(new_path)); |
434 EXPECT_CALL(*download_file, Rename(_)) | 437 EXPECT_CALL(*download_file, Rename(_)) |
435 .WillOnce(testing::WithArgs<0>(Invoke(CreateFunctor( | 438 .WillOnce(testing::WithArgs<0>(Invoke(CreateFunctor( |
436 download_file, &MockDownloadFile::TestMultipleRename, | 439 download_file, &MockDownloadFile::TestMultipleRename, |
437 1, crdownload)))) | 440 1, crdownload)))) |
438 .WillOnce(testing::WithArgs<0>(Invoke(CreateFunctor( | 441 .WillOnce(testing::WithArgs<0>(Invoke(CreateFunctor( |
439 download_file, &MockDownloadFile::TestMultipleRename, | 442 download_file, &MockDownloadFile::TestMultipleRename, |
440 2, new_path)))); | 443 2, new_path)))); |
441 } | 444 } |
442 download_manager_->CreateDownloadItem(info.get()); | 445 download_manager_->CreateDownloadItem(info.get(), DownloadRequestHandle()); |
443 DownloadItem* download = GetActiveDownloadItem(i); | 446 DownloadItem* download = GetActiveDownloadItem(i); |
444 ASSERT_TRUE(download != NULL); | 447 ASSERT_TRUE(download != NULL); |
445 if (kDownloadRenameCases[i].is_dangerous_file) | 448 if (kDownloadRenameCases[i].is_dangerous_file) |
446 download->MarkFileDangerous(); | 449 download->MarkFileDangerous(); |
447 if (kDownloadRenameCases[i].is_dangerous_url) | 450 if (kDownloadRenameCases[i].is_dangerous_url) |
448 download->MarkUrlDangerous(); | 451 download->MarkUrlDangerous(); |
449 | 452 |
450 int32* id_ptr = new int32; | 453 int32* id_ptr = new int32; |
451 *id_ptr = i; // Deleted in FileSelected(). | 454 *id_ptr = i; // Deleted in FileSelected(). |
452 if (kDownloadRenameCases[i].finish_before_rename) { | 455 if (kDownloadRenameCases[i].finish_before_rename) { |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
486 MockDownloadFile* download_file( | 489 MockDownloadFile* download_file( |
487 new MockDownloadFile(info.get(), download_manager_)); | 490 new MockDownloadFile(info.get(), download_manager_)); |
488 AddDownloadToFileManager(info->download_id, download_file); | 491 AddDownloadToFileManager(info->download_id, download_file); |
489 | 492 |
490 // |download_file| is owned by DownloadFileManager. | 493 // |download_file| is owned by DownloadFileManager. |
491 ::testing::Mock::AllowLeak(download_file); | 494 ::testing::Mock::AllowLeak(download_file); |
492 EXPECT_CALL(*download_file, Destructed()).Times(1); | 495 EXPECT_CALL(*download_file, Destructed()).Times(1); |
493 | 496 |
494 EXPECT_CALL(*download_file, Rename(cr_path)).WillOnce(Return(net::OK)); | 497 EXPECT_CALL(*download_file, Rename(cr_path)).WillOnce(Return(net::OK)); |
495 | 498 |
496 download_manager_->CreateDownloadItem(info.get()); | 499 download_manager_->CreateDownloadItem(info.get(), DownloadRequestHandle()); |
497 | 500 |
498 DownloadItem* download = GetActiveDownloadItem(0); | 501 DownloadItem* download = GetActiveDownloadItem(0); |
499 ASSERT_TRUE(download != NULL); | 502 ASSERT_TRUE(download != NULL); |
500 scoped_ptr<DownloadItemModel> download_item_model( | 503 scoped_ptr<DownloadItemModel> download_item_model( |
501 new DownloadItemModel(download)); | 504 new DownloadItemModel(download)); |
502 | 505 |
503 EXPECT_EQ(DownloadItem::IN_PROGRESS, download->state()); | 506 EXPECT_EQ(DownloadItem::IN_PROGRESS, download->state()); |
504 scoped_ptr<ItemObserver> observer(new ItemObserver(download)); | 507 scoped_ptr<ItemObserver> observer(new ItemObserver(download)); |
505 | 508 |
506 download_file->AppendDataToFile(kTestData, kTestDataLen); | 509 download_file->AppendDataToFile(kTestData, kTestDataLen); |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
572 info->url_chain.push_back(GURL()); | 575 info->url_chain.push_back(GURL()); |
573 info->total_bytes = static_cast<int64>(kTestDataLen * 3); | 576 info->total_bytes = static_cast<int64>(kTestDataLen * 3); |
574 info->save_info.file_path = path; | 577 info->save_info.file_path = path; |
575 | 578 |
576 // Create a download file that we can insert errors into. | 579 // Create a download file that we can insert errors into. |
577 DownloadFileWithMockStream* download_file(new DownloadFileWithMockStream( | 580 DownloadFileWithMockStream* download_file(new DownloadFileWithMockStream( |
578 info.get(), download_manager_, mock_stream)); | 581 info.get(), download_manager_, mock_stream)); |
579 AddDownloadToFileManager(id, download_file); | 582 AddDownloadToFileManager(id, download_file); |
580 | 583 |
581 // |download_file| is owned by DownloadFileManager. | 584 // |download_file| is owned by DownloadFileManager. |
582 download_manager_->CreateDownloadItem(info.get()); | 585 download_manager_->CreateDownloadItem(info.get(), DownloadRequestHandle()); |
583 | 586 |
584 DownloadItem* download = GetActiveDownloadItem(0); | 587 DownloadItem* download = GetActiveDownloadItem(0); |
585 ASSERT_TRUE(download != NULL); | 588 ASSERT_TRUE(download != NULL); |
586 // This will keep track of what should be displayed on the shelf. | 589 // This will keep track of what should be displayed on the shelf. |
587 scoped_ptr<DownloadItemModel> download_item_model( | 590 scoped_ptr<DownloadItemModel> download_item_model( |
588 new DownloadItemModel(download)); | 591 new DownloadItemModel(download)); |
589 | 592 |
590 EXPECT_EQ(DownloadItem::IN_PROGRESS, download->state()); | 593 EXPECT_EQ(DownloadItem::IN_PROGRESS, download->state()); |
591 scoped_ptr<ItemObserver> observer(new ItemObserver(download)); | 594 scoped_ptr<ItemObserver> observer(new ItemObserver(download)); |
592 | 595 |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
654 MockDownloadFile* download_file( | 657 MockDownloadFile* download_file( |
655 new MockDownloadFile(info.get(), download_manager_)); | 658 new MockDownloadFile(info.get(), download_manager_)); |
656 AddDownloadToFileManager(info->download_id, download_file); | 659 AddDownloadToFileManager(info->download_id, download_file); |
657 | 660 |
658 // |download_file| is owned by DownloadFileManager. | 661 // |download_file| is owned by DownloadFileManager. |
659 ::testing::Mock::AllowLeak(download_file); | 662 ::testing::Mock::AllowLeak(download_file); |
660 EXPECT_CALL(*download_file, Destructed()).Times(1); | 663 EXPECT_CALL(*download_file, Destructed()).Times(1); |
661 | 664 |
662 EXPECT_CALL(*download_file, Rename(cr_path)).WillOnce(Return(net::OK)); | 665 EXPECT_CALL(*download_file, Rename(cr_path)).WillOnce(Return(net::OK)); |
663 | 666 |
664 download_manager_->CreateDownloadItem(info.get()); | 667 download_manager_->CreateDownloadItem(info.get(), DownloadRequestHandle()); |
665 | 668 |
666 DownloadItem* download = GetActiveDownloadItem(0); | 669 DownloadItem* download = GetActiveDownloadItem(0); |
667 ASSERT_TRUE(download != NULL); | 670 ASSERT_TRUE(download != NULL); |
668 scoped_ptr<DownloadItemModel> download_item_model( | 671 scoped_ptr<DownloadItemModel> download_item_model( |
669 new DownloadItemModel(download)); | 672 new DownloadItemModel(download)); |
670 | 673 |
671 EXPECT_EQ(DownloadItem::IN_PROGRESS, download->state()); | 674 EXPECT_EQ(DownloadItem::IN_PROGRESS, download->state()); |
672 scoped_ptr<ItemObserver> observer(new ItemObserver(download)); | 675 scoped_ptr<ItemObserver> observer(new ItemObserver(download)); |
673 | 676 |
674 ContinueDownloadWithPath(download, new_path); | 677 ContinueDownloadWithPath(download, new_path); |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
726 DownloadFile::AppendNumberToPath(&unique_new_path, uniquifier); | 729 DownloadFile::AppendNumberToPath(&unique_new_path, uniquifier); |
727 | 730 |
728 // Normally, the download system takes ownership of info, and is | 731 // Normally, the download system takes ownership of info, and is |
729 // responsible for deleting it. In these unit tests, however, we | 732 // responsible for deleting it. In these unit tests, however, we |
730 // don't call the function that deletes it, so we do so ourselves. | 733 // don't call the function that deletes it, so we do so ourselves. |
731 scoped_ptr<DownloadCreateInfo> info(new DownloadCreateInfo); | 734 scoped_ptr<DownloadCreateInfo> info(new DownloadCreateInfo); |
732 info->download_id = static_cast<int>(0); | 735 info->download_id = static_cast<int>(0); |
733 info->prompt_user_for_save_location = true; | 736 info->prompt_user_for_save_location = true; |
734 info->url_chain.push_back(GURL()); | 737 info->url_chain.push_back(GURL()); |
735 | 738 |
736 download_manager_->CreateDownloadItem(info.get()); | 739 download_manager_->CreateDownloadItem(info.get(), DownloadRequestHandle()); |
737 | 740 |
738 DownloadItem* download = GetActiveDownloadItem(0); | 741 DownloadItem* download = GetActiveDownloadItem(0); |
739 ASSERT_TRUE(download != NULL); | 742 ASSERT_TRUE(download != NULL); |
740 scoped_ptr<DownloadItemModel> download_item_model( | 743 scoped_ptr<DownloadItemModel> download_item_model( |
741 new DownloadItemModel(download)); | 744 new DownloadItemModel(download)); |
742 | 745 |
743 EXPECT_EQ(DownloadItem::IN_PROGRESS, download->state()); | 746 EXPECT_EQ(DownloadItem::IN_PROGRESS, download->state()); |
744 scoped_ptr<ItemObserver> observer(new ItemObserver(download)); | 747 scoped_ptr<ItemObserver> observer(new ItemObserver(download)); |
745 | 748 |
746 // Create and initialize the download file. We're bypassing the first part | 749 // Create and initialize the download file. We're bypassing the first part |
747 // of the download process and skipping to the part after the final file | 750 // of the download process and skipping to the part after the final file |
748 // name has been chosen, so we need to initialize the download file | 751 // name has been chosen, so we need to initialize the download file |
749 // properly. | 752 // properly. |
750 DownloadFile* download_file( | 753 DownloadFile* download_file( |
751 new DownloadFile(info.get(), download_manager_)); | 754 new DownloadFile(info.get(), DownloadRequestHandle(), download_manager_)); |
752 download_file->Rename(cr_path); | 755 download_file->Rename(cr_path); |
753 // This creates the .crdownload version of the file. | 756 // This creates the .crdownload version of the file. |
754 download_file->Initialize(false); | 757 download_file->Initialize(false); |
755 // |download_file| is owned by DownloadFileManager. | 758 // |download_file| is owned by DownloadFileManager. |
756 AddDownloadToFileManager(info->download_id, download_file); | 759 AddDownloadToFileManager(info->download_id, download_file); |
757 | 760 |
758 ContinueDownloadWithPath(download, new_path); | 761 ContinueDownloadWithPath(download, new_path); |
759 message_loop_.RunAllPending(); | 762 message_loop_.RunAllPending(); |
760 EXPECT_TRUE(GetActiveDownloadItem(0) != NULL); | 763 EXPECT_TRUE(GetActiveDownloadItem(0) != NULL); |
761 | 764 |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
802 EXPECT_FALSE(file_util::PathExists(new_path)); | 805 EXPECT_FALSE(file_util::PathExists(new_path)); |
803 | 806 |
804 // Normally, the download system takes ownership of info, and is | 807 // Normally, the download system takes ownership of info, and is |
805 // responsible for deleting it. In these unit tests, however, we | 808 // responsible for deleting it. In these unit tests, however, we |
806 // don't call the function that deletes it, so we do so ourselves. | 809 // don't call the function that deletes it, so we do so ourselves. |
807 scoped_ptr<DownloadCreateInfo> info(new DownloadCreateInfo); | 810 scoped_ptr<DownloadCreateInfo> info(new DownloadCreateInfo); |
808 info->download_id = static_cast<int>(0); | 811 info->download_id = static_cast<int>(0); |
809 info->prompt_user_for_save_location = true; | 812 info->prompt_user_for_save_location = true; |
810 info->url_chain.push_back(GURL()); | 813 info->url_chain.push_back(GURL()); |
811 | 814 |
812 download_manager_->CreateDownloadItem(info.get()); | 815 download_manager_->CreateDownloadItem(info.get(), DownloadRequestHandle()); |
813 | 816 |
814 DownloadItem* download = GetActiveDownloadItem(0); | 817 DownloadItem* download = GetActiveDownloadItem(0); |
815 ASSERT_TRUE(download != NULL); | 818 ASSERT_TRUE(download != NULL); |
816 scoped_ptr<DownloadItemModel> download_item_model( | 819 scoped_ptr<DownloadItemModel> download_item_model( |
817 new DownloadItemModel(download)); | 820 new DownloadItemModel(download)); |
818 | 821 |
819 EXPECT_EQ(DownloadItem::IN_PROGRESS, download->state()); | 822 EXPECT_EQ(DownloadItem::IN_PROGRESS, download->state()); |
820 scoped_ptr<ItemObserver> observer(new ItemObserver(download)); | 823 scoped_ptr<ItemObserver> observer(new ItemObserver(download)); |
821 | 824 |
822 // Create and initialize the download file. We're bypassing the first part | 825 // Create and initialize the download file. We're bypassing the first part |
823 // of the download process and skipping to the part after the final file | 826 // of the download process and skipping to the part after the final file |
824 // name has been chosen, so we need to initialize the download file | 827 // name has been chosen, so we need to initialize the download file |
825 // properly. | 828 // properly. |
826 DownloadFile* download_file( | 829 DownloadFile* download_file( |
827 new DownloadFile(info.get(), download_manager_)); | 830 new DownloadFile(info.get(), DownloadRequestHandle(), download_manager_)); |
828 download_file->Rename(cr_path); | 831 download_file->Rename(cr_path); |
829 // This creates the .crdownload version of the file. | 832 // This creates the .crdownload version of the file. |
830 download_file->Initialize(false); | 833 download_file->Initialize(false); |
831 // |download_file| is owned by DownloadFileManager. | 834 // |download_file| is owned by DownloadFileManager. |
832 AddDownloadToFileManager(info->download_id, download_file); | 835 AddDownloadToFileManager(info->download_id, download_file); |
833 | 836 |
834 ContinueDownloadWithPath(download, new_path); | 837 ContinueDownloadWithPath(download, new_path); |
835 message_loop_.RunAllPending(); | 838 message_loop_.RunAllPending(); |
836 EXPECT_TRUE(GetActiveDownloadItem(0) != NULL); | 839 EXPECT_TRUE(GetActiveDownloadItem(0) != NULL); |
837 | 840 |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
870 EXPECT_FALSE(observer->hit_state(DownloadItem::REMOVING)); | 873 EXPECT_FALSE(observer->hit_state(DownloadItem::REMOVING)); |
871 EXPECT_TRUE(observer->was_updated()); | 874 EXPECT_TRUE(observer->was_updated()); |
872 EXPECT_FALSE(observer->was_opened()); | 875 EXPECT_FALSE(observer->was_opened()); |
873 EXPECT_TRUE(download->file_externally_removed()); | 876 EXPECT_TRUE(download->file_externally_removed()); |
874 EXPECT_EQ(DownloadItem::COMPLETE, download->state()); | 877 EXPECT_EQ(DownloadItem::COMPLETE, download->state()); |
875 EXPECT_EQ(download_item_model->GetStatusText(), | 878 EXPECT_EQ(download_item_model->GetStatusText(), |
876 l10n_util::GetStringUTF16(IDS_DOWNLOAD_STATUS_REMOVED)); | 879 l10n_util::GetStringUTF16(IDS_DOWNLOAD_STATUS_REMOVED)); |
877 | 880 |
878 EXPECT_FALSE(file_util::PathExists(new_path)); | 881 EXPECT_FALSE(file_util::PathExists(new_path)); |
879 } | 882 } |
OLD | NEW |