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

Unified Diff: base/mac_util_unittest.mm

Issue 387016: For the immediate milestone, exclude History and Thumbnails from being backed... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 11 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
Index: base/mac_util_unittest.mm
===================================================================
--- base/mac_util_unittest.mm (revision 31614)
+++ base/mac_util_unittest.mm (working copy)
@@ -8,6 +8,7 @@
#include "base/mac_util.h"
#include "base/file_path.h"
+#include "base/file_util.h"
#include "base/scoped_nsobject.h"
#include "base/scoped_ptr.h"
#include "testing/gtest/include/gtest/gtest.h"
@@ -101,3 +102,26 @@
out.value().c_str()) << "loop: " << i;
}
}
+
+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.
+ mac_util::SetFileBackupExclusion(file_path, false);
+ Boolean excludeByPath;
+ // Initial state should be non-excluded.
+ EXPECT_FALSE(CSBackupIsItemExcluded((CFURLRef)fileURL, &excludeByPath));
+ // Exclude the file.
+ EXPECT_TRUE(mac_util::SetFileBackupExclusion(file_path, true));
+ EXPECT_TRUE(CSBackupIsItemExcluded((CFURLRef)fileURL, &excludeByPath));
+ // Un-exclude the file.
+ EXPECT_TRUE(mac_util::SetFileBackupExclusion(file_path, false));
+ EXPECT_FALSE(CSBackupIsItemExcluded((CFURLRef)fileURL, &excludeByPath));
+}

Powered by Google App Engine
This is Rietveld 408576698