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

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: Move comment 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
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 e4177b1fb5ef5eb8cf7b7c26f7a811cdabcea91b..41ec67deea6b941aae168165c9ee044bf3f9b31f 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,39 @@ 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());
+ // 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.
Randy Smith (Not in Mondays) 2016/12/06 23:44:43 Sorry, what's the pathway that makes this true? I
mmenke 2016/12/07 16:17:15 You're right, the comment is false. Was just blin
+ // EXPECT_EQ(0, d.bytes_received());
+ 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,6 +5635,7 @@ TEST_F(URLRequestTestHTTP, CancelTest3) {
base::RunLoop().Run();
EXPECT_EQ(1, d.response_started_count());
+ EXPECT_EQ(0, d.received_bytes_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.
@@ -5617,7 +5645,7 @@ TEST_F(URLRequestTestHTTP, CancelTest3) {
}
}
-TEST_F(URLRequestTestHTTP, CancelTest4) {
+TEST_F(URLRequestTestHTTP, CancelByDestroyingAfterStart) {
ASSERT_TRUE(http_test_server()->Start());
TestDelegate d;
@@ -5643,7 +5671,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

Powered by Google App Engine
This is Rietveld 408576698