| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 #include <stdint.h> | 5 #include <stdint.h> |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/files/file.h" | 10 #include "base/files/file.h" |
| 11 #include "base/files/file_path.h" | 11 #include "base/files/file_path.h" |
| 12 #include "base/files/file_util.h" | 12 #include "base/files/file_util.h" |
| 13 #include "base/files/scoped_temp_dir.h" | 13 #include "base/files/scoped_temp_dir.h" |
| 14 #include "base/macros.h" | 14 #include "base/macros.h" |
| 15 #include "base/run_loop.h" | 15 #include "base/run_loop.h" |
| 16 #include "base/strings/sys_string_conversions.h" | 16 #include "base/strings/sys_string_conversions.h" |
| 17 #include "base/strings/utf_string_conversions.h" | 17 #include "base/strings/utf_string_conversions.h" |
| 18 #include "base/test/scoped_task_environment.h" |
| 18 #include "build/build_config.h" | 19 #include "build/build_config.h" |
| 19 #include "content/public/test/async_file_test_helper.h" | 20 #include "content/public/test/async_file_test_helper.h" |
| 20 #include "content/public/test/test_file_system_context.h" | 21 #include "content/public/test/test_file_system_context.h" |
| 21 #include "storage/browser/fileapi/async_file_util_adapter.h" | 22 #include "storage/browser/fileapi/async_file_util_adapter.h" |
| 22 #include "storage/browser/fileapi/file_system_context.h" | 23 #include "storage/browser/fileapi/file_system_context.h" |
| 23 #include "storage/browser/fileapi/file_system_file_util.h" | 24 #include "storage/browser/fileapi/file_system_file_util.h" |
| 24 #include "storage/browser/fileapi/file_system_operation_context.h" | 25 #include "storage/browser/fileapi/file_system_operation_context.h" |
| 25 #include "storage/browser/fileapi/local_file_util.h" | 26 #include "storage/browser/fileapi/local_file_util.h" |
| 26 #include "storage/browser/fileapi/native_file_util.h" | 27 #include "storage/browser/fileapi/native_file_util.h" |
| 27 #include "storage/common/fileapi/file_system_types.h" | 28 #include "storage/common/fileapi/file_system_types.h" |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 114 std::unique_ptr<FileSystemOperationContext> context(NewContext()); | 115 std::unique_ptr<FileSystemOperationContext> context(NewContext()); |
| 115 return file_util()->EnsureFileExists(context.get(), | 116 return file_util()->EnsureFileExists(context.get(), |
| 116 CreateURL(file_name), created); | 117 CreateURL(file_name), created); |
| 117 } | 118 } |
| 118 | 119 |
| 119 FileSystemContext* file_system_context() { | 120 FileSystemContext* file_system_context() { |
| 120 return file_system_context_.get(); | 121 return file_system_context_.get(); |
| 121 } | 122 } |
| 122 | 123 |
| 123 private: | 124 private: |
| 124 base::MessageLoop message_loop_; | 125 base::test::ScopedTaskEnvironment scoped_task_environment_; |
| 125 scoped_refptr<FileSystemContext> file_system_context_; | 126 scoped_refptr<FileSystemContext> file_system_context_; |
| 126 base::ScopedTempDir data_dir_; | 127 base::ScopedTempDir data_dir_; |
| 127 | 128 |
| 128 DISALLOW_COPY_AND_ASSIGN(LocalFileUtilTest); | 129 DISALLOW_COPY_AND_ASSIGN(LocalFileUtilTest); |
| 129 }; | 130 }; |
| 130 | 131 |
| 131 TEST_F(LocalFileUtilTest, CreateAndClose) { | 132 TEST_F(LocalFileUtilTest, CreateAndClose) { |
| 132 const char *file_name = "test_file"; | 133 const char *file_name = "test_file"; |
| 133 base::File file = CreateFile(file_name); | 134 base::File file = CreateFile(file_name); |
| 134 ASSERT_TRUE(file.IsValid()); | 135 ASSERT_TRUE(file.IsValid()); |
| (...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 372 CreateURL(from_dir), | 373 CreateURL(from_dir), |
| 373 CreateURL(to_dir))); | 374 CreateURL(to_dir))); |
| 374 | 375 |
| 375 EXPECT_FALSE(DirectoryExists(from_dir)); | 376 EXPECT_FALSE(DirectoryExists(from_dir)); |
| 376 EXPECT_TRUE(DirectoryExists(to_dir)); | 377 EXPECT_TRUE(DirectoryExists(to_dir)); |
| 377 EXPECT_TRUE(FileExists(to_file)); | 378 EXPECT_TRUE(FileExists(to_file)); |
| 378 EXPECT_EQ(1020, GetSize(to_file)); | 379 EXPECT_EQ(1020, GetSize(to_file)); |
| 379 } | 380 } |
| 380 | 381 |
| 381 } // namespace content | 382 } // namespace content |
| OLD | NEW |