OLD | NEW |
(Empty) | |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include <Foundation/Foundation.h> |
| 6 |
| 7 #include "base/files/file_path.h" |
| 8 #include "base/files/file_util.h" |
| 9 #include "base/files/scoped_temp_dir.h" |
| 10 #include "content/browser/download/file_metadata_mac.h" |
| 11 #include "testing/gtest/include/gtest/gtest.h" |
| 12 |
| 13 namespace content { |
| 14 namespace { |
| 15 |
| 16 class FileMetadataMacTest : public testing::Test { |
| 17 public: |
| 18 FileMetadataMacTest() {}; |
| 19 |
| 20 const base::FilePath& test_file() const { |
| 21 return test_file_; |
| 22 } |
| 23 |
| 24 protected: |
| 25 void SetUp() override { |
| 26 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); |
| 27 ASSERT_TRUE(base::CreateTemporaryFileInDir(temp_dir_.path(), &test_file_)); |
| 28 } |
| 29 |
| 30 private: |
| 31 base::ScopedTempDir temp_dir_; |
| 32 base::FilePath test_file_; |
| 33 }; |
| 34 |
| 35 TEST_F(FileMetadataMacTest, CheckSetExtensionHiddenForFile) { |
| 36 NSString* file_path = |
| 37 [NSString stringWithUTF8String:test_file().value().c_str()]; |
| 38 content::SetExtensionHiddenForFile(test_file(), true); |
| 39 NSError* error = nil; |
| 40 NSDictionary* attributes = |
| 41 [[NSFileManager defaultManager] attributesOfItemAtPath:file_path |
| 42 error:&error]; |
| 43 bool file_extension_hidden = |
| 44 [[attributes objectForKey:NSFileExtensionHidden] boolValue]; |
| 45 EXPECT_TRUE(!error && file_extension_hidden); |
| 46 content::SetExtensionHiddenForFile(test_file(), false); |
| 47 error = nil; |
| 48 attributes = [[NSFileManager defaultManager] attributesOfItemAtPath:file_path |
| 49 error:&error]; |
| 50 file_extension_hidden = |
| 51 [[attributes objectForKey:NSFileExtensionHidden] boolValue]; |
| 52 EXPECT_TRUE(!error && !file_extension_hidden); |
| 53 } |
| 54 |
| 55 } // namespace |
| 56 } // namespace content |
OLD | NEW |