| 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 16 matching lines...) Expand all Loading... |
| 27 #include "content/public/test/browser_test_utils.h" | 27 #include "content/public/test/browser_test_utils.h" |
| 28 #include "content/public/test/content_browser_test.h" | 28 #include "content/public/test/content_browser_test.h" |
| 29 #include "content/public/test/content_browser_test_utils.h" | 29 #include "content/public/test/content_browser_test_utils.h" |
| 30 #include "content/public/test/download_test_observer.h" | 30 #include "content/public/test/download_test_observer.h" |
| 31 #include "content/public/test/test_file_error_injector.h" | 31 #include "content/public/test/test_file_error_injector.h" |
| 32 #include "content/public/test/test_utils.h" | 32 #include "content/public/test/test_utils.h" |
| 33 #include "content/shell/browser/shell.h" | 33 #include "content/shell/browser/shell.h" |
| 34 #include "content/shell/browser/shell_browser_context.h" | 34 #include "content/shell/browser/shell_browser_context.h" |
| 35 #include "content/shell/browser/shell_download_manager_delegate.h" | 35 #include "content/shell/browser/shell_download_manager_delegate.h" |
| 36 #include "content/shell/browser/shell_network_delegate.h" | 36 #include "content/shell/browser/shell_network_delegate.h" |
| 37 #include "content/test/net/url_request_mock_http_job.h" | |
| 38 #include "content/test/net/url_request_slow_download_job.h" | 37 #include "content/test/net/url_request_slow_download_job.h" |
| 39 #include "net/test/embedded_test_server/embedded_test_server.h" | 38 #include "net/test/embedded_test_server/embedded_test_server.h" |
| 40 #include "net/test/embedded_test_server/http_request.h" | 39 #include "net/test/embedded_test_server/http_request.h" |
| 41 #include "net/test/embedded_test_server/http_response.h" | 40 #include "net/test/embedded_test_server/http_response.h" |
| 42 #include "net/test/spawned_test_server/spawned_test_server.h" | 41 #include "net/test/spawned_test_server/spawned_test_server.h" |
| 42 #include "net/test/url_request/url_request_mock_http_job.h" |
| 43 #include "testing/gmock/include/gmock/gmock.h" | 43 #include "testing/gmock/include/gmock/gmock.h" |
| 44 #include "testing/gtest/include/gtest/gtest.h" | 44 #include "testing/gtest/include/gtest/gtest.h" |
| 45 #include "url/gurl.h" | 45 #include "url/gurl.h" |
| 46 | 46 |
| 47 using ::net::test_server::EmbeddedTestServer; | 47 using ::net::test_server::EmbeddedTestServer; |
| 48 using ::testing::AllOf; | 48 using ::testing::AllOf; |
| 49 using ::testing::Field; | 49 using ::testing::Field; |
| 50 using ::testing::InSequence; | 50 using ::testing::InSequence; |
| 51 using ::testing::Property; | 51 using ::testing::Property; |
| 52 using ::testing::Return; | 52 using ::testing::Return; |
| (...skipping 526 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 579 manager->GetDelegate()->Shutdown(); | 579 manager->GetDelegate()->Shutdown(); |
| 580 manager->SetDelegate(test_delegate_.get()); | 580 manager->SetDelegate(test_delegate_.get()); |
| 581 test_delegate_->SetDownloadManager(manager); | 581 test_delegate_->SetDownloadManager(manager); |
| 582 | 582 |
| 583 BrowserThread::PostTask( | 583 BrowserThread::PostTask( |
| 584 BrowserThread::IO, FROM_HERE, | 584 BrowserThread::IO, FROM_HERE, |
| 585 base::Bind(&URLRequestSlowDownloadJob::AddUrlHandler)); | 585 base::Bind(&URLRequestSlowDownloadJob::AddUrlHandler)); |
| 586 base::FilePath mock_base(GetTestFilePath("download", "")); | 586 base::FilePath mock_base(GetTestFilePath("download", "")); |
| 587 BrowserThread::PostTask( | 587 BrowserThread::PostTask( |
| 588 BrowserThread::IO, FROM_HERE, | 588 BrowserThread::IO, FROM_HERE, |
| 589 base::Bind(&URLRequestMockHTTPJob::AddUrlHandler, mock_base)); | 589 base::Bind( |
| 590 &net::URLRequestMockHTTPJob::AddUrlHandler, |
| 591 mock_base, |
| 592 make_scoped_refptr( |
| 593 content::BrowserThread::GetBlockingPool()))); |
| 590 } | 594 } |
| 591 | 595 |
| 592 TestShellDownloadManagerDelegate* GetDownloadManagerDelegate() { | 596 TestShellDownloadManagerDelegate* GetDownloadManagerDelegate() { |
| 593 return test_delegate_.get(); | 597 return test_delegate_.get(); |
| 594 } | 598 } |
| 595 | 599 |
| 596 // Create a DownloadTestObserverTerminal that will wait for the | 600 // Create a DownloadTestObserverTerminal that will wait for the |
| 597 // specified number of downloads to finish. | 601 // specified number of downloads to finish. |
| 598 DownloadTestObserver* CreateWaiter( | 602 DownloadTestObserver* CreateWaiter( |
| 599 Shell* shell, int num_downloads) { | 603 Shell* shell, int num_downloads) { |
| (...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 791 observer1->WaitForFinished(); | 795 observer1->WaitForFinished(); |
| 792 | 796 |
| 793 std::vector<DownloadItem*> downloads; | 797 std::vector<DownloadItem*> downloads; |
| 794 DownloadManagerForShell(shell())->GetAllDownloads(&downloads); | 798 DownloadManagerForShell(shell())->GetAllDownloads(&downloads); |
| 795 ASSERT_EQ(1u, downloads.size()); | 799 ASSERT_EQ(1u, downloads.size()); |
| 796 ASSERT_EQ(DownloadItem::IN_PROGRESS, downloads[0]->GetState()); | 800 ASSERT_EQ(DownloadItem::IN_PROGRESS, downloads[0]->GetState()); |
| 797 DownloadItem* download1 = downloads[0]; // The only download. | 801 DownloadItem* download1 = downloads[0]; // The only download. |
| 798 | 802 |
| 799 // Start the second download and wait until it's done. | 803 // Start the second download and wait until it's done. |
| 800 base::FilePath file(FILE_PATH_LITERAL("download-test.lib")); | 804 base::FilePath file(FILE_PATH_LITERAL("download-test.lib")); |
| 801 GURL url(URLRequestMockHTTPJob::GetMockUrl(file)); | 805 GURL url(net::URLRequestMockHTTPJob::GetMockUrl(file)); |
| 802 // Download the file and wait. | 806 // Download the file and wait. |
| 803 NavigateToURLAndWaitForDownload(shell(), url, DownloadItem::COMPLETE); | 807 NavigateToURLAndWaitForDownload(shell(), url, DownloadItem::COMPLETE); |
| 804 | 808 |
| 805 // Should now have 2 items on the manager. | 809 // Should now have 2 items on the manager. |
| 806 downloads.clear(); | 810 downloads.clear(); |
| 807 DownloadManagerForShell(shell())->GetAllDownloads(&downloads); | 811 DownloadManagerForShell(shell())->GetAllDownloads(&downloads); |
| 808 ASSERT_EQ(2u, downloads.size()); | 812 ASSERT_EQ(2u, downloads.size()); |
| 809 // We don't know the order of the downloads. | 813 // We don't know the order of the downloads. |
| 810 DownloadItem* download2 = downloads[(download1 == downloads[0]) ? 1 : 0]; | 814 DownloadItem* download2 = downloads[(download1 == downloads[0]) ? 1 : 0]; |
| 811 | 815 |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 846 const char kTestMimeType[] = "application/x-test-mime-type"; | 850 const char kTestMimeType[] = "application/x-test-mime-type"; |
| 847 const char kTestFileType[] = "abc"; | 851 const char kTestFileType[] = "abc"; |
| 848 | 852 |
| 849 WebPluginInfo plugin_info; | 853 WebPluginInfo plugin_info; |
| 850 plugin_info.name = base::ASCIIToUTF16(kTestPluginName); | 854 plugin_info.name = base::ASCIIToUTF16(kTestPluginName); |
| 851 plugin_info.mime_types.push_back( | 855 plugin_info.mime_types.push_back( |
| 852 WebPluginMimeType(kTestMimeType, kTestFileType, "")); | 856 WebPluginMimeType(kTestMimeType, kTestFileType, "")); |
| 853 PluginServiceImpl::GetInstance()->RegisterInternalPlugin(plugin_info, false); | 857 PluginServiceImpl::GetInstance()->RegisterInternalPlugin(plugin_info, false); |
| 854 | 858 |
| 855 // The following is served with a Content-Type of application/octet-stream. | 859 // The following is served with a Content-Type of application/octet-stream. |
| 856 GURL url(URLRequestMockHTTPJob::GetMockUrl(base::FilePath(kTestFilePath))); | 860 GURL url(net::URLRequestMockHTTPJob::GetMockUrl( |
| 861 base::FilePath(kTestFilePath))); |
| 857 NavigateToURLAndWaitForDownload(shell(), url, DownloadItem::COMPLETE); | 862 NavigateToURLAndWaitForDownload(shell(), url, DownloadItem::COMPLETE); |
| 858 } | 863 } |
| 859 #endif | 864 #endif |
| 860 | 865 |
| 861 // Try to cancel just before we release the download file, by delaying final | 866 // Try to cancel just before we release the download file, by delaying final |
| 862 // rename callback. | 867 // rename callback. |
| 863 IN_PROC_BROWSER_TEST_F(DownloadContentTest, CancelAtFinalRename) { | 868 IN_PROC_BROWSER_TEST_F(DownloadContentTest, CancelAtFinalRename) { |
| 864 // Setup new factory. | 869 // Setup new factory. |
| 865 DownloadFileWithDelayFactory* file_factory = | 870 DownloadFileWithDelayFactory* file_factory = |
| 866 new DownloadFileWithDelayFactory(); | 871 new DownloadFileWithDelayFactory(); |
| 867 DownloadManagerImpl* download_manager(DownloadManagerForShell(shell())); | 872 DownloadManagerImpl* download_manager(DownloadManagerForShell(shell())); |
| 868 download_manager->SetDownloadFileFactoryForTesting( | 873 download_manager->SetDownloadFileFactoryForTesting( |
| 869 scoped_ptr<DownloadFileFactory>(file_factory).Pass()); | 874 scoped_ptr<DownloadFileFactory>(file_factory).Pass()); |
| 870 | 875 |
| 871 // Create a download | 876 // Create a download |
| 872 base::FilePath file(FILE_PATH_LITERAL("download-test.lib")); | 877 base::FilePath file(FILE_PATH_LITERAL("download-test.lib")); |
| 873 NavigateToURL(shell(), URLRequestMockHTTPJob::GetMockUrl(file)); | 878 NavigateToURL(shell(), net::URLRequestMockHTTPJob::GetMockUrl(file)); |
| 874 | 879 |
| 875 // Wait until the first (intermediate file) rename and execute the callback. | 880 // Wait until the first (intermediate file) rename and execute the callback. |
| 876 file_factory->WaitForSomeCallback(); | 881 file_factory->WaitForSomeCallback(); |
| 877 std::vector<base::Closure> callbacks; | 882 std::vector<base::Closure> callbacks; |
| 878 file_factory->GetAllRenameCallbacks(&callbacks); | 883 file_factory->GetAllRenameCallbacks(&callbacks); |
| 879 ASSERT_EQ(1u, callbacks.size()); | 884 ASSERT_EQ(1u, callbacks.size()); |
| 880 callbacks[0].Run(); | 885 callbacks[0].Run(); |
| 881 callbacks.clear(); | 886 callbacks.clear(); |
| 882 | 887 |
| 883 // Wait until the second (final) rename callback is posted. | 888 // Wait until the second (final) rename callback is posted. |
| (...skipping 28 matching lines...) Expand all Loading... |
| 912 GetDownloadManagerDelegate()->SetDelayedOpen(true); | 917 GetDownloadManagerDelegate()->SetDelayedOpen(true); |
| 913 | 918 |
| 914 // Setup new factory. | 919 // Setup new factory. |
| 915 DownloadFileWithDelayFactory* file_factory = | 920 DownloadFileWithDelayFactory* file_factory = |
| 916 new DownloadFileWithDelayFactory(); | 921 new DownloadFileWithDelayFactory(); |
| 917 download_manager->SetDownloadFileFactoryForTesting( | 922 download_manager->SetDownloadFileFactoryForTesting( |
| 918 scoped_ptr<DownloadFileFactory>(file_factory).Pass()); | 923 scoped_ptr<DownloadFileFactory>(file_factory).Pass()); |
| 919 | 924 |
| 920 // Create a download | 925 // Create a download |
| 921 base::FilePath file(FILE_PATH_LITERAL("download-test.lib")); | 926 base::FilePath file(FILE_PATH_LITERAL("download-test.lib")); |
| 922 NavigateToURL(shell(), URLRequestMockHTTPJob::GetMockUrl(file)); | 927 NavigateToURL(shell(), net::URLRequestMockHTTPJob::GetMockUrl(file)); |
| 923 | 928 |
| 924 // Wait until the first (intermediate file) rename and execute the callback. | 929 // Wait until the first (intermediate file) rename and execute the callback. |
| 925 file_factory->WaitForSomeCallback(); | 930 file_factory->WaitForSomeCallback(); |
| 926 std::vector<base::Closure> callbacks; | 931 std::vector<base::Closure> callbacks; |
| 927 file_factory->GetAllRenameCallbacks(&callbacks); | 932 file_factory->GetAllRenameCallbacks(&callbacks); |
| 928 ASSERT_EQ(1u, callbacks.size()); | 933 ASSERT_EQ(1u, callbacks.size()); |
| 929 callbacks[0].Run(); | 934 callbacks[0].Run(); |
| 930 callbacks.clear(); | 935 callbacks.clear(); |
| 931 | 936 |
| 932 // Wait until the second (final) rename callback is posted. | 937 // Wait until the second (final) rename callback is posted. |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1022 GetDownloadManagerDelegate()->SetDelayedOpen(true); | 1027 GetDownloadManagerDelegate()->SetDelayedOpen(true); |
| 1023 | 1028 |
| 1024 // Setup new factory. | 1029 // Setup new factory. |
| 1025 DownloadFileWithDelayFactory* file_factory = | 1030 DownloadFileWithDelayFactory* file_factory = |
| 1026 new DownloadFileWithDelayFactory(); | 1031 new DownloadFileWithDelayFactory(); |
| 1027 download_manager->SetDownloadFileFactoryForTesting( | 1032 download_manager->SetDownloadFileFactoryForTesting( |
| 1028 scoped_ptr<DownloadFileFactory>(file_factory).Pass()); | 1033 scoped_ptr<DownloadFileFactory>(file_factory).Pass()); |
| 1029 | 1034 |
| 1030 // Create a download | 1035 // Create a download |
| 1031 base::FilePath file(FILE_PATH_LITERAL("download-test.lib")); | 1036 base::FilePath file(FILE_PATH_LITERAL("download-test.lib")); |
| 1032 NavigateToURL(shell(), URLRequestMockHTTPJob::GetMockUrl(file)); | 1037 NavigateToURL(shell(), net::URLRequestMockHTTPJob::GetMockUrl(file)); |
| 1033 | 1038 |
| 1034 // Wait until the first (intermediate file) rename and execute the callback. | 1039 // Wait until the first (intermediate file) rename and execute the callback. |
| 1035 file_factory->WaitForSomeCallback(); | 1040 file_factory->WaitForSomeCallback(); |
| 1036 std::vector<base::Closure> callbacks; | 1041 std::vector<base::Closure> callbacks; |
| 1037 file_factory->GetAllRenameCallbacks(&callbacks); | 1042 file_factory->GetAllRenameCallbacks(&callbacks); |
| 1038 ASSERT_EQ(1u, callbacks.size()); | 1043 ASSERT_EQ(1u, callbacks.size()); |
| 1039 callbacks[0].Run(); | 1044 callbacks[0].Run(); |
| 1040 callbacks.clear(); | 1045 callbacks.clear(); |
| 1041 | 1046 |
| 1042 // Wait until the second (final) rename callback is posted. | 1047 // Wait until the second (final) rename callback is posted. |
| (...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1329 {DownloadItem::COMPLETE, GetSafeBufferChunk() * 3}, | 1334 {DownloadItem::COMPLETE, GetSafeBufferChunk() * 3}, |
| 1330 }; | 1335 }; |
| 1331 | 1336 |
| 1332 recorder.CompareToExpectedRecord(expected_record, arraysize(expected_record)); | 1337 recorder.CompareToExpectedRecord(expected_record, arraysize(expected_record)); |
| 1333 } | 1338 } |
| 1334 | 1339 |
| 1335 IN_PROC_BROWSER_TEST_F(DownloadContentTest, ResumeWithFileInitError) { | 1340 IN_PROC_BROWSER_TEST_F(DownloadContentTest, ResumeWithFileInitError) { |
| 1336 base::CommandLine::ForCurrentProcess()->AppendSwitch( | 1341 base::CommandLine::ForCurrentProcess()->AppendSwitch( |
| 1337 switches::kEnableDownloadResumption); | 1342 switches::kEnableDownloadResumption); |
| 1338 base::FilePath file(FILE_PATH_LITERAL("download-test.lib")); | 1343 base::FilePath file(FILE_PATH_LITERAL("download-test.lib")); |
| 1339 GURL url(URLRequestMockHTTPJob::GetMockUrl(file)); | 1344 GURL url(net::URLRequestMockHTTPJob::GetMockUrl(file)); |
| 1340 | 1345 |
| 1341 // Setup the error injector. | 1346 // Setup the error injector. |
| 1342 scoped_refptr<TestFileErrorInjector> injector( | 1347 scoped_refptr<TestFileErrorInjector> injector( |
| 1343 TestFileErrorInjector::Create(DownloadManagerForShell(shell()))); | 1348 TestFileErrorInjector::Create(DownloadManagerForShell(shell()))); |
| 1344 | 1349 |
| 1345 TestFileErrorInjector::FileErrorInfo err = { | 1350 TestFileErrorInjector::FileErrorInfo err = { |
| 1346 url.spec(), | 1351 url.spec(), |
| 1347 TestFileErrorInjector::FILE_OPERATION_INITIALIZE, | 1352 TestFileErrorInjector::FILE_OPERATION_INITIALIZE, |
| 1348 0, | 1353 0, |
| 1349 DOWNLOAD_INTERRUPT_REASON_FILE_NO_SPACE | 1354 DOWNLOAD_INTERRUPT_REASON_FILE_NO_SPACE |
| (...skipping 30 matching lines...) Expand all Loading... |
| 1380 download->Resume(); | 1385 download->Resume(); |
| 1381 completion_observer.WaitForEvent(); | 1386 completion_observer.WaitForEvent(); |
| 1382 EXPECT_EQ(download->GetState(), DownloadItem::COMPLETE); | 1387 EXPECT_EQ(download->GetState(), DownloadItem::COMPLETE); |
| 1383 } | 1388 } |
| 1384 | 1389 |
| 1385 IN_PROC_BROWSER_TEST_F(DownloadContentTest, | 1390 IN_PROC_BROWSER_TEST_F(DownloadContentTest, |
| 1386 ResumeWithFileIntermediateRenameError) { | 1391 ResumeWithFileIntermediateRenameError) { |
| 1387 base::CommandLine::ForCurrentProcess()->AppendSwitch( | 1392 base::CommandLine::ForCurrentProcess()->AppendSwitch( |
| 1388 switches::kEnableDownloadResumption); | 1393 switches::kEnableDownloadResumption); |
| 1389 base::FilePath file(FILE_PATH_LITERAL("download-test.lib")); | 1394 base::FilePath file(FILE_PATH_LITERAL("download-test.lib")); |
| 1390 GURL url(URLRequestMockHTTPJob::GetMockUrl(file)); | 1395 GURL url(net::URLRequestMockHTTPJob::GetMockUrl(file)); |
| 1391 | 1396 |
| 1392 // Setup the error injector. | 1397 // Setup the error injector. |
| 1393 scoped_refptr<TestFileErrorInjector> injector( | 1398 scoped_refptr<TestFileErrorInjector> injector( |
| 1394 TestFileErrorInjector::Create(DownloadManagerForShell(shell()))); | 1399 TestFileErrorInjector::Create(DownloadManagerForShell(shell()))); |
| 1395 | 1400 |
| 1396 TestFileErrorInjector::FileErrorInfo err = { | 1401 TestFileErrorInjector::FileErrorInfo err = { |
| 1397 url.spec(), | 1402 url.spec(), |
| 1398 TestFileErrorInjector::FILE_OPERATION_RENAME_UNIQUIFY, | 1403 TestFileErrorInjector::FILE_OPERATION_RENAME_UNIQUIFY, |
| 1399 0, | 1404 0, |
| 1400 DOWNLOAD_INTERRUPT_REASON_FILE_NO_SPACE | 1405 DOWNLOAD_INTERRUPT_REASON_FILE_NO_SPACE |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1432 download, base::Bind(DownloadCompleteFilter)); | 1437 download, base::Bind(DownloadCompleteFilter)); |
| 1433 download->Resume(); | 1438 download->Resume(); |
| 1434 completion_observer.WaitForEvent(); | 1439 completion_observer.WaitForEvent(); |
| 1435 EXPECT_EQ(download->GetState(), DownloadItem::COMPLETE); | 1440 EXPECT_EQ(download->GetState(), DownloadItem::COMPLETE); |
| 1436 } | 1441 } |
| 1437 | 1442 |
| 1438 IN_PROC_BROWSER_TEST_F(DownloadContentTest, ResumeWithFileFinalRenameError) { | 1443 IN_PROC_BROWSER_TEST_F(DownloadContentTest, ResumeWithFileFinalRenameError) { |
| 1439 base::CommandLine::ForCurrentProcess()->AppendSwitch( | 1444 base::CommandLine::ForCurrentProcess()->AppendSwitch( |
| 1440 switches::kEnableDownloadResumption); | 1445 switches::kEnableDownloadResumption); |
| 1441 base::FilePath file(FILE_PATH_LITERAL("download-test.lib")); | 1446 base::FilePath file(FILE_PATH_LITERAL("download-test.lib")); |
| 1442 GURL url(URLRequestMockHTTPJob::GetMockUrl(file)); | 1447 GURL url(net::URLRequestMockHTTPJob::GetMockUrl(file)); |
| 1443 | 1448 |
| 1444 // Setup the error injector. | 1449 // Setup the error injector. |
| 1445 scoped_refptr<TestFileErrorInjector> injector( | 1450 scoped_refptr<TestFileErrorInjector> injector( |
| 1446 TestFileErrorInjector::Create(DownloadManagerForShell(shell()))); | 1451 TestFileErrorInjector::Create(DownloadManagerForShell(shell()))); |
| 1447 | 1452 |
| 1448 DownloadManagerForShell(shell())->RemoveAllDownloads(); | 1453 DownloadManagerForShell(shell())->RemoveAllDownloads(); |
| 1449 TestFileErrorInjector::FileErrorInfo err = { | 1454 TestFileErrorInjector::FileErrorInfo err = { |
| 1450 url.spec(), | 1455 url.spec(), |
| 1451 TestFileErrorInjector::FILE_OPERATION_RENAME_ANNOTATE, | 1456 TestFileErrorInjector::FILE_OPERATION_RENAME_ANNOTATE, |
| 1452 0, | 1457 0, |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1547 | 1552 |
| 1548 // The intermediate file should now be gone. | 1553 // The intermediate file should now be gone. |
| 1549 EXPECT_FALSE(base::PathExists(intermediate_path)); | 1554 EXPECT_FALSE(base::PathExists(intermediate_path)); |
| 1550 } | 1555 } |
| 1551 | 1556 |
| 1552 // A completed download shouldn't delete the downloaded file when it is | 1557 // A completed download shouldn't delete the downloaded file when it is |
| 1553 // removed. | 1558 // removed. |
| 1554 { | 1559 { |
| 1555 // Start the second download and wait until it's done. | 1560 // Start the second download and wait until it's done. |
| 1556 base::FilePath file2(FILE_PATH_LITERAL("download-test.lib")); | 1561 base::FilePath file2(FILE_PATH_LITERAL("download-test.lib")); |
| 1557 GURL url2(URLRequestMockHTTPJob::GetMockUrl(file2)); | 1562 GURL url2(net::URLRequestMockHTTPJob::GetMockUrl(file2)); |
| 1558 scoped_ptr<DownloadTestObserver> completion_observer( | 1563 scoped_ptr<DownloadTestObserver> completion_observer( |
| 1559 CreateWaiter(shell(), 1)); | 1564 CreateWaiter(shell(), 1)); |
| 1560 DownloadItem* download(StartDownloadAndReturnItem(url2)); | 1565 DownloadItem* download(StartDownloadAndReturnItem(url2)); |
| 1561 completion_observer->WaitForFinished(); | 1566 completion_observer->WaitForFinished(); |
| 1562 | 1567 |
| 1563 // The target path should exist. | 1568 // The target path should exist. |
| 1564 base::FilePath target_path(download->GetTargetFilePath()); | 1569 base::FilePath target_path(download->GetTargetFilePath()); |
| 1565 EXPECT_TRUE(base::PathExists(target_path)); | 1570 EXPECT_TRUE(base::PathExists(target_path)); |
| 1566 download->Remove(); | 1571 download->Remove(); |
| 1567 RunAllPendingInMessageLoop(BrowserThread::FILE); | 1572 RunAllPendingInMessageLoop(BrowserThread::FILE); |
| (...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1805 ASSERT_TRUE(test_server.InitializeAndWaitUntilReady()); | 1810 ASSERT_TRUE(test_server.InitializeAndWaitUntilReady()); |
| 1806 | 1811 |
| 1807 GURL url = test_server.GetURL("/empty.bin"); | 1812 GURL url = test_server.GetURL("/empty.bin"); |
| 1808 test_server.ServeFilesFromDirectory(GetTestFilePath("download", "")); | 1813 test_server.ServeFilesFromDirectory(GetTestFilePath("download", "")); |
| 1809 | 1814 |
| 1810 NavigateToURLAndWaitForDownload(shell(), url, DownloadItem::COMPLETE); | 1815 NavigateToURLAndWaitForDownload(shell(), url, DownloadItem::COMPLETE); |
| 1811 // That's it. This should work without crashing. | 1816 // That's it. This should work without crashing. |
| 1812 } | 1817 } |
| 1813 | 1818 |
| 1814 } // namespace content | 1819 } // namespace content |
| OLD | NEW |