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

Unified Diff: net/url_request/url_request_unittest.cc

Issue 538012: Support the PUT HTTP verb in ChromeFrame in the IE host network stack impleme... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 10 years, 11 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/tools/testserver/testserver.py ('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
===================================================================
--- net/url_request/url_request_unittest.cc (revision 35831)
+++ net/url_request/url_request_unittest.cc (working copy)
@@ -102,6 +102,51 @@
server_ = NULL;
}
+ void HTTPUploadDataOperationTest(const std::string& method) {
+ ASSERT_TRUE(NULL != server_.get());
+ const int kMsgSize = 20000; // multiple of 10
+ const int kIterations = 50;
+ char *uploadBytes = new char[kMsgSize+1];
+ char *ptr = uploadBytes;
+ char marker = 'a';
+ for (int idx = 0; idx < kMsgSize/10; idx++) {
+ memcpy(ptr, "----------", 10);
+ ptr += 10;
+ if (idx % 100 == 0) {
+ ptr--;
+ *ptr++ = marker;
+ if (++marker > 'z')
+ marker = 'a';
+ }
+ }
+ uploadBytes[kMsgSize] = '\0';
+
+ scoped_refptr<URLRequestContext> context = new URLRequestTestContext();
+
+ for (int i = 0; i < kIterations; ++i) {
+ TestDelegate d;
+ URLRequest r(server_->TestServerPage("echo"), &d);
+ r.set_context(context);
+ r.set_method(method.c_str());
+
+ r.AppendBytesToUpload(uploadBytes, kMsgSize);
+
+ r.Start();
+ EXPECT_TRUE(r.is_pending());
+
+ MessageLoop::current()->Run();
+
+ 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());
+ EXPECT_EQ(uploadBytes, d.data_received());
+ EXPECT_EQ(memcmp(uploadBytes, d.data_received().c_str(), kMsgSize), 0);
+ EXPECT_EQ(d.data_received().compare(uploadBytes), 0);
+ }
+ delete[] uploadBytes;
+ }
+
static scoped_refptr<HTTPTestServer> server_;
};
@@ -484,48 +529,11 @@
}
TEST_F(URLRequestTestHTTP, PostTest) {
- ASSERT_TRUE(NULL != server_.get());
- const int kMsgSize = 20000; // multiple of 10
- const int kIterations = 50;
- char *uploadBytes = new char[kMsgSize+1];
- char *ptr = uploadBytes;
- char marker = 'a';
- for (int idx = 0; idx < kMsgSize/10; idx++) {
- memcpy(ptr, "----------", 10);
- ptr += 10;
- if (idx % 100 == 0) {
- ptr--;
- *ptr++ = marker;
- if (++marker > 'z')
- marker = 'a';
- }
- }
- uploadBytes[kMsgSize] = '\0';
+ HTTPUploadDataOperationTest("POST");
+}
- scoped_refptr<URLRequestContext> context = new URLRequestTestContext();
-
- for (int i = 0; i < kIterations; ++i) {
- TestDelegate d;
- URLRequest r(server_->TestServerPage("echo"), &d);
- r.set_context(context);
- r.set_method("POST");
-
- r.AppendBytesToUpload(uploadBytes, kMsgSize);
-
- r.Start();
- EXPECT_TRUE(r.is_pending());
-
- MessageLoop::current()->Run();
-
- 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());
- EXPECT_EQ(uploadBytes, d.data_received());
- EXPECT_EQ(memcmp(uploadBytes, d.data_received().c_str(), kMsgSize), 0);
- EXPECT_EQ(d.data_received().compare(uploadBytes), 0);
- }
- delete[] uploadBytes;
+TEST_F(URLRequestTestHTTP, PutTest) {
+ HTTPUploadDataOperationTest("PUT");
}
TEST_F(URLRequestTestHTTP, PostEmptyTest) {
« no previous file with comments | « net/tools/testserver/testserver.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698