Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(538)

Unified Diff: net/url_request/url_request_unittest.cc

Issue 10911151: URLRequestHttpJob::StartTransaction should honour network delegate. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Added a unit-test, not fully working yet Created 8 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « net/url_request/url_request_http_job.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/url_request/url_request_unittest.cc
diff --git a/net/url_request/url_request_unittest.cc b/net/url_request/url_request_unittest.cc
index 089721786f44602a36d9ec3da26a2d2debcef4d3..227ea24228fc289080bb6914a75980f57fe55ca3 100644
--- a/net/url_request/url_request_unittest.cc
+++ b/net/url_request/url_request_unittest.cc
@@ -696,6 +696,43 @@ TEST_F(URLRequestTestHTTP, NetworkDelegateCancelRequestSynchronously) {
EXPECT_EQ(1, network_delegate.destroyed_requests());
}
+// Tests that the network delegate can cancel a request asynchronously in
+// various stages of the request.
+TEST_F(URLRequestTestHTTP, NetworkDelegateCancelRequestAsynchronously) {
+ ASSERT_TRUE(test_server_.Start());
+
+ static const BlockingNetworkDelegateWithManualCallback::State
+ blocking_states[] = {
+ //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
+ BlockingNetworkDelegateWithManualCallback::ON_BEFORE_SEND_HEADERS,
+ BlockingNetworkDelegateWithManualCallback::ON_HEADERS_RECEIVED
+ };
+
+ for (size_t i = 0; i < arraysize(blocking_states); ++i) {
+ TestDelegate d;
+ BlockingNetworkDelegateWithManualCallback network_delegate;
+ network_delegate.BlockOn(blocking_states[i]);
+
+ TestURLRequestContextWithProxy context(
+ test_server_.host_port_pair().ToString(),
+ &network_delegate);
+
+ {
+ URLRequest r(test_server_.GetURL(""), &d, &context);
+
+ r.Start();
+ network_delegate.WaitForState(blocking_states[i]);
+ network_delegate.DoCallback(ERR_BLOCKED_BY_CLIENT);
+
+ EXPECT_EQ(URLRequestStatus::FAILED, r.status().status());
+ EXPECT_EQ(ERR_BLOCKED_BY_CLIENT, r.status().error());
+ EXPECT_EQ(1, network_delegate.created_requests());
+ EXPECT_EQ(0, network_delegate.destroyed_requests());
+ }
+ EXPECT_EQ(1, network_delegate.destroyed_requests());
+ }
+}
+
// Tests that the network delegate can block and redirect a request to a new
// URL.
TEST_F(URLRequestTestHTTP, NetworkDelegateRedirectRequest) {
« no previous file with comments | « net/url_request/url_request_http_job.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698