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

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

Issue 2705283003: Added last_access_time to DownloadItem and History DB (Closed)
Patch Set: Fix tests 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, base::Time());
1851 1851
1852 download->Resume(); 1852 download->Resume();
1853 WaitForCompletion(download); 1853 WaitForCompletion(download);
1854 1854
1855 EXPECT_FALSE(PathExists(intermediate_file_path)); 1855 EXPECT_FALSE(PathExists(intermediate_file_path));
1856 ReadAndVerifyFileContents(parameters.pattern_generator_seed, 1856 ReadAndVerifyFileContents(parameters.pattern_generator_seed,
1857 parameters.size, 1857 parameters.size,
1858 download->GetTargetFilePath()); 1858 download->GetTargetFilePath());
1859 1859
1860 TestDownloadRequestHandler::CompletedRequests completed_requests; 1860 TestDownloadRequestHandler::CompletedRequests completed_requests;
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
1902 1902
1903 url_chain.push_back(request_handler.url()); 1903 url_chain.push_back(request_handler.url());
1904 1904
1905 DownloadItem* download = DownloadManagerForShell(shell())->CreateDownloadItem( 1905 DownloadItem* download = DownloadManagerForShell(shell())->CreateDownloadItem(
1906 "F7FB1F59-7DE1-4845-AFDB-8A688F70F583", 1, intermediate_file_path, 1906 "F7FB1F59-7DE1-4845-AFDB-8A688F70F583", 1, intermediate_file_path,
1907 base::FilePath(), url_chain, GURL(), GURL(), GURL(), GURL(), 1907 base::FilePath(), url_chain, GURL(), GURL(), GURL(), GURL(),
1908 "application/octet-stream", "application/octet-stream", base::Time::Now(), 1908 "application/octet-stream", "application/octet-stream", base::Time::Now(),
1909 base::Time(), parameters.etag, std::string(), kIntermediateSize, 1909 base::Time(), parameters.etag, std::string(), kIntermediateSize,
1910 parameters.size, std::string(), DownloadItem::INTERRUPTED, 1910 parameters.size, std::string(), DownloadItem::INTERRUPTED,
1911 DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS, 1911 DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS,
1912 DOWNLOAD_INTERRUPT_REASON_NETWORK_FAILED, false); 1912 DOWNLOAD_INTERRUPT_REASON_NETWORK_FAILED, false, base::Time());
1913 1913
1914 download->Resume(); 1914 download->Resume();
1915 WaitForCompletion(download); 1915 WaitForCompletion(download);
1916 1916
1917 EXPECT_FALSE(PathExists(intermediate_file_path)); 1917 EXPECT_FALSE(PathExists(intermediate_file_path));
1918 ReadAndVerifyFileContents(parameters.pattern_generator_seed, 1918 ReadAndVerifyFileContents(parameters.pattern_generator_seed,
1919 parameters.size, 1919 parameters.size,
1920 download->GetTargetFilePath()); 1920 download->GetTargetFilePath());
1921 1921
1922 TestDownloadRequestHandler::CompletedRequests completed_requests; 1922 TestDownloadRequestHandler::CompletedRequests completed_requests;
(...skipping 28 matching lines...) Expand all
1951 1951
1952 url_chain.push_back(request_handler.url()); 1952 url_chain.push_back(request_handler.url());
1953 1953
1954 DownloadItem* download = DownloadManagerForShell(shell())->CreateDownloadItem( 1954 DownloadItem* download = DownloadManagerForShell(shell())->CreateDownloadItem(
1955 "F7FB1F59-7DE1-4845-AFDB-8A688F70F583", 1, intermediate_file_path, 1955 "F7FB1F59-7DE1-4845-AFDB-8A688F70F583", 1, intermediate_file_path,
1956 base::FilePath(), url_chain, GURL(), GURL(), GURL(), GURL(), 1956 base::FilePath(), url_chain, GURL(), GURL(), GURL(), GURL(),
1957 "application/octet-stream", "application/octet-stream", base::Time::Now(), 1957 "application/octet-stream", "application/octet-stream", base::Time::Now(),
1958 base::Time(), "fake-etag", std::string(), kIntermediateSize, 1958 base::Time(), "fake-etag", std::string(), kIntermediateSize,
1959 parameters.size, std::string(), DownloadItem::INTERRUPTED, 1959 parameters.size, std::string(), DownloadItem::INTERRUPTED,
1960 DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS, 1960 DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS,
1961 DOWNLOAD_INTERRUPT_REASON_NETWORK_FAILED, false); 1961 DOWNLOAD_INTERRUPT_REASON_NETWORK_FAILED, false, base::Time());
1962 1962
1963 download->Resume(); 1963 download->Resume();
1964 WaitForCompletion(download); 1964 WaitForCompletion(download);
1965 1965
1966 EXPECT_FALSE(PathExists(intermediate_file_path)); 1966 EXPECT_FALSE(PathExists(intermediate_file_path));
1967 ReadAndVerifyFileContents(parameters.pattern_generator_seed, 1967 ReadAndVerifyFileContents(parameters.pattern_generator_seed,
1968 parameters.size, 1968 parameters.size,
1969 download->GetTargetFilePath()); 1969 download->GetTargetFilePath());
1970 1970
1971 TestDownloadRequestHandler::CompletedRequests completed_requests; 1971 TestDownloadRequestHandler::CompletedRequests completed_requests;
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
2006 url_chain.push_back(request_handler.url()); 2006 url_chain.push_back(request_handler.url());
2007 2007
2008 DownloadItem* download = DownloadManagerForShell(shell())->CreateDownloadItem( 2008 DownloadItem* download = DownloadManagerForShell(shell())->CreateDownloadItem(
2009 "F7FB1F59-7DE1-4845-AFDB-8A688F70F583", 1, intermediate_file_path, 2009 "F7FB1F59-7DE1-4845-AFDB-8A688F70F583", 1, intermediate_file_path,
2010 base::FilePath(), url_chain, GURL(), GURL(), GURL(), GURL(), 2010 base::FilePath(), url_chain, GURL(), GURL(), GURL(), GURL(),
2011 "application/octet-stream", "application/octet-stream", base::Time::Now(), 2011 "application/octet-stream", "application/octet-stream", base::Time::Now(),
2012 base::Time(), parameters.etag, std::string(), kIntermediateSize, 2012 base::Time(), parameters.etag, std::string(), kIntermediateSize,
2013 parameters.size, 2013 parameters.size,
2014 std::string(std::begin(kPartialHash), std::end(kPartialHash)), 2014 std::string(std::begin(kPartialHash), std::end(kPartialHash)),
2015 DownloadItem::INTERRUPTED, DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS, 2015 DownloadItem::INTERRUPTED, DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS,
2016 DOWNLOAD_INTERRUPT_REASON_NETWORK_FAILED, false); 2016 DOWNLOAD_INTERRUPT_REASON_NETWORK_FAILED, false, base::Time());
2017 2017
2018 download->Resume(); 2018 download->Resume();
2019 WaitForCompletion(download); 2019 WaitForCompletion(download);
2020 2020
2021 EXPECT_FALSE(PathExists(intermediate_file_path)); 2021 EXPECT_FALSE(PathExists(intermediate_file_path));
2022 ReadAndVerifyFileContents(parameters.pattern_generator_seed, 2022 ReadAndVerifyFileContents(parameters.pattern_generator_seed,
2023 parameters.size, 2023 parameters.size,
2024 download->GetTargetFilePath()); 2024 download->GetTargetFilePath());
2025 2025
2026 TestDownloadRequestHandler::CompletedRequests completed_requests; 2026 TestDownloadRequestHandler::CompletedRequests completed_requests;
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
2067 url_chain.push_back(request_handler.url()); 2067 url_chain.push_back(request_handler.url());
2068 2068
2069 DownloadItem* download = DownloadManagerForShell(shell())->CreateDownloadItem( 2069 DownloadItem* download = DownloadManagerForShell(shell())->CreateDownloadItem(
2070 "F7FB1F59-7DE1-4845-AFDB-8A688F70F583", 1, intermediate_file_path, 2070 "F7FB1F59-7DE1-4845-AFDB-8A688F70F583", 1, intermediate_file_path,
2071 base::FilePath(), url_chain, GURL(), GURL(), GURL(), GURL(), 2071 base::FilePath(), url_chain, GURL(), GURL(), GURL(), GURL(),
2072 "application/octet-stream", "application/octet-stream", base::Time::Now(), 2072 "application/octet-stream", "application/octet-stream", base::Time::Now(),
2073 base::Time(), parameters.etag, std::string(), kIntermediateSize, 2073 base::Time(), parameters.etag, std::string(), kIntermediateSize,
2074 parameters.size, 2074 parameters.size,
2075 std::string(std::begin(kPartialHash), std::end(kPartialHash)), 2075 std::string(std::begin(kPartialHash), std::end(kPartialHash)),
2076 DownloadItem::INTERRUPTED, DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS, 2076 DownloadItem::INTERRUPTED, DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS,
2077 DOWNLOAD_INTERRUPT_REASON_NETWORK_FAILED, false); 2077 DOWNLOAD_INTERRUPT_REASON_NETWORK_FAILED, false, base::Time());
2078 2078
2079 download->Resume(); 2079 download->Resume();
2080 WaitForCompletion(download); 2080 WaitForCompletion(download);
2081 2081
2082 EXPECT_FALSE(PathExists(intermediate_file_path)); 2082 EXPECT_FALSE(PathExists(intermediate_file_path));
2083 ReadAndVerifyFileContents(parameters.pattern_generator_seed, 2083 ReadAndVerifyFileContents(parameters.pattern_generator_seed,
2084 parameters.size, 2084 parameters.size,
2085 download->GetTargetFilePath()); 2085 download->GetTargetFilePath());
2086 2086
2087 TestDownloadRequestHandler::CompletedRequests completed_requests; 2087 TestDownloadRequestHandler::CompletedRequests completed_requests;
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
2137 } 2137 }
2138 url_chain.push_back(request_handler.url()); 2138 url_chain.push_back(request_handler.url());
2139 2139
2140 DownloadItem* download = DownloadManagerForShell(shell())->CreateDownloadItem( 2140 DownloadItem* download = DownloadManagerForShell(shell())->CreateDownloadItem(
2141 "F7FB1F59-7DE1-4845-AFDB-8A688F70F583", 1, intermediate_file_path, 2141 "F7FB1F59-7DE1-4845-AFDB-8A688F70F583", 1, intermediate_file_path,
2142 base::FilePath(), url_chain, GURL(), GURL(), GURL(), GURL(), 2142 base::FilePath(), url_chain, GURL(), GURL(), GURL(), GURL(),
2143 "application/octet-stream", "application/octet-stream", base::Time::Now(), 2143 "application/octet-stream", "application/octet-stream", base::Time::Now(),
2144 base::Time(), parameters.etag, std::string(), kIntermediateSize, 2144 base::Time(), parameters.etag, std::string(), kIntermediateSize,
2145 parameters.size, std::string(), DownloadItem::INTERRUPTED, 2145 parameters.size, std::string(), DownloadItem::INTERRUPTED,
2146 DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS, 2146 DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS,
2147 DOWNLOAD_INTERRUPT_REASON_NETWORK_FAILED, false); 2147 DOWNLOAD_INTERRUPT_REASON_NETWORK_FAILED, false, base::Time());
2148 2148
2149 download->Resume(); 2149 download->Resume();
2150 WaitForCompletion(download); 2150 WaitForCompletion(download);
2151 2151
2152 EXPECT_FALSE(PathExists(intermediate_file_path)); 2152 EXPECT_FALSE(PathExists(intermediate_file_path));
2153 ReadAndVerifyFileContents(parameters.pattern_generator_seed, 2153 ReadAndVerifyFileContents(parameters.pattern_generator_seed,
2154 parameters.size, 2154 parameters.size,
2155 download->GetTargetFilePath()); 2155 download->GetTargetFilePath());
2156 2156
2157 TestDownloadRequestHandler::CompletedRequests completed_requests; 2157 TestDownloadRequestHandler::CompletedRequests completed_requests;
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
2205 } 2205 }
2206 url_chain.push_back(request_handler.url()); 2206 url_chain.push_back(request_handler.url());
2207 2207
2208 DownloadItem* download = DownloadManagerForShell(shell())->CreateDownloadItem( 2208 DownloadItem* download = DownloadManagerForShell(shell())->CreateDownloadItem(
2209 "F7FB1F59-7DE1-4845-AFDB-8A688F70F583", 1, intermediate_file_path, 2209 "F7FB1F59-7DE1-4845-AFDB-8A688F70F583", 1, intermediate_file_path,
2210 base::FilePath(), url_chain, GURL(), GURL(), GURL(), GURL(), 2210 base::FilePath(), url_chain, GURL(), GURL(), GURL(), GURL(),
2211 "application/octet-stream", "application/octet-stream", base::Time::Now(), 2211 "application/octet-stream", "application/octet-stream", base::Time::Now(),
2212 base::Time(), parameters.etag, std::string(), kIntermediateSize, 2212 base::Time(), parameters.etag, std::string(), kIntermediateSize,
2213 parameters.size, std::string(), DownloadItem::INTERRUPTED, 2213 parameters.size, std::string(), DownloadItem::INTERRUPTED,
2214 DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS, 2214 DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS,
2215 DOWNLOAD_INTERRUPT_REASON_NETWORK_FAILED, false); 2215 DOWNLOAD_INTERRUPT_REASON_NETWORK_FAILED, false, base::Time());
2216 2216
2217 download->Resume(); 2217 download->Resume();
2218 WaitForCompletion(download); 2218 WaitForCompletion(download);
2219 2219
2220 EXPECT_FALSE(PathExists(intermediate_file_path)); 2220 EXPECT_FALSE(PathExists(intermediate_file_path));
2221 ReadAndVerifyFileContents(parameters.pattern_generator_seed, 2221 ReadAndVerifyFileContents(parameters.pattern_generator_seed,
2222 parameters.size, 2222 parameters.size,
2223 download->GetTargetFilePath()); 2223 download->GetTargetFilePath());
2224 2224
2225 TestDownloadRequestHandler::CompletedRequests completed_requests; 2225 TestDownloadRequestHandler::CompletedRequests completed_requests;
(...skipping 411 matching lines...) Expand 10 before | Expand all | Expand 10 after
2637 GURL document_url = 2637 GURL document_url =
2638 origin_two.GetURL("/iframe-host.html?target=" + frame_url.spec()); 2638 origin_two.GetURL("/iframe-host.html?target=" + frame_url.spec());
2639 DownloadItem* download = StartDownloadAndReturnItem(shell(), document_url); 2639 DownloadItem* download = StartDownloadAndReturnItem(shell(), document_url);
2640 WaitForCompletion(download); 2640 WaitForCompletion(download);
2641 2641
2642 EXPECT_STREQ(FILE_PATH_LITERAL("download-test.lib"), 2642 EXPECT_STREQ(FILE_PATH_LITERAL("download-test.lib"),
2643 download->GetTargetFilePath().BaseName().value().c_str()); 2643 download->GetTargetFilePath().BaseName().value().c_str());
2644 } 2644 }
2645 2645
2646 } // namespace content 2646 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698