Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(860)

Side by Side Diff: content/browser/fileapi/file_system_url_request_job_unittest.cc

Issue 2316043002: //content: Change ScopedTempDir::path() to GetPath() (Closed)
Patch Set: Just rebased Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 <stddef.h> 5 #include <stddef.h>
6 #include <string> 6 #include <string>
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/files/file_path.h" 10 #include "base/files/file_path.h"
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
133 protected: 133 protected:
134 FileSystemURLRequestJobTest() : weak_factory_(this) { 134 FileSystemURLRequestJobTest() : weak_factory_(this) {
135 } 135 }
136 136
137 void SetUp() override { 137 void SetUp() override {
138 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); 138 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir());
139 139
140 // We use the main thread so that we can get the root path synchronously. 140 // We use the main thread so that we can get the root path synchronously.
141 // TODO(adamk): Run this on the FILE thread we've created as well. 141 // TODO(adamk): Run this on the FILE thread we've created as well.
142 file_system_context_ = 142 file_system_context_ =
143 CreateFileSystemContextForTesting(NULL, temp_dir_.path()); 143 CreateFileSystemContextForTesting(NULL, temp_dir_.GetPath());
144 144
145 file_system_context_->OpenFileSystem( 145 file_system_context_->OpenFileSystem(
146 GURL("http://remote/"), 146 GURL("http://remote/"),
147 storage::kFileSystemTypeTemporary, 147 storage::kFileSystemTypeTemporary,
148 storage::OPEN_FILE_SYSTEM_CREATE_IF_NONEXISTENT, 148 storage::OPEN_FILE_SYSTEM_CREATE_IF_NONEXISTENT,
149 base::Bind(&FileSystemURLRequestJobTest::OnOpenFileSystem, 149 base::Bind(&FileSystemURLRequestJobTest::OnOpenFileSystem,
150 weak_factory_.GetWeakPtr())); 150 weak_factory_.GetWeakPtr()));
151 base::RunLoop().RunUntilIdle(); 151 base::RunLoop().RunUntilIdle();
152 } 152 }
153 153
154 void TearDown() override { 154 void TearDown() override {
155 // FileReader posts a task to close the file in destructor. 155 // FileReader posts a task to close the file in destructor.
156 base::RunLoop().RunUntilIdle(); 156 base::RunLoop().RunUntilIdle();
157 } 157 }
158 158
159 void SetUpAutoMountContext() { 159 void SetUpAutoMountContext() {
160 base::FilePath mnt_point = temp_dir_.path().AppendASCII("auto_mount_dir"); 160 base::FilePath mnt_point =
161 temp_dir_.GetPath().AppendASCII("auto_mount_dir");
161 ASSERT_TRUE(base::CreateDirectory(mnt_point)); 162 ASSERT_TRUE(base::CreateDirectory(mnt_point));
162 163
163 ScopedVector<storage::FileSystemBackend> additional_providers; 164 ScopedVector<storage::FileSystemBackend> additional_providers;
164 additional_providers.push_back(new TestFileSystemBackend( 165 additional_providers.push_back(new TestFileSystemBackend(
165 base::ThreadTaskRunnerHandle::Get().get(), mnt_point)); 166 base::ThreadTaskRunnerHandle::Get().get(), mnt_point));
166 167
167 std::vector<storage::URLRequestAutoMountHandler> handlers; 168 std::vector<storage::URLRequestAutoMountHandler> handlers;
168 handlers.push_back(base::Bind(&TestAutoMountForURLRequest)); 169 handlers.push_back(base::Bind(&TestAutoMountForURLRequest));
169 170
170 file_system_context_ = CreateFileSystemContextWithAutoMountersForTesting( 171 file_system_context_ = CreateFileSystemContextWithAutoMountersForTesting(
171 NULL, std::move(additional_providers), handlers, temp_dir_.path()); 172 NULL, std::move(additional_providers), handlers, temp_dir_.GetPath());
172 173
173 ASSERT_EQ(static_cast<int>(sizeof(kTestFileData)) - 1, 174 ASSERT_EQ(static_cast<int>(sizeof(kTestFileData)) - 1,
174 base::WriteFile(mnt_point.AppendASCII("foo"), kTestFileData, 175 base::WriteFile(mnt_point.AppendASCII("foo"), kTestFileData,
175 sizeof(kTestFileData) - 1)); 176 sizeof(kTestFileData) - 1));
176 } 177 }
177 178
178 void OnOpenFileSystem(const GURL& root_url, 179 void OnOpenFileSystem(const GURL& root_url,
179 const std::string& name, 180 const std::string& name,
180 base::File::Error result) { 181 base::File::Error result) {
181 ASSERT_EQ(base::File::FILE_OK, result); 182 ASSERT_EQ(base::File::FILE_OK, result);
(...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after
414 std::string mime_type_from_job; 415 std::string mime_type_from_job;
415 request_->GetMimeType(&mime_type_from_job); 416 request_->GetMimeType(&mime_type_from_job);
416 EXPECT_EQ(mime_type_direct, mime_type_from_job); 417 EXPECT_EQ(mime_type_direct, mime_type_from_job);
417 } 418 }
418 419
419 TEST_F(FileSystemURLRequestJobTest, Incognito) { 420 TEST_F(FileSystemURLRequestJobTest, Incognito) {
420 WriteFile("file", kTestFileData, arraysize(kTestFileData) - 1); 421 WriteFile("file", kTestFileData, arraysize(kTestFileData) - 1);
421 422
422 // Creates a new filesystem context for incognito mode. 423 // Creates a new filesystem context for incognito mode.
423 scoped_refptr<FileSystemContext> file_system_context = 424 scoped_refptr<FileSystemContext> file_system_context =
424 CreateIncognitoFileSystemContextForTesting(NULL, temp_dir_.path()); 425 CreateIncognitoFileSystemContextForTesting(NULL, temp_dir_.GetPath());
425 426
426 // The request should return NOT_FOUND error if it's in incognito mode. 427 // The request should return NOT_FOUND error if it's in incognito mode.
427 TestRequestWithContext(CreateFileSystemURL("file"), 428 TestRequestWithContext(CreateFileSystemURL("file"),
428 file_system_context.get()); 429 file_system_context.get());
429 ASSERT_FALSE(request_->is_pending()); 430 ASSERT_FALSE(request_->is_pending());
430 EXPECT_TRUE(delegate_->request_failed()); 431 EXPECT_TRUE(delegate_->request_failed());
431 EXPECT_EQ(net::ERR_FILE_NOT_FOUND, request_->status().error()); 432 EXPECT_EQ(net::ERR_FILE_NOT_FOUND, request_->status().error());
432 433
433 // Make sure it returns success with regular (non-incognito) context. 434 // Make sure it returns success with regular (non-incognito) context.
434 TestRequest(CreateFileSystemURL("file")); 435 TestRequest(CreateFileSystemURL("file"));
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
476 EXPECT_TRUE(delegate_->request_failed()); 477 EXPECT_TRUE(delegate_->request_failed());
477 EXPECT_EQ(net::ERR_FILE_NOT_FOUND, request_->status().error()); 478 EXPECT_EQ(net::ERR_FILE_NOT_FOUND, request_->status().error());
478 479
479 ASSERT_FALSE( 480 ASSERT_FALSE(
480 storage::ExternalMountPoints::GetSystemInstance()->RevokeFileSystem( 481 storage::ExternalMountPoints::GetSystemInstance()->RevokeFileSystem(
481 kValidExternalMountPoint)); 482 kValidExternalMountPoint));
482 } 483 }
483 484
484 } // namespace 485 } // namespace
485 } // namespace content 486 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698