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/command_line.h" | 5 #include "base/command_line.h" |
6 #include "base/message_loop.h" | 6 #include "base/message_loop.h" |
7 #include "base/stl_util.h" | 7 #include "base/stl_util.h" |
8 #include "base/threading/thread.h" | 8 #include "base/threading/thread.h" |
9 #include "content/browser/byte_stream.h" | 9 #include "content/browser/byte_stream.h" |
10 #include "content/browser/download/download_create_info.h" | 10 #include "content/browser/download/download_create_info.h" |
(...skipping 326 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
337 // State changing functions not tested: | 337 // State changing functions not tested: |
338 // void OpenDownload(); | 338 // void OpenDownload(); |
339 // void ShowDownloadInShell(); | 339 // void ShowDownloadInShell(); |
340 // void CompleteDelayedDownload(); | 340 // void CompleteDelayedDownload(); |
341 // set_* mutators | 341 // set_* mutators |
342 | 342 |
343 TEST_F(DownloadItemTest, NotificationAfterUpdate) { | 343 TEST_F(DownloadItemTest, NotificationAfterUpdate) { |
344 DownloadItemImpl* item = CreateDownloadItem(); | 344 DownloadItemImpl* item = CreateDownloadItem(); |
345 MockObserver observer(item); | 345 MockObserver observer(item); |
346 | 346 |
347 item->UpdateProgress(kDownloadChunkSize, kDownloadSpeed, ""); | 347 item->UpdateProgress(kDownloadChunkSize, kDownloadSpeed, std::string()); |
348 ASSERT_TRUE(observer.CheckUpdated()); | 348 ASSERT_TRUE(observer.CheckUpdated()); |
349 EXPECT_EQ(kDownloadSpeed, item->CurrentSpeed()); | 349 EXPECT_EQ(kDownloadSpeed, item->CurrentSpeed()); |
350 } | 350 } |
351 | 351 |
352 TEST_F(DownloadItemTest, NotificationAfterCancel) { | 352 TEST_F(DownloadItemTest, NotificationAfterCancel) { |
353 DownloadItemImpl* user_cancel = CreateDownloadItem(); | 353 DownloadItemImpl* user_cancel = CreateDownloadItem(); |
354 MockDownloadFile* download_file = | 354 MockDownloadFile* download_file = |
355 AddDownloadFileToDownloadItem(user_cancel, NULL); | 355 AddDownloadFileToDownloadItem(user_cancel, NULL); |
356 EXPECT_CALL(*download_file, Cancel()); | 356 EXPECT_CALL(*download_file, Cancel()); |
357 MockObserver observer1(user_cancel); | 357 MockObserver observer1(user_cancel); |
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
538 item->Remove(); | 538 item->Remove(); |
539 ASSERT_TRUE(observer.CheckUpdated()); | 539 ASSERT_TRUE(observer.CheckUpdated()); |
540 ASSERT_TRUE(observer.CheckRemoved()); | 540 ASSERT_TRUE(observer.CheckRemoved()); |
541 } | 541 } |
542 | 542 |
543 TEST_F(DownloadItemTest, NotificationAfterOnContentCheckCompleted) { | 543 TEST_F(DownloadItemTest, NotificationAfterOnContentCheckCompleted) { |
544 // Setting to NOT_DANGEROUS does not trigger a notification. | 544 // Setting to NOT_DANGEROUS does not trigger a notification. |
545 DownloadItemImpl* safe_item = CreateDownloadItem(); | 545 DownloadItemImpl* safe_item = CreateDownloadItem(); |
546 MockObserver safe_observer(safe_item); | 546 MockObserver safe_observer(safe_item); |
547 | 547 |
548 safe_item->OnAllDataSaved(""); | 548 safe_item->OnAllDataSaved(std::string()); |
549 EXPECT_TRUE(safe_observer.CheckUpdated()); | 549 EXPECT_TRUE(safe_observer.CheckUpdated()); |
550 safe_item->OnContentCheckCompleted(DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS); | 550 safe_item->OnContentCheckCompleted(DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS); |
551 EXPECT_TRUE(safe_observer.CheckUpdated()); | 551 EXPECT_TRUE(safe_observer.CheckUpdated()); |
552 | 552 |
553 // Setting to unsafe url or unsafe file should trigger a notification. | 553 // Setting to unsafe url or unsafe file should trigger a notification. |
554 DownloadItemImpl* unsafeurl_item = | 554 DownloadItemImpl* unsafeurl_item = |
555 CreateDownloadItem(); | 555 CreateDownloadItem(); |
556 MockObserver unsafeurl_observer(unsafeurl_item); | 556 MockObserver unsafeurl_observer(unsafeurl_item); |
557 | 557 |
558 unsafeurl_item->OnAllDataSaved(""); | 558 unsafeurl_item->OnAllDataSaved(std::string()); |
559 EXPECT_TRUE(unsafeurl_observer.CheckUpdated()); | 559 EXPECT_TRUE(unsafeurl_observer.CheckUpdated()); |
560 unsafeurl_item->OnContentCheckCompleted(DOWNLOAD_DANGER_TYPE_DANGEROUS_URL); | 560 unsafeurl_item->OnContentCheckCompleted(DOWNLOAD_DANGER_TYPE_DANGEROUS_URL); |
561 EXPECT_TRUE(unsafeurl_observer.CheckUpdated()); | 561 EXPECT_TRUE(unsafeurl_observer.CheckUpdated()); |
562 | 562 |
563 unsafeurl_item->DangerousDownloadValidated(); | 563 unsafeurl_item->DangerousDownloadValidated(); |
564 EXPECT_TRUE(unsafeurl_observer.CheckUpdated()); | 564 EXPECT_TRUE(unsafeurl_observer.CheckUpdated()); |
565 | 565 |
566 DownloadItemImpl* unsafefile_item = | 566 DownloadItemImpl* unsafefile_item = |
567 CreateDownloadItem(); | 567 CreateDownloadItem(); |
568 MockObserver unsafefile_observer(unsafefile_item); | 568 MockObserver unsafefile_observer(unsafefile_item); |
569 | 569 |
570 unsafefile_item->OnAllDataSaved(""); | 570 unsafefile_item->OnAllDataSaved(std::string()); |
571 EXPECT_TRUE(unsafefile_observer.CheckUpdated()); | 571 EXPECT_TRUE(unsafefile_observer.CheckUpdated()); |
572 unsafefile_item->OnContentCheckCompleted(DOWNLOAD_DANGER_TYPE_DANGEROUS_FILE); | 572 unsafefile_item->OnContentCheckCompleted(DOWNLOAD_DANGER_TYPE_DANGEROUS_FILE); |
573 EXPECT_TRUE(unsafefile_observer.CheckUpdated()); | 573 EXPECT_TRUE(unsafefile_observer.CheckUpdated()); |
574 | 574 |
575 unsafefile_item->DangerousDownloadValidated(); | 575 unsafefile_item->DangerousDownloadValidated(); |
576 EXPECT_TRUE(unsafefile_observer.CheckUpdated()); | 576 EXPECT_TRUE(unsafefile_observer.CheckUpdated()); |
577 } | 577 } |
578 | 578 |
579 // DownloadItemImpl::OnDownloadTargetDetermined will schedule a task to run | 579 // DownloadItemImpl::OnDownloadTargetDetermined will schedule a task to run |
580 // DownloadFile::Rename(). Once the rename | 580 // DownloadFile::Rename(). Once the rename |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
690 // All the callbacks should have happened by now. | 690 // All the callbacks should have happened by now. |
691 ::testing::Mock::VerifyAndClearExpectations(download_file); | 691 ::testing::Mock::VerifyAndClearExpectations(download_file); |
692 mock_delegate()->VerifyAndClearExpectations(); | 692 mock_delegate()->VerifyAndClearExpectations(); |
693 | 693 |
694 EXPECT_CALL(*mock_delegate(), ShouldCompleteDownload(item, _)) | 694 EXPECT_CALL(*mock_delegate(), ShouldCompleteDownload(item, _)) |
695 .WillOnce(Return(true)); | 695 .WillOnce(Return(true)); |
696 EXPECT_CALL(*download_file, RenameAndAnnotate(final_path, _)) | 696 EXPECT_CALL(*download_file, RenameAndAnnotate(final_path, _)) |
697 .WillOnce(ScheduleRenameCallback(DOWNLOAD_INTERRUPT_REASON_NONE, | 697 .WillOnce(ScheduleRenameCallback(DOWNLOAD_INTERRUPT_REASON_NONE, |
698 final_path)); | 698 final_path)); |
699 EXPECT_CALL(*download_file, Detach()); | 699 EXPECT_CALL(*download_file, Detach()); |
700 item->DestinationObserverAsWeakPtr()->DestinationCompleted(""); | 700 item->DestinationObserverAsWeakPtr()->DestinationCompleted(std::string()); |
701 RunAllPendingInMessageLoops(); | 701 RunAllPendingInMessageLoops(); |
702 ::testing::Mock::VerifyAndClearExpectations(download_file); | 702 ::testing::Mock::VerifyAndClearExpectations(download_file); |
703 mock_delegate()->VerifyAndClearExpectations(); | 703 mock_delegate()->VerifyAndClearExpectations(); |
704 } | 704 } |
705 | 705 |
706 // Test that the delegate is invoked after the download file is renamed and the | 706 // Test that the delegate is invoked after the download file is renamed and the |
707 // download item is in an interrupted state. | 707 // download item is in an interrupted state. |
708 TEST_F(DownloadItemTest, CallbackAfterInterruptedRename) { | 708 TEST_F(DownloadItemTest, CallbackAfterInterruptedRename) { |
709 DownloadItemImpl* item = CreateDownloadItem(); | 709 DownloadItemImpl* item = CreateDownloadItem(); |
710 DownloadItemImplDelegate::DownloadTargetCallback callback; | 710 DownloadItemImplDelegate::DownloadTargetCallback callback; |
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
855 EXPECT_TRUE(item->CanShowInFolder()); | 855 EXPECT_TRUE(item->CanShowInFolder()); |
856 EXPECT_TRUE(item->CanOpenDownload()); | 856 EXPECT_TRUE(item->CanOpenDownload()); |
857 | 857 |
858 // Complete | 858 // Complete |
859 EXPECT_CALL(*download_file, RenameAndAnnotate(_, _)) | 859 EXPECT_CALL(*download_file, RenameAndAnnotate(_, _)) |
860 .WillOnce(ScheduleRenameCallback(DOWNLOAD_INTERRUPT_REASON_NONE, | 860 .WillOnce(ScheduleRenameCallback(DOWNLOAD_INTERRUPT_REASON_NONE, |
861 base::FilePath(kDummyPath))); | 861 base::FilePath(kDummyPath))); |
862 EXPECT_CALL(*mock_delegate(), ShouldCompleteDownload(item, _)) | 862 EXPECT_CALL(*mock_delegate(), ShouldCompleteDownload(item, _)) |
863 .WillOnce(Return(true)); | 863 .WillOnce(Return(true)); |
864 EXPECT_CALL(*download_file, Detach()); | 864 EXPECT_CALL(*download_file, Detach()); |
865 item->DestinationObserverAsWeakPtr()->DestinationCompleted(""); | 865 item->DestinationObserverAsWeakPtr()->DestinationCompleted(std::string()); |
866 RunAllPendingInMessageLoops(); | 866 RunAllPendingInMessageLoops(); |
867 | 867 |
868 ASSERT_TRUE(item->IsComplete()); | 868 ASSERT_TRUE(item->IsComplete()); |
869 EXPECT_TRUE(item->CanShowInFolder()); | 869 EXPECT_TRUE(item->CanShowInFolder()); |
870 EXPECT_TRUE(item->CanOpenDownload()); | 870 EXPECT_TRUE(item->CanOpenDownload()); |
871 } | 871 } |
872 | 872 |
873 TEST_F(DownloadItemTest, EnabledActionsForTemporaryDownload) { | 873 TEST_F(DownloadItemTest, EnabledActionsForTemporaryDownload) { |
874 DownloadItemImpl* item = CreateDownloadItem(); | 874 DownloadItemImpl* item = CreateDownloadItem(); |
875 MockDownloadFile* download_file = DoIntermediateRename(item); | 875 MockDownloadFile* download_file = DoIntermediateRename(item); |
876 item->SetIsTemporary(true); | 876 item->SetIsTemporary(true); |
877 | 877 |
878 // InProgress Temporary | 878 // InProgress Temporary |
879 ASSERT_TRUE(item->IsInProgress()); | 879 ASSERT_TRUE(item->IsInProgress()); |
880 ASSERT_FALSE(item->GetTargetFilePath().empty()); | 880 ASSERT_FALSE(item->GetTargetFilePath().empty()); |
881 ASSERT_TRUE(item->IsTemporary()); | 881 ASSERT_TRUE(item->IsTemporary()); |
882 EXPECT_FALSE(item->CanShowInFolder()); | 882 EXPECT_FALSE(item->CanShowInFolder()); |
883 EXPECT_FALSE(item->CanOpenDownload()); | 883 EXPECT_FALSE(item->CanOpenDownload()); |
884 | 884 |
885 // Complete Temporary | 885 // Complete Temporary |
886 EXPECT_CALL(*mock_delegate(), ShouldCompleteDownload(item, _)) | 886 EXPECT_CALL(*mock_delegate(), ShouldCompleteDownload(item, _)) |
887 .WillOnce(Return(true)); | 887 .WillOnce(Return(true)); |
888 EXPECT_CALL(*download_file, RenameAndAnnotate(_, _)) | 888 EXPECT_CALL(*download_file, RenameAndAnnotate(_, _)) |
889 .WillOnce(ScheduleRenameCallback(DOWNLOAD_INTERRUPT_REASON_NONE, | 889 .WillOnce(ScheduleRenameCallback(DOWNLOAD_INTERRUPT_REASON_NONE, |
890 base::FilePath(kDummyPath))); | 890 base::FilePath(kDummyPath))); |
891 EXPECT_CALL(*download_file, Detach()); | 891 EXPECT_CALL(*download_file, Detach()); |
892 item->DestinationObserverAsWeakPtr()->DestinationCompleted(""); | 892 item->DestinationObserverAsWeakPtr()->DestinationCompleted(std::string()); |
893 RunAllPendingInMessageLoops(); | 893 RunAllPendingInMessageLoops(); |
894 | 894 |
895 ASSERT_TRUE(item->IsComplete()); | 895 ASSERT_TRUE(item->IsComplete()); |
896 EXPECT_FALSE(item->CanShowInFolder()); | 896 EXPECT_FALSE(item->CanShowInFolder()); |
897 EXPECT_FALSE(item->CanOpenDownload()); | 897 EXPECT_FALSE(item->CanOpenDownload()); |
898 } | 898 } |
899 | 899 |
900 TEST_F(DownloadItemTest, EnabledActionsForInterruptedDownload) { | 900 TEST_F(DownloadItemTest, EnabledActionsForInterruptedDownload) { |
901 DownloadItemImpl* item = CreateDownloadItem(); | 901 DownloadItemImpl* item = CreateDownloadItem(); |
902 MockDownloadFile* download_file = DoIntermediateRename(item); | 902 MockDownloadFile* download_file = DoIntermediateRename(item); |
(...skipping 27 matching lines...) Expand all Loading... |
930 // Just allowing completion. | 930 // Just allowing completion. |
931 TEST_F(DownloadItemTest, CompleteDelegate_ReturnTrue) { | 931 TEST_F(DownloadItemTest, CompleteDelegate_ReturnTrue) { |
932 // Test to confirm that if we have a callback that returns true, | 932 // Test to confirm that if we have a callback that returns true, |
933 // we complete immediately. | 933 // we complete immediately. |
934 DownloadItemImpl* item = CreateDownloadItem(); | 934 DownloadItemImpl* item = CreateDownloadItem(); |
935 MockDownloadFile* download_file = DoIntermediateRename(item); | 935 MockDownloadFile* download_file = DoIntermediateRename(item); |
936 | 936 |
937 // Drive the delegate interaction. | 937 // Drive the delegate interaction. |
938 EXPECT_CALL(*mock_delegate(), ShouldCompleteDownload(item, _)) | 938 EXPECT_CALL(*mock_delegate(), ShouldCompleteDownload(item, _)) |
939 .WillOnce(Return(true)); | 939 .WillOnce(Return(true)); |
940 item->DestinationObserverAsWeakPtr()->DestinationCompleted(""); | 940 item->DestinationObserverAsWeakPtr()->DestinationCompleted(std::string()); |
941 EXPECT_EQ(DownloadItem::IN_PROGRESS, item->GetState()); | 941 EXPECT_EQ(DownloadItem::IN_PROGRESS, item->GetState()); |
942 EXPECT_FALSE(item->IsDangerous()); | 942 EXPECT_FALSE(item->IsDangerous()); |
943 | 943 |
944 // Make sure the download can complete. | 944 // Make sure the download can complete. |
945 EXPECT_CALL(*download_file, RenameAndAnnotate(base::FilePath(kDummyPath), _)) | 945 EXPECT_CALL(*download_file, RenameAndAnnotate(base::FilePath(kDummyPath), _)) |
946 .WillOnce(ScheduleRenameCallback(DOWNLOAD_INTERRUPT_REASON_NONE, | 946 .WillOnce(ScheduleRenameCallback(DOWNLOAD_INTERRUPT_REASON_NONE, |
947 base::FilePath(kDummyPath))); | 947 base::FilePath(kDummyPath))); |
948 EXPECT_CALL(*mock_delegate(), ShouldOpenDownload(item, _)) | 948 EXPECT_CALL(*mock_delegate(), ShouldOpenDownload(item, _)) |
949 .WillOnce(Return(true)); | 949 .WillOnce(Return(true)); |
950 EXPECT_CALL(*download_file, Detach()); | 950 EXPECT_CALL(*download_file, Detach()); |
951 RunAllPendingInMessageLoops(); | 951 RunAllPendingInMessageLoops(); |
952 EXPECT_EQ(DownloadItem::COMPLETE, item->GetState()); | 952 EXPECT_EQ(DownloadItem::COMPLETE, item->GetState()); |
953 } | 953 } |
954 | 954 |
955 // Just delaying completion. | 955 // Just delaying completion. |
956 TEST_F(DownloadItemTest, CompleteDelegate_BlockOnce) { | 956 TEST_F(DownloadItemTest, CompleteDelegate_BlockOnce) { |
957 // Test to confirm that if we have a callback that returns true, | 957 // Test to confirm that if we have a callback that returns true, |
958 // we complete immediately. | 958 // we complete immediately. |
959 DownloadItemImpl* item = CreateDownloadItem(); | 959 DownloadItemImpl* item = CreateDownloadItem(); |
960 MockDownloadFile* download_file = DoIntermediateRename(item); | 960 MockDownloadFile* download_file = DoIntermediateRename(item); |
961 | 961 |
962 // Drive the delegate interaction. | 962 // Drive the delegate interaction. |
963 base::Closure delegate_callback; | 963 base::Closure delegate_callback; |
964 base::Closure copy_delegate_callback; | 964 base::Closure copy_delegate_callback; |
965 EXPECT_CALL(*mock_delegate(), ShouldCompleteDownload(item, _)) | 965 EXPECT_CALL(*mock_delegate(), ShouldCompleteDownload(item, _)) |
966 .WillOnce(DoAll(SaveArg<1>(&delegate_callback), | 966 .WillOnce(DoAll(SaveArg<1>(&delegate_callback), |
967 Return(false))) | 967 Return(false))) |
968 .WillOnce(Return(true)); | 968 .WillOnce(Return(true)); |
969 item->DestinationObserverAsWeakPtr()->DestinationCompleted(""); | 969 item->DestinationObserverAsWeakPtr()->DestinationCompleted(std::string()); |
970 ASSERT_FALSE(delegate_callback.is_null()); | 970 ASSERT_FALSE(delegate_callback.is_null()); |
971 copy_delegate_callback = delegate_callback; | 971 copy_delegate_callback = delegate_callback; |
972 delegate_callback.Reset(); | 972 delegate_callback.Reset(); |
973 EXPECT_EQ(DownloadItem::IN_PROGRESS, item->GetState()); | 973 EXPECT_EQ(DownloadItem::IN_PROGRESS, item->GetState()); |
974 copy_delegate_callback.Run(); | 974 copy_delegate_callback.Run(); |
975 ASSERT_TRUE(delegate_callback.is_null()); | 975 ASSERT_TRUE(delegate_callback.is_null()); |
976 EXPECT_EQ(DownloadItem::IN_PROGRESS, item->GetState()); | 976 EXPECT_EQ(DownloadItem::IN_PROGRESS, item->GetState()); |
977 EXPECT_FALSE(item->IsDangerous()); | 977 EXPECT_FALSE(item->IsDangerous()); |
978 | 978 |
979 // Make sure the download can complete. | 979 // Make sure the download can complete. |
(...skipping 14 matching lines...) Expand all Loading... |
994 DownloadItemImpl* item = CreateDownloadItem(); | 994 DownloadItemImpl* item = CreateDownloadItem(); |
995 MockDownloadFile* download_file = DoIntermediateRename(item); | 995 MockDownloadFile* download_file = DoIntermediateRename(item); |
996 | 996 |
997 // Drive the delegate interaction. | 997 // Drive the delegate interaction. |
998 base::Closure delegate_callback; | 998 base::Closure delegate_callback; |
999 base::Closure copy_delegate_callback; | 999 base::Closure copy_delegate_callback; |
1000 EXPECT_CALL(*mock_delegate(), ShouldCompleteDownload(item, _)) | 1000 EXPECT_CALL(*mock_delegate(), ShouldCompleteDownload(item, _)) |
1001 .WillOnce(DoAll(SaveArg<1>(&delegate_callback), | 1001 .WillOnce(DoAll(SaveArg<1>(&delegate_callback), |
1002 Return(false))) | 1002 Return(false))) |
1003 .WillOnce(Return(true)); | 1003 .WillOnce(Return(true)); |
1004 item->DestinationObserverAsWeakPtr()->DestinationCompleted(""); | 1004 item->DestinationObserverAsWeakPtr()->DestinationCompleted(std::string()); |
1005 ASSERT_FALSE(delegate_callback.is_null()); | 1005 ASSERT_FALSE(delegate_callback.is_null()); |
1006 copy_delegate_callback = delegate_callback; | 1006 copy_delegate_callback = delegate_callback; |
1007 delegate_callback.Reset(); | 1007 delegate_callback.Reset(); |
1008 EXPECT_FALSE(item->IsDangerous()); | 1008 EXPECT_FALSE(item->IsDangerous()); |
1009 item->OnContentCheckCompleted( | 1009 item->OnContentCheckCompleted( |
1010 content::DOWNLOAD_DANGER_TYPE_DANGEROUS_FILE); | 1010 content::DOWNLOAD_DANGER_TYPE_DANGEROUS_FILE); |
1011 EXPECT_EQ(DownloadItem::IN_PROGRESS, item->GetState()); | 1011 EXPECT_EQ(DownloadItem::IN_PROGRESS, item->GetState()); |
1012 copy_delegate_callback.Run(); | 1012 copy_delegate_callback.Run(); |
1013 ASSERT_TRUE(delegate_callback.is_null()); | 1013 ASSERT_TRUE(delegate_callback.is_null()); |
1014 EXPECT_EQ(DownloadItem::IN_PROGRESS, item->GetState()); | 1014 EXPECT_EQ(DownloadItem::IN_PROGRESS, item->GetState()); |
(...skipping 25 matching lines...) Expand all Loading... |
1040 | 1040 |
1041 // Drive the delegate interaction. | 1041 // Drive the delegate interaction. |
1042 base::Closure delegate_callback; | 1042 base::Closure delegate_callback; |
1043 base::Closure copy_delegate_callback; | 1043 base::Closure copy_delegate_callback; |
1044 EXPECT_CALL(*mock_delegate(), ShouldCompleteDownload(item, _)) | 1044 EXPECT_CALL(*mock_delegate(), ShouldCompleteDownload(item, _)) |
1045 .WillOnce(DoAll(SaveArg<1>(&delegate_callback), | 1045 .WillOnce(DoAll(SaveArg<1>(&delegate_callback), |
1046 Return(false))) | 1046 Return(false))) |
1047 .WillOnce(DoAll(SaveArg<1>(&delegate_callback), | 1047 .WillOnce(DoAll(SaveArg<1>(&delegate_callback), |
1048 Return(false))) | 1048 Return(false))) |
1049 .WillOnce(Return(true)); | 1049 .WillOnce(Return(true)); |
1050 item->DestinationObserverAsWeakPtr()->DestinationCompleted(""); | 1050 item->DestinationObserverAsWeakPtr()->DestinationCompleted(std::string()); |
1051 ASSERT_FALSE(delegate_callback.is_null()); | 1051 ASSERT_FALSE(delegate_callback.is_null()); |
1052 copy_delegate_callback = delegate_callback; | 1052 copy_delegate_callback = delegate_callback; |
1053 delegate_callback.Reset(); | 1053 delegate_callback.Reset(); |
1054 EXPECT_EQ(DownloadItem::IN_PROGRESS, item->GetState()); | 1054 EXPECT_EQ(DownloadItem::IN_PROGRESS, item->GetState()); |
1055 copy_delegate_callback.Run(); | 1055 copy_delegate_callback.Run(); |
1056 ASSERT_FALSE(delegate_callback.is_null()); | 1056 ASSERT_FALSE(delegate_callback.is_null()); |
1057 copy_delegate_callback = delegate_callback; | 1057 copy_delegate_callback = delegate_callback; |
1058 delegate_callback.Reset(); | 1058 delegate_callback.Reset(); |
1059 EXPECT_EQ(DownloadItem::IN_PROGRESS, item->GetState()); | 1059 EXPECT_EQ(DownloadItem::IN_PROGRESS, item->GetState()); |
1060 copy_delegate_callback.Run(); | 1060 copy_delegate_callback.Run(); |
(...skipping 10 matching lines...) Expand all Loading... |
1071 EXPECT_CALL(*download_file, Detach()); | 1071 EXPECT_CALL(*download_file, Detach()); |
1072 RunAllPendingInMessageLoops(); | 1072 RunAllPendingInMessageLoops(); |
1073 EXPECT_EQ(DownloadItem::COMPLETE, item->GetState()); | 1073 EXPECT_EQ(DownloadItem::COMPLETE, item->GetState()); |
1074 } | 1074 } |
1075 | 1075 |
1076 TEST(MockDownloadItem, Compiles) { | 1076 TEST(MockDownloadItem, Compiles) { |
1077 MockDownloadItem mock_item; | 1077 MockDownloadItem mock_item; |
1078 } | 1078 } |
1079 | 1079 |
1080 } // namespace content | 1080 } // namespace content |
OLD | NEW |