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 "base/message_loop.h" | 5 #include "base/message_loop.h" |
6 #include "base/stl_util.h" | 6 #include "base/stl_util.h" |
7 #include "base/threading/thread.h" | 7 #include "base/threading/thread.h" |
8 #include "content/browser/download/byte_stream.h" | 8 #include "content/browser/download/byte_stream.h" |
9 #include "content/browser/download/download_create_info.h" | 9 #include "content/browser/download/download_create_info.h" |
10 #include "content/browser/download/download_file_factory.h" | 10 #include "content/browser/download/download_file_factory.h" |
(...skipping 442 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
453 EXPECT_CALL(*mock_delegate(), ShowDownloadInBrowser(item)) | 453 EXPECT_CALL(*mock_delegate(), ShowDownloadInBrowser(item)) |
454 .Times(1); | 454 .Times(1); |
455 | 455 |
456 callback.Run(final_path, DownloadItem::TARGET_DISPOSITION_OVERWRITE, | 456 callback.Run(final_path, DownloadItem::TARGET_DISPOSITION_OVERWRITE, |
457 DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS, intermediate_path); | 457 DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS, intermediate_path); |
458 RunAllPendingInMessageLoops(); | 458 RunAllPendingInMessageLoops(); |
459 // All the callbacks should have happened by now. | 459 // All the callbacks should have happened by now. |
460 ::testing::Mock::VerifyAndClearExpectations(download_file); | 460 ::testing::Mock::VerifyAndClearExpectations(download_file); |
461 ::testing::Mock::VerifyAndClearExpectations(mock_delegate()); | 461 ::testing::Mock::VerifyAndClearExpectations(mock_delegate()); |
462 | 462 |
463 item->OnAllDataSaved(""); | |
464 EXPECT_CALL(*download_file, RenameAndAnnotate(final_path, _)) | 463 EXPECT_CALL(*download_file, RenameAndAnnotate(final_path, _)) |
465 .WillOnce(ScheduleRenameCallback(final_path)); | 464 .WillOnce(ScheduleRenameCallback(final_path)); |
466 EXPECT_CALL(*mock_delegate(), ShouldOpenDownload(item, _)) | 465 EXPECT_CALL(*mock_delegate(), ShouldOpenDownload(item, _)) |
467 .WillOnce(Return(true)); | 466 .WillOnce(Return(true)); |
468 EXPECT_CALL(*download_file, Detach()); | 467 EXPECT_CALL(*download_file, Detach()); |
469 item->MaybeCompleteDownload(); | 468 item->DestinationObserverAsWeakPtr()->DestinationCompleted(""); |
470 RunAllPendingInMessageLoops(); | 469 RunAllPendingInMessageLoops(); |
471 ::testing::Mock::VerifyAndClearExpectations(download_file); | 470 ::testing::Mock::VerifyAndClearExpectations(download_file); |
472 ::testing::Mock::VerifyAndClearExpectations(mock_delegate()); | 471 ::testing::Mock::VerifyAndClearExpectations(mock_delegate()); |
473 } | 472 } |
474 | 473 |
475 TEST_F(DownloadItemTest, Interrupted) { | 474 TEST_F(DownloadItemTest, Interrupted) { |
476 DownloadItemImpl* item = CreateDownloadItem(DownloadItem::IN_PROGRESS); | 475 DownloadItemImpl* item = CreateDownloadItem(DownloadItem::IN_PROGRESS); |
477 MockDownloadFile* download_file = AddDownloadFileToDownloadItem(item, NULL); | 476 MockDownloadFile* download_file = AddDownloadFileToDownloadItem(item, NULL); |
478 | 477 |
479 const DownloadInterruptReason reason( | 478 const DownloadInterruptReason reason( |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
587 EXPECT_EQ("livebeef", item->GetHash()); | 586 EXPECT_EQ("livebeef", item->GetHash()); |
588 EXPECT_EQ("", item->GetHashState()); | 587 EXPECT_EQ("", item->GetHashState()); |
589 EXPECT_TRUE(item->AllDataSaved()); | 588 EXPECT_TRUE(item->AllDataSaved()); |
590 } | 589 } |
591 | 590 |
592 TEST(MockDownloadItem, Compiles) { | 591 TEST(MockDownloadItem, Compiles) { |
593 MockDownloadItem mock_item; | 592 MockDownloadItem mock_item; |
594 } | 593 } |
595 | 594 |
596 } // namespace content | 595 } // namespace content |
OLD | NEW |