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 82efe662e52dc9a36e45fd6554b34f2791160465..9498b78de30d5c00b4b8920df684dc5314a2c66e 100644 |
--- a/net/url_request/url_request_unittest.cc |
+++ b/net/url_request/url_request_unittest.cc |
@@ -638,6 +638,42 @@ TEST_F(URLRequestTestHTTP, PostFileTest) { |
} |
} |
+TEST_F(URLRequestTestHTTP, PostChunkedDataTest) { |
vandebo (ex-Chrome)
2011/01/21 18:08:41
If I read this test right, it looks like all the d
Satish
2011/01/21 20:29:57
Makes sense. I could do that in this same test by
|
+ ASSERT_TRUE(test_server_.Start()); |
+ |
+ TestDelegate d; |
+ { |
+ TestURLRequest r(test_server_.GetURL("echo"), &d); |
+ r.EnableChunkedUpload(); |
+ r.set_method("POST"); |
+ r.AppendChunkToUpload("a", 1); |
vandebo (ex-Chrome)
2011/01/21 18:08:41
I thought you weren't supposed to call AppendChunk
Satish
2011/01/21 20:29:57
Good catch, yes the code is allowing these calls b
vandebo (ex-Chrome)
2011/01/21 20:47:13
Having two tests would yield better test coverage.
|
+ r.AppendChunkToUpload("bcd", 3); |
+ |
+ r.Start(); |
+ EXPECT_TRUE(r.is_pending()); |
+ |
+ r.AppendChunkToUpload("this is a longer chunk than before.", 35); |
+ r.AppendChunkToUpload("\r\n\r\n", 4); |
+ r.AppendChunkToUpload("0", 1); |
+ r.AppendChunkToUpload("2323", 4); |
+ r.MarkEndOfChunks(); |
+ |
+ MessageLoop::current()->Run(); |
+ |
+ const char* encoded_data = |
+ "abcdthis is a longer chunk than before.\r\n\r\n02323"; |
+ |
+ ASSERT_EQ(1, d.response_started_count()) << "request failed: " << |
+ (int) r.status().status() << ", os error: " << r.status().os_error(); |
+ |
+ EXPECT_FALSE(d.received_data_before_response()); |
+ |
+ ASSERT_EQ(strlen(encoded_data), static_cast<size_t>(d.bytes_received())); |
+ EXPECT_EQ(0, memcmp(d.data_received().c_str(), encoded_data, |
+ strlen(encoded_data))); |
+ } |
+} |
+ |
TEST_F(URLRequestTest, AboutBlankTest) { |
TestDelegate d; |
{ |