Skip to content

Commit

Permalink
Misc minor changes in WebSockets tests.
Browse files Browse the repository at this point in the history
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 <bnc@chromium.org>
Reviewed-by: Adam Rice <ricea@chromium.org>
Cr-Commit-Position: refs/heads/master@{#540509}
  • Loading branch information
Bence Béky authored and Commit Bot committed Mar 2, 2018
1 parent 8d95669 commit 3a0c485
Show file tree
Hide file tree
Showing 6 changed files with 290 additions and 303 deletions.
1 change: 1 addition & 0 deletions net/spdy/chromium/spdy_network_transaction_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
#include "net/http/http_network_session.h"
#include "net/http/http_network_session_peer.h"
#include "net/http/http_network_transaction.h"
#include "net/http/http_response_info.h"
#include "net/http/http_server_properties.h"
#include "net/http/http_transaction_test_util.h"
#include "net/log/net_log_event_type.h"
Expand Down
2 changes: 1 addition & 1 deletion net/websockets/websocket_basic_stream_adapters_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,7 @@ class WebSocketSpdyStreamAdapterTest : public Test {

void AddSSLSocketData() {
ssl_.ssl_info.cert =
ImportCertFromFile(GetTestCertsDirectory(), "spdy_pooling.pem");
ImportCertFromFile(GetTestCertsDirectory(), "wildcard.pem");
ASSERT_TRUE(ssl_.ssl_info.cert);
session_deps_.socket_factory->AddSSLSocketDataProvider(&ssl_);
}
Expand Down
13 changes: 1 addition & 12 deletions net/websockets/websocket_handshake_stream_create_helper_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -51,17 +51,6 @@ namespace {

enum HandshakeStreamType { BASIC_HANDSHAKE_STREAM, HTTP2_HANDSHAKE_STREAM };

std::string WebSocketExtraHeadersToString(WebSocketExtraHeaders headers) {
std::string answer;
for (const auto& header : headers) {
answer.append(header.first);
answer.append(": ");
answer.append(header.second);
answer.append("\r\n");
}
return answer;
}

// This class encapsulates the details of creating a mock ClientSocketHandle.
class MockClientSocketHandleFactory {
public:
Expand Down Expand Up @@ -214,7 +203,7 @@ class WebSocketHandshakeStreamCreateHelperTest

SSLSocketDataProvider ssl(ASYNC, OK);
ssl.ssl_info.cert =
ImportCertFromFile(GetTestCertsDirectory(), "spdy_pooling.pem");
ImportCertFromFile(GetTestCertsDirectory(), "wildcard.pem");

SpdySessionDependencies session_deps;
session_deps.socket_factory->AddSocketDataProvider(&data);
Expand Down
Loading

0 comments on commit 3a0c485

Please sign in to comment.