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

Side by Side Diff: content/browser/blob_storage/blob_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 <stdint.h> 5 #include <stdint.h>
6 6
7 #include <limits> 7 #include <limits>
8 #include <memory> 8 #include <memory>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
146 private: 146 private:
147 BlobURLRequestJobTest* test_; 147 BlobURLRequestJobTest* test_;
148 }; 148 };
149 149
150 BlobURLRequestJobTest() 150 BlobURLRequestJobTest()
151 : blob_data_(new BlobDataBuilder("uuid")), expected_status_code_(0) {} 151 : blob_data_(new BlobDataBuilder("uuid")), expected_status_code_(0) {}
152 152
153 void SetUp() override { 153 void SetUp() override {
154 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); 154 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir());
155 155
156 temp_file1_ = temp_dir_.path().AppendASCII("BlobFile1.dat"); 156 temp_file1_ = temp_dir_.GetPath().AppendASCII("BlobFile1.dat");
157 ASSERT_EQ(static_cast<int>(arraysize(kTestFileData1) - 1), 157 ASSERT_EQ(static_cast<int>(arraysize(kTestFileData1) - 1),
158 base::WriteFile(temp_file1_, kTestFileData1, 158 base::WriteFile(temp_file1_, kTestFileData1,
159 arraysize(kTestFileData1) - 1)); 159 arraysize(kTestFileData1) - 1));
160 base::File::Info file_info1; 160 base::File::Info file_info1;
161 base::GetFileInfo(temp_file1_, &file_info1); 161 base::GetFileInfo(temp_file1_, &file_info1);
162 temp_file_modification_time1_ = file_info1.last_modified; 162 temp_file_modification_time1_ = file_info1.last_modified;
163 163
164 temp_file2_ = temp_dir_.path().AppendASCII("BlobFile2.dat"); 164 temp_file2_ = temp_dir_.GetPath().AppendASCII("BlobFile2.dat");
165 ASSERT_EQ(static_cast<int>(arraysize(kTestFileData2) - 1), 165 ASSERT_EQ(static_cast<int>(arraysize(kTestFileData2) - 1),
166 base::WriteFile(temp_file2_, kTestFileData2, 166 base::WriteFile(temp_file2_, kTestFileData2,
167 arraysize(kTestFileData2) - 1)); 167 arraysize(kTestFileData2) - 1));
168 base::File::Info file_info2; 168 base::File::Info file_info2;
169 base::GetFileInfo(temp_file2_, &file_info2); 169 base::GetFileInfo(temp_file2_, &file_info2);
170 temp_file_modification_time2_ = file_info2.last_modified; 170 temp_file_modification_time2_ = file_info2.last_modified;
171 171
172 disk_cache_backend_ = CreateInMemoryDiskCache(); 172 disk_cache_backend_ = CreateInMemoryDiskCache();
173 disk_cache_entry_ = CreateDiskCacheEntry( 173 disk_cache_entry_ = CreateDiskCacheEntry(
174 disk_cache_backend_.get(), kTestDiskCacheKey1, kTestDiskCacheData1); 174 disk_cache_backend_.get(), kTestDiskCacheKey1, kTestDiskCacheData1);
175 175
176 url_request_job_factory_.SetProtocolHandler( 176 url_request_job_factory_.SetProtocolHandler(
177 "blob", base::MakeUnique<MockProtocolHandler>(this)); 177 "blob", base::MakeUnique<MockProtocolHandler>(this));
178 url_request_context_.set_job_factory(&url_request_job_factory_); 178 url_request_context_.set_job_factory(&url_request_job_factory_);
179 } 179 }
180 180
181 void TearDown() override { 181 void TearDown() override {
182 blob_handle_.reset(); 182 blob_handle_.reset();
183 request_.reset(); 183 request_.reset();
184 // Clean up for ASAN 184 // Clean up for ASAN
185 base::RunLoop run_loop; 185 base::RunLoop run_loop;
186 run_loop.RunUntilIdle(); 186 run_loop.RunUntilIdle();
187 } 187 }
188 188
189 void SetUpFileSystem() { 189 void SetUpFileSystem() {
190 // Prepare file system. 190 // Prepare file system.
191 file_system_context_ = CreateFileSystemContextForTesting( 191 file_system_context_ =
192 NULL, temp_dir_.path()); 192 CreateFileSystemContextForTesting(NULL, temp_dir_.GetPath());
193 193
194 file_system_context_->OpenFileSystem( 194 file_system_context_->OpenFileSystem(
195 GURL(kFileSystemURLOrigin), 195 GURL(kFileSystemURLOrigin),
196 kFileSystemType, 196 kFileSystemType,
197 storage::OPEN_FILE_SYSTEM_CREATE_IF_NONEXISTENT, 197 storage::OPEN_FILE_SYSTEM_CREATE_IF_NONEXISTENT,
198 base::Bind(&BlobURLRequestJobTest::OnValidateFileSystem, 198 base::Bind(&BlobURLRequestJobTest::OnValidateFileSystem,
199 base::Unretained(this))); 199 base::Unretained(this)));
200 base::RunLoop().RunUntilIdle(); 200 base::RunLoop().RunUntilIdle();
201 ASSERT_TRUE(file_system_root_url_.is_valid()); 201 ASSERT_TRUE(file_system_root_url_.is_valid());
202 202
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after
366 } 366 }
367 367
368 TEST_F(BlobURLRequestJobTest, TestGetSimpleFileRequest) { 368 TEST_F(BlobURLRequestJobTest, TestGetSimpleFileRequest) {
369 blob_data_->AppendFile(temp_file1_, 0, std::numeric_limits<uint64_t>::max(), 369 blob_data_->AppendFile(temp_file1_, 0, std::numeric_limits<uint64_t>::max(),
370 base::Time()); 370 base::Time());
371 TestSuccessNonrangeRequest(kTestFileData1, arraysize(kTestFileData1) - 1); 371 TestSuccessNonrangeRequest(kTestFileData1, arraysize(kTestFileData1) - 1);
372 } 372 }
373 373
374 TEST_F(BlobURLRequestJobTest, TestGetLargeFileRequest) { 374 TEST_F(BlobURLRequestJobTest, TestGetLargeFileRequest) {
375 base::FilePath large_temp_file = 375 base::FilePath large_temp_file =
376 temp_dir_.path().AppendASCII("LargeBlob.dat"); 376 temp_dir_.GetPath().AppendASCII("LargeBlob.dat");
377 std::string large_data; 377 std::string large_data;
378 large_data.reserve(kBufferSize * 5); 378 large_data.reserve(kBufferSize * 5);
379 for (int i = 0; i < kBufferSize * 5; ++i) 379 for (int i = 0; i < kBufferSize * 5; ++i)
380 large_data.append(1, static_cast<char>(i % 256)); 380 large_data.append(1, static_cast<char>(i % 256));
381 ASSERT_EQ(static_cast<int>(large_data.size()), 381 ASSERT_EQ(static_cast<int>(large_data.size()),
382 base::WriteFile(large_temp_file, large_data.data(), 382 base::WriteFile(large_temp_file, large_data.data(),
383 large_data.size())); 383 large_data.size()));
384 blob_data_->AppendFile(large_temp_file, 0, 384 blob_data_->AppendFile(large_temp_file, 0,
385 std::numeric_limits<uint64_t>::max(), base::Time()); 385 std::numeric_limits<uint64_t>::max(), base::Time());
386 TestSuccessNonrangeRequest(large_data, large_data.size()); 386 TestSuccessNonrangeRequest(large_data, large_data.size());
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after
597 expected_status_code_ = 200; 597 expected_status_code_ = 200;
598 expected_response_ = kTestDiskCacheData2; 598 expected_response_ = kTestDiskCacheData2;
599 TestRequest("GET", net::HttpRequestHeaders()); 599 TestRequest("GET", net::HttpRequestHeaders());
600 EXPECT_EQ(static_cast<int>(arraysize(kTestDiskCacheData2) - 1), 600 EXPECT_EQ(static_cast<int>(arraysize(kTestDiskCacheData2) - 1),
601 request_->response_headers()->GetContentLength()); 601 request_->response_headers()->GetContentLength());
602 602
603 EXPECT_FALSE(url_request_delegate_.metadata()); 603 EXPECT_FALSE(url_request_delegate_.metadata());
604 } 604 }
605 605
606 } // namespace content 606 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698