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

Unified Diff: base/mac/mac_util_unittest.mm

Issue 7069021: Non-path Time Machine Exclusions (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 9 years, 7 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/mac/mac_util_unittest.mm
===================================================================
--- base/mac/mac_util_unittest.mm (revision 86429)
+++ base/mac/mac_util_unittest.mm (working copy)
@@ -95,26 +95,30 @@
}
TEST_F(MacUtilTest, TestExcludeFileFromBackups) {
- NSString* homeDirectory = NSHomeDirectory();
- NSString* dummyFilePath =
- [homeDirectory stringByAppendingPathComponent:@"DummyFile"];
- const char* dummy_file_path = [dummyFilePath fileSystemRepresentation];
- ASSERT_TRUE(dummy_file_path);
- FilePath file_path(dummy_file_path);
- // It is not actually necessary to have a physical file in order to
- // set its exclusion property.
- NSURL* fileURL = [NSURL URLWithString:dummyFilePath];
- // Reset the exclusion in case it was set previously.
- SetFileBackupExclusion(file_path, false);
- Boolean excludeByPath;
+ FilePath temp_dir;
+ ASSERT_TRUE(file_util::CreateNewTempDirectory(FilePath::StringType(),
+ &temp_dir));
Mark Mentovai 2011/05/25 19:19:06 Who’s responsible for cleaning up temp_dir? Maybe
mrossetti 2011/05/25 21:12:31 Done.
+ EXPECT_TRUE(file_util::PathExists(temp_dir));
+ FilePath dummy_file_path = temp_dir.Append("DummyFile");
+ FILE* dummy_file = file_util::OpenFile(dummy_file_path, "w");
Mark Mentovai 2011/05/25 19:19:06 Put this in a file_util::ScopedFILE to ensure it c
mrossetti 2011/05/25 21:12:31 Eliminated in favor of just using WriteFile.
+ EXPECT_TRUE(dummy_file);
+ const char dummy_data[] = "All your base are belong to us!";
Mark Mentovai 2011/05/25 19:19:06 :)
+ EXPECT_TRUE(fwrite(dummy_data, ARRAYSIZE_UNSAFE(dummy_data), 1, dummy_file));
Mark Mentovai 2011/05/25 19:19:06 Instead of file_util::OpenFile + fwrite + file_uti
Mark Mentovai 2011/05/25 19:19:06 The “safe” arraysize didn’t work here?
mrossetti 2011/05/25 21:12:31 Done.
mrossetti 2011/05/25 21:12:31 Done.
+ // The file must already exist in order to set its exclusion property.
+ NSString* fileURLString =
+ [NSString stringWithUTF8String:dummy_file_path.value().c_str()];
+ NSURL* fileURL = [NSURL URLWithString:fileURLString];
// Initial state should be non-excluded.
- EXPECT_FALSE(CSBackupIsItemExcluded((CFURLRef)fileURL, &excludeByPath));
+ EXPECT_FALSE(CSBackupIsItemExcluded((CFURLRef)fileURL, NULL));
Mark Mentovai 2011/05/25 19:19:06 I wonder if this is always true in the temp direct
mrossetti 2011/05/25 21:12:31 It might be different under 10.7 but it comes up n
// Exclude the file.
- EXPECT_TRUE(SetFileBackupExclusion(file_path, true));
- EXPECT_TRUE(CSBackupIsItemExcluded((CFURLRef)fileURL, &excludeByPath));
- // Un-exclude the file.
- EXPECT_TRUE(SetFileBackupExclusion(file_path, false));
- EXPECT_FALSE(CSBackupIsItemExcluded((CFURLRef)fileURL, &excludeByPath));
+ EXPECT_TRUE(SetFileBackupExclusion(dummy_file_path));
+ // SetFileBackupExclusion never excludes by path.
+ Boolean excluded_by_path = false;
Mark Mentovai 2011/05/25 19:19:06 FALSE
mrossetti 2011/05/25 21:12:31 Yeah, yeah — I'm getting it. ;^)
+ Boolean excluded =
+ CSBackupIsItemExcluded((CFURLRef)fileURL, &excluded_by_path);
+ EXPECT_TRUE(excluded);
+ EXPECT_FALSE(excluded_by_path);
+ EXPECT_TRUE(file_util::CloseFile(dummy_file));
}
TEST_F(MacUtilTest, TestGetValueFromDictionary) {

Powered by Google App Engine
This is Rietveld 408576698