Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 <string> | 5 #include <string> |
| 6 | 6 |
| 7 #include "chrome/browser/download/download_manager.h" | 7 #include "chrome/browser/download/download_manager.h" |
| 8 #include "chrome/browser/download/download_util.h" | 8 #include "chrome/browser/download/download_util.h" |
| 9 #include "testing/gtest/include/gtest/gtest.h" | 9 #include "testing/gtest/include/gtest/gtest.h" |
| 10 | 10 |
| (...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 306 "http://www.google.com/%EC%98%88%EC%88%A0%20%EC%98%88%EC%88%A0.jpg", | 306 "http://www.google.com/%EC%98%88%EC%88%A0%20%EC%98%88%EC%88%A0.jpg", |
| 307 "image/jpeg", | 307 "image/jpeg", |
| 308 L"\uc608\uc220 \uc608\uc220.jpg"}, | 308 L"\uc608\uc220 \uc608\uc220.jpg"}, |
| 309 | 309 |
| 310 // Invalid C-D. No filename from URL. Falls back to 'download'. | 310 // Invalid C-D. No filename from URL. Falls back to 'download'. |
| 311 {"attachment; filename==?iso88591?Q?caf=E3?", | 311 {"attachment; filename==?iso88591?Q?caf=E3?", |
| 312 "http://www.google.com/path1/path2/", | 312 "http://www.google.com/path1/path2/", |
| 313 "image/jpeg", | 313 "image/jpeg", |
| 314 L"download.jpg"}, | 314 L"download.jpg"}, |
| 315 | 315 |
| 316 // For bug 5772 | |
|
sidchat (Google)
2009/03/25 22:09:36
// Issue = 5772.
| |
| 317 {"", | |
| 318 "http://www.example.com/foo.tar.gz", | |
| 319 "application/x-tar", | |
| 320 L"foo.tar.gz"}, | |
| 321 | |
| 322 {"", | |
| 323 "http://www.example.com/bar.tar", | |
| 324 "application/x-tar", | |
| 325 L"bar.tar"}, | |
| 326 | |
| 327 {"", | |
| 328 "http://www.example.com/bar.bogus", | |
| 329 "application/x-tar", | |
| 330 L"bar.bogus.tar"}, | |
| 331 | |
| 316 // TODO(darin): Add some raw 8-bit Content-Disposition tests. | 332 // TODO(darin): Add some raw 8-bit Content-Disposition tests. |
| 317 }; | 333 }; |
| 318 | 334 |
| 319 } // namespace | 335 } // namespace |
| 320 | 336 |
| 321 // Tests to ensure that the file names we generate from hints from the server | 337 // Tests to ensure that the file names we generate from hints from the server |
| 322 // (content-disposition, URL name, etc) don't cause security holes. | 338 // (content-disposition, URL name, etc) don't cause security holes. |
| 323 TEST_F(DownloadManagerTest, TestDownloadFilename) { | 339 TEST_F(DownloadManagerTest, TestDownloadFilename) { |
| 324 for (int i = 0; i < arraysize(kGeneratedFiles); ++i) { | 340 for (int i = 0; i < arraysize(kGeneratedFiles); ++i) { |
| 325 std::wstring file_name; | 341 std::wstring file_name; |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 377 } // namespace | 393 } // namespace |
| 378 | 394 |
| 379 TEST_F(DownloadManagerTest, GetSafeFilename) { | 395 TEST_F(DownloadManagerTest, GetSafeFilename) { |
| 380 for (int i = 0; i < arraysize(kSafeFilenameCases); ++i) { | 396 for (int i = 0; i < arraysize(kSafeFilenameCases); ++i) { |
| 381 FilePath path(kSafeFilenameCases[i].path); | 397 FilePath path(kSafeFilenameCases[i].path); |
| 382 download_manager_->GenerateSafeFilename(kSafeFilenameCases[i].mime_type, | 398 download_manager_->GenerateSafeFilename(kSafeFilenameCases[i].mime_type, |
| 383 &path); | 399 &path); |
| 384 EXPECT_EQ(kSafeFilenameCases[i].expected_path, path.value()); | 400 EXPECT_EQ(kSafeFilenameCases[i].expected_path, path.value()); |
| 385 } | 401 } |
| 386 } | 402 } |
| OLD | NEW |