summaryrefslogtreecommitdiffstats
path: root/base/file_util_unittest.cc
diff options
context:
space:
mode:
authortkent@chromium.org <tkent@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-10-09 07:33:39 +0000
committertkent@chromium.org <tkent@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-10-09 07:33:39 +0000
commit7d95aae72e11aabaffd68d8b1f7864729713dd43 (patch)
treece67574fe2c9e393ac933242217a95137b6b2e3b /base/file_util_unittest.cc
parent08f669c629934824bbe4ac0b43443c40cdd3cb48 (diff)
downloadchromium_src-7d95aae72e11aabaffd68d8b1f7864729713dd43.zip
chromium_src-7d95aae72e11aabaffd68d8b1f7864729713dd43.tar.gz
chromium_src-7d95aae72e11aabaffd68d8b1f7864729713dd43.tar.bz2
Fixes a bug that .crx can not be installed by "Could not create
directory for unzipping." in the case that the environment variable TMP is set to a root directory of a drive such as "C:\" TEST=Add new tests to base_unittest BUG=23911 Review URL: http://codereview.chromium.org/257061 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@28529 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/file_util_unittest.cc')
-rw-r--r--base/file_util_unittest.cc31
1 files changed, 30 insertions, 1 deletions
diff --git a/base/file_util_unittest.cc b/base/file_util_unittest.cc
index b1f9fed..073dbae 100644
--- a/base/file_util_unittest.cc
+++ b/base/file_util_unittest.cc
@@ -8,6 +8,7 @@
#include <windows.h>
#include <shellapi.h>
#include <shlobj.h>
+#include <tchar.h>
#endif
#include <fstream>
@@ -773,7 +774,35 @@ TEST_F(FileUtilTest, CopyAndDeleteDirectoryTest) {
EXPECT_TRUE(file_util::PathExists(dir_name_to));
EXPECT_TRUE(file_util::PathExists(file_name_to));
}
-#endif
+
+TEST_F(FileUtilTest, GetTempDirTest) {
+ static const TCHAR* kTmpKey = _T("TMP");
+ static const TCHAR* kTmpValues[] = {
+ _T(""), _T("C:"), _T("C:\\"), _T("C:\\tmp"), _T("C:\\tmp\\")
+ };
+ // Save the original $TMP.
+ size_t original_tmp_size;
+ TCHAR* original_tmp;
+ ASSERT_EQ(0, ::_tdupenv_s(&original_tmp, &original_tmp_size, kTmpKey));
+ // original_tmp may be NULL.
+
+ for (unsigned int i = 0; i < arraysize(kTmpValues); ++i) {
+ FilePath path;
+ ::_tputenv_s(kTmpKey, kTmpValues[i]);
+ file_util::GetTempDir(&path);
+ EXPECT_TRUE(path.IsAbsolute()) << "$TMP=" << kTmpValues[i] <<
+ " result=" << path.value();
+ }
+
+ // Restore the original $TMP.
+ if (original_tmp) {
+ ::_tputenv_s(kTmpKey, original_tmp);
+ free(original_tmp);
+ } else {
+ ::_tputenv_s(kTmpKey, _T(""));
+ }
+}
+#endif // OS_WIN
TEST_F(FileUtilTest, CreateTemporaryFileTest) {
FilePath temp_files[3];