| 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_string) { | 22 std::wstring* generated_name) { |
| 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 FilePath generated_name; | 27 download_manager_->GenerateFilename(&info, generated_name); |
| 28 download_manager_->GenerateFilename(&info, &generated_name); | |
| 29 *generated_name_string = generated_name.ToWStringHack(); | |
| 30 } | 28 } |
| 31 | 29 |
| 32 protected: | 30 protected: |
| 33 scoped_refptr<DownloadManager> download_manager_; | 31 scoped_refptr<DownloadManager> download_manager_; |
| 34 MessageLoopForUI message_loop_; | 32 MessageLoopForUI message_loop_; |
| 35 | 33 |
| 36 DISALLOW_EVIL_CONSTRUCTORS(DownloadManagerTest); | 34 DISALLOW_EVIL_CONSTRUCTORS(DownloadManagerTest); |
| 37 }; | 35 }; |
| 38 | 36 |
| 39 static const struct { | 37 static const struct { |
| (...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 318 for (int i = 0; i < arraysize(kGeneratedFiles); ++i) { | 316 for (int i = 0; i < arraysize(kGeneratedFiles); ++i) { |
| 319 std::wstring file_name; | 317 std::wstring file_name; |
| 320 GetGeneratedFilename(kGeneratedFiles[i].disposition, | 318 GetGeneratedFilename(kGeneratedFiles[i].disposition, |
| 321 kGeneratedFiles[i].url, | 319 kGeneratedFiles[i].url, |
| 322 kGeneratedFiles[i].mime_type, | 320 kGeneratedFiles[i].mime_type, |
| 323 &file_name); | 321 &file_name); |
| 324 EXPECT_EQ(kGeneratedFiles[i].expected_name, file_name); | 322 EXPECT_EQ(kGeneratedFiles[i].expected_name, file_name); |
| 325 } | 323 } |
| 326 } | 324 } |
| 327 | 325 |
| OLD | NEW |