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

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

Issue 2703883003: Read and restore persisted slice info (Closed)
Patch Set: Created 3 years, 10 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 <stddef.h> 8 #include <stddef.h>
9 #include <stdint.h> 9 #include <stdint.h>
10 #include <utility> 10 #include <utility>
(...skipping 1829 matching lines...) Expand 10 before | Expand all | Expand 10 after
1840 const int kIntermediateSize = 1331; 1840 const int kIntermediateSize = 1331;
1841 url_chain.push_back(request_handler.url()); 1841 url_chain.push_back(request_handler.url());
1842 1842
1843 DownloadItem* download = DownloadManagerForShell(shell())->CreateDownloadItem( 1843 DownloadItem* download = DownloadManagerForShell(shell())->CreateDownloadItem(
1844 "F7FB1F59-7DE1-4845-AFDB-8A688F70F583", 1, intermediate_file_path, 1844 "F7FB1F59-7DE1-4845-AFDB-8A688F70F583", 1, intermediate_file_path,
1845 base::FilePath(), url_chain, GURL(), GURL(), GURL(), GURL(), 1845 base::FilePath(), url_chain, GURL(), GURL(), GURL(), GURL(),
1846 "application/octet-stream", "application/octet-stream", base::Time::Now(), 1846 "application/octet-stream", "application/octet-stream", base::Time::Now(),
1847 base::Time(), parameters.etag, std::string(), kIntermediateSize, 1847 base::Time(), parameters.etag, std::string(), kIntermediateSize,
1848 parameters.size, std::string(), DownloadItem::INTERRUPTED, 1848 parameters.size, std::string(), DownloadItem::INTERRUPTED,
1849 DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS, 1849 DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS,
1850 DOWNLOAD_INTERRUPT_REASON_NETWORK_FAILED, false); 1850 DOWNLOAD_INTERRUPT_REASON_NETWORK_FAILED, false,
1851 std::vector<DownloadItem::ReceivedSlice>());
1851 1852
1852 download->Resume(); 1853 download->Resume();
1853 WaitForCompletion(download); 1854 WaitForCompletion(download);
1854 1855
1855 EXPECT_FALSE(PathExists(intermediate_file_path)); 1856 EXPECT_FALSE(PathExists(intermediate_file_path));
1856 ReadAndVerifyFileContents(parameters.pattern_generator_seed, 1857 ReadAndVerifyFileContents(parameters.pattern_generator_seed,
1857 parameters.size, 1858 parameters.size,
1858 download->GetTargetFilePath()); 1859 download->GetTargetFilePath());
1859 1860
1860 TestDownloadRequestHandler::CompletedRequests completed_requests; 1861 TestDownloadRequestHandler::CompletedRequests completed_requests;
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
1902 1903
1903 url_chain.push_back(request_handler.url()); 1904 url_chain.push_back(request_handler.url());
1904 1905
1905 DownloadItem* download = DownloadManagerForShell(shell())->CreateDownloadItem( 1906 DownloadItem* download = DownloadManagerForShell(shell())->CreateDownloadItem(
1906 "F7FB1F59-7DE1-4845-AFDB-8A688F70F583", 1, intermediate_file_path, 1907 "F7FB1F59-7DE1-4845-AFDB-8A688F70F583", 1, intermediate_file_path,
1907 base::FilePath(), url_chain, GURL(), GURL(), GURL(), GURL(), 1908 base::FilePath(), url_chain, GURL(), GURL(), GURL(), GURL(),
1908 "application/octet-stream", "application/octet-stream", base::Time::Now(), 1909 "application/octet-stream", "application/octet-stream", base::Time::Now(),
1909 base::Time(), parameters.etag, std::string(), kIntermediateSize, 1910 base::Time(), parameters.etag, std::string(), kIntermediateSize,
1910 parameters.size, std::string(), DownloadItem::INTERRUPTED, 1911 parameters.size, std::string(), DownloadItem::INTERRUPTED,
1911 DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS, 1912 DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS,
1912 DOWNLOAD_INTERRUPT_REASON_NETWORK_FAILED, false); 1913 DOWNLOAD_INTERRUPT_REASON_NETWORK_FAILED, false,
1914 std::vector<DownloadItem::ReceivedSlice>());
1913 1915
1914 download->Resume(); 1916 download->Resume();
1915 WaitForCompletion(download); 1917 WaitForCompletion(download);
1916 1918
1917 EXPECT_FALSE(PathExists(intermediate_file_path)); 1919 EXPECT_FALSE(PathExists(intermediate_file_path));
1918 ReadAndVerifyFileContents(parameters.pattern_generator_seed, 1920 ReadAndVerifyFileContents(parameters.pattern_generator_seed,
1919 parameters.size, 1921 parameters.size,
1920 download->GetTargetFilePath()); 1922 download->GetTargetFilePath());
1921 1923
1922 TestDownloadRequestHandler::CompletedRequests completed_requests; 1924 TestDownloadRequestHandler::CompletedRequests completed_requests;
(...skipping 28 matching lines...) Expand all
1951 1953
1952 url_chain.push_back(request_handler.url()); 1954 url_chain.push_back(request_handler.url());
1953 1955
1954 DownloadItem* download = DownloadManagerForShell(shell())->CreateDownloadItem( 1956 DownloadItem* download = DownloadManagerForShell(shell())->CreateDownloadItem(
1955 "F7FB1F59-7DE1-4845-AFDB-8A688F70F583", 1, intermediate_file_path, 1957 "F7FB1F59-7DE1-4845-AFDB-8A688F70F583", 1, intermediate_file_path,
1956 base::FilePath(), url_chain, GURL(), GURL(), GURL(), GURL(), 1958 base::FilePath(), url_chain, GURL(), GURL(), GURL(), GURL(),
1957 "application/octet-stream", "application/octet-stream", base::Time::Now(), 1959 "application/octet-stream", "application/octet-stream", base::Time::Now(),
1958 base::Time(), "fake-etag", std::string(), kIntermediateSize, 1960 base::Time(), "fake-etag", std::string(), kIntermediateSize,
1959 parameters.size, std::string(), DownloadItem::INTERRUPTED, 1961 parameters.size, std::string(), DownloadItem::INTERRUPTED,
1960 DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS, 1962 DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS,
1961 DOWNLOAD_INTERRUPT_REASON_NETWORK_FAILED, false); 1963 DOWNLOAD_INTERRUPT_REASON_NETWORK_FAILED, false,
1964 std::vector<DownloadItem::ReceivedSlice>());
1962 1965
1963 download->Resume(); 1966 download->Resume();
1964 WaitForCompletion(download); 1967 WaitForCompletion(download);
1965 1968
1966 EXPECT_FALSE(PathExists(intermediate_file_path)); 1969 EXPECT_FALSE(PathExists(intermediate_file_path));
1967 ReadAndVerifyFileContents(parameters.pattern_generator_seed, 1970 ReadAndVerifyFileContents(parameters.pattern_generator_seed,
1968 parameters.size, 1971 parameters.size,
1969 download->GetTargetFilePath()); 1972 download->GetTargetFilePath());
1970 1973
1971 TestDownloadRequestHandler::CompletedRequests completed_requests; 1974 TestDownloadRequestHandler::CompletedRequests completed_requests;
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
2006 url_chain.push_back(request_handler.url()); 2009 url_chain.push_back(request_handler.url());
2007 2010
2008 DownloadItem* download = DownloadManagerForShell(shell())->CreateDownloadItem( 2011 DownloadItem* download = DownloadManagerForShell(shell())->CreateDownloadItem(
2009 "F7FB1F59-7DE1-4845-AFDB-8A688F70F583", 1, intermediate_file_path, 2012 "F7FB1F59-7DE1-4845-AFDB-8A688F70F583", 1, intermediate_file_path,
2010 base::FilePath(), url_chain, GURL(), GURL(), GURL(), GURL(), 2013 base::FilePath(), url_chain, GURL(), GURL(), GURL(), GURL(),
2011 "application/octet-stream", "application/octet-stream", base::Time::Now(), 2014 "application/octet-stream", "application/octet-stream", base::Time::Now(),
2012 base::Time(), parameters.etag, std::string(), kIntermediateSize, 2015 base::Time(), parameters.etag, std::string(), kIntermediateSize,
2013 parameters.size, 2016 parameters.size,
2014 std::string(std::begin(kPartialHash), std::end(kPartialHash)), 2017 std::string(std::begin(kPartialHash), std::end(kPartialHash)),
2015 DownloadItem::INTERRUPTED, DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS, 2018 DownloadItem::INTERRUPTED, DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS,
2016 DOWNLOAD_INTERRUPT_REASON_NETWORK_FAILED, false); 2019 DOWNLOAD_INTERRUPT_REASON_NETWORK_FAILED, false,
2020 std::vector<DownloadItem::ReceivedSlice>());
2017 2021
2018 download->Resume(); 2022 download->Resume();
2019 WaitForCompletion(download); 2023 WaitForCompletion(download);
2020 2024
2021 EXPECT_FALSE(PathExists(intermediate_file_path)); 2025 EXPECT_FALSE(PathExists(intermediate_file_path));
2022 ReadAndVerifyFileContents(parameters.pattern_generator_seed, 2026 ReadAndVerifyFileContents(parameters.pattern_generator_seed,
2023 parameters.size, 2027 parameters.size,
2024 download->GetTargetFilePath()); 2028 download->GetTargetFilePath());
2025 2029
2026 TestDownloadRequestHandler::CompletedRequests completed_requests; 2030 TestDownloadRequestHandler::CompletedRequests completed_requests;
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
2067 url_chain.push_back(request_handler.url()); 2071 url_chain.push_back(request_handler.url());
2068 2072
2069 DownloadItem* download = DownloadManagerForShell(shell())->CreateDownloadItem( 2073 DownloadItem* download = DownloadManagerForShell(shell())->CreateDownloadItem(
2070 "F7FB1F59-7DE1-4845-AFDB-8A688F70F583", 1, intermediate_file_path, 2074 "F7FB1F59-7DE1-4845-AFDB-8A688F70F583", 1, intermediate_file_path,
2071 base::FilePath(), url_chain, GURL(), GURL(), GURL(), GURL(), 2075 base::FilePath(), url_chain, GURL(), GURL(), GURL(), GURL(),
2072 "application/octet-stream", "application/octet-stream", base::Time::Now(), 2076 "application/octet-stream", "application/octet-stream", base::Time::Now(),
2073 base::Time(), parameters.etag, std::string(), kIntermediateSize, 2077 base::Time(), parameters.etag, std::string(), kIntermediateSize,
2074 parameters.size, 2078 parameters.size,
2075 std::string(std::begin(kPartialHash), std::end(kPartialHash)), 2079 std::string(std::begin(kPartialHash), std::end(kPartialHash)),
2076 DownloadItem::INTERRUPTED, DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS, 2080 DownloadItem::INTERRUPTED, DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS,
2077 DOWNLOAD_INTERRUPT_REASON_NETWORK_FAILED, false); 2081 DOWNLOAD_INTERRUPT_REASON_NETWORK_FAILED, false,
2082 std::vector<DownloadItem::ReceivedSlice>());
2078 2083
2079 download->Resume(); 2084 download->Resume();
2080 WaitForCompletion(download); 2085 WaitForCompletion(download);
2081 2086
2082 EXPECT_FALSE(PathExists(intermediate_file_path)); 2087 EXPECT_FALSE(PathExists(intermediate_file_path));
2083 ReadAndVerifyFileContents(parameters.pattern_generator_seed, 2088 ReadAndVerifyFileContents(parameters.pattern_generator_seed,
2084 parameters.size, 2089 parameters.size,
2085 download->GetTargetFilePath()); 2090 download->GetTargetFilePath());
2086 2091
2087 TestDownloadRequestHandler::CompletedRequests completed_requests; 2092 TestDownloadRequestHandler::CompletedRequests completed_requests;
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
2137 } 2142 }
2138 url_chain.push_back(request_handler.url()); 2143 url_chain.push_back(request_handler.url());
2139 2144
2140 DownloadItem* download = DownloadManagerForShell(shell())->CreateDownloadItem( 2145 DownloadItem* download = DownloadManagerForShell(shell())->CreateDownloadItem(
2141 "F7FB1F59-7DE1-4845-AFDB-8A688F70F583", 1, intermediate_file_path, 2146 "F7FB1F59-7DE1-4845-AFDB-8A688F70F583", 1, intermediate_file_path,
2142 base::FilePath(), url_chain, GURL(), GURL(), GURL(), GURL(), 2147 base::FilePath(), url_chain, GURL(), GURL(), GURL(), GURL(),
2143 "application/octet-stream", "application/octet-stream", base::Time::Now(), 2148 "application/octet-stream", "application/octet-stream", base::Time::Now(),
2144 base::Time(), parameters.etag, std::string(), kIntermediateSize, 2149 base::Time(), parameters.etag, std::string(), kIntermediateSize,
2145 parameters.size, std::string(), DownloadItem::INTERRUPTED, 2150 parameters.size, std::string(), DownloadItem::INTERRUPTED,
2146 DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS, 2151 DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS,
2147 DOWNLOAD_INTERRUPT_REASON_NETWORK_FAILED, false); 2152 DOWNLOAD_INTERRUPT_REASON_NETWORK_FAILED, false,
2153 std::vector<DownloadItem::ReceivedSlice>());
2148 2154
2149 download->Resume(); 2155 download->Resume();
2150 WaitForCompletion(download); 2156 WaitForCompletion(download);
2151 2157
2152 EXPECT_FALSE(PathExists(intermediate_file_path)); 2158 EXPECT_FALSE(PathExists(intermediate_file_path));
2153 ReadAndVerifyFileContents(parameters.pattern_generator_seed, 2159 ReadAndVerifyFileContents(parameters.pattern_generator_seed,
2154 parameters.size, 2160 parameters.size,
2155 download->GetTargetFilePath()); 2161 download->GetTargetFilePath());
2156 2162
2157 TestDownloadRequestHandler::CompletedRequests completed_requests; 2163 TestDownloadRequestHandler::CompletedRequests completed_requests;
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
2205 } 2211 }
2206 url_chain.push_back(request_handler.url()); 2212 url_chain.push_back(request_handler.url());
2207 2213
2208 DownloadItem* download = DownloadManagerForShell(shell())->CreateDownloadItem( 2214 DownloadItem* download = DownloadManagerForShell(shell())->CreateDownloadItem(
2209 "F7FB1F59-7DE1-4845-AFDB-8A688F70F583", 1, intermediate_file_path, 2215 "F7FB1F59-7DE1-4845-AFDB-8A688F70F583", 1, intermediate_file_path,
2210 base::FilePath(), url_chain, GURL(), GURL(), GURL(), GURL(), 2216 base::FilePath(), url_chain, GURL(), GURL(), GURL(), GURL(),
2211 "application/octet-stream", "application/octet-stream", base::Time::Now(), 2217 "application/octet-stream", "application/octet-stream", base::Time::Now(),
2212 base::Time(), parameters.etag, std::string(), kIntermediateSize, 2218 base::Time(), parameters.etag, std::string(), kIntermediateSize,
2213 parameters.size, std::string(), DownloadItem::INTERRUPTED, 2219 parameters.size, std::string(), DownloadItem::INTERRUPTED,
2214 DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS, 2220 DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS,
2215 DOWNLOAD_INTERRUPT_REASON_NETWORK_FAILED, false); 2221 DOWNLOAD_INTERRUPT_REASON_NETWORK_FAILED, false,
2222 std::vector<DownloadItem::ReceivedSlice>());
2216 2223
2217 download->Resume(); 2224 download->Resume();
2218 WaitForCompletion(download); 2225 WaitForCompletion(download);
2219 2226
2220 EXPECT_FALSE(PathExists(intermediate_file_path)); 2227 EXPECT_FALSE(PathExists(intermediate_file_path));
2221 ReadAndVerifyFileContents(parameters.pattern_generator_seed, 2228 ReadAndVerifyFileContents(parameters.pattern_generator_seed,
2222 parameters.size, 2229 parameters.size,
2223 download->GetTargetFilePath()); 2230 download->GetTargetFilePath());
2224 2231
2225 TestDownloadRequestHandler::CompletedRequests completed_requests; 2232 TestDownloadRequestHandler::CompletedRequests completed_requests;
(...skipping 411 matching lines...) Expand 10 before | Expand all | Expand 10 after
2637 GURL document_url = 2644 GURL document_url =
2638 origin_two.GetURL("/iframe-host.html?target=" + frame_url.spec()); 2645 origin_two.GetURL("/iframe-host.html?target=" + frame_url.spec());
2639 DownloadItem* download = StartDownloadAndReturnItem(shell(), document_url); 2646 DownloadItem* download = StartDownloadAndReturnItem(shell(), document_url);
2640 WaitForCompletion(download); 2647 WaitForCompletion(download);
2641 2648
2642 EXPECT_STREQ(FILE_PATH_LITERAL("download-test.lib"), 2649 EXPECT_STREQ(FILE_PATH_LITERAL("download-test.lib"),
2643 download->GetTargetFilePath().BaseName().value().c_str()); 2650 download->GetTargetFilePath().BaseName().value().c_str());
2644 } 2651 }
2645 2652
2646 } // namespace content 2653 } // namespace content
OLDNEW
« no previous file with comments | « components/history/content/browser/download_database_helper.cc ('k') | content/browser/download/download_item_factory.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698