Misc minor changes in WebSockets tests.
This CL partially re-lands https://crrev.com/c/927491 among other
things. This CL is mostly to prepare for adding tests for WebSockets
over HTTP/2.
Add missing include to spdy_network_transaction_unittest.cc for
HttpResponseInfo.
Change two WebSockets test file to use wildcard.pem instead of
spdy_pooling.pem.
Move WebSocketExtraHeadersToString from a test file anonymous namespace
to websocket_test_utils.h. Also change argument type for extra headers
in websocket_stream_test.cc to WebSocketExtraHeaders and use this helper
function to convert them to a string.
In websocket_stream_test.cc:
* Change all tests to use www.example.org instead of localhost so that
it is compatible with the test certificate wildcard.pem. (This is
only a requirement for wss, but it is cleaner if all tests use the
same hostname.)
* Change tests that will be parametrized to test WebSockets over HTTP/2
as well to use wss scheme.
* Change WebSocketStreamCreateUMATest to be a derived class of
WebSocketStreamCreateTest instead of creating an instance of it, and
use HistogramTester for simplicity.
* Change test base class methods and members from public to protected.
* Inline trivial AddRawExpectations() method.
Bug: 801564
Change-Id: I76a3ed145baa0f9171089765852e3165d43c9710
Reviewed-on: https://chromium-review.googlesource.com/942522
Commit-Queue: Bence Béky <[email protected]>
Reviewed-by: Adam Rice <[email protected]>
Cr-Commit-Position: refs/heads/master@{#540509}
diff --git a/net/websockets/websocket_test_util.cc b/net/websockets/websocket_test_util.cc
index 38499ed..77072e6 100644
--- a/net/websockets/websocket_test_util.cc
+++ b/net/websockets/websocket_test_util.cc
@@ -8,6 +8,7 @@
#include <algorithm>
#include <utility>
+#include "base/strings/strcat.h"
#include "base/strings/string_util.h"
#include "base/strings/stringprintf.h"
#include "net/proxy_resolution/proxy_service.h"
@@ -36,6 +37,15 @@
return static_cast<uint32_t>(result >> 16);
}
+std::string WebSocketExtraHeadersToString(
+ const WebSocketExtraHeaders& headers) {
+ std::string answer;
+ for (const auto& header : headers) {
+ base::StrAppend(&answer, {header.first, ": ", header.second, "\r\n"});
+ }
+ return answer;
+}
+
std::string WebSocketStandardRequest(
const std::string& path,
const std::string& host,