mirror of
https://github.com/chromium/crashpad.git
synced 2025-03-09 14:06:33 +00:00
[net] specify parameter name in parameterized test suite
* this renders as "HTTPTransport/HTTPTransport.ValidFormData_Gzip/http" instead of the default "HTTPTransport/HTTPTransport.ValidFormData_Gzip/0" * switch the parameter type from a base::FilePath::StringType to a string Change-Id: I19743966406f92176c566827d74a79aef5a87bb5 Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/1900324 Reviewed-by: Scott Graham <scottmg@chromium.org> Commit-Queue: Francois Rousseau <frousseau@google.com>
This commit is contained in:
parent
272c4bb64e
commit
27322abb7e
@ -54,10 +54,10 @@ std::string ToUTF8IfWin(const std::string& x) {
|
||||
|
||||
class HTTPTransportTestFixture : public MultiprocessExec {
|
||||
public:
|
||||
using RequestValidator =
|
||||
void(*)(HTTPTransportTestFixture*, const std::string&);
|
||||
using RequestValidator = void (*)(HTTPTransportTestFixture*,
|
||||
const std::string&);
|
||||
|
||||
HTTPTransportTestFixture(const base::FilePath::StringType& scheme,
|
||||
HTTPTransportTestFixture(const std::string& scheme,
|
||||
const HTTPHeaders& headers,
|
||||
std::unique_ptr<HTTPBodyStream> body_stream,
|
||||
uint16_t http_response_code,
|
||||
@ -76,7 +76,7 @@ class HTTPTransportTestFixture : public MultiprocessExec {
|
||||
#endif
|
||||
);
|
||||
|
||||
if (ToUTF8IfWin(scheme) == "http") {
|
||||
if (scheme == "http") {
|
||||
scheme_and_host_ = "http://localhost";
|
||||
SetChildCommand(server_path, nullptr);
|
||||
} else {
|
||||
@ -116,9 +116,8 @@ class HTTPTransportTestFixture : public MultiprocessExec {
|
||||
// 200.
|
||||
const std::string random_string = RandomString();
|
||||
|
||||
ASSERT_TRUE(LoggingWriteFile(WritePipeHandle(),
|
||||
random_string.c_str(),
|
||||
random_string.size()));
|
||||
ASSERT_TRUE(LoggingWriteFile(
|
||||
WritePipeHandle(), random_string.c_str(), random_string.size()));
|
||||
|
||||
// Now execute the HTTP request.
|
||||
std::unique_ptr<HTTPTransport> transport(HTTPTransport::Create());
|
||||
@ -245,8 +244,7 @@ void ValidFormData(HTTPTransportTestFixture* fixture,
|
||||
EXPECT_EQ(request.substr(body_start), expected);
|
||||
}
|
||||
|
||||
class HTTPTransport
|
||||
: public testing::TestWithParam<base::FilePath::StringType> {};
|
||||
class HTTPTransport : public testing::TestWithParam<std::string> {};
|
||||
|
||||
TEST_P(HTTPTransport, ValidFormData) {
|
||||
HTTPMultipartBuilder builder;
|
||||
@ -256,8 +254,8 @@ TEST_P(HTTPTransport, ValidFormData) {
|
||||
HTTPHeaders headers;
|
||||
builder.PopulateContentHeaders(&headers);
|
||||
|
||||
HTTPTransportTestFixture test(GetParam(),
|
||||
headers, builder.GetBodyStream(), 200, &ValidFormData);
|
||||
HTTPTransportTestFixture test(
|
||||
GetParam(), headers, builder.GetBodyStream(), 200, &ValidFormData);
|
||||
test.Run();
|
||||
}
|
||||
|
||||
@ -288,8 +286,8 @@ TEST_P(HTTPTransport, ErrorResponse) {
|
||||
HTTPMultipartBuilder builder;
|
||||
HTTPHeaders headers;
|
||||
headers[kContentType] = kTextPlain;
|
||||
HTTPTransportTestFixture test(GetParam(), headers, builder.GetBodyStream(),
|
||||
404, &ErrorResponse);
|
||||
HTTPTransportTestFixture test(
|
||||
GetParam(), headers, builder.GetBodyStream(), 404, &ErrorResponse);
|
||||
test.Run();
|
||||
}
|
||||
|
||||
@ -320,13 +318,12 @@ TEST_P(HTTPTransport, UnchunkedPlainText) {
|
||||
headers[kContentType] = kTextPlain;
|
||||
headers[kContentLength] = base::StringPrintf("%" PRIuS, strlen(kTextBody));
|
||||
|
||||
HTTPTransportTestFixture test(GetParam(),
|
||||
headers, std::move(body_stream), 200, &UnchunkedPlainText);
|
||||
HTTPTransportTestFixture test(
|
||||
GetParam(), headers, std::move(body_stream), 200, &UnchunkedPlainText);
|
||||
test.Run();
|
||||
}
|
||||
|
||||
void RunUpload33k(const base::FilePath::StringType& scheme,
|
||||
bool has_content_length) {
|
||||
void RunUpload33k(const std::string& scheme, bool has_content_length) {
|
||||
// On macOS, NSMutableURLRequest winds up calling into a CFReadStream’s Read()
|
||||
// callback with a 32kB buffer. Make sure that it’s able to get everything
|
||||
// when enough is available to fill this buffer, requiring more than one
|
||||
@ -375,12 +372,17 @@ TEST_P(HTTPTransport, Upload33k_LengthUnknown) {
|
||||
// re-running generate_test_server_key.py.
|
||||
INSTANTIATE_TEST_SUITE_P(HTTPTransport,
|
||||
HTTPTransport,
|
||||
testing::Values(FILE_PATH_LITERAL("http"),
|
||||
FILE_PATH_LITERAL("https")));
|
||||
testing::Values("http", "https"),
|
||||
[](const testing::TestParamInfo<std::string>& info) {
|
||||
return info.param;
|
||||
});
|
||||
#else
|
||||
INSTANTIATE_TEST_SUITE_P(HTTPTransport,
|
||||
HTTPTransport,
|
||||
testing::Values(FILE_PATH_LITERAL("http")));
|
||||
testing::Values("http"),
|
||||
[](const testing::TestParamInfo<std::string>& info) {
|
||||
return info.param;
|
||||
});
|
||||
#endif
|
||||
|
||||
} // namespace
|
||||
|
Loading…
x
Reference in New Issue
Block a user