summaryrefslogtreecommitdiffstats
path: root/base/file_util_unittest.cc
diff options
context:
space:
mode:
authorjrg@chromium.org <jrg@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-02-04 00:58:39 +0000
committerjrg@chromium.org <jrg@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-02-04 00:58:39 +0000
commit9e51af9018550b6b23802f66469310f5d1790ab9 (patch)
tree9ab6f3e0532f6d23c2af1d0acc5605ad00876418 /base/file_util_unittest.cc
parent4c7ca4b8c2ceb6f823474744f035672c8501d23b (diff)
downloadchromium_src-9e51af9018550b6b23802f66469310f5d1790ab9.zip
chromium_src-9e51af9018550b6b23802f66469310f5d1790ab9.tar.gz
chromium_src-9e51af9018550b6b23802f66469310f5d1790ab9.tar.bz2
Properly honor base::SharedMemory semantics for name="" to mean
new/private shared memory on POSIX. Transition base::SharedMemory implementation to file/mmap() to prevent leaking of wired kernel resources and allow easier cleanup. Enable one more shared_memory unit test for POSIX. Enable stats_table_unittest.cc for Mac, and modify it so it cleans up. Review URL: http://codereview.chromium.org/19724 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@9114 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/file_util_unittest.cc')
-rw-r--r--base/file_util_unittest.cc46
1 files changed, 41 insertions, 5 deletions
diff --git a/base/file_util_unittest.cc b/base/file_util_unittest.cc
index 98c2032..a00fc0b 100644
--- a/base/file_util_unittest.cc
+++ b/base/file_util_unittest.cc
@@ -688,10 +688,40 @@ TEST_F(FileUtilTest, CreateShortcutTest) {
#endif
TEST_F(FileUtilTest, CreateTemporaryFileNameTest) {
- std::wstring temp_file;
- ASSERT_TRUE(file_util::CreateTemporaryFileName(&temp_file));
- EXPECT_TRUE(file_util::PathExists(temp_file));
- EXPECT_TRUE(file_util::Delete(temp_file, false));
+ std::wstring temp_files[3];
+ for (int i = 0; i < 3; i++) {
+ ASSERT_TRUE(file_util::CreateTemporaryFileName(&(temp_files[i])));
+ EXPECT_TRUE(file_util::PathExists(temp_files[i]));
+ EXPECT_FALSE(file_util::DirectoryExists(temp_files[i]));
+ }
+ for (int i = 0; i < 3; i++)
+ EXPECT_FALSE(temp_files[i] == temp_files[(i+1)%3]);
+ for (int i = 0; i < 3; i++)
+ EXPECT_TRUE(file_util::Delete(temp_files[i], false));
+}
+
+TEST_F(FileUtilTest, CreateAndOpenTemporaryFileNameTest) {
+ FilePath names[3];
+ FILE *fps[3];
+ int i;
+
+ // Create; make sure they are open and exist.
+ for (i = 0; i < 3; ++i) {
+ fps[i] = file_util::CreateAndOpenTemporaryFile(&(names[i]));
+ ASSERT_TRUE(fps[i]);
+ EXPECT_TRUE(file_util::PathExists(names[i]));
+ }
+
+ // Make sure all names are unique.
+ for (i = 0; i < 3; ++i) {
+ EXPECT_FALSE(names[i] == names[(i+1)%3]);
+ }
+
+ // Close and delete.
+ for (i = 0; i < 3; ++i) {
+ EXPECT_TRUE(file_util::CloseFile(fps[i]));
+ EXPECT_TRUE(file_util::Delete(names[i], false));
+ }
}
TEST_F(FileUtilTest, CreateNewTempDirectoryTest) {
@@ -701,6 +731,12 @@ TEST_F(FileUtilTest, CreateNewTempDirectoryTest) {
EXPECT_TRUE(file_util::Delete(temp_dir, false));
}
+TEST_F(FileUtilTest, GetShmemTempDirTest) {
+ FilePath dir;
+ EXPECT_TRUE(file_util::GetShmemTempDir(&dir));
+ EXPECT_TRUE(file_util::DirectoryExists(dir));
+}
+
TEST_F(FileUtilTest, CreateDirectoryTest) {
FilePath test_root =
test_dir_.Append(FILE_PATH_LITERAL("create_directory_test"));
@@ -1015,7 +1051,7 @@ TEST_F(FileUtilTest, Contains) {
#if defined(OS_WIN)
EXPECT_TRUE(file_util::ContainsPath(foo,
foo_caps.Append(FILE_PATH_LITERAL("bar.txt"))));
- EXPECT_TRUE(file_util::ContainsPath(foo,
+ EXPECT_TRUE(file_util::ContainsPath(foo,
FilePath(foo.value() + FILE_PATH_LITERAL("/bar.txt"))));
#elif defined(OS_LINUX)
EXPECT_FALSE(file_util::ContainsPath(foo,