Chromium Code Reviews| 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 2433 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2444 | 2444 |
| 2445 EXPECT_TRUE(!r.is_pending()); | 2445 EXPECT_TRUE(!r.is_pending()); |
| 2446 EXPECT_EQ(1, d.response_started_count()); | 2446 EXPECT_EQ(1, d.response_started_count()); |
| 2447 EXPECT_FALSE(d.received_data_before_response()); | 2447 EXPECT_FALSE(d.received_data_before_response()); |
| 2448 EXPECT_EQ(d.bytes_received(), static_cast<int>(file_size)); | 2448 EXPECT_EQ(d.bytes_received(), static_cast<int>(file_size)); |
| 2449 EXPECT_EQ("", r.GetSocketAddress().host()); | 2449 EXPECT_EQ("", r.GetSocketAddress().host()); |
| 2450 EXPECT_EQ(0, r.GetSocketAddress().port()); | 2450 EXPECT_EQ(0, r.GetSocketAddress().port()); |
| 2451 } | 2451 } |
| 2452 } | 2452 } |
| 2453 | 2453 |
| 2454 TEST_F(URLRequestTest, FileTest_Cancel) { | |
|
wtc
2012/08/14 18:00:40
Nit: FileTest_Cancel => FileTestCancel
| |
| 2455 FilePath app_path; | |
| 2456 PathService::Get(base::FILE_EXE, &app_path); | |
| 2457 GURL app_url = FilePathToFileURL(app_path); | |
| 2458 | |
| 2459 TestDelegate d; | |
| 2460 { | |
| 2461 URLRequest r(app_url, &d, &default_context_); | |
| 2462 | |
| 2463 r.Start(); | |
| 2464 EXPECT_TRUE(r.is_pending()); | |
| 2465 r.Cancel(); | |
| 2466 } | |
| 2467 // Async cancelation should be safe even when URLRequest has been already | |
| 2468 // destroyed. | |
| 2469 MessageLoop::current()->RunAllPending(); | |
| 2470 } | |
| 2471 | |
| 2454 TEST_F(URLRequestTest, FileTestFullSpecifiedRange) { | 2472 TEST_F(URLRequestTest, FileTestFullSpecifiedRange) { |
| 2455 const size_t buffer_size = 4000; | 2473 const size_t buffer_size = 4000; |
| 2456 scoped_array<char> buffer(new char[buffer_size]); | 2474 scoped_array<char> buffer(new char[buffer_size]); |
| 2457 FillBuffer(buffer.get(), buffer_size); | 2475 FillBuffer(buffer.get(), buffer_size); |
| 2458 | 2476 |
| 2459 FilePath temp_path; | 2477 FilePath temp_path; |
| 2460 EXPECT_TRUE(file_util::CreateTemporaryFile(&temp_path)); | 2478 EXPECT_TRUE(file_util::CreateTemporaryFile(&temp_path)); |
| 2461 GURL temp_url = FilePathToFileURL(temp_path); | 2479 GURL temp_url = FilePathToFileURL(temp_path); |
| 2462 EXPECT_TRUE(file_util::WriteFile(temp_path, buffer.get(), buffer_size)); | 2480 EXPECT_TRUE(file_util::WriteFile(temp_path, buffer.get(), buffer_size)); |
| 2463 | 2481 |
| (...skipping 2164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4628 req.SetExtraRequestHeaders(headers); | 4646 req.SetExtraRequestHeaders(headers); |
| 4629 req.Start(); | 4647 req.Start(); |
| 4630 MessageLoop::current()->Run(); | 4648 MessageLoop::current()->Run(); |
| 4631 // If the net tests are being run with ChromeFrame then we need to allow for | 4649 // If the net tests are being run with ChromeFrame then we need to allow for |
| 4632 // the 'chromeframe' suffix which is added to the user agent before the | 4650 // the 'chromeframe' suffix which is added to the user agent before the |
| 4633 // closing parentheses. | 4651 // closing parentheses. |
| 4634 EXPECT_TRUE(StartsWithASCII(d.data_received(), "Lynx (textmode", true)); | 4652 EXPECT_TRUE(StartsWithASCII(d.data_received(), "Lynx (textmode", true)); |
| 4635 } | 4653 } |
| 4636 | 4654 |
| 4637 } // namespace net | 4655 } // namespace net |
| OLD | NEW |