| 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 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 85 } | 85 } |
| 86 | 86 |
| 87 virtual void SetUp() { | 87 virtual void SetUp() { |
| 88 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); | 88 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); |
| 89 | 89 |
| 90 special_storage_policy_ = new TestSpecialStoragePolicy(); | 90 special_storage_policy_ = new TestSpecialStoragePolicy(); |
| 91 // We use the main thread so that we can get the root path synchronously. | 91 // We use the main thread so that we can get the root path synchronously. |
| 92 // TODO(adamk): Run this on the FILE thread we've created as well. | 92 // TODO(adamk): Run this on the FILE thread we've created as well. |
| 93 file_system_context_ = | 93 file_system_context_ = |
| 94 new FileSystemContext( | 94 new FileSystemContext( |
| 95 base::MessageLoopProxy::CreateForCurrentThread(), | 95 base::MessageLoopProxy::current(), |
| 96 base::MessageLoopProxy::CreateForCurrentThread(), | 96 base::MessageLoopProxy::current(), |
| 97 special_storage_policy_, NULL, | 97 special_storage_policy_, NULL, |
| 98 FilePath(), false /* is_incognito */, | 98 FilePath(), false /* is_incognito */, |
| 99 false, true, | 99 false, true, |
| 100 new FileSystemPathManager( | 100 new FileSystemPathManager( |
| 101 base::MessageLoopProxy::CreateForCurrentThread(), | 101 base::MessageLoopProxy::current(), |
| 102 temp_dir_.path(), NULL, false, false)); | 102 temp_dir_.path(), NULL, false, false)); |
| 103 | 103 |
| 104 file_system_context_->path_manager()->ValidateFileSystemRootAndGetURL( | 104 file_system_context_->path_manager()->ValidateFileSystemRootAndGetURL( |
| 105 GURL("http://remote/"), kFileSystemTypeTemporary, true, // create | 105 GURL("http://remote/"), kFileSystemTypeTemporary, true, // create |
| 106 callback_factory_.NewCallback( | 106 callback_factory_.NewCallback( |
| 107 &FileSystemURLRequestJobTest::OnGetRootPath)); | 107 &FileSystemURLRequestJobTest::OnGetRootPath)); |
| 108 MessageLoop::current()->RunAllPending(); | 108 MessageLoop::current()->RunAllPending(); |
| 109 | 109 |
| 110 net::URLRequest::Deprecated::RegisterProtocolFactory( | 110 net::URLRequest::Deprecated::RegisterProtocolFactory( |
| 111 "filesystem", &FileSystemURLRequestJobFactory); | 111 "filesystem", &FileSystemURLRequestJobFactory); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 127 delegate_.reset(new TestDelegate()); | 127 delegate_.reset(new TestDelegate()); |
| 128 // Make delegate_ exit the MessageLoop when the request is done. | 128 // Make delegate_ exit the MessageLoop when the request is done. |
| 129 delegate_->set_quit_on_complete(true); | 129 delegate_->set_quit_on_complete(true); |
| 130 delegate_->set_quit_on_redirect(true); | 130 delegate_->set_quit_on_redirect(true); |
| 131 request_.reset(new net::URLRequest(url, delegate_.get())); | 131 request_.reset(new net::URLRequest(url, delegate_.get())); |
| 132 if (headers) | 132 if (headers) |
| 133 request_->SetExtraRequestHeaders(*headers); | 133 request_->SetExtraRequestHeaders(*headers); |
| 134 job_ = new FileSystemURLRequestJob( | 134 job_ = new FileSystemURLRequestJob( |
| 135 request_.get(), | 135 request_.get(), |
| 136 file_system_context_.get(), | 136 file_system_context_.get(), |
| 137 base::MessageLoopProxy::CreateForCurrentThread()); | 137 base::MessageLoopProxy::current()); |
| 138 | 138 |
| 139 request_->Start(); | 139 request_->Start(); |
| 140 ASSERT_TRUE(request_->is_pending()); // verify that we're starting async | 140 ASSERT_TRUE(request_->is_pending()); // verify that we're starting async |
| 141 if (run_to_completion) | 141 if (run_to_completion) |
| 142 MessageLoop::current()->Run(); | 142 MessageLoop::current()->Run(); |
| 143 } | 143 } |
| 144 | 144 |
| 145 void TestRequest(const GURL& url) { | 145 void TestRequest(const GURL& url) { |
| 146 TestRequestHelper(url, NULL, true); | 146 TestRequestHelper(url, NULL, true); |
| 147 } | 147 } |
| (...skipping 235 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 |