| OLD | NEW |
| 1 // Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2009 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 "net/url_request/url_request_unittest.h" | 5 #include "net/url_request/url_request_unittest.h" |
| 6 | 6 |
| 7 #include "build/build_config.h" | 7 #include "build/build_config.h" |
| 8 | 8 |
| 9 #if defined(OS_WIN) | 9 #if defined(OS_WIN) |
| 10 #include <windows.h> | 10 #include <windows.h> |
| (...skipping 647 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 658 DCHECK_EQ(url_request_metrics.object_count, 0); | 658 DCHECK_EQ(url_request_metrics.object_count, 0); |
| 659 #endif | 659 #endif |
| 660 } | 660 } |
| 661 | 661 |
| 662 TEST_F(URLRequestTest, FileTestFullSpecifiedRange) { | 662 TEST_F(URLRequestTest, FileTestFullSpecifiedRange) { |
| 663 const size_t buffer_size = 4000; | 663 const size_t buffer_size = 4000; |
| 664 scoped_array<char> buffer(new char[buffer_size]); | 664 scoped_array<char> buffer(new char[buffer_size]); |
| 665 FillBuffer(buffer.get(), buffer_size); | 665 FillBuffer(buffer.get(), buffer_size); |
| 666 | 666 |
| 667 FilePath temp_path; | 667 FilePath temp_path; |
| 668 EXPECT_TRUE(file_util::CreateTemporaryFileName(&temp_path)); | 668 EXPECT_TRUE(file_util::CreateTemporaryFile(&temp_path)); |
| 669 GURL temp_url = net::FilePathToFileURL(temp_path); | 669 GURL temp_url = net::FilePathToFileURL(temp_path); |
| 670 file_util::WriteFile(temp_path, buffer.get(), buffer_size); | 670 file_util::WriteFile(temp_path, buffer.get(), buffer_size); |
| 671 | 671 |
| 672 int64 file_size; | 672 int64 file_size; |
| 673 EXPECT_TRUE(file_util::GetFileSize(temp_path, &file_size)); | 673 EXPECT_TRUE(file_util::GetFileSize(temp_path, &file_size)); |
| 674 | 674 |
| 675 const size_t first_byte_position = 500; | 675 const size_t first_byte_position = 500; |
| 676 const size_t last_byte_position = buffer_size - first_byte_position; | 676 const size_t last_byte_position = buffer_size - first_byte_position; |
| 677 const size_t content_length = last_byte_position - first_byte_position + 1; | 677 const size_t content_length = last_byte_position - first_byte_position + 1; |
| 678 std::string partial_buffer_string(buffer.get() + first_byte_position, | 678 std::string partial_buffer_string(buffer.get() + first_byte_position, |
| (...skipping 23 matching lines...) Expand all Loading... |
| 702 DCHECK_EQ(url_request_metrics.object_count, 0); | 702 DCHECK_EQ(url_request_metrics.object_count, 0); |
| 703 #endif | 703 #endif |
| 704 } | 704 } |
| 705 | 705 |
| 706 TEST_F(URLRequestTest, FileTestHalfSpecifiedRange) { | 706 TEST_F(URLRequestTest, FileTestHalfSpecifiedRange) { |
| 707 const size_t buffer_size = 4000; | 707 const size_t buffer_size = 4000; |
| 708 scoped_array<char> buffer(new char[buffer_size]); | 708 scoped_array<char> buffer(new char[buffer_size]); |
| 709 FillBuffer(buffer.get(), buffer_size); | 709 FillBuffer(buffer.get(), buffer_size); |
| 710 | 710 |
| 711 FilePath temp_path; | 711 FilePath temp_path; |
| 712 EXPECT_TRUE(file_util::CreateTemporaryFileName(&temp_path)); | 712 EXPECT_TRUE(file_util::CreateTemporaryFile(&temp_path)); |
| 713 GURL temp_url = net::FilePathToFileURL(temp_path); | 713 GURL temp_url = net::FilePathToFileURL(temp_path); |
| 714 file_util::WriteFile(temp_path, buffer.get(), buffer_size); | 714 file_util::WriteFile(temp_path, buffer.get(), buffer_size); |
| 715 | 715 |
| 716 int64 file_size; | 716 int64 file_size; |
| 717 EXPECT_TRUE(file_util::GetFileSize(temp_path, &file_size)); | 717 EXPECT_TRUE(file_util::GetFileSize(temp_path, &file_size)); |
| 718 | 718 |
| 719 const size_t first_byte_position = 500; | 719 const size_t first_byte_position = 500; |
| 720 const size_t last_byte_position = buffer_size - 1; | 720 const size_t last_byte_position = buffer_size - 1; |
| 721 const size_t content_length = last_byte_position - first_byte_position + 1; | 721 const size_t content_length = last_byte_position - first_byte_position + 1; |
| 722 std::string partial_buffer_string(buffer.get() + first_byte_position, | 722 std::string partial_buffer_string(buffer.get() + first_byte_position, |
| (...skipping 22 matching lines...) Expand all Loading... |
| 745 DCHECK_EQ(url_request_metrics.object_count, 0); | 745 DCHECK_EQ(url_request_metrics.object_count, 0); |
| 746 #endif | 746 #endif |
| 747 } | 747 } |
| 748 | 748 |
| 749 TEST_F(URLRequestTest, FileTestMultipleRanges) { | 749 TEST_F(URLRequestTest, FileTestMultipleRanges) { |
| 750 const size_t buffer_size = 400000; | 750 const size_t buffer_size = 400000; |
| 751 scoped_array<char> buffer(new char[buffer_size]); | 751 scoped_array<char> buffer(new char[buffer_size]); |
| 752 FillBuffer(buffer.get(), buffer_size); | 752 FillBuffer(buffer.get(), buffer_size); |
| 753 | 753 |
| 754 FilePath temp_path; | 754 FilePath temp_path; |
| 755 EXPECT_TRUE(file_util::CreateTemporaryFileName(&temp_path)); | 755 EXPECT_TRUE(file_util::CreateTemporaryFile(&temp_path)); |
| 756 GURL temp_url = net::FilePathToFileURL(temp_path); | 756 GURL temp_url = net::FilePathToFileURL(temp_path); |
| 757 file_util::WriteFile(temp_path, buffer.get(), buffer_size); | 757 file_util::WriteFile(temp_path, buffer.get(), buffer_size); |
| 758 | 758 |
| 759 int64 file_size; | 759 int64 file_size; |
| 760 EXPECT_TRUE(file_util::GetFileSize(temp_path, &file_size)); | 760 EXPECT_TRUE(file_util::GetFileSize(temp_path, &file_size)); |
| 761 | 761 |
| 762 TestDelegate d; | 762 TestDelegate d; |
| 763 { | 763 { |
| 764 TestURLRequest r(temp_url, &d); | 764 TestURLRequest r(temp_url, &d); |
| 765 | 765 |
| (...skipping 1104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1870 | 1870 |
| 1871 int64 file_size = 0; | 1871 int64 file_size = 0; |
| 1872 file_util::GetFileSize(app_path, &file_size); | 1872 file_util::GetFileSize(app_path, &file_size); |
| 1873 | 1873 |
| 1874 EXPECT_FALSE(r.is_pending()); | 1874 EXPECT_FALSE(r.is_pending()); |
| 1875 EXPECT_EQ(1, d.response_started_count()); | 1875 EXPECT_EQ(1, d.response_started_count()); |
| 1876 EXPECT_FALSE(d.received_data_before_response()); | 1876 EXPECT_FALSE(d.received_data_before_response()); |
| 1877 EXPECT_EQ(d.bytes_received(), 0); | 1877 EXPECT_EQ(d.bytes_received(), 0); |
| 1878 } | 1878 } |
| 1879 } | 1879 } |
| OLD | NEW |