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

Unified Diff: base/scoped_temp_dir_unittest.cc

Issue 5340004: Make ScopedTempDir::Delete return a bool so that its functionality can be te... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 10 years, 1 month 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
« base/scoped_temp_dir.h ('K') | « base/scoped_temp_dir.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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,23 @@
EXPECT_FALSE(dir.CreateUniqueTempDir());
EXPECT_FALSE(other_dir.CreateUniqueTempDir());
}
+
+#if defined(OS_WIN)
+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;
+ FilePath file_path(dir.path().Append(FILE_PATH_LITERAL("temp")));
+ base::PlatformFile file = base::CreatePlatformFile(file_path, 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.
+ EXPECT_FALSE(dir.path().empty()); // We should still have a valid path.
+ EXPECT_TRUE(base::ClosePlatformFile(file));
+ // Now, we should be able to delete.
+ EXPECT_TRUE(dir.Delete());
+}
+#endif // defined(OS_WIN)
« base/scoped_temp_dir.h ('K') | « base/scoped_temp_dir.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698