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_url_request_job.h" | 5 #include "webkit/fileapi/file_system_url_request_job.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/file_util.h" | 10 #include "base/file_util.h" |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
53 class FileSystemURLRequestJobTest : public testing::Test { | 53 class FileSystemURLRequestJobTest : public testing::Test { |
54 protected: | 54 protected: |
55 FileSystemURLRequestJobTest() | 55 FileSystemURLRequestJobTest() |
56 : message_loop_(MessageLoop::TYPE_IO), // simulate an IO thread | 56 : message_loop_(MessageLoop::TYPE_IO), // simulate an IO thread |
57 ALLOW_THIS_IN_INITIALIZER_LIST(weak_factory_(this)) { | 57 ALLOW_THIS_IN_INITIALIZER_LIST(weak_factory_(this)) { |
58 } | 58 } |
59 | 59 |
60 virtual void SetUp() OVERRIDE { | 60 virtual void SetUp() OVERRIDE { |
61 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); | 61 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); |
62 | 62 |
63 special_storage_policy_ = new quota::MockSpecialStoragePolicy; | |
64 // We use the main thread so that we can get the root path synchronously. | 63 // We use the main thread so that we can get the root path synchronously. |
65 // TODO(adamk): Run this on the FILE thread we've created as well. | 64 // TODO(adamk): Run this on the FILE thread we've created as well. |
66 file_system_context_ = | 65 file_system_context_ = |
67 new FileSystemContext( | 66 new FileSystemContext( |
68 FileSystemTaskRunners::CreateMockTaskRunners(), | 67 FileSystemTaskRunners::CreateMockTaskRunners(), |
69 ExternalMountPoints::CreateRefCounted().get(), | 68 NULL, |
70 special_storage_policy_, NULL, | 69 ScopedVector<FileSystemMountPointProvider>(), |
| 70 std::vector<MountPoints*>(), |
71 temp_dir_.path(), | 71 temp_dir_.path(), |
72 CreateDisallowFileAccessOptions()); | 72 CreateDisallowFileAccessOptions()); |
73 | 73 |
74 file_system_context_->sandbox_provider()->ValidateFileSystemRoot( | 74 file_system_context_->sandbox_provider()->ValidateFileSystemRoot( |
75 GURL("http://remote/"), kFileSystemTypeTemporary, true, // create | 75 GURL("http://remote/"), kFileSystemTypeTemporary, true, // create |
76 base::Bind(&FileSystemURLRequestJobTest::OnValidateFileSystem, | 76 base::Bind(&FileSystemURLRequestJobTest::OnValidateFileSystem, |
77 weak_factory_.GetWeakPtr())); | 77 weak_factory_.GetWeakPtr())); |
78 MessageLoop::current()->RunUntilIdle(); | 78 MessageLoop::current()->RunUntilIdle(); |
79 | 79 |
80 net::URLRequest::Deprecated::RegisterProtocolFactory( | 80 net::URLRequest::Deprecated::RegisterProtocolFactory( |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
193 if (job_) { | 193 if (job_) { |
194 scoped_refptr<net::URLRequestJob> deleter = job_; | 194 scoped_refptr<net::URLRequestJob> deleter = job_; |
195 job_ = NULL; | 195 job_ = NULL; |
196 } | 196 } |
197 } | 197 } |
198 | 198 |
199 // Put the message loop at the top, so that it's the last thing deleted. | 199 // Put the message loop at the top, so that it's the last thing deleted. |
200 MessageLoop message_loop_; | 200 MessageLoop message_loop_; |
201 | 201 |
202 base::ScopedTempDir temp_dir_; | 202 base::ScopedTempDir temp_dir_; |
203 scoped_refptr<quota::MockSpecialStoragePolicy> special_storage_policy_; | |
204 scoped_refptr<FileSystemContext> file_system_context_; | 203 scoped_refptr<FileSystemContext> file_system_context_; |
205 base::WeakPtrFactory<FileSystemURLRequestJobTest> weak_factory_; | 204 base::WeakPtrFactory<FileSystemURLRequestJobTest> weak_factory_; |
206 | 205 |
207 net::URLRequestContext empty_context_; | 206 net::URLRequestContext empty_context_; |
208 | 207 |
209 // NOTE: order matters, request must die before delegate | 208 // NOTE: order matters, request must die before delegate |
210 scoped_ptr<net::TestDelegate> delegate_; | 209 scoped_ptr<net::TestDelegate> delegate_; |
211 scoped_ptr<net::URLRequest> request_; | 210 scoped_ptr<net::URLRequest> request_; |
212 | 211 |
213 scoped_refptr<net::URLRequestJob> pending_job_; | 212 scoped_refptr<net::URLRequestJob> pending_job_; |
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
360 | 359 |
361 TestRequest(CreateFileSystemURL(kFilename)); | 360 TestRequest(CreateFileSystemURL(kFilename)); |
362 | 361 |
363 std::string mime_type_from_job; | 362 std::string mime_type_from_job; |
364 request_->GetMimeType(&mime_type_from_job); | 363 request_->GetMimeType(&mime_type_from_job); |
365 EXPECT_EQ(mime_type_direct, mime_type_from_job); | 364 EXPECT_EQ(mime_type_direct, mime_type_from_job); |
366 } | 365 } |
367 | 366 |
368 } // namespace | 367 } // namespace |
369 } // namespace fileapi | 368 } // namespace fileapi |
OLD | NEW |