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] ? true | |
45 : false; | |
Avi (use Gerrit)
2015/12/12 00:41:46
Again, not needed. You can straight-up assign a BO
shrike
2015/12/16 19:04:12
Acknowledged.
| |
46 EXPECT_TRUE(!error && file_extension_hidden); | |
47 content::SetExtensionHiddenForFile(test_file(), false); | |
48 error = nil; | |
49 attributes = [[NSFileManager defaultManager] attributesOfItemAtPath:file_path | |
50 error:&error]; | |
51 file_extension_hidden = | |
52 [[attributes objectForKey:NSFileExtensionHidden] boolValue] ? true | |
53 : false; | |
Avi (use Gerrit)
2015/12/12 00:41:46
Ditto.
shrike
2015/12/16 19:04:12
Acknowledged.
| |
54 EXPECT_TRUE(!error && !file_extension_hidden); | |
55 } | |
56 | |
57 } // namespace | |
58 } // namespace content | |
OLD | NEW |