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

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

Issue 2720613002: Downloads: Added transient flag to download item and download database (Closed)
Patch Set: Fixed migration unit test Created 3 years, 9 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, base::Time(), 1850 DOWNLOAD_INTERRUPT_REASON_NETWORK_FAILED, false, base::Time(), true,
1851 std::vector<DownloadItem::ReceivedSlice>()); 1851 std::vector<DownloadItem::ReceivedSlice>());
1852 1852
1853 download->Resume(); 1853 download->Resume();
1854 WaitForCompletion(download); 1854 WaitForCompletion(download);
1855 1855
1856 EXPECT_FALSE(PathExists(intermediate_file_path)); 1856 EXPECT_FALSE(PathExists(intermediate_file_path));
1857 ReadAndVerifyFileContents(parameters.pattern_generator_seed, 1857 ReadAndVerifyFileContents(parameters.pattern_generator_seed,
1858 parameters.size, 1858 parameters.size,
1859 download->GetTargetFilePath()); 1859 download->GetTargetFilePath());
1860 1860
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
1903 1903
1904 url_chain.push_back(request_handler.url()); 1904 url_chain.push_back(request_handler.url());
1905 1905
1906 DownloadItem* download = DownloadManagerForShell(shell())->CreateDownloadItem( 1906 DownloadItem* download = DownloadManagerForShell(shell())->CreateDownloadItem(
1907 "F7FB1F59-7DE1-4845-AFDB-8A688F70F583", 1, intermediate_file_path, 1907 "F7FB1F59-7DE1-4845-AFDB-8A688F70F583", 1, intermediate_file_path,
1908 base::FilePath(), url_chain, GURL(), GURL(), GURL(), GURL(), 1908 base::FilePath(), url_chain, GURL(), GURL(), GURL(), GURL(),
1909 "application/octet-stream", "application/octet-stream", base::Time::Now(), 1909 "application/octet-stream", "application/octet-stream", base::Time::Now(),
1910 base::Time(), parameters.etag, std::string(), kIntermediateSize, 1910 base::Time(), parameters.etag, std::string(), kIntermediateSize,
1911 parameters.size, std::string(), DownloadItem::INTERRUPTED, 1911 parameters.size, std::string(), DownloadItem::INTERRUPTED,
1912 DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS, 1912 DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS,
1913 DOWNLOAD_INTERRUPT_REASON_NETWORK_FAILED, false, base::Time(), 1913 DOWNLOAD_INTERRUPT_REASON_NETWORK_FAILED, false, base::Time(), true,
1914 std::vector<DownloadItem::ReceivedSlice>()); 1914 std::vector<DownloadItem::ReceivedSlice>());
1915 1915
1916 download->Resume(); 1916 download->Resume();
1917 WaitForCompletion(download); 1917 WaitForCompletion(download);
1918 1918
1919 EXPECT_FALSE(PathExists(intermediate_file_path)); 1919 EXPECT_FALSE(PathExists(intermediate_file_path));
1920 ReadAndVerifyFileContents(parameters.pattern_generator_seed, 1920 ReadAndVerifyFileContents(parameters.pattern_generator_seed,
1921 parameters.size, 1921 parameters.size,
1922 download->GetTargetFilePath()); 1922 download->GetTargetFilePath());
1923 1923
(...skipping 29 matching lines...) Expand all
1953 1953
1954 url_chain.push_back(request_handler.url()); 1954 url_chain.push_back(request_handler.url());
1955 1955
1956 DownloadItem* download = DownloadManagerForShell(shell())->CreateDownloadItem( 1956 DownloadItem* download = DownloadManagerForShell(shell())->CreateDownloadItem(
1957 "F7FB1F59-7DE1-4845-AFDB-8A688F70F583", 1, intermediate_file_path, 1957 "F7FB1F59-7DE1-4845-AFDB-8A688F70F583", 1, intermediate_file_path,
1958 base::FilePath(), url_chain, GURL(), GURL(), GURL(), GURL(), 1958 base::FilePath(), url_chain, GURL(), GURL(), GURL(), GURL(),
1959 "application/octet-stream", "application/octet-stream", base::Time::Now(), 1959 "application/octet-stream", "application/octet-stream", base::Time::Now(),
1960 base::Time(), "fake-etag", std::string(), kIntermediateSize, 1960 base::Time(), "fake-etag", std::string(), kIntermediateSize,
1961 parameters.size, std::string(), DownloadItem::INTERRUPTED, 1961 parameters.size, std::string(), DownloadItem::INTERRUPTED,
1962 DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS, 1962 DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS,
1963 DOWNLOAD_INTERRUPT_REASON_NETWORK_FAILED, false, base::Time(), 1963 DOWNLOAD_INTERRUPT_REASON_NETWORK_FAILED, false, base::Time(), false,
1964 std::vector<DownloadItem::ReceivedSlice>()); 1964 std::vector<DownloadItem::ReceivedSlice>());
1965 1965
1966 download->Resume(); 1966 download->Resume();
1967 WaitForCompletion(download); 1967 WaitForCompletion(download);
1968 1968
1969 EXPECT_FALSE(PathExists(intermediate_file_path)); 1969 EXPECT_FALSE(PathExists(intermediate_file_path));
1970 ReadAndVerifyFileContents(parameters.pattern_generator_seed, 1970 ReadAndVerifyFileContents(parameters.pattern_generator_seed,
1971 parameters.size, 1971 parameters.size,
1972 download->GetTargetFilePath()); 1972 download->GetTargetFilePath());
1973 1973
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
2009 url_chain.push_back(request_handler.url()); 2009 url_chain.push_back(request_handler.url());
2010 2010
2011 DownloadItem* download = DownloadManagerForShell(shell())->CreateDownloadItem( 2011 DownloadItem* download = DownloadManagerForShell(shell())->CreateDownloadItem(
2012 "F7FB1F59-7DE1-4845-AFDB-8A688F70F583", 1, intermediate_file_path, 2012 "F7FB1F59-7DE1-4845-AFDB-8A688F70F583", 1, intermediate_file_path,
2013 base::FilePath(), url_chain, GURL(), GURL(), GURL(), GURL(), 2013 base::FilePath(), url_chain, GURL(), GURL(), GURL(), GURL(),
2014 "application/octet-stream", "application/octet-stream", base::Time::Now(), 2014 "application/octet-stream", "application/octet-stream", base::Time::Now(),
2015 base::Time(), parameters.etag, std::string(), kIntermediateSize, 2015 base::Time(), parameters.etag, std::string(), kIntermediateSize,
2016 parameters.size, 2016 parameters.size,
2017 std::string(std::begin(kPartialHash), std::end(kPartialHash)), 2017 std::string(std::begin(kPartialHash), std::end(kPartialHash)),
2018 DownloadItem::INTERRUPTED, DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS, 2018 DownloadItem::INTERRUPTED, DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS,
2019 DOWNLOAD_INTERRUPT_REASON_NETWORK_FAILED, false, base::Time(), 2019 DOWNLOAD_INTERRUPT_REASON_NETWORK_FAILED, false, base::Time(), true,
2020 std::vector<DownloadItem::ReceivedSlice>()); 2020 std::vector<DownloadItem::ReceivedSlice>());
2021 2021
2022 download->Resume(); 2022 download->Resume();
2023 WaitForCompletion(download); 2023 WaitForCompletion(download);
2024 2024
2025 EXPECT_FALSE(PathExists(intermediate_file_path)); 2025 EXPECT_FALSE(PathExists(intermediate_file_path));
2026 ReadAndVerifyFileContents(parameters.pattern_generator_seed, 2026 ReadAndVerifyFileContents(parameters.pattern_generator_seed,
2027 parameters.size, 2027 parameters.size,
2028 download->GetTargetFilePath()); 2028 download->GetTargetFilePath());
2029 2029
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
2071 url_chain.push_back(request_handler.url()); 2071 url_chain.push_back(request_handler.url());
2072 2072
2073 DownloadItem* download = DownloadManagerForShell(shell())->CreateDownloadItem( 2073 DownloadItem* download = DownloadManagerForShell(shell())->CreateDownloadItem(
2074 "F7FB1F59-7DE1-4845-AFDB-8A688F70F583", 1, intermediate_file_path, 2074 "F7FB1F59-7DE1-4845-AFDB-8A688F70F583", 1, intermediate_file_path,
2075 base::FilePath(), url_chain, GURL(), GURL(), GURL(), GURL(), 2075 base::FilePath(), url_chain, GURL(), GURL(), GURL(), GURL(),
2076 "application/octet-stream", "application/octet-stream", base::Time::Now(), 2076 "application/octet-stream", "application/octet-stream", base::Time::Now(),
2077 base::Time(), parameters.etag, std::string(), kIntermediateSize, 2077 base::Time(), parameters.etag, std::string(), kIntermediateSize,
2078 parameters.size, 2078 parameters.size,
2079 std::string(std::begin(kPartialHash), std::end(kPartialHash)), 2079 std::string(std::begin(kPartialHash), std::end(kPartialHash)),
2080 DownloadItem::INTERRUPTED, DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS, 2080 DownloadItem::INTERRUPTED, DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS,
2081 DOWNLOAD_INTERRUPT_REASON_NETWORK_FAILED, false, base::Time(), 2081 DOWNLOAD_INTERRUPT_REASON_NETWORK_FAILED, false, base::Time(), true,
2082 std::vector<DownloadItem::ReceivedSlice>()); 2082 std::vector<DownloadItem::ReceivedSlice>());
2083 2083
2084 download->Resume(); 2084 download->Resume();
2085 WaitForCompletion(download); 2085 WaitForCompletion(download);
2086 2086
2087 EXPECT_FALSE(PathExists(intermediate_file_path)); 2087 EXPECT_FALSE(PathExists(intermediate_file_path));
2088 ReadAndVerifyFileContents(parameters.pattern_generator_seed, 2088 ReadAndVerifyFileContents(parameters.pattern_generator_seed,
2089 parameters.size, 2089 parameters.size,
2090 download->GetTargetFilePath()); 2090 download->GetTargetFilePath());
2091 2091
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
2142 } 2142 }
2143 url_chain.push_back(request_handler.url()); 2143 url_chain.push_back(request_handler.url());
2144 2144
2145 DownloadItem* download = DownloadManagerForShell(shell())->CreateDownloadItem( 2145 DownloadItem* download = DownloadManagerForShell(shell())->CreateDownloadItem(
2146 "F7FB1F59-7DE1-4845-AFDB-8A688F70F583", 1, intermediate_file_path, 2146 "F7FB1F59-7DE1-4845-AFDB-8A688F70F583", 1, intermediate_file_path,
2147 base::FilePath(), url_chain, GURL(), GURL(), GURL(), GURL(), 2147 base::FilePath(), url_chain, GURL(), GURL(), GURL(), GURL(),
2148 "application/octet-stream", "application/octet-stream", base::Time::Now(), 2148 "application/octet-stream", "application/octet-stream", base::Time::Now(),
2149 base::Time(), parameters.etag, std::string(), kIntermediateSize, 2149 base::Time(), parameters.etag, std::string(), kIntermediateSize,
2150 parameters.size, std::string(), DownloadItem::INTERRUPTED, 2150 parameters.size, std::string(), DownloadItem::INTERRUPTED,
2151 DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS, 2151 DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS,
2152 DOWNLOAD_INTERRUPT_REASON_NETWORK_FAILED, false, base::Time(), 2152 DOWNLOAD_INTERRUPT_REASON_NETWORK_FAILED, false, base::Time(), true,
2153 std::vector<DownloadItem::ReceivedSlice>()); 2153 std::vector<DownloadItem::ReceivedSlice>());
2154 2154
2155 download->Resume(); 2155 download->Resume();
2156 WaitForCompletion(download); 2156 WaitForCompletion(download);
2157 2157
2158 EXPECT_FALSE(PathExists(intermediate_file_path)); 2158 EXPECT_FALSE(PathExists(intermediate_file_path));
2159 ReadAndVerifyFileContents(parameters.pattern_generator_seed, 2159 ReadAndVerifyFileContents(parameters.pattern_generator_seed,
2160 parameters.size, 2160 parameters.size,
2161 download->GetTargetFilePath()); 2161 download->GetTargetFilePath());
2162 2162
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
2211 } 2211 }
2212 url_chain.push_back(request_handler.url()); 2212 url_chain.push_back(request_handler.url());
2213 2213
2214 DownloadItem* download = DownloadManagerForShell(shell())->CreateDownloadItem( 2214 DownloadItem* download = DownloadManagerForShell(shell())->CreateDownloadItem(
2215 "F7FB1F59-7DE1-4845-AFDB-8A688F70F583", 1, intermediate_file_path, 2215 "F7FB1F59-7DE1-4845-AFDB-8A688F70F583", 1, intermediate_file_path,
2216 base::FilePath(), url_chain, GURL(), GURL(), GURL(), GURL(), 2216 base::FilePath(), url_chain, GURL(), GURL(), GURL(), GURL(),
2217 "application/octet-stream", "application/octet-stream", base::Time::Now(), 2217 "application/octet-stream", "application/octet-stream", base::Time::Now(),
2218 base::Time(), parameters.etag, std::string(), kIntermediateSize, 2218 base::Time(), parameters.etag, std::string(), kIntermediateSize,
2219 parameters.size, std::string(), DownloadItem::INTERRUPTED, 2219 parameters.size, std::string(), DownloadItem::INTERRUPTED,
2220 DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS, 2220 DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS,
2221 DOWNLOAD_INTERRUPT_REASON_NETWORK_FAILED, false, base::Time(), 2221 DOWNLOAD_INTERRUPT_REASON_NETWORK_FAILED, false, base::Time(), true,
2222 std::vector<DownloadItem::ReceivedSlice>()); 2222 std::vector<DownloadItem::ReceivedSlice>());
2223 2223
2224 download->Resume(); 2224 download->Resume();
2225 WaitForCompletion(download); 2225 WaitForCompletion(download);
2226 2226
2227 EXPECT_FALSE(PathExists(intermediate_file_path)); 2227 EXPECT_FALSE(PathExists(intermediate_file_path));
2228 ReadAndVerifyFileContents(parameters.pattern_generator_seed, 2228 ReadAndVerifyFileContents(parameters.pattern_generator_seed,
2229 parameters.size, 2229 parameters.size,
2230 download->GetTargetFilePath()); 2230 download->GetTargetFilePath());
2231 2231
(...skipping 412 matching lines...) Expand 10 before | Expand all | Expand 10 after
2644 GURL document_url = 2644 GURL document_url =
2645 origin_two.GetURL("/iframe-host.html?target=" + frame_url.spec()); 2645 origin_two.GetURL("/iframe-host.html?target=" + frame_url.spec());
2646 DownloadItem* download = StartDownloadAndReturnItem(shell(), document_url); 2646 DownloadItem* download = StartDownloadAndReturnItem(shell(), document_url);
2647 WaitForCompletion(download); 2647 WaitForCompletion(download);
2648 2648
2649 EXPECT_STREQ(FILE_PATH_LITERAL("download-test.lib"), 2649 EXPECT_STREQ(FILE_PATH_LITERAL("download-test.lib"),
2650 download->GetTargetFilePath().BaseName().value().c_str()); 2650 download->GetTargetFilePath().BaseName().value().c_str());
2651 } 2651 }
2652 2652
2653 } // namespace content 2653 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698