OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 #ifndef BASE_TEST_TEST_FILE_UTIL_H_ | 5 #ifndef BASE_TEST_TEST_FILE_UTIL_H_ |
6 #define BASE_TEST_TEST_FILE_UTIL_H_ | 6 #define BASE_TEST_TEST_FILE_UTIL_H_ |
7 | 7 |
8 // File utility functions used only by tests. | 8 // File utility functions used only by tests. |
9 | 9 |
10 #include <string> | 10 #include <string> |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
45 // the one that set the zone identifier. I.e. don't use it in UI/automation | 45 // the one that set the zone identifier. I.e. don't use it in UI/automation |
46 // based tests. | 46 // based tests. |
47 bool HasInternetZoneIdentifier(const FilePath& full_path); | 47 bool HasInternetZoneIdentifier(const FilePath& full_path); |
48 #endif // defined(OS_WIN) | 48 #endif // defined(OS_WIN) |
49 | 49 |
50 } // namespace base | 50 } // namespace base |
51 | 51 |
52 // TODO(brettw) move all of this to the base namespace. | 52 // TODO(brettw) move all of this to the base namespace. |
53 namespace file_util { | 53 namespace file_util { |
54 | 54 |
55 // In general it's not reliable to convert a FilePath to a wstring and we use | |
56 // string16 elsewhere for Unicode strings, but in tests it is frequently | |
57 // convenient to be able to compare paths to literals like L"foobar". | |
58 std::wstring FilePathAsWString(const base::FilePath& path); | |
59 base::FilePath WStringAsFilePath(const std::wstring& path); | |
60 | |
61 // For testing, make the file unreadable or unwritable. | 55 // For testing, make the file unreadable or unwritable. |
62 // In POSIX, this does not apply to the root user. | 56 // In POSIX, this does not apply to the root user. |
63 bool MakeFileUnreadable(const base::FilePath& path) WARN_UNUSED_RESULT; | 57 bool MakeFileUnreadable(const base::FilePath& path) WARN_UNUSED_RESULT; |
64 bool MakeFileUnwritable(const base::FilePath& path) WARN_UNUSED_RESULT; | 58 bool MakeFileUnwritable(const base::FilePath& path) WARN_UNUSED_RESULT; |
65 | 59 |
66 #if defined(OS_ANDROID) | 60 #if defined(OS_ANDROID) |
67 // Register the ContentUriTestUrils JNI bindings. | 61 // Register the ContentUriTestUrils JNI bindings. |
68 bool RegisterContentUriTestUtils(JNIEnv* env); | 62 bool RegisterContentUriTestUtils(JNIEnv* env); |
69 | 63 |
70 // Insert an image file into the MediaStore, and retrieve the content URI for | 64 // Insert an image file into the MediaStore, and retrieve the content URI for |
(...skipping 11 matching lines...) Expand all Loading... |
82 const base::FilePath path_; | 76 const base::FilePath path_; |
83 void* info_; // The opaque stored permission information. | 77 void* info_; // The opaque stored permission information. |
84 size_t length_; // The length of the stored permission information. | 78 size_t length_; // The length of the stored permission information. |
85 | 79 |
86 DISALLOW_COPY_AND_ASSIGN(PermissionRestorer); | 80 DISALLOW_COPY_AND_ASSIGN(PermissionRestorer); |
87 }; | 81 }; |
88 | 82 |
89 } // namespace file_util | 83 } // namespace file_util |
90 | 84 |
91 #endif // BASE_TEST_TEST_FILE_UTIL_H_ | 85 #endif // BASE_TEST_TEST_FILE_UTIL_H_ |
OLD | NEW |