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

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

Issue 351029: Support dragging a virtual file out of the browser. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 10 years, 11 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 | Annotate | Revision Log
« no previous file with comments | « chrome/browser/download/download_manager.cc ('k') | chrome/browser/download/download_util.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) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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/string_util.h" 7 #include "base/string_util.h"
8 #include "build/build_config.h" 8 #include "build/build_config.h"
9 #include "chrome/browser/download/download_manager.h" 9 #include "chrome/browser/download/download_manager.h"
10 #include "chrome/browser/download/download_util.h"
11 #include "testing/gtest/include/gtest/gtest.h" 10 #include "testing/gtest/include/gtest/gtest.h"
12 11
13 #if defined(OS_LINUX) 12 #if defined(OS_LINUX)
14 #include <locale.h> 13 #include <locale.h>
15 #endif 14 #endif
16 15
17 #if defined(OS_WIN) 16 #if defined(OS_WIN)
18 #define JPEG_EXT L".jpg" 17 #define JPEG_EXT L".jpg"
19 #define HTML_EXT L".htm" 18 #define HTML_EXT L".htm"
20 #define TXT_EXT L".txt" 19 #define TXT_EXT L".txt"
21 #define TAR_EXT L".tar" 20 #define TAR_EXT L".tar"
22 #elif defined(OS_MACOSX) 21 #elif defined(OS_MACOSX)
23 #define JPEG_EXT L".jpeg" 22 #define JPEG_EXT L".jpeg"
24 #define HTML_EXT L".html" 23 #define HTML_EXT L".html"
25 #define TXT_EXT L".txt" 24 #define TXT_EXT L".txt"
26 #define TAR_EXT L".tar" 25 #define TAR_EXT L".tar"
27 #else 26 #else
28 #define JPEG_EXT L"" 27 #define JPEG_EXT L""
29 #define HTML_EXT L"" 28 #define HTML_EXT L""
30 #define TXT_EXT L"" 29 #define TXT_EXT L""
31 #define TAR_EXT L"" 30 #define TAR_EXT L""
32 #endif 31 #endif
33 32
34 class DownloadManagerTest : public testing::Test { 33 class DownloadManagerTest : public testing::Test {
35 public: 34 public:
36 DownloadManagerTest() { 35 DownloadManagerTest() {
37 download_manager_ = new DownloadManager(); 36 download_manager_ = new DownloadManager();
38 download_util::InitializeExeTypes(&download_manager_->exe_types_);
39 } 37 }
40 38
41 void GetGeneratedFilename(const std::string& content_disposition, 39 void GetGeneratedFilename(const std::string& content_disposition,
42 const std::string& url, 40 const std::string& url,
43 const std::string& mime_type, 41 const std::string& mime_type,
44 const std::string& referrer_charset, 42 const std::string& referrer_charset,
45 std::wstring* generated_name_string) { 43 std::wstring* generated_name_string) {
46 DownloadCreateInfo info; 44 DownloadCreateInfo info;
47 info.content_disposition = content_disposition; 45 info.content_disposition = content_disposition;
48 info.url = GURL(url); 46 info.url = GURL(url);
49 info.mime_type = mime_type; 47 info.mime_type = mime_type;
50 info.referrer_charset = referrer_charset; 48 info.referrer_charset = referrer_charset;
51 FilePath generated_name; 49 FilePath generated_name;
52 download_manager_->GenerateFilename(&info, &generated_name); 50 DownloadManager::GenerateFileNameFromInfo(&info, &generated_name);
53 *generated_name_string = generated_name.ToWStringHack(); 51 *generated_name_string = generated_name.ToWStringHack();
54 } 52 }
55 53
56 protected: 54 protected:
57 scoped_refptr<DownloadManager> download_manager_; 55 scoped_refptr<DownloadManager> download_manager_;
58 MessageLoopForUI message_loop_; 56 MessageLoopForUI message_loop_;
59 57
60 DISALLOW_EVIL_CONSTRUCTORS(DownloadManagerTest); 58 DISALLOW_EVIL_CONSTRUCTORS(DownloadManagerTest);
61 }; 59 };
62 60
(...skipping 509 matching lines...) Expand 10 before | Expand all | Expand 10 after
572 #endif // OS_WIN 570 #endif // OS_WIN
573 }; 571 };
574 572
575 } // namespace 573 } // namespace
576 574
577 #if !defined(OS_LINUX) 575 #if !defined(OS_LINUX)
578 // TODO(port): port to Linux. 576 // TODO(port): port to Linux.
579 TEST_F(DownloadManagerTest, GetSafeFilename) { 577 TEST_F(DownloadManagerTest, GetSafeFilename) {
580 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(kSafeFilenameCases); ++i) { 578 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(kSafeFilenameCases); ++i) {
581 FilePath path(kSafeFilenameCases[i].path); 579 FilePath path(kSafeFilenameCases[i].path);
582 download_manager_->GenerateSafeFilename(kSafeFilenameCases[i].mime_type, 580 download_manager_->GenerateSafeFileName(kSafeFilenameCases[i].mime_type,
583 &path); 581 &path);
584 EXPECT_EQ(kSafeFilenameCases[i].expected_path, path.value()); 582 EXPECT_EQ(kSafeFilenameCases[i].expected_path, path.value());
585 } 583 }
586 } 584 }
587 #endif // OS_LINUX 585 #endif // OS_LINUX
OLDNEW
« no previous file with comments | « chrome/browser/download/download_manager.cc ('k') | chrome/browser/download/download_util.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698