| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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_util.h" | 5 #include "chrome/browser/download/download_util.h" |
| 6 | 6 |
| 7 #if defined(OS_POSIX) && !defined(OS_MACOSX) | 7 #if defined(OS_POSIX) && !defined(OS_MACOSX) |
| 8 #include <locale.h> | 8 #include <locale.h> |
| 9 #endif | 9 #endif |
| 10 | 10 |
| 11 #include "base/path_service.h" |
| 11 #include "base/string_util.h" | 12 #include "base/string_util.h" |
| 12 #include "base/test/test_file_util.h" | 13 #include "base/test/test_file_util.h" |
| 14 #include "chrome/common/chrome_paths.h" |
| 13 #include "googleurl/src/gurl.h" | 15 #include "googleurl/src/gurl.h" |
| 14 #include "testing/gtest/include/gtest/gtest.h" | 16 #include "testing/gtest/include/gtest/gtest.h" |
| 15 | 17 |
| 16 #if defined(OS_WIN) | 18 #if defined(OS_WIN) |
| 17 #define JPEG_EXT L".jpg" | 19 #define JPEG_EXT L".jpg" |
| 18 #define HTML_EXT L".htm" | 20 #define HTML_EXT L".htm" |
| 19 #define TXT_EXT L".txt" | 21 #define TXT_EXT L".txt" |
| 20 #define TAR_EXT L".tar" | 22 #define TAR_EXT L".tar" |
| 21 #elif defined(OS_MACOSX) | 23 #elif defined(OS_MACOSX) |
| 22 #define JPEG_EXT L".jpeg" | 24 #define JPEG_EXT L".jpeg" |
| (...skipping 548 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 571 }; | 573 }; |
| 572 | 574 |
| 573 TEST(DownloadUtilTest, GenerateSafeFileName) { | 575 TEST(DownloadUtilTest, GenerateSafeFileName) { |
| 574 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(kSafeFilenameCases); ++i) { | 576 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(kSafeFilenameCases); ++i) { |
| 575 FilePath path(kSafeFilenameCases[i].path); | 577 FilePath path(kSafeFilenameCases[i].path); |
| 576 download_util::GenerateSafeFileName(kSafeFilenameCases[i].mime_type, &path); | 578 download_util::GenerateSafeFileName(kSafeFilenameCases[i].mime_type, &path); |
| 577 EXPECT_EQ(kSafeFilenameCases[i].expected_path, path.value()) << i; | 579 EXPECT_EQ(kSafeFilenameCases[i].expected_path, path.value()) << i; |
| 578 } | 580 } |
| 579 } | 581 } |
| 580 | 582 |
| 583 TEST(DownloadUtilTest, OverrideDefaultDownloadFolder) { |
| 584 FilePath override_path(FILE_PATH_LITERAL("/koakuma/mikity/moemoe/nyannyan")); |
| 585 FilePath original_path; |
| 586 ASSERT_TRUE(PathService::Get(chrome::DIR_DEFAULT_DOWNLOADS, &original_path)); |
| 587 |
| 588 FilePath current_path; |
| 589 ASSERT_TRUE(download_util::DefaultDownloadDirectory::Get(¤t_path)); |
| 590 EXPECT_EQ(current_path, original_path); |
| 591 |
| 592 download_util::DefaultDownloadDirectory::Override(override_path); |
| 593 ASSERT_TRUE(download_util::DefaultDownloadDirectory::Get(¤t_path)); |
| 594 EXPECT_EQ(current_path, override_path); |
| 595 |
| 596 download_util::DefaultDownloadDirectory::UnOverride(); |
| 597 ASSERT_TRUE(download_util::DefaultDownloadDirectory::Get(¤t_path)); |
| 598 EXPECT_EQ(current_path, original_path); |
| 599 } |
| 600 |
| 581 } // namespace | 601 } // namespace |
| 582 | |
| OLD | NEW |