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 2436 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2447 | 2447 |
2448 EXPECT_TRUE(!r.is_pending()); | 2448 EXPECT_TRUE(!r.is_pending()); |
2449 EXPECT_EQ(1, d.response_started_count()); | 2449 EXPECT_EQ(1, d.response_started_count()); |
2450 EXPECT_FALSE(d.received_data_before_response()); | 2450 EXPECT_FALSE(d.received_data_before_response()); |
2451 EXPECT_EQ(d.bytes_received(), static_cast<int>(file_size)); | 2451 EXPECT_EQ(d.bytes_received(), static_cast<int>(file_size)); |
2452 EXPECT_EQ("", r.GetSocketAddress().host()); | 2452 EXPECT_EQ("", r.GetSocketAddress().host()); |
2453 EXPECT_EQ(0, r.GetSocketAddress().port()); | 2453 EXPECT_EQ(0, r.GetSocketAddress().port()); |
2454 } | 2454 } |
2455 } | 2455 } |
2456 | 2456 |
| 2457 TEST_F(URLRequestTest, FileTest_Cancel) { |
| 2458 FilePath app_path; |
| 2459 PathService::Get(base::FILE_EXE, &app_path); |
| 2460 GURL app_url = FilePathToFileURL(app_path); |
| 2461 |
| 2462 TestDelegate d; |
| 2463 { |
| 2464 URLRequest r(app_url, &d, &default_context_); |
| 2465 |
| 2466 r.Start(); |
| 2467 EXPECT_TRUE(r.is_pending()); |
| 2468 r.Cancel(); |
| 2469 } |
| 2470 // Async cancelation should be safe even when URLRequest has been already |
| 2471 // destroyed. |
| 2472 MessageLoop::current()->RunAllPending(); |
| 2473 } |
| 2474 |
2457 TEST_F(URLRequestTest, FileTestFullSpecifiedRange) { | 2475 TEST_F(URLRequestTest, FileTestFullSpecifiedRange) { |
2458 const size_t buffer_size = 4000; | 2476 const size_t buffer_size = 4000; |
2459 scoped_array<char> buffer(new char[buffer_size]); | 2477 scoped_array<char> buffer(new char[buffer_size]); |
2460 FillBuffer(buffer.get(), buffer_size); | 2478 FillBuffer(buffer.get(), buffer_size); |
2461 | 2479 |
2462 FilePath temp_path; | 2480 FilePath temp_path; |
2463 EXPECT_TRUE(file_util::CreateTemporaryFile(&temp_path)); | 2481 EXPECT_TRUE(file_util::CreateTemporaryFile(&temp_path)); |
2464 GURL temp_url = FilePathToFileURL(temp_path); | 2482 GURL temp_url = FilePathToFileURL(temp_path); |
2465 EXPECT_TRUE(file_util::WriteFile(temp_path, buffer.get(), buffer_size)); | 2483 EXPECT_TRUE(file_util::WriteFile(temp_path, buffer.get(), buffer_size)); |
2466 | 2484 |
(...skipping 2171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4638 req.SetExtraRequestHeaders(headers); | 4656 req.SetExtraRequestHeaders(headers); |
4639 req.Start(); | 4657 req.Start(); |
4640 MessageLoop::current()->Run(); | 4658 MessageLoop::current()->Run(); |
4641 // If the net tests are being run with ChromeFrame then we need to allow for | 4659 // If the net tests are being run with ChromeFrame then we need to allow for |
4642 // the 'chromeframe' suffix which is added to the user agent before the | 4660 // the 'chromeframe' suffix which is added to the user agent before the |
4643 // closing parentheses. | 4661 // closing parentheses. |
4644 EXPECT_TRUE(StartsWithASCII(d.data_received(), "Lynx (textmode", true)); | 4662 EXPECT_TRUE(StartsWithASCII(d.data_received(), "Lynx (textmode", true)); |
4645 } | 4663 } |
4646 | 4664 |
4647 } // namespace net | 4665 } // namespace net |
OLD | NEW |