Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(49)

Unified Diff: base/platform_file_unittest.cc

Issue 7233007: Add a flag to open files in share delete mode (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « base/platform_file.h ('k') | base/platform_file_win.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/platform_file_unittest.cc
diff --git a/base/platform_file_unittest.cc b/base/platform_file_unittest.cc
index 0bd4fb327e20727612e7a05a6027af270aa9e0ab..039c7efb91d905b143e8b4a4c2881de57c71fa47 100644
--- a/base/platform_file_unittest.cc
+++ b/base/platform_file_unittest.cc
@@ -127,6 +127,42 @@ TEST(PlatformFile, CreatePlatformFile) {
EXPECT_FALSE(file_util::PathExists(file_path));
}
+TEST(PlatformFile, DeleteOpenFile) {
+ ScopedTempDir temp_dir;
+ ASSERT_TRUE(temp_dir.CreateUniqueTempDir());
+ FilePath file_path = temp_dir.path().AppendASCII("create_file_1");
+
+ // Create a file.
+ bool created = false;
+ base::PlatformFileError error_code = base::PLATFORM_FILE_OK;
+ base::PlatformFile file = base::CreatePlatformFile(
+ file_path,
+ base::PLATFORM_FILE_OPEN_ALWAYS |
+ base::PLATFORM_FILE_READ |
+ base::PLATFORM_FILE_SHARE_DELETE,
+ &created, &error_code);
+ EXPECT_NE(base::kInvalidPlatformFileValue, file);
+ EXPECT_TRUE(created);
+ EXPECT_EQ(base::PLATFORM_FILE_OK, error_code);
+
+ // Open an existing file and mark it as delete on close.
+ created = false;
+ base::PlatformFile same_file = base::CreatePlatformFile(
+ file_path,
+ base::PLATFORM_FILE_OPEN |
+ base::PLATFORM_FILE_DELETE_ON_CLOSE |
+ base::PLATFORM_FILE_READ,
+ &created, &error_code);
+ EXPECT_NE(base::kInvalidPlatformFileValue, file);
+ EXPECT_FALSE(created);
+ EXPECT_EQ(base::PLATFORM_FILE_OK, error_code);
+
+ // Close both handles and check that the file is gone.
+ base::ClosePlatformFile(file);
+ base::ClosePlatformFile(same_file);
+ EXPECT_FALSE(file_util::PathExists(file_path));
+}
+
TEST(PlatformFile, ReadWritePlatformFile) {
ScopedTempDir temp_dir;
ASSERT_TRUE(temp_dir.CreateUniqueTempDir());
« no previous file with comments | « base/platform_file.h ('k') | base/platform_file_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698