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 1107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1118 recorder.CompareToExpectedRecord(expected_record, arraysize(expected_record)); | 1118 recorder.CompareToExpectedRecord(expected_record, arraysize(expected_record)); |
1119 } | 1119 } |
1120 | 1120 |
1121 // Confirm restart fallback happens if a precondition is failed. | 1121 // Confirm restart fallback happens if a precondition is failed. |
1122 IN_PROC_BROWSER_TEST_F(DownloadContentTest, | 1122 IN_PROC_BROWSER_TEST_F(DownloadContentTest, |
1123 ResumeInterruptedDownloadBadPrecondition) { | 1123 ResumeInterruptedDownloadBadPrecondition) { |
1124 CommandLine::ForCurrentProcess()->AppendSwitch( | 1124 CommandLine::ForCurrentProcess()->AppendSwitch( |
1125 switches::kEnableDownloadResumption); | 1125 switches::kEnableDownloadResumption); |
1126 ASSERT_TRUE(test_server()->Start()); | 1126 ASSERT_TRUE(test_server()->Start()); |
1127 | 1127 |
1128 GURL url = test_server()->GetURL( | 1128 GURL url = test_server()->GetURL(base::StringPrintf( |
1129 base::StringPrintf( | 1129 // First download hits an RST, rest don't, precondition fail. |
1130 // First download hits an RST, rest don't, precondition fail. | 1130 "rangereset?size=%d&rst_boundary=%d&" |
1131 "rangereset?size=%d&rst_boundary=%d&" | 1131 "token=BadPrecondition&rst_limit=1&fail_precondition=2", |
1132 "token=NoRange&rst_limit=1&fail_precondition=2", | 1132 GetSafeBufferChunk() * 3, |
1133 GetSafeBufferChunk() * 3, GetSafeBufferChunk())); | 1133 GetSafeBufferChunk())); |
1134 | 1134 |
1135 // Start the download and wait for first data chunk. | 1135 // Start the download and wait for first data chunk. |
1136 DownloadItem* download(StartDownloadAndReturnItem(url)); | 1136 DownloadItem* download(StartDownloadAndReturnItem(url)); |
1137 WaitForData(download, GetSafeBufferChunk()); | 1137 WaitForData(download, GetSafeBufferChunk()); |
1138 | 1138 |
1139 RecordingDownloadObserver recorder(download); | 1139 RecordingDownloadObserver recorder(download); |
1140 | 1140 |
1141 ReleaseRSTAndConfirmInterruptForResume(download); | 1141 ReleaseRSTAndConfirmInterruptForResume(download); |
1142 ConfirmFileStatusForResume( | 1142 ConfirmFileStatusForResume( |
1143 download, true, GetSafeBufferChunk(), GetSafeBufferChunk() * 3, | 1143 download, true, GetSafeBufferChunk(), GetSafeBufferChunk() * 3, |
1144 base::FilePath(FILE_PATH_LITERAL("rangereset.crdownload"))); | 1144 base::FilePath(FILE_PATH_LITERAL("rangereset.crdownload"))); |
| 1145 EXPECT_EQ("BadPrecondition2", download->GetETag()); |
1145 | 1146 |
1146 DownloadUpdatedObserver completion_observer( | 1147 DownloadUpdatedObserver completion_observer( |
1147 download, base::Bind(DownloadCompleteFilter)); | 1148 download, base::Bind(DownloadCompleteFilter)); |
1148 download->Resume(); | 1149 download->Resume(); |
1149 completion_observer.WaitForEvent(); | 1150 completion_observer.WaitForEvent(); |
1150 | 1151 |
1151 ConfirmFileStatusForResume( | 1152 ConfirmFileStatusForResume( |
1152 download, true, GetSafeBufferChunk() * 3, GetSafeBufferChunk() * 3, | 1153 download, true, GetSafeBufferChunk() * 3, GetSafeBufferChunk() * 3, |
1153 base::FilePath(FILE_PATH_LITERAL("rangereset"))); | 1154 base::FilePath(FILE_PATH_LITERAL("rangereset"))); |
| 1155 EXPECT_EQ("BadPrecondition0", download->GetETag()); |
1154 | 1156 |
1155 static const RecordingDownloadObserver::RecordStruct expected_record[] = { | 1157 static const RecordingDownloadObserver::RecordStruct expected_record[] = { |
1156 // Result of RST | 1158 // Result of RST |
1157 {DownloadItem::INTERRUPTED, GetSafeBufferChunk()}, | 1159 {DownloadItem::INTERRUPTED, GetSafeBufferChunk()}, |
1158 // Starting continuation | 1160 // Starting continuation |
1159 {DownloadItem::IN_PROGRESS, GetSafeBufferChunk()}, | 1161 {DownloadItem::IN_PROGRESS, GetSafeBufferChunk()}, |
1160 // Server precondition fail. | 1162 // Server precondition fail. |
1161 {DownloadItem::INTERRUPTED, 0}, | 1163 {DownloadItem::INTERRUPTED, 0}, |
1162 // Notification of successful restart. | 1164 // Notification of successful restart. |
1163 {DownloadItem::IN_PROGRESS, 0}, | 1165 {DownloadItem::IN_PROGRESS, 0}, |
(...skipping 468 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1632 ASSERT_EQ(1u, downloads.size()); | 1634 ASSERT_EQ(1u, downloads.size()); |
1633 ASSERT_EQ(DownloadItem::COMPLETE, downloads[0]->GetState()); | 1635 ASSERT_EQ(DownloadItem::COMPLETE, downloads[0]->GetState()); |
1634 | 1636 |
1635 // Check that the cookies were correctly set. | 1637 // Check that the cookies were correctly set. |
1636 EXPECT_EQ("A=B", | 1638 EXPECT_EQ("A=B", |
1637 content::GetCookies(shell()->web_contents()->GetBrowserContext(), | 1639 content::GetCookies(shell()->web_contents()->GetBrowserContext(), |
1638 GURL(download))); | 1640 GURL(download))); |
1639 } | 1641 } |
1640 | 1642 |
1641 } // namespace content | 1643 } // namespace content |
OLD | NEW |