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 545 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
556 | 556 |
557 EXPECT_TRUE(!r.is_pending()); | 557 EXPECT_TRUE(!r.is_pending()); |
558 EXPECT_EQ(1, d.response_started_count()); | 558 EXPECT_EQ(1, d.response_started_count()); |
559 EXPECT_FALSE(d.received_data_before_response()); | 559 EXPECT_FALSE(d.received_data_before_response()); |
560 EXPECT_EQ(d.bytes_received(), static_cast<int>(file_size)); | 560 EXPECT_EQ(d.bytes_received(), static_cast<int>(file_size)); |
561 EXPECT_EQ("", r.GetSocketAddress().host()); | 561 EXPECT_EQ("", r.GetSocketAddress().host()); |
562 EXPECT_EQ(0, r.GetSocketAddress().port()); | 562 EXPECT_EQ(0, r.GetSocketAddress().port()); |
563 } | 563 } |
564 } | 564 } |
565 | 565 |
| 566 TEST_F(URLRequestTest, FileTestCancel) { |
| 567 FilePath app_path; |
| 568 PathService::Get(base::FILE_EXE, &app_path); |
| 569 GURL app_url = FilePathToFileURL(app_path); |
| 570 |
| 571 TestDelegate d; |
| 572 { |
| 573 URLRequest r(app_url, &d, &default_context_); |
| 574 |
| 575 r.Start(); |
| 576 EXPECT_TRUE(r.is_pending()); |
| 577 r.Cancel(); |
| 578 } |
| 579 // Async cancelation should be safe even when URLRequest has been already |
| 580 // destroyed. |
| 581 MessageLoop::current()->RunUntilIdle(); |
| 582 } |
| 583 |
566 TEST_F(URLRequestTest, FileTestFullSpecifiedRange) { | 584 TEST_F(URLRequestTest, FileTestFullSpecifiedRange) { |
567 const size_t buffer_size = 4000; | 585 const size_t buffer_size = 4000; |
568 scoped_array<char> buffer(new char[buffer_size]); | 586 scoped_array<char> buffer(new char[buffer_size]); |
569 FillBuffer(buffer.get(), buffer_size); | 587 FillBuffer(buffer.get(), buffer_size); |
570 | 588 |
571 FilePath temp_path; | 589 FilePath temp_path; |
572 EXPECT_TRUE(file_util::CreateTemporaryFile(&temp_path)); | 590 EXPECT_TRUE(file_util::CreateTemporaryFile(&temp_path)); |
573 GURL temp_url = FilePathToFileURL(temp_path); | 591 GURL temp_url = FilePathToFileURL(temp_path); |
574 EXPECT_TRUE(file_util::WriteFile(temp_path, buffer.get(), buffer_size)); | 592 EXPECT_TRUE(file_util::WriteFile(temp_path, buffer.get(), buffer_size)); |
575 | 593 |
(...skipping 4589 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5165 | 5183 |
5166 EXPECT_FALSE(r.is_pending()); | 5184 EXPECT_FALSE(r.is_pending()); |
5167 EXPECT_EQ(1, d->response_started_count()); | 5185 EXPECT_EQ(1, d->response_started_count()); |
5168 EXPECT_FALSE(d->received_data_before_response()); | 5186 EXPECT_FALSE(d->received_data_before_response()); |
5169 EXPECT_EQ(d->bytes_received(), static_cast<int>(file_size)); | 5187 EXPECT_EQ(d->bytes_received(), static_cast<int>(file_size)); |
5170 } | 5188 } |
5171 } | 5189 } |
5172 #endif // !defined(DISABLE_FTP_SUPPORT) | 5190 #endif // !defined(DISABLE_FTP_SUPPORT) |
5173 | 5191 |
5174 } // namespace net | 5192 } // namespace net |
OLD | NEW |