Chromium Code Reviews| Index: base/scoped_temp_dir_unittest.cc |
| =================================================================== |
| --- base/scoped_temp_dir_unittest.cc (revision 67430) |
| +++ base/scoped_temp_dir_unittest.cc (working copy) |
| @@ -3,6 +3,7 @@ |
| // found in the LICENSE file. |
| #include "base/file_util.h" |
| +#include "base/platform_file.h" |
| #include "base/scoped_temp_dir.h" |
| #include "testing/gtest/include/gtest/gtest.h" |
| @@ -87,3 +88,20 @@ |
| EXPECT_FALSE(dir.CreateUniqueTempDir()); |
| EXPECT_FALSE(other_dir.CreateUniqueTempDir()); |
| } |
| + |
| +TEST(ScopedTempDir, LockedTempDir) { |
| + ScopedTempDir dir; |
| + EXPECT_TRUE(dir.CreateUniqueTempDir()); |
| + int file_flags = base::PLATFORM_FILE_CREATE_ALWAYS | |
| + base::PLATFORM_FILE_WRITE; |
| + base::PlatformFileError error_code = base::PLATFORM_FILE_OK; |
| + base::PlatformFile file = base::CreatePlatformFile( |
| + dir.path().Append(FILE_PATH_LITERAL("temp")), file_flags, NULL, |
| + &error_code); |
| + EXPECT_NE(base::kInvalidPlatformFileValue, file); |
| + EXPECT_EQ(base::PLATFORM_FILE_OK, error_code); |
| + EXPECT_FALSE(dir.Delete()); // We should not be able to delete. |
|
Paweł Hajdan Jr.
2010/11/26 21:01:20
That's only true on Windows, right?
tommi (sloooow) - chröme
2010/11/26 21:04:44
Apparently so :)
http://build.chromium.org/p/tryse
|
| + EXPECT_FALSE(dir.path().empty()); // We should still have a valid path. |
| + EXPECT_TRUE(base::ClosePlatformFile(file)); |
| + EXPECT_TRUE(dir.Delete()); // Now, we should be able to delete. |
| +} |