| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "webkit/fileapi/file_system_dir_url_request_job.h" | 5 #include "webkit/fileapi/file_system_dir_url_request_job.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/files/file_path.h" | 9 #include "base/files/file_path.h" |
| 10 #include "base/files/scoped_temp_dir.h" | 10 #include "base/files/scoped_temp_dir.h" |
| 11 #include "base/format_macros.h" | 11 #include "base/format_macros.h" |
| 12 #include "base/memory/weak_ptr.h" | 12 #include "base/memory/weak_ptr.h" |
| 13 #include "base/message_loop.h" | 13 #include "base/message_loop.h" |
| 14 #include "base/platform_file.h" | 14 #include "base/platform_file.h" |
| 15 #include "base/string_piece.h" | 15 #include "base/string_piece.h" |
| 16 #include "base/utf_string_conversions.h" | 16 #include "base/utf_string_conversions.h" |
| 17 #include "net/base/net_errors.h" | 17 #include "net/base/net_errors.h" |
| 18 #include "net/base/net_util.h" | 18 #include "net/base/net_util.h" |
| 19 #include "net/http/http_request_headers.h" | 19 #include "net/http/http_request_headers.h" |
| 20 #include "net/url_request/url_request.h" | 20 #include "net/url_request/url_request.h" |
| 21 #include "net/url_request/url_request_context.h" | 21 #include "net/url_request/url_request_context.h" |
| 22 #include "net/url_request/url_request_test_util.h" | 22 #include "net/url_request/url_request_test_util.h" |
| 23 #include "testing/gtest/include/gtest/gtest.h" | 23 #include "testing/gtest/include/gtest/gtest.h" |
| 24 #include "third_party/icu/public/i18n/unicode/regex.h" | 24 #include "third_party/icu/public/i18n/unicode/regex.h" |
| 25 #include "webkit/fileapi/external_mount_points.h" | |
| 26 #include "webkit/fileapi/file_system_context.h" | 25 #include "webkit/fileapi/file_system_context.h" |
| 27 #include "webkit/fileapi/file_system_file_util.h" | 26 #include "webkit/fileapi/file_system_file_util.h" |
| 28 #include "webkit/fileapi/file_system_operation_context.h" | 27 #include "webkit/fileapi/file_system_operation_context.h" |
| 29 #include "webkit/fileapi/file_system_task_runners.h" | |
| 30 #include "webkit/fileapi/file_system_url.h" | 28 #include "webkit/fileapi/file_system_url.h" |
| 31 #include "webkit/fileapi/mock_file_system_options.h" | 29 #include "webkit/fileapi/mock_file_system_context.h" |
| 32 #include "webkit/fileapi/sandbox_mount_point_provider.h" | 30 #include "webkit/fileapi/sandbox_mount_point_provider.h" |
| 33 #include "webkit/quota/mock_special_storage_policy.h" | 31 #include "webkit/quota/mock_special_storage_policy.h" |
| 34 | 32 |
| 35 namespace fileapi { | 33 namespace fileapi { |
| 36 namespace { | 34 namespace { |
| 37 | 35 |
| 38 // We always use the TEMPORARY FileSystem in this test. | 36 // We always use the TEMPORARY FileSystem in this test. |
| 39 static const char kFileSystemURLPrefix[] = | 37 static const char kFileSystemURLPrefix[] = |
| 40 "filesystem:http://remote/temporary/"; | 38 "filesystem:http://remote/temporary/"; |
| 41 | 39 |
| 42 } // namespace | 40 } // namespace |
| 43 | 41 |
| 44 class FileSystemDirURLRequestJobTest : public testing::Test { | 42 class FileSystemDirURLRequestJobTest : public testing::Test { |
| 45 protected: | 43 protected: |
| 46 FileSystemDirURLRequestJobTest() | 44 FileSystemDirURLRequestJobTest() |
| 47 : message_loop_(MessageLoop::TYPE_IO), // simulate an IO thread | 45 : message_loop_(MessageLoop::TYPE_IO), // simulate an IO thread |
| 48 ALLOW_THIS_IN_INITIALIZER_LIST(weak_factory_(this)) { | 46 ALLOW_THIS_IN_INITIALIZER_LIST(weak_factory_(this)) { |
| 49 } | 47 } |
| 50 | 48 |
| 51 virtual void SetUp() OVERRIDE { | 49 virtual void SetUp() OVERRIDE { |
| 52 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); | 50 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); |
| 53 | 51 |
| 54 special_storage_policy_ = new quota::MockSpecialStoragePolicy; | 52 special_storage_policy_ = new quota::MockSpecialStoragePolicy; |
| 55 file_system_context_ = | 53 file_system_context_ = CreateFileSystemContextForTesting( |
| 56 new FileSystemContext( | 54 NULL, temp_dir_.path()); |
| 57 FileSystemTaskRunners::CreateMockTaskRunners(), | |
| 58 ExternalMountPoints::CreateRefCounted().get(), | |
| 59 special_storage_policy_, NULL, | |
| 60 temp_dir_.path(), | |
| 61 CreateAllowFileAccessOptions()); | |
| 62 | 55 |
| 63 file_system_context_->sandbox_provider()->ValidateFileSystemRoot( | 56 file_system_context_->sandbox_provider()->ValidateFileSystemRoot( |
| 64 GURL("http://remote/"), kFileSystemTypeTemporary, true, // create | 57 GURL("http://remote/"), kFileSystemTypeTemporary, true, // create |
| 65 base::Bind(&FileSystemDirURLRequestJobTest::OnValidateFileSystem, | 58 base::Bind(&FileSystemDirURLRequestJobTest::OnValidateFileSystem, |
| 66 weak_factory_.GetWeakPtr())); | 59 weak_factory_.GetWeakPtr())); |
| 67 MessageLoop::current()->RunUntilIdle(); | 60 MessageLoop::current()->RunUntilIdle(); |
| 68 | 61 |
| 69 net::URLRequest::Deprecated::RegisterProtocolFactory( | 62 net::URLRequest::Deprecated::RegisterProtocolFactory( |
| 70 "filesystem", &FileSystemDirURLRequestJobFactory); | 63 "filesystem", &FileSystemDirURLRequestJobFactory); |
| 71 } | 64 } |
| (...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 287 CreateDirectory("foo"); | 280 CreateDirectory("foo"); |
| 288 TestRequestNoRun(CreateFileSystemURL("foo/")); | 281 TestRequestNoRun(CreateFileSystemURL("foo/")); |
| 289 // Run StartAsync() and only StartAsync(). | 282 // Run StartAsync() and only StartAsync(). |
| 290 MessageLoop::current()->DeleteSoon(FROM_HERE, request_.release()); | 283 MessageLoop::current()->DeleteSoon(FROM_HERE, request_.release()); |
| 291 MessageLoop::current()->RunUntilIdle(); | 284 MessageLoop::current()->RunUntilIdle(); |
| 292 // If we get here, success! we didn't crash! | 285 // If we get here, success! we didn't crash! |
| 293 } | 286 } |
| 294 | 287 |
| 295 } // namespace (anonymous) | 288 } // namespace (anonymous) |
| 296 } // namespace fileapi | 289 } // namespace fileapi |
| OLD | NEW |