| 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 "base/basictypes.h" | 5 #include "base/basictypes.h" |
| 6 #include "base/bind.h" | 6 #include "base/bind.h" |
| 7 #include "base/file_util.h" | 7 #include "base/file_util.h" |
| 8 #include "base/files/file_path.h" | 8 #include "base/files/file_path.h" |
| 9 #include "base/files/scoped_temp_dir.h" | 9 #include "base/files/scoped_temp_dir.h" |
| 10 #include "base/message_loop/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
| 11 #include "base/message_loop/message_loop_proxy.h" | 11 #include "base/message_loop/message_loop_proxy.h" |
| 12 #include "chrome/browser/media_galleries/fileapi/media_file_system_mount_point_p
rovider.h" | 12 #include "chrome/browser/media_galleries/fileapi/media_file_system_backend.h" |
| 13 #include "chrome/test/base/in_process_browser_test.h" | 13 #include "chrome/test/base/in_process_browser_test.h" |
| 14 #include "content/public/test/browser_test.h" | 14 #include "content/public/test/browser_test.h" |
| 15 #include "content/public/test/test_utils.h" | 15 #include "content/public/test/test_utils.h" |
| 16 #include "testing/gtest/include/gtest/gtest.h" | 16 #include "testing/gtest/include/gtest/gtest.h" |
| 17 #include "webkit/browser/fileapi/copy_or_move_file_validator.h" | 17 #include "webkit/browser/fileapi/copy_or_move_file_validator.h" |
| 18 #include "webkit/browser/fileapi/file_system_backend.h" |
| 18 #include "webkit/browser/fileapi/file_system_context.h" | 19 #include "webkit/browser/fileapi/file_system_context.h" |
| 19 #include "webkit/browser/fileapi/file_system_mount_point_provider.h" | |
| 20 #include "webkit/browser/fileapi/file_system_operation_runner.h" | 20 #include "webkit/browser/fileapi/file_system_operation_runner.h" |
| 21 #include "webkit/browser/fileapi/file_system_url.h" | 21 #include "webkit/browser/fileapi/file_system_url.h" |
| 22 #include "webkit/browser/fileapi/isolated_context.h" | 22 #include "webkit/browser/fileapi/isolated_context.h" |
| 23 #include "webkit/browser/fileapi/mock_file_system_context.h" | 23 #include "webkit/browser/fileapi/mock_file_system_context.h" |
| 24 #include "webkit/browser/fileapi/test_mount_point_provider.h" | 24 #include "webkit/browser/fileapi/test_mount_point_provider.h" |
| 25 #include "webkit/common/fileapi/file_system_types.h" | 25 #include "webkit/common/fileapi/file_system_types.h" |
| 26 | 26 |
| 27 namespace { | 27 namespace { |
| 28 | 28 |
| 29 const char kOrigin[] = "http://foo"; | 29 const char kOrigin[] = "http://foo"; |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 81 private: | 81 private: |
| 82 // Create the test files, filesystem objects, etc. | 82 // Create the test files, filesystem objects, etc. |
| 83 void SetupOnFileThread(const std::string& filename, | 83 void SetupOnFileThread(const std::string& filename, |
| 84 const std::string& content, | 84 const std::string& content, |
| 85 bool expected_result) { | 85 bool expected_result) { |
| 86 ASSERT_TRUE(base_dir_.CreateUniqueTempDir()); | 86 ASSERT_TRUE(base_dir_.CreateUniqueTempDir()); |
| 87 base::FilePath base = base_dir_.path(); | 87 base::FilePath base = base_dir_.path(); |
| 88 base::FilePath src_path = base.AppendASCII("src_fs"); | 88 base::FilePath src_path = base.AppendASCII("src_fs"); |
| 89 ASSERT_TRUE(file_util::CreateDirectory(src_path)); | 89 ASSERT_TRUE(file_util::CreateDirectory(src_path)); |
| 90 | 90 |
| 91 ScopedVector<fileapi::FileSystemMountPointProvider> additional_providers; | 91 ScopedVector<fileapi::FileSystemBackend> additional_providers; |
| 92 additional_providers.push_back(new fileapi::TestMountPointProvider( | 92 additional_providers.push_back(new fileapi::TestMountPointProvider( |
| 93 base::MessageLoopProxy::current().get(), src_path)); | 93 base::MessageLoopProxy::current().get(), src_path)); |
| 94 additional_providers.push_back(new MediaFileSystemMountPointProvider( | 94 additional_providers.push_back(new MediaFileSystemBackend( |
| 95 base, base::MessageLoopProxy::current().get())); | 95 base, base::MessageLoopProxy::current().get())); |
| 96 file_system_context_ = | 96 file_system_context_ = |
| 97 fileapi::CreateFileSystemContextWithAdditionalProvidersForTesting( | 97 fileapi::CreateFileSystemContextWithAdditionalProvidersForTesting( |
| 98 NULL, additional_providers.Pass(), base); | 98 NULL, additional_providers.Pass(), base); |
| 99 | 99 |
| 100 move_src_ = file_system_context_->CreateCrackedFileSystemURL( | 100 move_src_ = file_system_context_->CreateCrackedFileSystemURL( |
| 101 GURL(kOrigin), fileapi::kFileSystemTypeTest, | 101 GURL(kOrigin), fileapi::kFileSystemTypeTest, |
| 102 base::FilePath::FromUTF8Unsafe(filename)); | 102 base::FilePath::FromUTF8Unsafe(filename)); |
| 103 | 103 |
| 104 test_file_size_ = content.size(); | 104 test_file_size_ = content.size(); |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 219 IN_PROC_BROWSER_TEST_F(MediaFileValidatorTest, InvalidImage) { | 219 IN_PROC_BROWSER_TEST_F(MediaFileValidatorTest, InvalidImage) { |
| 220 MoveTest("a.webp", std::string(kInvalidImage, arraysize(kInvalidImage)), | 220 MoveTest("a.webp", std::string(kInvalidImage, arraysize(kInvalidImage)), |
| 221 false); | 221 false); |
| 222 } | 222 } |
| 223 | 223 |
| 224 IN_PROC_BROWSER_TEST_F(MediaFileValidatorTest, UnsupportedExtension) { | 224 IN_PROC_BROWSER_TEST_F(MediaFileValidatorTest, UnsupportedExtension) { |
| 225 MoveTest("a.txt", std::string(kValidImage, arraysize(kValidImage)), false); | 225 MoveTest("a.txt", std::string(kValidImage, arraysize(kValidImage)), false); |
| 226 } | 226 } |
| 227 | 227 |
| 228 } // namespace chrome | 228 } // namespace chrome |
| OLD | NEW |