Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(585)

Side by Side Diff: content/browser/download/download_browsertest.cc

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

Powered by Google App Engine
This is Rietveld 408576698