OLD | NEW |
---|---|
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "base/i18n/file_util_icu.h" | 5 #include "base/i18n/file_util_icu.h" |
6 | 6 |
7 #include "base/file_util.h" | 7 #include "base/file_util.h" |
8 #include "base/path_service.h" | |
9 #include "base/utf_string_conversions.h" | 8 #include "base/utf_string_conversions.h" |
10 #include "testing/gtest/include/gtest/gtest.h" | 9 #include "testing/gtest/include/gtest/gtest.h" |
11 #include "testing/platform_test.h" | 10 #include "testing/platform_test.h" |
12 | 11 |
13 // file_util winds up using autoreleased objects on the Mac, so this needs | 12 // file_util winds up using autoreleased objects on the Mac, so this needs |
14 // to be a PlatformTest | 13 // to be a PlatformTest |
15 class FileUtilICUTest : public PlatformTest { | 14 class FileUtilICUTest : public PlatformTest { |
Paweł Hajdan Jr.
2011/04/08 15:58:17
Please switch it to a typedef then, or at least do
Mike West
2011/04/11 14:47:04
Fair enough. I've dropped the overrides, but left
| |
16 protected: | 15 protected: |
17 virtual void SetUp() { | 16 virtual void SetUp() { |
18 PlatformTest::SetUp(); | 17 PlatformTest::SetUp(); |
19 // Name a subdirectory of the temp directory. | |
20 ASSERT_TRUE(PathService::Get(base::DIR_TEMP, &test_dir_)); | |
21 test_dir_ = test_dir_.Append(FILE_PATH_LITERAL("FileUtilTest")); | |
22 | |
23 // Create a fresh, empty copy of this directory. | |
24 file_util::Delete(test_dir_, true); | |
25 file_util::CreateDirectory(test_dir_); | |
26 } | 18 } |
27 virtual void TearDown() { | 19 virtual void TearDown() { |
28 PlatformTest::TearDown(); | 20 PlatformTest::TearDown(); |
29 // Clean up test directory | |
30 ASSERT_TRUE(file_util::Delete(test_dir_, true)); | |
31 ASSERT_FALSE(file_util::PathExists(test_dir_)); | |
32 } | 21 } |
33 | |
34 // the path to temporary directory used to contain the test operations | |
35 FilePath test_dir_; | |
36 }; | 22 }; |
37 | 23 |
38 #if defined(OS_POSIX) && !defined(OS_MACOSX) | 24 #if defined(OS_POSIX) && !defined(OS_MACOSX) |
39 | 25 |
40 // Linux disallows some evil ASCII characters, but passes all non-ASCII. | 26 // Linux disallows some evil ASCII characters, but passes all non-ASCII. |
41 static const struct goodbad_pair { | 27 static const struct goodbad_pair { |
42 const char* bad_name; | 28 const char* bad_name; |
43 const char* good_name; | 29 const char* good_name; |
44 } kIllegalCharacterCases[] = { | 30 } kIllegalCharacterCases[] = { |
45 {"bad*file:name?.jpg", "bad-file-name-.jpg"}, | 31 {"bad*file:name?.jpg", "bad-file-name-.jpg"}, |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
96 #elif defined(OS_MACOSX) | 82 #elif defined(OS_MACOSX) |
97 std::string bad_name(WideToUTF8(kIllegalCharacterCases[i].bad_name)); | 83 std::string bad_name(WideToUTF8(kIllegalCharacterCases[i].bad_name)); |
98 file_util::ReplaceIllegalCharactersInPath(&bad_name, '-'); | 84 file_util::ReplaceIllegalCharactersInPath(&bad_name, '-'); |
99 EXPECT_EQ(WideToUTF8(kIllegalCharacterCases[i].good_name), bad_name); | 85 EXPECT_EQ(WideToUTF8(kIllegalCharacterCases[i].good_name), bad_name); |
100 #endif | 86 #endif |
101 } | 87 } |
102 } | 88 } |
103 | 89 |
104 #endif | 90 #endif |
105 | 91 |
OLD | NEW |