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

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

Issue 184563006: Move WriteFile and WriteFileDescriptor from file_util to base namespace. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 9 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 | Annotate | Revision Log
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 "base/basictypes.h" 5 #include "base/basictypes.h"
6 #include "base/bind.h" 6 #include "base/bind.h"
7 #include "base/file_util.h" 7 #include "base/file_util.h"
8 #include "base/files/file_path.h" 8 #include "base/files/file_path.h"
9 #include "base/files/scoped_temp_dir.h" 9 #include "base/files/scoped_temp_dir.h"
10 #include "base/memory/ref_counted.h" 10 #include "base/memory/ref_counted.h"
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
141 141
142 BlobURLRequestJobTest() 142 BlobURLRequestJobTest()
143 : blob_data_(new BlobData()), 143 : blob_data_(new BlobData()),
144 expected_status_code_(0) {} 144 expected_status_code_(0) {}
145 145
146 virtual void SetUp() { 146 virtual void SetUp() {
147 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); 147 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir());
148 148
149 temp_file1_ = temp_dir_.path().AppendASCII("BlobFile1.dat"); 149 temp_file1_ = temp_dir_.path().AppendASCII("BlobFile1.dat");
150 ASSERT_EQ(static_cast<int>(arraysize(kTestFileData1) - 1), 150 ASSERT_EQ(static_cast<int>(arraysize(kTestFileData1) - 1),
151 file_util::WriteFile(temp_file1_, kTestFileData1, 151 base::WriteFile(temp_file1_, kTestFileData1,
152 arraysize(kTestFileData1) - 1)); 152 arraysize(kTestFileData1) - 1));
153 base::File::Info file_info1; 153 base::File::Info file_info1;
154 base::GetFileInfo(temp_file1_, &file_info1); 154 base::GetFileInfo(temp_file1_, &file_info1);
155 temp_file_modification_time1_ = file_info1.last_modified; 155 temp_file_modification_time1_ = file_info1.last_modified;
156 156
157 temp_file2_ = temp_dir_.path().AppendASCII("BlobFile2.dat"); 157 temp_file2_ = temp_dir_.path().AppendASCII("BlobFile2.dat");
158 ASSERT_EQ(static_cast<int>(arraysize(kTestFileData2) - 1), 158 ASSERT_EQ(static_cast<int>(arraysize(kTestFileData2) - 1),
159 file_util::WriteFile(temp_file2_, kTestFileData2, 159 base::WriteFile(temp_file2_, kTestFileData2,
160 arraysize(kTestFileData2) - 1)); 160 arraysize(kTestFileData2) - 1));
161 base::File::Info file_info2; 161 base::File::Info file_info2;
162 base::GetFileInfo(temp_file2_, &file_info2); 162 base::GetFileInfo(temp_file2_, &file_info2);
163 temp_file_modification_time2_ = file_info2.last_modified; 163 temp_file_modification_time2_ = file_info2.last_modified;
164 164
165 url_request_job_factory_.SetProtocolHandler("blob", 165 url_request_job_factory_.SetProtocolHandler("blob",
166 new MockProtocolHandler(this)); 166 new MockProtocolHandler(this));
167 url_request_context_.set_job_factory(&url_request_job_factory_); 167 url_request_context_.set_job_factory(&url_request_job_factory_);
168 } 168 }
169 169
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
329 } 329 }
330 330
331 TEST_F(BlobURLRequestJobTest, TestGetLargeFileRequest) { 331 TEST_F(BlobURLRequestJobTest, TestGetLargeFileRequest) {
332 base::FilePath large_temp_file = 332 base::FilePath large_temp_file =
333 temp_dir_.path().AppendASCII("LargeBlob.dat"); 333 temp_dir_.path().AppendASCII("LargeBlob.dat");
334 std::string large_data; 334 std::string large_data;
335 large_data.reserve(kBufferSize * 5); 335 large_data.reserve(kBufferSize * 5);
336 for (int i = 0; i < kBufferSize * 5; ++i) 336 for (int i = 0; i < kBufferSize * 5; ++i)
337 large_data.append(1, static_cast<char>(i % 256)); 337 large_data.append(1, static_cast<char>(i % 256));
338 ASSERT_EQ(static_cast<int>(large_data.size()), 338 ASSERT_EQ(static_cast<int>(large_data.size()),
339 file_util::WriteFile(large_temp_file, large_data.data(), 339 base::WriteFile(large_temp_file, large_data.data(),
340 large_data.size())); 340 large_data.size()));
341 blob_data_->AppendFile(large_temp_file, 0, -1, base::Time()); 341 blob_data_->AppendFile(large_temp_file, 0, -1, base::Time());
342 TestSuccessNonrangeRequest(large_data, large_data.size()); 342 TestSuccessNonrangeRequest(large_data, large_data.size());
343 } 343 }
344 344
345 TEST_F(BlobURLRequestJobTest, TestGetNonExistentFileRequest) { 345 TEST_F(BlobURLRequestJobTest, TestGetNonExistentFileRequest) {
346 base::FilePath non_existent_file = 346 base::FilePath non_existent_file =
347 temp_file1_.InsertBeforeExtension(FILE_PATH_LITERAL("-na")); 347 temp_file1_.InsertBeforeExtension(FILE_PATH_LITERAL("-na"));
348 blob_data_->AppendFile(non_existent_file, 0, -1, base::Time()); 348 blob_data_->AppendFile(non_existent_file, 0, -1, base::Time());
349 TestErrorRequest(404); 349 TestErrorRequest(404);
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
471 EXPECT_TRUE(request_->response_headers()->GetMimeType(&content_type)); 471 EXPECT_TRUE(request_->response_headers()->GetMimeType(&content_type));
472 EXPECT_EQ(kTestContentType, content_type); 472 EXPECT_EQ(kTestContentType, content_type);
473 void* iter = NULL; 473 void* iter = NULL;
474 std::string content_disposition; 474 std::string content_disposition;
475 EXPECT_TRUE(request_->response_headers()->EnumerateHeader( 475 EXPECT_TRUE(request_->response_headers()->EnumerateHeader(
476 &iter, "Content-Disposition", &content_disposition)); 476 &iter, "Content-Disposition", &content_disposition));
477 EXPECT_EQ(kTestContentDisposition, content_disposition); 477 EXPECT_EQ(kTestContentDisposition, content_disposition);
478 } 478 }
479 479
480 } // namespace content 480 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698