| 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 <memory> | 5 #include <memory> |
| 6 | 6 |
| 7 #include "base/files/file_path.h" | 7 #include "base/files/file_path.h" |
| 8 #include "base/files/file_util.h" | 8 #include "base/files/file_util.h" |
| 9 #include "base/files/scoped_temp_dir.h" | 9 #include "base/files/scoped_temp_dir.h" |
| 10 #include "base/macros.h" | 10 #include "base/macros.h" |
| 11 #include "base/memory/ptr_util.h" | 11 #include "base/memory/ptr_util.h" |
| 12 #include "base/run_loop.h" | 12 #include "base/run_loop.h" |
| 13 #include "base/test/scoped_task_environment.h" |
| 13 #include "content/public/test/test_file_system_context.h" | 14 #include "content/public/test/test_file_system_context.h" |
| 14 #include "storage/browser/blob/scoped_file.h" | 15 #include "storage/browser/blob/scoped_file.h" |
| 15 #include "storage/browser/fileapi/file_system_context.h" | 16 #include "storage/browser/fileapi/file_system_context.h" |
| 16 #include "storage/browser/fileapi/file_system_operation_context.h" | 17 #include "storage/browser/fileapi/file_system_operation_context.h" |
| 17 #include "storage/browser/fileapi/isolated_context.h" | 18 #include "storage/browser/fileapi/isolated_context.h" |
| 18 #include "storage/browser/fileapi/transient_file_util.h" | 19 #include "storage/browser/fileapi/transient_file_util.h" |
| 19 #include "testing/gtest/include/gtest/gtest.h" | 20 #include "testing/gtest/include/gtest/gtest.h" |
| 20 | 21 |
| 21 using storage::FileSystemURL; | 22 using storage::FileSystemURL; |
| 22 | 23 |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 62 std::unique_ptr<storage::FileSystemOperationContext> NewOperationContext() { | 63 std::unique_ptr<storage::FileSystemOperationContext> NewOperationContext() { |
| 63 return base::MakeUnique<storage::FileSystemOperationContext>( | 64 return base::MakeUnique<storage::FileSystemOperationContext>( |
| 64 file_system_context_.get()); | 65 file_system_context_.get()); |
| 65 } | 66 } |
| 66 | 67 |
| 67 storage::FileSystemFileUtil* file_util() { | 68 storage::FileSystemFileUtil* file_util() { |
| 68 return transient_file_util_.get(); | 69 return transient_file_util_.get(); |
| 69 } | 70 } |
| 70 | 71 |
| 71 private: | 72 private: |
| 72 base::MessageLoop message_loop_; | 73 base::test::ScopedTaskEnvironment scoped_task_environment_; |
| 73 base::ScopedTempDir data_dir_; | 74 base::ScopedTempDir data_dir_; |
| 74 scoped_refptr<storage::FileSystemContext> file_system_context_; | 75 scoped_refptr<storage::FileSystemContext> file_system_context_; |
| 75 std::unique_ptr<storage::TransientFileUtil> transient_file_util_; | 76 std::unique_ptr<storage::TransientFileUtil> transient_file_util_; |
| 76 | 77 |
| 77 DISALLOW_COPY_AND_ASSIGN(TransientFileUtilTest); | 78 DISALLOW_COPY_AND_ASSIGN(TransientFileUtilTest); |
| 78 }; | 79 }; |
| 79 | 80 |
| 80 TEST_F(TransientFileUtilTest, TransientFile) { | 81 TEST_F(TransientFileUtilTest, TransientFile) { |
| 81 FileSystemURL temp_url; | 82 FileSystemURL temp_url; |
| 82 base::FilePath temp_path; | 83 base::FilePath temp_path; |
| (...skipping 30 matching lines...) Expand all Loading... |
| 113 base::RunLoop().RunUntilIdle(); | 114 base::RunLoop().RunUntilIdle(); |
| 114 | 115 |
| 115 // Now the temporary file and the transient filesystem must be gone too. | 116 // Now the temporary file and the transient filesystem must be gone too. |
| 116 ASSERT_FALSE(base::PathExists(temp_path)); | 117 ASSERT_FALSE(base::PathExists(temp_path)); |
| 117 ASSERT_EQ(base::File::FILE_ERROR_NOT_FOUND, | 118 ASSERT_EQ(base::File::FILE_ERROR_NOT_FOUND, |
| 118 file_util()->GetFileInfo(NewOperationContext().get(), | 119 file_util()->GetFileInfo(NewOperationContext().get(), |
| 119 temp_url, &file_info, &path)); | 120 temp_url, &file_info, &path)); |
| 120 } | 121 } |
| 121 | 122 |
| 122 } // namespace content | 123 } // namespace content |
| OLD | NEW |