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

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

Powered by Google App Engine
This is Rietveld 408576698