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 "webkit/browser/fileapi/file_system_dir_url_request_job.h" | 5 #include "webkit/browser/fileapi/file_system_dir_url_request_job.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/file_util.h" | 9 #include "base/file_util.h" |
10 #include "base/files/file_path.h" | 10 #include "base/files/file_path.h" |
11 #include "base/files/scoped_temp_dir.h" | 11 #include "base/files/scoped_temp_dir.h" |
12 #include "base/format_macros.h" | 12 #include "base/format_macros.h" |
13 #include "base/memory/scoped_vector.h" | 13 #include "base/memory/scoped_vector.h" |
14 #include "base/memory/weak_ptr.h" | 14 #include "base/memory/weak_ptr.h" |
15 #include "base/message_loop/message_loop.h" | 15 #include "base/message_loop/message_loop.h" |
16 #include "base/platform_file.h" | 16 #include "base/platform_file.h" |
17 #include "base/run_loop.h" | 17 #include "base/run_loop.h" |
18 #include "base/strings/string_piece.h" | 18 #include "base/strings/string_piece.h" |
19 #include "base/strings/utf_string_conversions.h" | 19 #include "base/strings/utf_string_conversions.h" |
| 20 #include "content/public/test/mock_special_storage_policy.h" |
20 #include "content/public/test/test_file_system_backend.h" | 21 #include "content/public/test/test_file_system_backend.h" |
21 #include "content/public/test/test_file_system_context.h" | 22 #include "content/public/test/test_file_system_context.h" |
22 #include "net/base/net_errors.h" | 23 #include "net/base/net_errors.h" |
23 #include "net/base/net_util.h" | 24 #include "net/base/net_util.h" |
24 #include "net/base/request_priority.h" | 25 #include "net/base/request_priority.h" |
25 #include "net/http/http_request_headers.h" | 26 #include "net/http/http_request_headers.h" |
26 #include "net/url_request/url_request.h" | 27 #include "net/url_request/url_request.h" |
27 #include "net/url_request/url_request_context.h" | 28 #include "net/url_request/url_request_context.h" |
28 #include "net/url_request/url_request_test_util.h" | 29 #include "net/url_request/url_request_test_util.h" |
29 #include "testing/gtest/include/gtest/gtest.h" | 30 #include "testing/gtest/include/gtest/gtest.h" |
30 #include "third_party/icu/source/i18n/unicode/regex.h" | 31 #include "third_party/icu/source/i18n/unicode/regex.h" |
31 #include "webkit/browser/fileapi/external_mount_points.h" | 32 #include "webkit/browser/fileapi/external_mount_points.h" |
32 #include "webkit/browser/fileapi/file_system_context.h" | 33 #include "webkit/browser/fileapi/file_system_context.h" |
33 #include "webkit/browser/fileapi/file_system_file_util.h" | 34 #include "webkit/browser/fileapi/file_system_file_util.h" |
34 #include "webkit/browser/fileapi/file_system_operation_context.h" | 35 #include "webkit/browser/fileapi/file_system_operation_context.h" |
35 #include "webkit/browser/fileapi/file_system_url.h" | 36 #include "webkit/browser/fileapi/file_system_url.h" |
36 #include "webkit/browser/quota/mock_special_storage_policy.h" | |
37 | 37 |
38 using fileapi::FileSystemContext; | 38 using fileapi::FileSystemContext; |
39 using fileapi::FileSystemOperationContext; | 39 using fileapi::FileSystemOperationContext; |
40 using fileapi::FileSystemURL; | 40 using fileapi::FileSystemURL; |
41 | 41 |
42 namespace content { | 42 namespace content { |
43 namespace { | 43 namespace { |
44 | 44 |
45 // We always use the TEMPORARY FileSystem in this test. | 45 // We always use the TEMPORARY FileSystem in this test. |
46 const char kFileSystemURLPrefix[] = "filesystem:http://remote/temporary/"; | 46 const char kFileSystemURLPrefix[] = "filesystem:http://remote/temporary/"; |
(...skipping 29 matching lines...) Expand all Loading... |
76 | 76 |
77 class FileSystemDirURLRequestJobTest : public testing::Test { | 77 class FileSystemDirURLRequestJobTest : public testing::Test { |
78 protected: | 78 protected: |
79 FileSystemDirURLRequestJobTest() | 79 FileSystemDirURLRequestJobTest() |
80 : weak_factory_(this) { | 80 : weak_factory_(this) { |
81 } | 81 } |
82 | 82 |
83 virtual void SetUp() OVERRIDE { | 83 virtual void SetUp() OVERRIDE { |
84 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); | 84 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); |
85 | 85 |
86 special_storage_policy_ = new quota::MockSpecialStoragePolicy; | 86 special_storage_policy_ = new MockSpecialStoragePolicy; |
87 file_system_context_ = CreateFileSystemContextForTesting( | 87 file_system_context_ = CreateFileSystemContextForTesting( |
88 NULL, temp_dir_.path()); | 88 NULL, temp_dir_.path()); |
89 | 89 |
90 file_system_context_->OpenFileSystem( | 90 file_system_context_->OpenFileSystem( |
91 GURL("http://remote/"), fileapi::kFileSystemTypeTemporary, | 91 GURL("http://remote/"), fileapi::kFileSystemTypeTemporary, |
92 fileapi::OPEN_FILE_SYSTEM_CREATE_IF_NONEXISTENT, | 92 fileapi::OPEN_FILE_SYSTEM_CREATE_IF_NONEXISTENT, |
93 base::Bind(&FileSystemDirURLRequestJobTest::OnOpenFileSystem, | 93 base::Bind(&FileSystemDirURLRequestJobTest::OnOpenFileSystem, |
94 weak_factory_.GetWeakPtr())); | 94 weak_factory_.GetWeakPtr())); |
95 base::RunLoop().RunUntilIdle(); | 95 base::RunLoop().RunUntilIdle(); |
96 | 96 |
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
264 | 264 |
265 // Put the message loop at the top, so that it's the last thing deleted. | 265 // Put the message loop at the top, so that it's the last thing deleted. |
266 // Delete all MessageLoopProxy objects before the MessageLoop, to help prevent | 266 // Delete all MessageLoopProxy objects before the MessageLoop, to help prevent |
267 // leaks caused by tasks posted during shutdown. | 267 // leaks caused by tasks posted during shutdown. |
268 base::MessageLoopForIO message_loop_; | 268 base::MessageLoopForIO message_loop_; |
269 | 269 |
270 base::ScopedTempDir temp_dir_; | 270 base::ScopedTempDir temp_dir_; |
271 net::URLRequestContext empty_context_; | 271 net::URLRequestContext empty_context_; |
272 scoped_ptr<net::TestDelegate> delegate_; | 272 scoped_ptr<net::TestDelegate> delegate_; |
273 scoped_ptr<net::URLRequest> request_; | 273 scoped_ptr<net::URLRequest> request_; |
274 scoped_refptr<quota::MockSpecialStoragePolicy> special_storage_policy_; | 274 scoped_refptr<MockSpecialStoragePolicy> special_storage_policy_; |
275 scoped_refptr<FileSystemContext> file_system_context_; | 275 scoped_refptr<FileSystemContext> file_system_context_; |
276 base::WeakPtrFactory<FileSystemDirURLRequestJobTest> weak_factory_; | 276 base::WeakPtrFactory<FileSystemDirURLRequestJobTest> weak_factory_; |
277 | 277 |
278 static net::URLRequestJob* job_; | 278 static net::URLRequestJob* job_; |
279 }; | 279 }; |
280 | 280 |
281 // static | 281 // static |
282 net::URLRequestJob* FileSystemDirURLRequestJobTest::job_ = NULL; | 282 net::URLRequestJob* FileSystemDirURLRequestJobTest::job_ = NULL; |
283 | 283 |
284 namespace { | 284 namespace { |
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
427 ASSERT_FALSE(request_->status().is_success()); | 427 ASSERT_FALSE(request_->status().is_success()); |
428 EXPECT_EQ(net::ERR_FILE_NOT_FOUND, request_->status().error()); | 428 EXPECT_EQ(net::ERR_FILE_NOT_FOUND, request_->status().error()); |
429 | 429 |
430 ASSERT_FALSE( | 430 ASSERT_FALSE( |
431 fileapi::ExternalMountPoints::GetSystemInstance()->RevokeFileSystem( | 431 fileapi::ExternalMountPoints::GetSystemInstance()->RevokeFileSystem( |
432 kValidExternalMountPoint)); | 432 kValidExternalMountPoint)); |
433 } | 433 } |
434 | 434 |
435 } // namespace (anonymous) | 435 } // namespace (anonymous) |
436 } // namespace content | 436 } // namespace content |
OLD | NEW |