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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2008-2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2008-2009 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #import <Cocoa/Cocoa.h> 5 #import <Cocoa/Cocoa.h>
6 #include <vector> 6 #include <vector>
7 7
8 #include "base/mac_util.h" 8 #include "base/mac_util.h"
9 9
10 #include "base/file_path.h" 10 #include "base/file_path.h"
11 #include "base/file_util.h"
11 #include "base/scoped_nsobject.h" 12 #include "base/scoped_nsobject.h"
12 #include "base/scoped_ptr.h" 13 #include "base/scoped_ptr.h"
13 #include "testing/gtest/include/gtest/gtest.h" 14 #include "testing/gtest/include/gtest/gtest.h"
14 #include "testing/platform_test.h" 15 #include "testing/platform_test.h"
15 16
16 typedef PlatformTest MacUtilTest; 17 typedef PlatformTest MacUtilTest;
17 18
18 TEST_F(MacUtilTest, TestFSRef) { 19 TEST_F(MacUtilTest, TestFSRef) {
19 FSRef ref; 20 FSRef ref;
20 std::string path("/System/Library"); 21 std::string path("/System/Library");
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
94 { "/Applications/Google Foo.app/bar/Foo Helper.app/quux/Foo Helper", 95 { "/Applications/Google Foo.app/bar/Foo Helper.app/quux/Foo Helper",
95 "/Applications/Google Foo.app" }, 96 "/Applications/Google Foo.app" },
96 }; 97 };
97 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(valid_inputs); i++) { 98 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(valid_inputs); i++) {
98 out = mac_util::GetAppBundlePath(FilePath(valid_inputs[i].in)); 99 out = mac_util::GetAppBundlePath(FilePath(valid_inputs[i].in));
99 EXPECT_FALSE(out.empty()) << "loop: " << i; 100 EXPECT_FALSE(out.empty()) << "loop: " << i;
100 EXPECT_STREQ(valid_inputs[i].expected_out, 101 EXPECT_STREQ(valid_inputs[i].expected_out,
101 out.value().c_str()) << "loop: " << i; 102 out.value().c_str()) << "loop: " << i;
102 } 103 }
103 } 104 }
105
106 TEST_F(MacUtilTest, TestExcludeFileFromBackups) {
107 NSString* homeDirectory = NSHomeDirectory();
108 NSString* dummyFilePath =
109 [homeDirectory stringByAppendingPathComponent:@"DummyFile"];
110 const char* dummy_file_path = [dummyFilePath fileSystemRepresentation];
111 ASSERT_TRUE(dummy_file_path);
112 FilePath file_path(dummy_file_path);
113 // It is not actually necessary to have a physical file in order to
114 // set its exclusion property.
115 NSURL* fileURL = [NSURL URLWithString:dummyFilePath];
116 // Reset the exclusion in case it was set previously.
117 mac_util::SetFileBackupExclusion(file_path, false);
118 Boolean excludeByPath;
119 // Initial state should be non-excluded.
120 EXPECT_FALSE(CSBackupIsItemExcluded((CFURLRef)fileURL, &excludeByPath));
121 // Exclude the file.
122 EXPECT_TRUE(mac_util::SetFileBackupExclusion(file_path, true));
123 EXPECT_TRUE(CSBackupIsItemExcluded((CFURLRef)fileURL, &excludeByPath));
124 // Un-exclude the file.
125 EXPECT_TRUE(mac_util::SetFileBackupExclusion(file_path, false));
126 EXPECT_FALSE(CSBackupIsItemExcluded((CFURLRef)fileURL, &excludeByPath));
127 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698