| 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 "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "chrome/browser/download/download_manager.h" | 8 #include "chrome/browser/download/download_manager.h" |
| 9 #include "chrome/browser/download/download_util.h" | 9 #include "chrome/browser/download/download_util.h" |
| 10 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
| 11 | 11 |
| 12 class DownloadManagerTest : public testing::Test { | 12 class DownloadManagerTest : public testing::Test { |
| 13 public: | 13 public: |
| 14 DownloadManagerTest() { | 14 DownloadManagerTest() { |
| 15 download_manager_ = new DownloadManager(); | 15 download_manager_ = new DownloadManager(); |
| 16 download_util::InitializeExeTypes(&download_manager_->exe_types_); | 16 download_util::InitializeExeTypes(&download_manager_->exe_types_); |
| 17 } | 17 } |
| 18 | 18 |
| 19 void GetGeneratedFilename(const std::string& content_disposition, | 19 void GetGeneratedFilename(const std::string& content_disposition, |
| 20 const std::wstring& url, | 20 const std::wstring& url, |
| 21 const std::string& mime_type, | 21 const std::string& mime_type, |
| 22 std::wstring* generated_name) { | 22 std::wstring* generated_name_string) { |
| 23 DownloadCreateInfo info; | 23 DownloadCreateInfo info; |
| 24 info.content_disposition = content_disposition; | 24 info.content_disposition = content_disposition; |
| 25 info.url = url; | 25 info.url = url; |
| 26 info.mime_type = mime_type; | 26 info.mime_type = mime_type; |
| 27 download_manager_->GenerateFilename(&info, generated_name); | 27 FilePath generated_name; |
| 28 download_manager_->GenerateFilename(&info, &generated_name); |
| 29 *generated_name_string = generated_name.ToWStringHack(); |
| 28 } | 30 } |
| 29 | 31 |
| 30 protected: | 32 protected: |
| 31 scoped_refptr<DownloadManager> download_manager_; | 33 scoped_refptr<DownloadManager> download_manager_; |
| 32 MessageLoopForUI message_loop_; | 34 MessageLoopForUI message_loop_; |
| 33 | 35 |
| 34 DISALLOW_EVIL_CONSTRUCTORS(DownloadManagerTest); | 36 DISALLOW_EVIL_CONSTRUCTORS(DownloadManagerTest); |
| 35 }; | 37 }; |
| 36 | 38 |
| 37 namespace { | 39 namespace { |
| (...skipping 335 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 373 } // namespace | 375 } // namespace |
| 374 | 376 |
| 375 TEST_F(DownloadManagerTest, GetSafeFilename) { | 377 TEST_F(DownloadManagerTest, GetSafeFilename) { |
| 376 for (int i = 0; i < arraysize(kSafeFilenameCases); ++i) { | 378 for (int i = 0; i < arraysize(kSafeFilenameCases); ++i) { |
| 377 std::wstring path(kSafeFilenameCases[i].path); | 379 std::wstring path(kSafeFilenameCases[i].path); |
| 378 download_manager_->GenerateSafeFilename(kSafeFilenameCases[i].mime_type, | 380 download_manager_->GenerateSafeFilename(kSafeFilenameCases[i].mime_type, |
| 379 &path); | 381 &path); |
| 380 EXPECT_EQ(kSafeFilenameCases[i].expected_path, path); | 382 EXPECT_EQ(kSafeFilenameCases[i].expected_path, path); |
| 381 } | 383 } |
| 382 } | 384 } |
| OLD | NEW |