| OLD | NEW | 
|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "build/build_config.h" | 5 #include "build/build_config.h" | 
| 6 | 6 | 
| 7 #if defined(OS_WIN) | 7 #if defined(OS_WIN) | 
| 8 #include <windows.h> | 8 #include <windows.h> | 
| 9 #include <shlobj.h> | 9 #include <shlobj.h> | 
| 10 #endif | 10 #endif | 
| (...skipping 747 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 758 | 758 | 
| 759     base::MessageLoop::current()->Run(); | 759     base::MessageLoop::current()->Run(); | 
| 760     EXPECT_TRUE(!r.is_pending()); | 760     EXPECT_TRUE(!r.is_pending()); | 
| 761     EXPECT_EQ(1, d.response_started_count()); | 761     EXPECT_EQ(1, d.response_started_count()); | 
| 762     EXPECT_FALSE(d.received_data_before_response()); | 762     EXPECT_FALSE(d.received_data_before_response()); | 
| 763     EXPECT_EQ(static_cast<int>(content_length), d.bytes_received()); | 763     EXPECT_EQ(static_cast<int>(content_length), d.bytes_received()); | 
| 764     // Don't use EXPECT_EQ, it will print out a lot of garbage if check failed. | 764     // Don't use EXPECT_EQ, it will print out a lot of garbage if check failed. | 
| 765     EXPECT_TRUE(partial_buffer_string == d.data_received()); | 765     EXPECT_TRUE(partial_buffer_string == d.data_received()); | 
| 766   } | 766   } | 
| 767 | 767 | 
| 768   EXPECT_TRUE(base::Delete(temp_path, false)); | 768   EXPECT_TRUE(base::DeleteFile(temp_path, false)); | 
| 769 } | 769 } | 
| 770 | 770 | 
| 771 TEST_F(URLRequestTest, FileTestHalfSpecifiedRange) { | 771 TEST_F(URLRequestTest, FileTestHalfSpecifiedRange) { | 
| 772   const size_t buffer_size = 4000; | 772   const size_t buffer_size = 4000; | 
| 773   scoped_ptr<char[]> buffer(new char[buffer_size]); | 773   scoped_ptr<char[]> buffer(new char[buffer_size]); | 
| 774   FillBuffer(buffer.get(), buffer_size); | 774   FillBuffer(buffer.get(), buffer_size); | 
| 775 | 775 | 
| 776   base::FilePath temp_path; | 776   base::FilePath temp_path; | 
| 777   EXPECT_TRUE(file_util::CreateTemporaryFile(&temp_path)); | 777   EXPECT_TRUE(file_util::CreateTemporaryFile(&temp_path)); | 
| 778   GURL temp_url = FilePathToFileURL(temp_path); | 778   GURL temp_url = FilePathToFileURL(temp_path); | 
| (...skipping 22 matching lines...) Expand all  Loading... | 
| 801 | 801 | 
| 802     base::MessageLoop::current()->Run(); | 802     base::MessageLoop::current()->Run(); | 
| 803     EXPECT_TRUE(!r.is_pending()); | 803     EXPECT_TRUE(!r.is_pending()); | 
| 804     EXPECT_EQ(1, d.response_started_count()); | 804     EXPECT_EQ(1, d.response_started_count()); | 
| 805     EXPECT_FALSE(d.received_data_before_response()); | 805     EXPECT_FALSE(d.received_data_before_response()); | 
| 806     EXPECT_EQ(static_cast<int>(content_length), d.bytes_received()); | 806     EXPECT_EQ(static_cast<int>(content_length), d.bytes_received()); | 
| 807     // Don't use EXPECT_EQ, it will print out a lot of garbage if check failed. | 807     // Don't use EXPECT_EQ, it will print out a lot of garbage if check failed. | 
| 808     EXPECT_TRUE(partial_buffer_string == d.data_received()); | 808     EXPECT_TRUE(partial_buffer_string == d.data_received()); | 
| 809   } | 809   } | 
| 810 | 810 | 
| 811   EXPECT_TRUE(base::Delete(temp_path, false)); | 811   EXPECT_TRUE(base::DeleteFile(temp_path, false)); | 
| 812 } | 812 } | 
| 813 | 813 | 
| 814 TEST_F(URLRequestTest, FileTestMultipleRanges) { | 814 TEST_F(URLRequestTest, FileTestMultipleRanges) { | 
| 815   const size_t buffer_size = 400000; | 815   const size_t buffer_size = 400000; | 
| 816   scoped_ptr<char[]> buffer(new char[buffer_size]); | 816   scoped_ptr<char[]> buffer(new char[buffer_size]); | 
| 817   FillBuffer(buffer.get(), buffer_size); | 817   FillBuffer(buffer.get(), buffer_size); | 
| 818 | 818 | 
| 819   base::FilePath temp_path; | 819   base::FilePath temp_path; | 
| 820   EXPECT_TRUE(file_util::CreateTemporaryFile(&temp_path)); | 820   EXPECT_TRUE(file_util::CreateTemporaryFile(&temp_path)); | 
| 821   GURL temp_url = FilePathToFileURL(temp_path); | 821   GURL temp_url = FilePathToFileURL(temp_path); | 
| (...skipping 10 matching lines...) Expand all  Loading... | 
| 832     headers.SetHeader(HttpRequestHeaders::kRange, | 832     headers.SetHeader(HttpRequestHeaders::kRange, | 
| 833                       "bytes=0-0,10-200,200-300"); | 833                       "bytes=0-0,10-200,200-300"); | 
| 834     r.SetExtraRequestHeaders(headers); | 834     r.SetExtraRequestHeaders(headers); | 
| 835     r.Start(); | 835     r.Start(); | 
| 836     EXPECT_TRUE(r.is_pending()); | 836     EXPECT_TRUE(r.is_pending()); | 
| 837 | 837 | 
| 838     base::MessageLoop::current()->Run(); | 838     base::MessageLoop::current()->Run(); | 
| 839     EXPECT_TRUE(d.request_failed()); | 839     EXPECT_TRUE(d.request_failed()); | 
| 840   } | 840   } | 
| 841 | 841 | 
| 842   EXPECT_TRUE(base::Delete(temp_path, false)); | 842   EXPECT_TRUE(base::DeleteFile(temp_path, false)); | 
| 843 } | 843 } | 
| 844 | 844 | 
| 845 TEST_F(URLRequestTest, InvalidUrlTest) { | 845 TEST_F(URLRequestTest, InvalidUrlTest) { | 
| 846   TestDelegate d; | 846   TestDelegate d; | 
| 847   { | 847   { | 
| 848     URLRequest r(GURL("invalid url"), &d, &default_context_); | 848     URLRequest r(GURL("invalid url"), &d, &default_context_); | 
| 849 | 849 | 
| 850     r.Start(); | 850     r.Start(); | 
| 851     EXPECT_TRUE(r.is_pending()); | 851     EXPECT_TRUE(r.is_pending()); | 
| 852 | 852 | 
| (...skipping 5260 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 6113 | 6113 | 
| 6114     EXPECT_FALSE(r.is_pending()); | 6114     EXPECT_FALSE(r.is_pending()); | 
| 6115     EXPECT_EQ(1, d->response_started_count()); | 6115     EXPECT_EQ(1, d->response_started_count()); | 
| 6116     EXPECT_FALSE(d->received_data_before_response()); | 6116     EXPECT_FALSE(d->received_data_before_response()); | 
| 6117     EXPECT_EQ(d->bytes_received(), static_cast<int>(file_size)); | 6117     EXPECT_EQ(d->bytes_received(), static_cast<int>(file_size)); | 
| 6118   } | 6118   } | 
| 6119 } | 6119 } | 
| 6120 #endif  // !defined(DISABLE_FTP_SUPPORT) | 6120 #endif  // !defined(DISABLE_FTP_SUPPORT) | 
| 6121 | 6121 | 
| 6122 }  // namespace net | 6122 }  // namespace net | 
| OLD | NEW | 
|---|