OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 | 6 |
7 #include "base/mac/mac_util.h" | 7 #include "base/mac/mac_util.h" |
8 | 8 |
9 #include "base/file_util.h" | 9 #include "base/file_util.h" |
10 #include "base/files/file_path.h" | 10 #include "base/files/file_path.h" |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
101 } | 101 } |
102 | 102 |
103 TEST_F(MacUtilTest, TestExcludeFileFromBackups) { | 103 TEST_F(MacUtilTest, TestExcludeFileFromBackups) { |
104 // The file must already exist in order to set its exclusion property. | 104 // The file must already exist in order to set its exclusion property. |
105 ScopedTempDir temp_dir_; | 105 ScopedTempDir temp_dir_; |
106 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); | 106 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); |
107 FilePath dummy_file_path = temp_dir_.path().Append("DummyFile"); | 107 FilePath dummy_file_path = temp_dir_.path().Append("DummyFile"); |
108 const char dummy_data[] = "All your base are belong to us!"; | 108 const char dummy_data[] = "All your base are belong to us!"; |
109 // Dump something real into the file. | 109 // Dump something real into the file. |
110 ASSERT_EQ(static_cast<int>(arraysize(dummy_data)), | 110 ASSERT_EQ(static_cast<int>(arraysize(dummy_data)), |
111 file_util::WriteFile(dummy_file_path, dummy_data, arraysize(dummy_data))); | 111 WriteFile(dummy_file_path, dummy_data, arraysize(dummy_data))); |
112 NSString* fileURLString = | 112 NSString* fileURLString = |
113 [NSString stringWithUTF8String:dummy_file_path.value().c_str()]; | 113 [NSString stringWithUTF8String:dummy_file_path.value().c_str()]; |
114 NSURL* fileURL = [NSURL URLWithString:fileURLString]; | 114 NSURL* fileURL = [NSURL URLWithString:fileURLString]; |
115 // Initial state should be non-excluded. | 115 // Initial state should be non-excluded. |
116 EXPECT_FALSE(CSBackupIsItemExcluded(base::mac::NSToCFCast(fileURL), NULL)); | 116 EXPECT_FALSE(CSBackupIsItemExcluded(base::mac::NSToCFCast(fileURL), NULL)); |
117 // Exclude the file. | 117 // Exclude the file. |
118 EXPECT_TRUE(SetFileBackupExclusion(dummy_file_path)); | 118 EXPECT_TRUE(SetFileBackupExclusion(dummy_file_path)); |
119 // SetFileBackupExclusion never excludes by path. | 119 // SetFileBackupExclusion never excludes by path. |
120 Boolean excluded_by_path = FALSE; | 120 Boolean excluded_by_path = FALSE; |
121 Boolean excluded = | 121 Boolean excluded = |
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
253 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); | 253 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); |
254 FilePath non_existent_path = temp_dir_.path().Append("DummyPath"); | 254 FilePath non_existent_path = temp_dir_.path().Append("DummyPath"); |
255 ASSERT_FALSE(PathExists(non_existent_path)); | 255 ASSERT_FALSE(PathExists(non_existent_path)); |
256 EXPECT_FALSE(RemoveQuarantineAttribute(non_existent_path)); | 256 EXPECT_FALSE(RemoveQuarantineAttribute(non_existent_path)); |
257 } | 257 } |
258 | 258 |
259 } // namespace | 259 } // namespace |
260 | 260 |
261 } // namespace mac | 261 } // namespace mac |
262 } // namespace base | 262 } // namespace base |
OLD | NEW |