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 #include <stack> | 5 #include <stack> |
6 #include <utility> | 6 #include <utility> |
7 | 7 |
8 #include "base/file_path.h" | 8 #include "base/file_path.h" |
9 #include "base/file_util.h" | 9 #include "base/file_util.h" |
10 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
(...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
310 } | 310 } |
311 | 311 |
312 void TestGetChangedFileRequest() { | 312 void TestGetChangedFileRequest() { |
313 scoped_refptr<BlobData> blob_data(new BlobData()); | 313 scoped_refptr<BlobData> blob_data(new BlobData()); |
314 base::Time old_time = | 314 base::Time old_time = |
315 temp_file_modification_time1_ - base::TimeDelta::FromSeconds(10); | 315 temp_file_modification_time1_ - base::TimeDelta::FromSeconds(10); |
316 blob_data->AppendFile(temp_file1_, 0, 3, old_time); | 316 blob_data->AppendFile(temp_file1_, 0, 3, old_time); |
317 TestErrorRequest(blob_data, 404); | 317 TestErrorRequest(blob_data, 404); |
318 } | 318 } |
319 | 319 |
320 void TestGetSlicedDataRequest() { | |
321 scoped_refptr<BlobData> blob_data(new BlobData()); | |
322 blob_data->AppendData(kTestData2, 2, 4); | |
323 std::string result(kTestData2 + 2, 4); | |
324 TestSuccessRequest(blob_data, result); | |
325 } | |
326 | |
327 void TestGetSlicedFileRequest() { | 320 void TestGetSlicedFileRequest() { |
328 scoped_refptr<BlobData> blob_data(new BlobData()); | 321 scoped_refptr<BlobData> blob_data(new BlobData()); |
329 blob_data->AppendFile(temp_file1_, 2, 4, temp_file_modification_time1_); | 322 blob_data->AppendFile(temp_file1_, 2, 4, temp_file_modification_time1_); |
330 std::string result(kTestFileData1 + 2, 4); | 323 std::string result(kTestFileData1 + 2, 4); |
331 TestSuccessRequest(blob_data, result); | 324 TestSuccessRequest(blob_data, result); |
332 } | 325 } |
333 | 326 |
334 scoped_refptr<BlobData> BuildComplicatedData(std::string* expected_result) { | 327 scoped_refptr<BlobData> BuildComplicatedData(std::string* expected_result) { |
335 scoped_refptr<BlobData> blob_data(new BlobData()); | 328 scoped_refptr<BlobData> blob_data(new BlobData()); |
336 blob_data->AppendData(kTestData1, 1, 2); | 329 blob_data->AppendData(kTestData1 + 1, 2); |
337 blob_data->AppendFile(temp_file1_, 2, 3, temp_file_modification_time1_); | 330 blob_data->AppendFile(temp_file1_, 2, 3, temp_file_modification_time1_); |
338 blob_data->AppendData(kTestData2, 3, 4); | 331 blob_data->AppendData(kTestData2 + 3, 4); |
339 blob_data->AppendFile(temp_file2_, 4, 5, temp_file_modification_time2_); | 332 blob_data->AppendFile(temp_file2_, 4, 5, temp_file_modification_time2_); |
340 *expected_result = std::string(kTestData1 + 1, 2); | 333 *expected_result = std::string(kTestData1 + 1, 2); |
341 *expected_result += std::string(kTestFileData1 + 2, 3); | 334 *expected_result += std::string(kTestFileData1 + 2, 3); |
342 *expected_result += std::string(kTestData2 + 3, 4); | 335 *expected_result += std::string(kTestData2 + 3, 4); |
343 *expected_result += std::string(kTestFileData2 + 4, 5); | 336 *expected_result += std::string(kTestFileData2 + 4, 5); |
344 return blob_data; | 337 return blob_data; |
345 } | 338 } |
346 | 339 |
347 void TestGetComplicatedDataAndFileRequest() { | 340 void TestGetComplicatedDataAndFileRequest() { |
348 std::string result; | 341 std::string result; |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
424 } | 417 } |
425 | 418 |
426 TEST_F(BlobURLRequestJobTest, TestGetSimpleFileRequest) { | 419 TEST_F(BlobURLRequestJobTest, TestGetSimpleFileRequest) { |
427 RunTestOnIOThread(&BlobURLRequestJobTest::TestGetSimpleFileRequest); | 420 RunTestOnIOThread(&BlobURLRequestJobTest::TestGetSimpleFileRequest); |
428 } | 421 } |
429 | 422 |
430 TEST_F(BlobURLRequestJobTest, TestGetLargeFileRequest) { | 423 TEST_F(BlobURLRequestJobTest, TestGetLargeFileRequest) { |
431 RunTestOnIOThread(&BlobURLRequestJobTest::TestGetLargeFileRequest); | 424 RunTestOnIOThread(&BlobURLRequestJobTest::TestGetLargeFileRequest); |
432 } | 425 } |
433 | 426 |
434 TEST_F(BlobURLRequestJobTest, TestGetSlicedDataRequest) { | |
435 RunTestOnIOThread(&BlobURLRequestJobTest::TestGetSlicedDataRequest); | |
436 } | |
437 | |
438 TEST_F(BlobURLRequestJobTest, TestGetSlicedFileRequest) { | 427 TEST_F(BlobURLRequestJobTest, TestGetSlicedFileRequest) { |
439 RunTestOnIOThread(&BlobURLRequestJobTest::TestGetSlicedFileRequest); | 428 RunTestOnIOThread(&BlobURLRequestJobTest::TestGetSlicedFileRequest); |
440 } | 429 } |
441 | 430 |
442 TEST_F(BlobURLRequestJobTest, TestGetNonExistentFileRequest) { | 431 TEST_F(BlobURLRequestJobTest, TestGetNonExistentFileRequest) { |
443 RunTestOnIOThread(&BlobURLRequestJobTest::TestGetNonExistentFileRequest); | 432 RunTestOnIOThread(&BlobURLRequestJobTest::TestGetNonExistentFileRequest); |
444 } | 433 } |
445 | 434 |
446 TEST_F(BlobURLRequestJobTest, TestGetChangedFileRequest) { | 435 TEST_F(BlobURLRequestJobTest, TestGetChangedFileRequest) { |
447 RunTestOnIOThread(&BlobURLRequestJobTest::TestGetChangedFileRequest); | 436 RunTestOnIOThread(&BlobURLRequestJobTest::TestGetChangedFileRequest); |
(...skipping 14 matching lines...) Expand all Loading... |
462 | 451 |
463 TEST_F(BlobURLRequestJobTest, TestExtraHeaders) { | 452 TEST_F(BlobURLRequestJobTest, TestExtraHeaders) { |
464 RunTestOnIOThread(&BlobURLRequestJobTest::TestExtraHeaders); | 453 RunTestOnIOThread(&BlobURLRequestJobTest::TestExtraHeaders); |
465 } | 454 } |
466 | 455 |
467 } // namespace webkit_blob | 456 } // namespace webkit_blob |
468 | 457 |
469 // BlobURLRequestJobTest is expected to always live longer than the | 458 // BlobURLRequestJobTest is expected to always live longer than the |
470 // runnable methods. This lets us call NewRunnableMethod on its instances. | 459 // runnable methods. This lets us call NewRunnableMethod on its instances. |
471 DISABLE_RUNNABLE_METHOD_REFCOUNT(webkit_blob::BlobURLRequestJobTest); | 460 DISABLE_RUNNABLE_METHOD_REFCOUNT(webkit_blob::BlobURLRequestJobTest); |
OLD | NEW |