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

Unified Diff: base/file_util_unittest.cc

Issue 6660001: Getting service process on Mac to handle having things moved/changed underneath it. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fixed up phajdan's comments, got things working properly Created 9 years, 9 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
Index: base/file_util_unittest.cc
diff --git a/base/file_util_unittest.cc b/base/file_util_unittest.cc
index ea29df521720c8de2c4801c10f7c8e2a96cadd83..29e6e97dc2a1b90d5701c227b68e13383d7efd8c 100644
--- a/base/file_util_unittest.cc
+++ b/base/file_util_unittest.cc
@@ -1813,4 +1813,38 @@ TEST_F(FileUtilTest, IsDirectoryEmpty) {
EXPECT_FALSE(file_util::IsDirectoryEmpty(empty_dir));
}
+TEST_F(FileUtilTest, AreReferringToSameObject) {
+ FilePath dir1 = temp_dir_.path().Append(FILE_PATH_LITERAL("Directory"));
+ FilePath dir2 = temp_dir_.path().Append(FILE_PATH_LITERAL("Directory"));
+ ASSERT_FALSE(file_util::PathExists(dir1));
+ ASSERT_TRUE(file_util::CreateDirectory(dir1));
+ ASSERT_TRUE(file_util::AreReferringToSameObject(dir1, dir2));
+ ASSERT_FALSE(file_util::AreReferringToSameObject(temp_dir_.path(), dir2));
+
+#if defined(OS_POSIX)
+ FilePath sym = temp_dir_.path().Append(FILE_PATH_LITERAL("Symlink"));
+ ASSERT_FALSE(file_util::AreReferringToSameObject(dir1, sym));
+ ASSERT_TRUE(file_util::CreateSymbolicLink(dir1, sym));
+ ASSERT_TRUE(file_util::AreReferringToSameObject(dir1, sym));
+#endif // OS_POSIX
+}
+
+#if defined(OS_MACOSX)
+TEST_F(FileUtilTest, Trash) {
+ FilePath to_trash = temp_dir_.path().Append(FILE_PATH_LITERAL("TrashFile"));
+ ASSERT_FALSE(file_util::PathExists(to_trash));
+ std::string bar("baz");
+ ASSERT_TRUE(file_util::WriteFile(to_trash, bar.c_str(), bar.length()));
+ ASSERT_TRUE(file_util::PathExists(to_trash));
+ ASSERT_FALSE(file_util::IsInTrash(to_trash));
+
+ FilePath trashed;
+ ASSERT_TRUE(file_util::MoveToTrash(to_trash, &trashed));
+ ASSERT_TRUE(file_util::IsInTrash(trashed));
+ ASSERT_FALSE(file_util::IsInTrash(to_trash));
+ ASSERT_FALSE(file_util::PathExists(to_trash));
+ ASSERT_FALSE(file_util::MoveToTrash(to_trash, &trashed));
+}
Mark Mentovai 2011/03/11 20:13:52 Don’t leave it in the trash. Delete it.
+#endif // OS_MACOSX
+
} // namespace

Powered by Google App Engine
This is Rietveld 408576698