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

Unified Diff: content/browser/download/file_metadata_unittest_mac.mm

Issue 1513413002: Enable "Hide Extension" option when "Save Link As" on the Mac Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix nits. Created 5 years 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « content/browser/download/file_metadata_mac.mm ('k') | content/browser/download/mock_download_file.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
« no previous file with comments | « content/browser/download/file_metadata_mac.mm ('k') | content/browser/download/mock_download_file.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698