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 // This file contains download browser tests that are known to be runnable | 5 // This file contains download browser tests that are known to be runnable |
6 // in a pure content context. Over time tests should be migrated here. | 6 // in a pure content context. Over time tests should be migrated here. |
7 | 7 |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "base/file_util.h" | 9 #include "base/file_util.h" |
10 #include "base/files/file_path.h" | 10 #include "base/files/file_path.h" |
(...skipping 939 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
950 // crashes. | 950 // crashes. |
951 DownloadManagerForShell(shell())->Shutdown(); | 951 DownloadManagerForShell(shell())->Shutdown(); |
952 } | 952 } |
953 | 953 |
954 IN_PROC_BROWSER_TEST_F(DownloadContentTest, ResumeInterruptedDownload) { | 954 IN_PROC_BROWSER_TEST_F(DownloadContentTest, ResumeInterruptedDownload) { |
955 CommandLine::ForCurrentProcess()->AppendSwitch( | 955 CommandLine::ForCurrentProcess()->AppendSwitch( |
956 switches::kEnableDownloadResumption); | 956 switches::kEnableDownloadResumption); |
957 ASSERT_TRUE(test_server()->Start()); | 957 ASSERT_TRUE(test_server()->Start()); |
958 | 958 |
959 GURL url = test_server()->GetURL( | 959 GURL url = test_server()->GetURL( |
960 StringPrintf("rangereset?size=%d&rst_boundary=%d", | 960 base::StringPrintf("rangereset?size=%d&rst_boundary=%d", |
961 GetSafeBufferChunk() * 3, GetSafeBufferChunk())); | 961 GetSafeBufferChunk() * 3, GetSafeBufferChunk())); |
962 | 962 |
963 DownloadItem* download(StartDownloadAndReturnItem(url)); | 963 DownloadItem* download(StartDownloadAndReturnItem(url)); |
964 WaitForData(download, GetSafeBufferChunk()); | 964 WaitForData(download, GetSafeBufferChunk()); |
965 | 965 |
966 // Confirm resumption while in progress doesn't do anything. | 966 // Confirm resumption while in progress doesn't do anything. |
967 download->ResumeInterruptedDownload(); | 967 download->ResumeInterruptedDownload(); |
968 ASSERT_EQ(GetSafeBufferChunk(), download->GetReceivedBytes()); | 968 ASSERT_EQ(GetSafeBufferChunk(), download->GetReceivedBytes()); |
969 ASSERT_EQ(DownloadItem::IN_PROGRESS, download->GetState()); | 969 ASSERT_EQ(DownloadItem::IN_PROGRESS, download->GetState()); |
970 | 970 |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1011 } | 1011 } |
1012 | 1012 |
1013 // Confirm restart fallback happens if a range request is bounced. | 1013 // Confirm restart fallback happens if a range request is bounced. |
1014 IN_PROC_BROWSER_TEST_F(DownloadContentTest, ResumeInterruptedDownloadNoRange) { | 1014 IN_PROC_BROWSER_TEST_F(DownloadContentTest, ResumeInterruptedDownloadNoRange) { |
1015 CommandLine::ForCurrentProcess()->AppendSwitch( | 1015 CommandLine::ForCurrentProcess()->AppendSwitch( |
1016 switches::kEnableDownloadResumption); | 1016 switches::kEnableDownloadResumption); |
1017 ASSERT_TRUE(test_server()->Start()); | 1017 ASSERT_TRUE(test_server()->Start()); |
1018 | 1018 |
1019 // Auto-restart if server doesn't handle ranges. | 1019 // Auto-restart if server doesn't handle ranges. |
1020 GURL url = test_server()->GetURL( | 1020 GURL url = test_server()->GetURL( |
1021 StringPrintf( | 1021 base::StringPrintf( |
1022 // First download hits an RST, rest don't, no ranges. | 1022 // First download hits an RST, rest don't, no ranges. |
1023 "rangereset?size=%d&rst_boundary=%d&" | 1023 "rangereset?size=%d&rst_boundary=%d&" |
1024 "token=NoRange&rst_limit=1&bounce_range", | 1024 "token=NoRange&rst_limit=1&bounce_range", |
1025 GetSafeBufferChunk() * 3, GetSafeBufferChunk())); | 1025 GetSafeBufferChunk() * 3, GetSafeBufferChunk())); |
1026 | 1026 |
1027 // Start the download and wait for first data chunk. | 1027 // Start the download and wait for first data chunk. |
1028 DownloadItem* download(StartDownloadAndReturnItem(url)); | 1028 DownloadItem* download(StartDownloadAndReturnItem(url)); |
1029 WaitForData(download, GetSafeBufferChunk()); | 1029 WaitForData(download, GetSafeBufferChunk()); |
1030 | 1030 |
1031 RecordingDownloadObserver recorder(download); | 1031 RecordingDownloadObserver recorder(download); |
(...skipping 27 matching lines...) Expand all Loading... |
1059 } | 1059 } |
1060 | 1060 |
1061 // Confirm restart fallback happens if a precondition is failed. | 1061 // Confirm restart fallback happens if a precondition is failed. |
1062 IN_PROC_BROWSER_TEST_F(DownloadContentTest, | 1062 IN_PROC_BROWSER_TEST_F(DownloadContentTest, |
1063 ResumeInterruptedDownloadBadPrecondition) { | 1063 ResumeInterruptedDownloadBadPrecondition) { |
1064 CommandLine::ForCurrentProcess()->AppendSwitch( | 1064 CommandLine::ForCurrentProcess()->AppendSwitch( |
1065 switches::kEnableDownloadResumption); | 1065 switches::kEnableDownloadResumption); |
1066 ASSERT_TRUE(test_server()->Start()); | 1066 ASSERT_TRUE(test_server()->Start()); |
1067 | 1067 |
1068 GURL url = test_server()->GetURL( | 1068 GURL url = test_server()->GetURL( |
1069 StringPrintf( | 1069 base::StringPrintf( |
1070 // First download hits an RST, rest don't, precondition fail. | 1070 // First download hits an RST, rest don't, precondition fail. |
1071 "rangereset?size=%d&rst_boundary=%d&" | 1071 "rangereset?size=%d&rst_boundary=%d&" |
1072 "token=NoRange&rst_limit=1&fail_precondition=2", | 1072 "token=NoRange&rst_limit=1&fail_precondition=2", |
1073 GetSafeBufferChunk() * 3, GetSafeBufferChunk())); | 1073 GetSafeBufferChunk() * 3, GetSafeBufferChunk())); |
1074 | 1074 |
1075 // Start the download and wait for first data chunk. | 1075 // Start the download and wait for first data chunk. |
1076 DownloadItem* download(StartDownloadAndReturnItem(url)); | 1076 DownloadItem* download(StartDownloadAndReturnItem(url)); |
1077 WaitForData(download, GetSafeBufferChunk()); | 1077 WaitForData(download, GetSafeBufferChunk()); |
1078 | 1078 |
1079 RecordingDownloadObserver recorder(download); | 1079 RecordingDownloadObserver recorder(download); |
(...skipping 29 matching lines...) Expand all Loading... |
1109 } | 1109 } |
1110 | 1110 |
1111 // Confirm we don't try to resume if we don't have a verifier. | 1111 // Confirm we don't try to resume if we don't have a verifier. |
1112 IN_PROC_BROWSER_TEST_F(DownloadContentTest, | 1112 IN_PROC_BROWSER_TEST_F(DownloadContentTest, |
1113 ResumeInterruptedDownloadNoVerifiers) { | 1113 ResumeInterruptedDownloadNoVerifiers) { |
1114 CommandLine::ForCurrentProcess()->AppendSwitch( | 1114 CommandLine::ForCurrentProcess()->AppendSwitch( |
1115 switches::kEnableDownloadResumption); | 1115 switches::kEnableDownloadResumption); |
1116 ASSERT_TRUE(test_server()->Start()); | 1116 ASSERT_TRUE(test_server()->Start()); |
1117 | 1117 |
1118 GURL url = test_server()->GetURL( | 1118 GURL url = test_server()->GetURL( |
1119 StringPrintf( | 1119 base::StringPrintf( |
1120 // First download hits an RST, rest don't, no verifiers. | 1120 // First download hits an RST, rest don't, no verifiers. |
1121 "rangereset?size=%d&rst_boundary=%d&" | 1121 "rangereset?size=%d&rst_boundary=%d&" |
1122 "token=NoRange&rst_limit=1&no_verifiers", | 1122 "token=NoRange&rst_limit=1&no_verifiers", |
1123 GetSafeBufferChunk() * 3, GetSafeBufferChunk())); | 1123 GetSafeBufferChunk() * 3, GetSafeBufferChunk())); |
1124 | 1124 |
1125 // Start the download and wait for first data chunk. | 1125 // Start the download and wait for first data chunk. |
1126 DownloadItem* download(StartDownloadAndReturnItem(url)); | 1126 DownloadItem* download(StartDownloadAndReturnItem(url)); |
1127 WaitForData(download, GetSafeBufferChunk()); | 1127 WaitForData(download, GetSafeBufferChunk()); |
1128 | 1128 |
1129 RecordingDownloadObserver recorder(download); | 1129 RecordingDownloadObserver recorder(download); |
(...skipping 23 matching lines...) Expand all Loading... |
1153 | 1153 |
1154 recorder.CompareToExpectedRecord(expected_record, arraysize(expected_record)); | 1154 recorder.CompareToExpectedRecord(expected_record, arraysize(expected_record)); |
1155 } | 1155 } |
1156 | 1156 |
1157 IN_PROC_BROWSER_TEST_F(DownloadContentTest, ResumeWithDeletedFile) { | 1157 IN_PROC_BROWSER_TEST_F(DownloadContentTest, ResumeWithDeletedFile) { |
1158 CommandLine::ForCurrentProcess()->AppendSwitch( | 1158 CommandLine::ForCurrentProcess()->AppendSwitch( |
1159 switches::kEnableDownloadResumption); | 1159 switches::kEnableDownloadResumption); |
1160 ASSERT_TRUE(test_server()->Start()); | 1160 ASSERT_TRUE(test_server()->Start()); |
1161 | 1161 |
1162 GURL url = test_server()->GetURL( | 1162 GURL url = test_server()->GetURL( |
1163 StringPrintf( | 1163 base::StringPrintf( |
1164 // First download hits an RST, rest don't | 1164 // First download hits an RST, rest don't |
1165 "rangereset?size=%d&rst_boundary=%d&" | 1165 "rangereset?size=%d&rst_boundary=%d&" |
1166 "token=NoRange&rst_limit=1", | 1166 "token=NoRange&rst_limit=1", |
1167 GetSafeBufferChunk() * 3, GetSafeBufferChunk())); | 1167 GetSafeBufferChunk() * 3, GetSafeBufferChunk())); |
1168 | 1168 |
1169 // Start the download and wait for first data chunk. | 1169 // Start the download and wait for first data chunk. |
1170 DownloadItem* download(StartDownloadAndReturnItem(url)); | 1170 DownloadItem* download(StartDownloadAndReturnItem(url)); |
1171 WaitForData(download, GetSafeBufferChunk()); | 1171 WaitForData(download, GetSafeBufferChunk()); |
1172 | 1172 |
1173 RecordingDownloadObserver recorder(download); | 1173 RecordingDownloadObserver recorder(download); |
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1352 | 1352 |
1353 // Resume and watch completion. | 1353 // Resume and watch completion. |
1354 DownloadUpdatedObserver completion_observer( | 1354 DownloadUpdatedObserver completion_observer( |
1355 download, base::Bind(DownloadCompleteFilter)); | 1355 download, base::Bind(DownloadCompleteFilter)); |
1356 download->ResumeInterruptedDownload(); | 1356 download->ResumeInterruptedDownload(); |
1357 completion_observer.WaitForEvent(); | 1357 completion_observer.WaitForEvent(); |
1358 EXPECT_EQ(download->GetState(), DownloadItem::COMPLETE); | 1358 EXPECT_EQ(download->GetState(), DownloadItem::COMPLETE); |
1359 } | 1359 } |
1360 | 1360 |
1361 } // namespace content | 1361 } // namespace content |
OLD | NEW |