OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 // NOTE: These tests are run as part of "unit_tests" (in chrome/test/unit) | 5 // NOTE: These tests are run as part of "unit_tests" (in chrome/test/unit) |
6 // rather than as part of test_shell_tests because they rely on being able | 6 // rather than as part of test_shell_tests because they rely on being able |
7 // to instantiate a MessageLoop of type TYPE_IO. test_shell_tests uses | 7 // to instantiate a MessageLoop of type TYPE_IO. test_shell_tests uses |
8 // TYPE_UI, which URLRequest doesn't allow. | 8 // TYPE_UI, which URLRequest doesn't allow. |
9 // | 9 // |
10 | 10 |
(...skipping 15 matching lines...) Expand all Loading... |
26 #include "base/utf_string_conversions.h" | 26 #include "base/utf_string_conversions.h" |
27 #include "net/base/load_flags.h" | 27 #include "net/base/load_flags.h" |
28 #include "net/base/mime_util.h" | 28 #include "net/base/mime_util.h" |
29 #include "net/base/net_errors.h" | 29 #include "net/base/net_errors.h" |
30 #include "net/base/net_util.h" | 30 #include "net/base/net_util.h" |
31 #include "net/http/http_request_headers.h" | 31 #include "net/http/http_request_headers.h" |
32 #include "net/url_request/url_request.h" | 32 #include "net/url_request/url_request.h" |
33 #include "net/url_request/url_request_test_util.h" | 33 #include "net/url_request/url_request_test_util.h" |
34 #include "testing/gtest/include/gtest/gtest.h" | 34 #include "testing/gtest/include/gtest/gtest.h" |
35 #include "webkit/fileapi/file_system_context.h" | 35 #include "webkit/fileapi/file_system_context.h" |
36 #include "webkit/fileapi/file_system_file_util.h" | |
37 #include "webkit/fileapi/file_system_operation_context.h" | 36 #include "webkit/fileapi/file_system_operation_context.h" |
38 #include "webkit/fileapi/file_system_path_manager.h" | 37 #include "webkit/fileapi/file_system_path_manager.h" |
| 38 #include "webkit/fileapi/fileapi_file_util.h" |
39 #include "webkit/fileapi/sandbox_mount_point_provider.h" | 39 #include "webkit/fileapi/sandbox_mount_point_provider.h" |
40 | 40 |
41 namespace fileapi { | 41 namespace fileapi { |
42 namespace { | 42 namespace { |
43 | 43 |
44 // We always use the TEMPORARY FileSystem in this test. | 44 // We always use the TEMPORARY FileSystem in this test. |
45 const char kFileSystemURLPrefix[] = "filesystem:http://remote/temporary/"; | 45 const char kFileSystemURLPrefix[] = "filesystem:http://remote/temporary/"; |
46 const char kTestFileData[] = "0123456789"; | 46 const char kTestFileData[] = "0123456789"; |
47 | 47 |
48 void FillBuffer(char* buffer, size_t len) { | 48 void FillBuffer(char* buffer, size_t len) { |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
150 const net::HttpRequestHeaders* headers) { | 150 const net::HttpRequestHeaders* headers) { |
151 TestRequestHelper(url, headers, true); | 151 TestRequestHelper(url, headers, true); |
152 } | 152 } |
153 | 153 |
154 void TestRequestNoRun(const GURL& url) { | 154 void TestRequestNoRun(const GURL& url) { |
155 TestRequestHelper(url, NULL, false); | 155 TestRequestHelper(url, NULL, false); |
156 } | 156 } |
157 | 157 |
158 void CreateDirectory(const base::StringPiece& dir_name) { | 158 void CreateDirectory(const base::StringPiece& dir_name) { |
159 FilePath path = FilePath().AppendASCII(dir_name); | 159 FilePath path = FilePath().AppendASCII(dir_name); |
160 FileSystemFileUtil* file_util = file_system_context_->path_manager()-> | 160 FileUtil* file_util = file_system_context_->path_manager()-> |
161 sandbox_provider()->GetFileSystemFileUtil(); | 161 sandbox_provider()->GetFileUtil(); |
162 FileSystemOperationContext context(file_system_context_, file_util); | 162 FileSystemOperationContext context(file_system_context_, file_util); |
163 context.set_src_origin_url(GURL("http://remote")); | 163 context.set_src_origin_url(GURL("http://remote")); |
164 context.set_src_virtual_path(path); | 164 context.set_src_virtual_path(path); |
165 context.set_src_type(fileapi::kFileSystemTypeTemporary); | 165 context.set_src_type(fileapi::kFileSystemTypeTemporary); |
166 context.set_allowed_bytes_growth(1024); | 166 context.set_allowed_bytes_growth(1024); |
167 | 167 |
168 ASSERT_EQ(base::PLATFORM_FILE_OK, file_util->CreateDirectory( | 168 ASSERT_EQ(base::PLATFORM_FILE_OK, file_util->CreateDirectory( |
169 &context, | 169 &context, |
170 path, | 170 path, |
171 false /* exclusive */, | 171 false /* exclusive */, |
172 false /* recursive */)); | 172 false /* recursive */)); |
173 } | 173 } |
174 | 174 |
175 void WriteFile(const base::StringPiece& file_name, | 175 void WriteFile(const base::StringPiece& file_name, |
176 const char* buf, int buf_size) { | 176 const char* buf, int buf_size) { |
177 FilePath path = FilePath().AppendASCII(file_name); | 177 FilePath path = FilePath().AppendASCII(file_name); |
178 FileSystemFileUtil* file_util = file_system_context_->path_manager()-> | 178 FileUtil* file_util = file_system_context_->path_manager()-> |
179 sandbox_provider()->GetFileSystemFileUtil(); | 179 sandbox_provider()->GetFileUtil(); |
180 FileSystemOperationContext context(file_system_context_, file_util); | 180 FileSystemOperationContext context(file_system_context_, file_util); |
181 context.set_src_origin_url(GURL("http://remote")); | 181 context.set_src_origin_url(GURL("http://remote")); |
182 context.set_src_virtual_path(path); | 182 context.set_src_virtual_path(path); |
183 context.set_src_type(fileapi::kFileSystemTypeTemporary); | 183 context.set_src_type(fileapi::kFileSystemTypeTemporary); |
184 context.set_allowed_bytes_growth(1024); | 184 context.set_allowed_bytes_growth(1024); |
185 | 185 |
186 base::PlatformFile handle = base::kInvalidPlatformFileValue; | 186 base::PlatformFile handle = base::kInvalidPlatformFileValue; |
187 bool created = false; | 187 bool created = false; |
188 ASSERT_EQ(base::PLATFORM_FILE_OK, file_util->CreateOrOpen( | 188 ASSERT_EQ(base::PLATFORM_FILE_OK, file_util->CreateOrOpen( |
189 &context, | 189 &context, |
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
383 | 383 |
384 TestRequest(CreateFileSystemURL(kFilename)); | 384 TestRequest(CreateFileSystemURL(kFilename)); |
385 | 385 |
386 std::string mime_type_from_job; | 386 std::string mime_type_from_job; |
387 request_->GetMimeType(&mime_type_from_job); | 387 request_->GetMimeType(&mime_type_from_job); |
388 EXPECT_EQ(mime_type_direct, mime_type_from_job); | 388 EXPECT_EQ(mime_type_direct, mime_type_from_job); |
389 } | 389 } |
390 | 390 |
391 } // namespace (anonymous) | 391 } // namespace (anonymous) |
392 } // namespace fileapi | 392 } // namespace fileapi |
OLD | NEW |