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

Unified Diff: net/url_request/url_request_unittest.cc

Issue 2542843006: ResourceLoader: Fix a bunch of double-cancellation/double-error notification cases. (Closed)
Patch Set: Fix merge Created 4 years 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_test_util.cc ('k') | remoting/host/token_validator_base.cc » ('j') | 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 61994643d2a58351840ceab986950e6a69c44bf8..60920ef3de116317c49efeddd53b1a18670379a7 100644
--- a/net/url_request/url_request_unittest.cc
+++ b/net/url_request/url_request_unittest.cc
@@ -5549,7 +5549,7 @@ TEST_F(URLRequestTestHTTP, RedirectWithHeaderRemovalTest) {
EXPECT_EQ("None", d.data_received());
}
-TEST_F(URLRequestTestHTTP, CancelTest) {
+TEST_F(URLRequestTestHTTP, CancelAfterStart) {
TestDelegate d;
{
std::unique_ptr<URLRequest> r(default_context_.CreateRequest(
@@ -5570,7 +5570,7 @@ TEST_F(URLRequestTestHTTP, CancelTest) {
}
}
-TEST_F(URLRequestTestHTTP, CancelTest2) {
+TEST_F(URLRequestTestHTTP, CancelInResponseStarted) {
ASSERT_TRUE(http_test_server()->Start());
TestDelegate d;
@@ -5592,12 +5592,35 @@ TEST_F(URLRequestTestHTTP, CancelTest2) {
}
}
-TEST_F(URLRequestTestHTTP, CancelTest3) {
+TEST_F(URLRequestTestHTTP, CancelOnDataReceived) {
ASSERT_TRUE(http_test_server()->Start());
TestDelegate d;
{
std::unique_ptr<URLRequest> r(default_context_.CreateRequest(
+ http_test_server()->GetURL("/defaultresponse"), DEFAULT_PRIORITY, &d));
+
+ d.set_cancel_in_received_data(true);
+
+ r->Start();
+ EXPECT_TRUE(r->is_pending());
+
+ base::RunLoop().Run();
+
+ EXPECT_EQ(1, d.response_started_count());
+ EXPECT_NE(0, d.received_bytes_count());
+ EXPECT_FALSE(d.received_data_before_response());
+ EXPECT_EQ(ERR_ABORTED, d.request_status());
+ }
+}
+
+TEST_F(URLRequestTestHTTP, CancelDuringEofRead) {
+ ASSERT_TRUE(http_test_server()->Start());
+
+ TestDelegate d;
+ {
+ // This returns an empty response (With headers).
+ std::unique_ptr<URLRequest> r(default_context_.CreateRequest(
http_test_server()->GetURL("/"), DEFAULT_PRIORITY, &d));
d.set_cancel_in_received_data(true);
@@ -5608,16 +5631,13 @@ TEST_F(URLRequestTestHTTP, CancelTest3) {
base::RunLoop().Run();
EXPECT_EQ(1, d.response_started_count());
- // There is no guarantee about how much data was received
- // before the cancel was issued. It could have been 0 bytes,
- // or it could have been all the bytes.
- // EXPECT_EQ(0, d.bytes_received());
+ EXPECT_EQ(0, d.received_bytes_count());
EXPECT_FALSE(d.received_data_before_response());
EXPECT_EQ(ERR_ABORTED, d.request_status());
}
}
-TEST_F(URLRequestTestHTTP, CancelTest4) {
+TEST_F(URLRequestTestHTTP, CancelByDestroyingAfterStart) {
ASSERT_TRUE(http_test_server()->Start());
TestDelegate d;
@@ -5643,7 +5663,7 @@ TEST_F(URLRequestTestHTTP, CancelTest4) {
EXPECT_EQ(0, d.bytes_received());
}
-TEST_F(URLRequestTestHTTP, CancelTest5) {
+TEST_F(URLRequestTestHTTP, CancelWhileReadingFromCache) {
ASSERT_TRUE(http_test_server()->Start());
// populate cache
« no previous file with comments | « net/url_request/url_request_test_util.cc ('k') | remoting/host/token_validator_base.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698