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

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

Issue 2384713004: [downloads] Correctly plumb client ID for download file scanning. (Closed)
Patch Set: . Created 4 years, 2 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
« no previous file with comments | « no previous file | content/browser/download/download_manager_impl.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 #include "chrome/browser/download/download_browsertest.h" 5 #include "chrome/browser/download/download_browsertest.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 #include <sstream> 8 #include <sstream>
9 #include <utility> 9 #include <utility>
10 10
(...skipping 1161 matching lines...) Expand 10 before | Expand all | Expand 10 after
1172 1172
1173 // Check state. 1173 // Check state.
1174 EXPECT_EQ(1, browser()->tab_strip_model()->count()); 1174 EXPECT_EQ(1, browser()->tab_strip_model()->count());
1175 base::FilePath file(FILE_PATH_LITERAL("download-test1.lib")); 1175 base::FilePath file(FILE_PATH_LITERAL("download-test1.lib"));
1176 CheckDownload(browser(), file, file); 1176 CheckDownload(browser(), file, file);
1177 } 1177 }
1178 1178
1179 #if defined(OS_WIN) 1179 #if defined(OS_WIN)
1180 // Download a file and confirm that the zone identifier (on windows) 1180 // Download a file and confirm that the zone identifier (on windows)
1181 // is set to internet. 1181 // is set to internet.
1182 IN_PROC_BROWSER_TEST_F(DownloadTest, CheckInternetZone) { 1182 IN_PROC_BROWSER_TEST_F(DownloadTest, CheckInternetZone_DependsOnLocalConfig) {
1183 GURL url(URLRequestMockHTTPJob::GetMockUrl(kDownloadTest1Path)); 1183 GURL url(URLRequestMockHTTPJob::GetMockUrl(kDownloadTest1Path));
1184 1184
1185 // Download the file and wait. We do not expect the Select File dialog. 1185 // Download the file and wait. We do not expect the Select File dialog.
1186 DownloadAndWait(browser(), url); 1186 DownloadAndWait(browser(), url);
1187 1187
1188 // Check state. Special file state must be checked before CheckDownload, 1188 // Check state. Special file state must be checked before CheckDownload,
1189 // as CheckDownload will delete the output file. 1189 // as CheckDownload will delete the output file.
1190 EXPECT_EQ(1, browser()->tab_strip_model()->count()); 1190 EXPECT_EQ(1, browser()->tab_strip_model()->count());
1191 base::FilePath file(FILE_PATH_LITERAL("download-test1.lib")); 1191 base::FilePath file(FILE_PATH_LITERAL("download-test1.lib"));
1192 base::FilePath downloaded_file(DestinationFile(browser(), file)); 1192 base::FilePath downloaded_file(DestinationFile(browser(), file));
1193 if (base::VolumeSupportsADS(downloaded_file)) 1193 if (base::VolumeSupportsADS(downloaded_file))
1194 EXPECT_TRUE(base::HasInternetZoneIdentifier(downloaded_file)); 1194 EXPECT_TRUE(base::HasInternetZoneIdentifier(downloaded_file));
1195 CheckDownload(browser(), file, file); 1195 CheckDownload(browser(), file, file);
1196 } 1196 }
1197
1198 // Downloading a file from the local host shouldn't cause the application of a
1199 // zone identifier.
1200 IN_PROC_BROWSER_TEST_F(DownloadTest, CheckLocalhostZone_DependsOnLocalConfig) {
1201 embedded_test_server()->ServeFilesFromDirectory(GetTestDataDirectory());
1202 ASSERT_TRUE(embedded_test_server()->Start());
1203
1204 // Assumes that localhost maps to 127.0.0.1. Otherwise the test will fail
1205 // since EmbeddedTestServer is listening on that address.
1206 GURL url =
1207 embedded_test_server()->GetURL("localhost", "/downloads/a_zip_file.zip");
1208 DownloadAndWait(browser(), url);
1209 base::FilePath file(FILE_PATH_LITERAL("a_zip_file.zip"));
1210 base::FilePath downloaded_file(DestinationFile(browser(), file));
1211 EXPECT_FALSE(base::HasInternetZoneIdentifier(downloaded_file));
1212 }
1213
1214 // Same as the test above, but uses a file:// URL to a local file.
1215 IN_PROC_BROWSER_TEST_F(DownloadTest, CheckLocalFileZone_DependsOnLocalConfig) {
1216 base::FilePath source_file = GetTestDataDirectory()
1217 .AppendASCII("downloads")
1218 .AppendASCII("a_zip_file.zip");
1219
1220 GURL url = net::FilePathToFileURL(source_file);
1221 DownloadAndWait(browser(), url);
1222 base::FilePath file(FILE_PATH_LITERAL("a_zip_file.zip"));
1223 base::FilePath downloaded_file(DestinationFile(browser(), file));
1224 EXPECT_FALSE(base::HasInternetZoneIdentifier(downloaded_file));
1225 }
1197 #endif 1226 #endif
1198 1227
1199 // Put up a Select File dialog when the file is downloaded, due to 1228 // Put up a Select File dialog when the file is downloaded, due to
1200 // downloads preferences settings. 1229 // downloads preferences settings.
1201 IN_PROC_BROWSER_TEST_F(DownloadTest, DownloadMimeTypeSelect) { 1230 IN_PROC_BROWSER_TEST_F(DownloadTest, DownloadMimeTypeSelect) {
1202 // Re-enable prompting. 1231 // Re-enable prompting.
1203 browser()->profile()->GetPrefs()->SetBoolean( 1232 browser()->profile()->GetPrefs()->SetBoolean(
1204 prefs::kPromptForDownload, true); 1233 prefs::kPromptForDownload, true);
1205 GURL url(URLRequestMockHTTPJob::GetMockUrl(kDownloadTest1Path)); 1234 GURL url(URLRequestMockHTTPJob::GetMockUrl(kDownloadTest1Path));
1206 1235
(...skipping 2431 matching lines...) Expand 10 before | Expand all | Expand 10 after
3638 browser(), 1, 3667 browser(), 1,
3639 content::DownloadTestObserver::ON_DANGEROUS_DOWNLOAD_DENY)); 3668 content::DownloadTestObserver::ON_DANGEROUS_DOWNLOAD_DENY));
3640 ui_test_utils::NavigateToURL(browser(), extension_url); 3669 ui_test_utils::NavigateToURL(browser(), extension_url);
3641 3670
3642 observer->WaitForFinished(); 3671 observer->WaitForFinished();
3643 3672
3644 // Download shelf should close. 3673 // Download shelf should close.
3645 EXPECT_FALSE(browser()->window()->IsDownloadShelfVisible()); 3674 EXPECT_FALSE(browser()->window()->IsDownloadShelfVisible());
3646 } 3675 }
3647 #endif // defined(OS_CHROMEOS) 3676 #endif // defined(OS_CHROMEOS)
OLDNEW
« no previous file with comments | « no previous file | content/browser/download/download_manager_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698