summaryrefslogtreecommitdiffstats
path: root/base/test
diff options
context:
space:
mode:
authorevan@chromium.org <evan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-03-03 17:54:04 +0000
committerevan@chromium.org <evan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-03-03 17:54:04 +0000
commit9ffd9adb2cceb9f68596b23e30f9ec004949df36 (patch)
tree8c91cb1b2f1039c7bd8a20c35e1f97e3cd601a16 /base/test
parentb13dee3299a400d604038b6a49a161a1048a2373 (diff)
downloadchromium_src-9ffd9adb2cceb9f68596b23e30f9ec004949df36.zip
chromium_src-9ffd9adb2cceb9f68596b23e30f9ec004949df36.tar.gz
chromium_src-9ffd9adb2cceb9f68596b23e30f9ec004949df36.tar.bz2
wstring: allow converting FilePath to wstring in tests
Many of our tests want to use Unicode literal strings with the L"foobar" syntax. Allow us to test FilePaths against these strings. BUG=69467 Review URL: http://codereview.chromium.org/6606025 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@76763 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/test')
-rw-r--r--base/test/test_file_util.h7
-rw-r--r--base/test/test_file_util_posix.cc5
-rw-r--r--base/test/test_file_util_win.cc4
3 files changed, 16 insertions, 0 deletions
diff --git a/base/test/test_file_util.h b/base/test/test_file_util.h
index 6a6ae7d..e59456a 100644
--- a/base/test/test_file_util.h
+++ b/base/test/test_file_util.h
@@ -8,6 +8,8 @@
// File utility functions used only by tests.
+#include <string>
+
class FilePath;
namespace file_util {
@@ -41,6 +43,11 @@ bool VolumeSupportsADS(const FilePath& path);
bool HasInternetZoneIdentifier(const FilePath& full_path);
#endif // defined(OS_WIN)
+// In general it's not reliable to convert a FilePath to a wstring and we use
+// string16 elsewhere for Unicode strings, but in tests it is frequently
+// convenient to be able to compare paths to literals like L"foobar".
+std::wstring FilePathAsWString(const FilePath& path);
+
} // namespace file_util
#endif // BASE_TEST_TEST_FILE_UTIL_H_
diff --git a/base/test/test_file_util_posix.cc b/base/test/test_file_util_posix.cc
index 876e882..430e52e 100644
--- a/base/test/test_file_util_posix.cc
+++ b/base/test/test_file_util_posix.cc
@@ -15,6 +15,7 @@
#include "base/file_path.h"
#include "base/file_util.h"
#include "base/string_util.h"
+#include "base/utf_string_conversions.h"
namespace file_util {
@@ -109,4 +110,8 @@ bool EvictFileFromSystemCache(const FilePath& file) {
}
#endif
+std::wstring FilePathAsWString(const FilePath& path) {
+ return UTF8ToWide(path.value());
+}
+
} // namespace file_util
diff --git a/base/test/test_file_util_win.cc b/base/test/test_file_util_win.cc
index 9820c42..1f20740 100644
--- a/base/test/test_file_util_win.cc
+++ b/base/test/test_file_util_win.cc
@@ -217,4 +217,8 @@ bool HasInternetZoneIdentifier(const FilePath& full_path) {
zone_path_contents[kInternetIdentifierSize] == '\n'));
}
+std::wstring FilePathAsWString(const FilePath& path) {
+ return path.value();
+}
+
} // namespace file_util