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 1360 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1371 injector->InjectErrors(); | 1371 injector->InjectErrors(); |
1372 | 1372 |
1373 // Resume and watch completion. | 1373 // Resume and watch completion. |
1374 DownloadUpdatedObserver completion_observer( | 1374 DownloadUpdatedObserver completion_observer( |
1375 download, base::Bind(DownloadCompleteFilter)); | 1375 download, base::Bind(DownloadCompleteFilter)); |
1376 download->Resume(); | 1376 download->Resume(); |
1377 completion_observer.WaitForEvent(); | 1377 completion_observer.WaitForEvent(); |
1378 EXPECT_EQ(download->GetState(), DownloadItem::COMPLETE); | 1378 EXPECT_EQ(download->GetState(), DownloadItem::COMPLETE); |
1379 } | 1379 } |
1380 | 1380 |
| 1381 IN_PROC_BROWSER_TEST_F(DownloadContentTest, RemoveResumingDownload) { |
| 1382 SetupEnsureNoPendingDownloads(); |
| 1383 CommandLine::ForCurrentProcess()->AppendSwitch( |
| 1384 switches::kEnableDownloadResumption); |
| 1385 ASSERT_TRUE(test_server()->Start()); |
| 1386 |
| 1387 GURL url = test_server()->GetURL( |
| 1388 base::StringPrintf("rangereset?size=%d&rst_boundary=%d", |
| 1389 GetSafeBufferChunk() * 3, GetSafeBufferChunk())); |
| 1390 |
| 1391 MockDownloadManagerObserver dm_observer(DownloadManagerForShell(shell())); |
| 1392 EXPECT_CALL(dm_observer, OnDownloadCreated(_,_)).Times(1); |
| 1393 |
| 1394 DownloadItem* download(StartDownloadAndReturnItem(url)); |
| 1395 WaitForData(download, GetSafeBufferChunk()); |
| 1396 ::testing::Mock::VerifyAndClearExpectations(&dm_observer); |
| 1397 |
| 1398 // Tell the server to send the RST and confirm the interrupt happens. |
| 1399 ReleaseRSTAndConfirmInterruptForResume(download); |
| 1400 ConfirmFileStatusForResume( |
| 1401 download, true, GetSafeBufferChunk(), GetSafeBufferChunk() * 3, |
| 1402 base::FilePath(FILE_PATH_LITERAL("rangereset.crdownload"))); |
| 1403 |
| 1404 // Resume and remove download. We expect only a single OnDownloadCreated() |
| 1405 // call, and that's for the second download created below. |
| 1406 EXPECT_CALL(dm_observer, OnDownloadCreated(_,_)).Times(1); |
| 1407 download->Resume(); |
| 1408 download->Remove(); |
| 1409 |
| 1410 // Start the second download and wait until it's done. |
| 1411 base::FilePath file(FILE_PATH_LITERAL("download-test.lib")); |
| 1412 GURL url2(URLRequestMockHTTPJob::GetMockUrl(file)); |
| 1413 // Download the file and wait. |
| 1414 DownloadAndWait(shell(), url2, DownloadItem::COMPLETE); |
| 1415 |
| 1416 EXPECT_TRUE(EnsureNoPendingDownloads()); |
| 1417 } |
| 1418 |
1381 } // namespace content | 1419 } // namespace content |
OLD | NEW |