OLD | NEW |
---|---|
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "net/url_request/url_request_unittest.h" | 5 #include "net/url_request/url_request_unittest.h" |
6 | 6 |
7 #include "build/build_config.h" | 7 #include "build/build_config.h" |
8 | 8 |
9 #if defined(OS_WIN) | 9 #if defined(OS_WIN) |
10 #include <shlobj.h> | 10 #include <shlobj.h> |
(...skipping 620 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
631 ASSERT_EQ(1, d.response_started_count()) << "request failed: " << | 631 ASSERT_EQ(1, d.response_started_count()) << "request failed: " << |
632 (int) r.status().status() << ", os error: " << r.status().os_error(); | 632 (int) r.status().status() << ", os error: " << r.status().os_error(); |
633 | 633 |
634 EXPECT_FALSE(d.received_data_before_response()); | 634 EXPECT_FALSE(d.received_data_before_response()); |
635 | 635 |
636 ASSERT_EQ(size, d.bytes_received()); | 636 ASSERT_EQ(size, d.bytes_received()); |
637 EXPECT_EQ(0, memcmp(d.data_received().c_str(), buf.get(), size)); | 637 EXPECT_EQ(0, memcmp(d.data_received().c_str(), buf.get(), size)); |
638 } | 638 } |
639 } | 639 } |
640 | 640 |
641 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
| |
642 ASSERT_TRUE(test_server_.Start()); | |
643 | |
644 TestDelegate d; | |
645 { | |
646 TestURLRequest r(test_server_.GetURL("echo"), &d); | |
647 r.EnableChunkedUpload(); | |
648 r.set_method("POST"); | |
649 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.
| |
650 r.AppendChunkToUpload("bcd", 3); | |
651 | |
652 r.Start(); | |
653 EXPECT_TRUE(r.is_pending()); | |
654 | |
655 r.AppendChunkToUpload("this is a longer chunk than before.", 35); | |
656 r.AppendChunkToUpload("\r\n\r\n", 4); | |
657 r.AppendChunkToUpload("0", 1); | |
658 r.AppendChunkToUpload("2323", 4); | |
659 r.MarkEndOfChunks(); | |
660 | |
661 MessageLoop::current()->Run(); | |
662 | |
663 const char* encoded_data = | |
664 "abcdthis is a longer chunk than before.\r\n\r\n02323"; | |
665 | |
666 ASSERT_EQ(1, d.response_started_count()) << "request failed: " << | |
667 (int) r.status().status() << ", os error: " << r.status().os_error(); | |
668 | |
669 EXPECT_FALSE(d.received_data_before_response()); | |
670 | |
671 ASSERT_EQ(strlen(encoded_data), static_cast<size_t>(d.bytes_received())); | |
672 EXPECT_EQ(0, memcmp(d.data_received().c_str(), encoded_data, | |
673 strlen(encoded_data))); | |
674 } | |
675 } | |
676 | |
641 TEST_F(URLRequestTest, AboutBlankTest) { | 677 TEST_F(URLRequestTest, AboutBlankTest) { |
642 TestDelegate d; | 678 TestDelegate d; |
643 { | 679 { |
644 TestURLRequest r(GURL("about:blank"), &d); | 680 TestURLRequest r(GURL("about:blank"), &d); |
645 | 681 |
646 r.Start(); | 682 r.Start(); |
647 EXPECT_TRUE(r.is_pending()); | 683 EXPECT_TRUE(r.is_pending()); |
648 | 684 |
649 MessageLoop::current()->Run(); | 685 MessageLoop::current()->Run(); |
650 | 686 |
(...skipping 2013 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2664 TestURLRequest | 2700 TestURLRequest |
2665 req(test_server_.GetURL("echoheaderoverride?User-Agent"), &d); | 2701 req(test_server_.GetURL("echoheaderoverride?User-Agent"), &d); |
2666 req.set_context(new TestURLRequestContext()); | 2702 req.set_context(new TestURLRequestContext()); |
2667 net::HttpRequestHeaders headers; | 2703 net::HttpRequestHeaders headers; |
2668 headers.SetHeader(net::HttpRequestHeaders::kUserAgent, "Lynx (textmode)"); | 2704 headers.SetHeader(net::HttpRequestHeaders::kUserAgent, "Lynx (textmode)"); |
2669 req.SetExtraRequestHeaders(headers); | 2705 req.SetExtraRequestHeaders(headers); |
2670 req.Start(); | 2706 req.Start(); |
2671 MessageLoop::current()->Run(); | 2707 MessageLoop::current()->Run(); |
2672 EXPECT_EQ(std::string("Lynx (textmode)"), d.data_received()); | 2708 EXPECT_EQ(std::string("Lynx (textmode)"), d.data_received()); |
2673 } | 2709 } |
OLD | NEW |