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

Side by Side Diff: util/net/http_transport_test.cc

Issue 853853002: win: Stub reorganization of MultiprocessExec (Closed) Base URL: https://chromium.googlesource.com/crashpad/crashpad@master
Patch Set: . Created 5 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 unified diff | Download patch
« no previous file with comments | « util/mach/mach_message_server_test.cc ('k') | util/test/mac/mach_multiprocess.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Crashpad Authors. All rights reserved. 1 // Copyright 2014 The Crashpad Authors. All rights reserved.
2 // 2 //
3 // Licensed under the Apache License, Version 2.0 (the "License"); 3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License. 4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at 5 // You may obtain a copy of the License at
6 // 6 //
7 // http://www.apache.org/licenses/LICENSE-2.0 7 // http://www.apache.org/licenses/LICENSE-2.0
8 // 8 //
9 // Unless required by applicable law or agreed to in writing, software 9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS, 10 // distributed under the License is distributed on an "AS IS" BASIS,
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
50 request_validator_(request_validator) { 50 request_validator_(request_validator) {
51 // TODO(rsesek): Use a more robust mechanism to locate testdata 51 // TODO(rsesek): Use a more robust mechanism to locate testdata
52 // <https://code.google.com/p/crashpad/issues/detail?id=4>. 52 // <https://code.google.com/p/crashpad/issues/detail?id=4>.
53 SetChildCommand("util/net/http_transport_test_server.py", nullptr); 53 SetChildCommand("util/net/http_transport_test_server.py", nullptr);
54 } 54 }
55 55
56 const HTTPHeaders& headers() { return headers_; } 56 const HTTPHeaders& headers() { return headers_; }
57 57
58 private: 58 private:
59 void MultiprocessParent() override { 59 void MultiprocessParent() override {
60 // Use Logging*FD() instead of Checked*FD() so that the test can fail 60 // Use Logging*File() instead of Checked*File() so that the test can fail
61 // gracefully with a gtest assertion if the child does not execute properly. 61 // gracefully with a gtest assertion if the child does not execute properly.
62 62
63 // The child will write the HTTP server port number as a packed unsigned 63 // The child will write the HTTP server port number as a packed unsigned
64 // short to stdout. 64 // short to stdout.
65 uint16_t port; 65 uint16_t port;
66 ASSERT_TRUE(LoggingReadFile(ReadPipeFD(), &port, sizeof(port))); 66 ASSERT_TRUE(LoggingReadFile(ReadPipeHandle(), &port, sizeof(port)));
67 67
68 // Then the parent will tell the web server what response code to send 68 // Then the parent will tell the web server what response code to send
69 // for the HTTP request. 69 // for the HTTP request.
70 ASSERT_TRUE(LoggingWriteFile( 70 ASSERT_TRUE(LoggingWriteFile(
71 WritePipeFD(), &response_code_, sizeof(response_code_))); 71 WritePipeHandle(), &response_code_, sizeof(response_code_)));
72 72
73 // Now execute the HTTP request. 73 // Now execute the HTTP request.
74 scoped_ptr<HTTPTransport> transport(HTTPTransport::Create()); 74 scoped_ptr<HTTPTransport> transport(HTTPTransport::Create());
75 transport->SetMethod("POST"); 75 transport->SetMethod("POST");
76 transport->SetURL(base::StringPrintf("http://127.0.0.1:%d/upload", port)); 76 transport->SetURL(base::StringPrintf("http://127.0.0.1:%d/upload", port));
77 for (const auto& pair : headers_) { 77 for (const auto& pair : headers_) {
78 transport->SetHeader(pair.first, pair.second); 78 transport->SetHeader(pair.first, pair.second);
79 } 79 }
80 transport->SetBodyStream(body_stream_.Pass()); 80 transport->SetBodyStream(body_stream_.Pass());
81 81
82 EXPECT_EQ(transport->ExecuteSynchronously(), (response_code_ == 200)); 82 EXPECT_EQ(transport->ExecuteSynchronously(), (response_code_ == 200));
83 83
84 // Read until the child's stdout closes. 84 // Read until the child's stdout closes.
85 std::string request; 85 std::string request;
86 char buf[32]; 86 char buf[32];
87 ssize_t bytes_read; 87 ssize_t bytes_read;
88 while ((bytes_read = ReadFile(ReadPipeFD(), buf, sizeof(buf))) != 0) { 88 while ((bytes_read = ReadFile(ReadPipeHandle(), buf, sizeof(buf))) != 0) {
89 ASSERT_GE(bytes_read, 0); 89 ASSERT_GE(bytes_read, 0);
90 request.append(buf, bytes_read); 90 request.append(buf, bytes_read);
91 } 91 }
92 92
93 if (request_validator_) 93 if (request_validator_)
94 request_validator_(this, request); 94 request_validator_(this, request);
95 } 95 }
96 96
97 HTTPHeaders headers_; 97 HTTPHeaders headers_;
98 scoped_ptr<HTTPBodyStream> body_stream_; 98 scoped_ptr<HTTPBodyStream> body_stream_;
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
237 headers[kContentLength] = base::StringPrintf("%zu", strlen(kTextBody)); 237 headers[kContentLength] = base::StringPrintf("%zu", strlen(kTextBody));
238 238
239 HTTPTransportTestFixture test(headers, body_stream.Pass(), 200, 239 HTTPTransportTestFixture test(headers, body_stream.Pass(), 200,
240 &UnchunkedPlainText); 240 &UnchunkedPlainText);
241 test.Run(); 241 test.Run();
242 } 242 }
243 243
244 } // namespace 244 } // namespace
245 } // namespace test 245 } // namespace test
246 } // namespace crashpad 246 } // namespace crashpad
OLDNEW
« no previous file with comments | « util/mach/mach_message_server_test.cc ('k') | util/test/mac/mach_multiprocess.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698