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 <stdint.h> | 5 #include <stdint.h> |
6 #include <string> | 6 #include <string> |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/files/file_path.h" | 9 #include "base/files/file_path.h" |
10 #include "base/files/file_util.h" | 10 #include "base/files/file_util.h" |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
126 class FileSystemDirURLRequestJobTest : public testing::Test { | 126 class FileSystemDirURLRequestJobTest : public testing::Test { |
127 protected: | 127 protected: |
128 FileSystemDirURLRequestJobTest() | 128 FileSystemDirURLRequestJobTest() |
129 : weak_factory_(this) { | 129 : weak_factory_(this) { |
130 } | 130 } |
131 | 131 |
132 void SetUp() override { | 132 void SetUp() override { |
133 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); | 133 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); |
134 | 134 |
135 special_storage_policy_ = new MockSpecialStoragePolicy; | 135 special_storage_policy_ = new MockSpecialStoragePolicy; |
136 file_system_context_ = CreateFileSystemContextForTesting( | 136 file_system_context_ = |
137 NULL, temp_dir_.path()); | 137 CreateFileSystemContextForTesting(NULL, temp_dir_.GetPath()); |
138 | 138 |
139 file_system_context_->OpenFileSystem( | 139 file_system_context_->OpenFileSystem( |
140 GURL("http://remote/"), | 140 GURL("http://remote/"), |
141 storage::kFileSystemTypeTemporary, | 141 storage::kFileSystemTypeTemporary, |
142 storage::OPEN_FILE_SYSTEM_CREATE_IF_NONEXISTENT, | 142 storage::OPEN_FILE_SYSTEM_CREATE_IF_NONEXISTENT, |
143 base::Bind(&FileSystemDirURLRequestJobTest::OnOpenFileSystem, | 143 base::Bind(&FileSystemDirURLRequestJobTest::OnOpenFileSystem, |
144 weak_factory_.GetWeakPtr())); | 144 weak_factory_.GetWeakPtr())); |
145 base::RunLoop().RunUntilIdle(); | 145 base::RunLoop().RunUntilIdle(); |
146 } | 146 } |
147 | 147 |
148 void TearDown() override { | 148 void TearDown() override { |
149 // NOTE: order matters, request must die before delegate | 149 // NOTE: order matters, request must die before delegate |
150 request_.reset(NULL); | 150 request_.reset(NULL); |
151 delegate_.reset(NULL); | 151 delegate_.reset(NULL); |
152 } | 152 } |
153 | 153 |
154 void SetUpAutoMountContext(base::FilePath* mnt_point) { | 154 void SetUpAutoMountContext(base::FilePath* mnt_point) { |
155 *mnt_point = temp_dir_.path().AppendASCII("auto_mount_dir"); | 155 *mnt_point = temp_dir_.GetPath().AppendASCII("auto_mount_dir"); |
156 ASSERT_TRUE(base::CreateDirectory(*mnt_point)); | 156 ASSERT_TRUE(base::CreateDirectory(*mnt_point)); |
157 | 157 |
158 ScopedVector<storage::FileSystemBackend> additional_providers; | 158 ScopedVector<storage::FileSystemBackend> additional_providers; |
159 additional_providers.push_back(new TestFileSystemBackend( | 159 additional_providers.push_back(new TestFileSystemBackend( |
160 base::ThreadTaskRunnerHandle::Get().get(), *mnt_point)); | 160 base::ThreadTaskRunnerHandle::Get().get(), *mnt_point)); |
161 | 161 |
162 std::vector<storage::URLRequestAutoMountHandler> handlers; | 162 std::vector<storage::URLRequestAutoMountHandler> handlers; |
163 handlers.push_back(base::Bind(&TestAutoMountForURLRequest)); | 163 handlers.push_back(base::Bind(&TestAutoMountForURLRequest)); |
164 | 164 |
165 file_system_context_ = CreateFileSystemContextWithAutoMountersForTesting( | 165 file_system_context_ = CreateFileSystemContextWithAutoMountersForTesting( |
166 NULL, std::move(additional_providers), handlers, temp_dir_.path()); | 166 NULL, std::move(additional_providers), handlers, temp_dir_.GetPath()); |
167 } | 167 } |
168 | 168 |
169 void OnOpenFileSystem(const GURL& root_url, | 169 void OnOpenFileSystem(const GURL& root_url, |
170 const std::string& name, | 170 const std::string& name, |
171 base::File::Error result) { | 171 base::File::Error result) { |
172 ASSERT_EQ(base::File::FILE_OK, result); | 172 ASSERT_EQ(base::File::FILE_OK, result); |
173 } | 173 } |
174 | 174 |
175 void TestRequestHelper(const GURL& url, bool run_to_completion, | 175 void TestRequestHelper(const GURL& url, bool run_to_completion, |
176 FileSystemContext* file_system_context) { | 176 FileSystemContext* file_system_context) { |
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
372 base::ThreadTaskRunnerHandle::Get()->DeleteSoon(FROM_HERE, | 372 base::ThreadTaskRunnerHandle::Get()->DeleteSoon(FROM_HERE, |
373 request_.release()); | 373 request_.release()); |
374 base::RunLoop().RunUntilIdle(); | 374 base::RunLoop().RunUntilIdle(); |
375 // If we get here, success! we didn't crash! | 375 // If we get here, success! we didn't crash! |
376 } | 376 } |
377 | 377 |
378 TEST_F(FileSystemDirURLRequestJobTest, Incognito) { | 378 TEST_F(FileSystemDirURLRequestJobTest, Incognito) { |
379 CreateDirectory("foo"); | 379 CreateDirectory("foo"); |
380 | 380 |
381 scoped_refptr<FileSystemContext> file_system_context = | 381 scoped_refptr<FileSystemContext> file_system_context = |
382 CreateIncognitoFileSystemContextForTesting(NULL, temp_dir_.path()); | 382 CreateIncognitoFileSystemContextForTesting(NULL, temp_dir_.GetPath()); |
383 | 383 |
384 TestRequestWithContext(CreateFileSystemURL("/"), | 384 TestRequestWithContext(CreateFileSystemURL("/"), |
385 file_system_context.get()); | 385 file_system_context.get()); |
386 ASSERT_FALSE(request_->is_pending()); | 386 ASSERT_FALSE(request_->is_pending()); |
387 ASSERT_TRUE(request_->status().is_success()); | 387 ASSERT_TRUE(request_->status().is_success()); |
388 | 388 |
389 std::istringstream in(delegate_->data_received()); | 389 std::istringstream in(delegate_->data_received()); |
390 std::string line; | 390 std::string line; |
391 EXPECT_TRUE(std::getline(in, line)); | 391 EXPECT_TRUE(std::getline(in, line)); |
392 EXPECT_FALSE(!!std::getline(in, line)); | 392 EXPECT_FALSE(!!std::getline(in, line)); |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
455 ASSERT_FALSE(request_->status().is_success()); | 455 ASSERT_FALSE(request_->status().is_success()); |
456 EXPECT_EQ(net::ERR_FILE_NOT_FOUND, request_->status().error()); | 456 EXPECT_EQ(net::ERR_FILE_NOT_FOUND, request_->status().error()); |
457 | 457 |
458 ASSERT_FALSE( | 458 ASSERT_FALSE( |
459 storage::ExternalMountPoints::GetSystemInstance()->RevokeFileSystem( | 459 storage::ExternalMountPoints::GetSystemInstance()->RevokeFileSystem( |
460 kValidExternalMountPoint)); | 460 kValidExternalMountPoint)); |
461 } | 461 } |
462 | 462 |
463 } // namespace | 463 } // namespace |
464 } // namespace content | 464 } // namespace content |
OLD | NEW |