| Index: content/browser/download/file_metadata_unittest_mac.mm
|
| diff --git a/content/browser/download/file_metadata_unittest_mac.mm b/content/browser/download/file_metadata_unittest_mac.mm
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..af89e0b638766d92e8b1f168a364d0442527c661
|
| --- /dev/null
|
| +++ b/content/browser/download/file_metadata_unittest_mac.mm
|
| @@ -0,0 +1,56 @@
|
| +// Copyright 2015 The Chromium Authors. All rights reserved.
|
| +// Use of this source code is governed by a BSD-style license that can be
|
| +// found in the LICENSE file.
|
| +
|
| +#include <Foundation/Foundation.h>
|
| +
|
| +#include "base/files/file_path.h"
|
| +#include "base/files/file_util.h"
|
| +#include "base/files/scoped_temp_dir.h"
|
| +#include "content/browser/download/file_metadata_mac.h"
|
| +#include "testing/gtest/include/gtest/gtest.h"
|
| +
|
| +namespace content {
|
| +namespace {
|
| +
|
| +class FileMetadataMacTest : public testing::Test {
|
| + public:
|
| + FileMetadataMacTest() {};
|
| +
|
| + const base::FilePath& test_file() const {
|
| + return test_file_;
|
| + }
|
| +
|
| +protected:
|
| + void SetUp() override {
|
| + ASSERT_TRUE(temp_dir_.CreateUniqueTempDir());
|
| + ASSERT_TRUE(base::CreateTemporaryFileInDir(temp_dir_.path(), &test_file_));
|
| + }
|
| +
|
| +private:
|
| + base::ScopedTempDir temp_dir_;
|
| + base::FilePath test_file_;
|
| +};
|
| +
|
| +TEST_F(FileMetadataMacTest, CheckSetExtensionHiddenForFile) {
|
| + NSString* file_path =
|
| + [NSString stringWithUTF8String:test_file().value().c_str()];
|
| + content::SetExtensionHiddenForFile(test_file(), true);
|
| + NSError* error = nil;
|
| + NSDictionary* attributes =
|
| + [[NSFileManager defaultManager] attributesOfItemAtPath:file_path
|
| + error:&error];
|
| + bool file_extension_hidden =
|
| + [[attributes objectForKey:NSFileExtensionHidden] boolValue];
|
| + EXPECT_TRUE(!error && file_extension_hidden);
|
| + content::SetExtensionHiddenForFile(test_file(), false);
|
| + error = nil;
|
| + attributes = [[NSFileManager defaultManager] attributesOfItemAtPath:file_path
|
| + error:&error];
|
| + file_extension_hidden =
|
| + [[attributes objectForKey:NSFileExtensionHidden] boolValue];
|
| + EXPECT_TRUE(!error && !file_extension_hidden);
|
| +}
|
| +
|
| +} // namespace
|
| +} // namespace content
|
|
|