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 678 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 689 MessageLoop::current()->Run(); | 689 MessageLoop::current()->Run(); |
| 690 | 690 |
| 691 EXPECT_EQ(URLRequestStatus::FAILED, r.status().status()); | 691 EXPECT_EQ(URLRequestStatus::FAILED, r.status().status()); |
| 692 EXPECT_EQ(ERR_EMPTY_RESPONSE, r.status().error()); | 692 EXPECT_EQ(ERR_EMPTY_RESPONSE, r.status().error()); |
| 693 EXPECT_EQ(1, network_delegate.created_requests()); | 693 EXPECT_EQ(1, network_delegate.created_requests()); |
| 694 EXPECT_EQ(0, network_delegate.destroyed_requests()); | 694 EXPECT_EQ(0, network_delegate.destroyed_requests()); |
| 695 } | 695 } |
| 696 EXPECT_EQ(1, network_delegate.destroyed_requests()); | 696 EXPECT_EQ(1, network_delegate.destroyed_requests()); |
| 697 } | 697 } |
| 698 | 698 |
| 699 // Tests that the network delegate can cancel a request asynchronously in | |
| 700 // various stages of the request. | |
| 701 TEST_F(URLRequestTestHTTP, NetworkDelegateCancelRequestAsynchronously) { | |
| 702 ASSERT_TRUE(test_server_.Start()); | |
| 703 | |
| 704 static const BlockingNetworkDelegateWithManualCallback::State | |
| 705 blocking_states[] = { | |
| 706 //BlockingNetworkDelegateWithManualCallback::ON_BEFORE_URL_REQUEST, | |
|
vabr (Chromium)
2012/09/10 15:32:59
I'm not sure why, but if blocking ON_BEFORE_URL_RE
| |
| 707 BlockingNetworkDelegateWithManualCallback::ON_BEFORE_SEND_HEADERS, | |
| 708 BlockingNetworkDelegateWithManualCallback::ON_HEADERS_RECEIVED | |
| 709 }; | |
| 710 | |
| 711 for (size_t i = 0; i < arraysize(blocking_states); ++i) { | |
| 712 TestDelegate d; | |
| 713 BlockingNetworkDelegateWithManualCallback network_delegate; | |
| 714 network_delegate.BlockOn(blocking_states[i]); | |
| 715 | |
| 716 TestURLRequestContextWithProxy context( | |
| 717 test_server_.host_port_pair().ToString(), | |
| 718 &network_delegate); | |
| 719 | |
| 720 { | |
| 721 URLRequest r(test_server_.GetURL(""), &d, &context); | |
| 722 | |
| 723 r.Start(); | |
| 724 network_delegate.WaitForState(blocking_states[i]); | |
| 725 network_delegate.DoCallback(ERR_BLOCKED_BY_CLIENT); | |
| 726 | |
| 727 EXPECT_EQ(URLRequestStatus::FAILED, r.status().status()); | |
| 728 EXPECT_EQ(ERR_BLOCKED_BY_CLIENT, r.status().error()); | |
| 729 EXPECT_EQ(1, network_delegate.created_requests()); | |
| 730 EXPECT_EQ(0, network_delegate.destroyed_requests()); | |
| 731 } | |
| 732 EXPECT_EQ(1, network_delegate.destroyed_requests()); | |
| 733 } | |
| 734 } | |
| 735 | |
| 699 // Tests that the network delegate can block and redirect a request to a new | 736 // Tests that the network delegate can block and redirect a request to a new |
| 700 // URL. | 737 // URL. |
| 701 TEST_F(URLRequestTestHTTP, NetworkDelegateRedirectRequest) { | 738 TEST_F(URLRequestTestHTTP, NetworkDelegateRedirectRequest) { |
| 702 ASSERT_TRUE(test_server_.Start()); | 739 ASSERT_TRUE(test_server_.Start()); |
| 703 | 740 |
| 704 TestDelegate d; | 741 TestDelegate d; |
| 705 BlockingNetworkDelegate network_delegate; | 742 BlockingNetworkDelegate network_delegate; |
| 706 GURL redirect_url(test_server_.GetURL("simple.html")); | 743 GURL redirect_url(test_server_.GetURL("simple.html")); |
| 707 network_delegate.set_redirect_url(redirect_url); | 744 network_delegate.set_redirect_url(redirect_url); |
| 708 | 745 |
| (...skipping 3972 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4681 req.SetExtraRequestHeaders(headers); | 4718 req.SetExtraRequestHeaders(headers); |
| 4682 req.Start(); | 4719 req.Start(); |
| 4683 MessageLoop::current()->Run(); | 4720 MessageLoop::current()->Run(); |
| 4684 // If the net tests are being run with ChromeFrame then we need to allow for | 4721 // If the net tests are being run with ChromeFrame then we need to allow for |
| 4685 // the 'chromeframe' suffix which is added to the user agent before the | 4722 // the 'chromeframe' suffix which is added to the user agent before the |
| 4686 // closing parentheses. | 4723 // closing parentheses. |
| 4687 EXPECT_TRUE(StartsWithASCII(d.data_received(), "Lynx (textmode", true)); | 4724 EXPECT_TRUE(StartsWithASCII(d.data_received(), "Lynx (textmode", true)); |
| 4688 } | 4725 } |
| 4689 | 4726 |
| 4690 } // namespace net | 4727 } // namespace net |
| OLD | NEW |