Commit 033fb2d0 authored by toyoshim@chromium.org's avatar toyoshim@chromium.org

WebSocket test server migration on PPAPI tests

WebSocket test server migration from content::TestWebSocketServer to 
net::TestServer. 
This is a part of migration change for PPAPI tests.

BUG=137639
TEST=browser_tests --gtest_filter='*.WebSocket_*'

Review URL: https://chromiumcodereview.appspot.com/11048050

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@162330 0039d316-1c4b-4281-b951-d872f2087c98
parent 1339a2a2
......@@ -194,12 +194,11 @@ void PPAPITestBase::RunTestWithSSLServer(const std::string& test_case) {
}
void PPAPITestBase::RunTestWithWebSocketServer(const std::string& test_case) {
FilePath websocket_root_dir;
ASSERT_TRUE(
PathService::Get(content::DIR_LAYOUT_TESTS, &websocket_root_dir));
content::TestWebSocketServer server;
int port = server.UseRandomPort();
ASSERT_TRUE(server.Start(websocket_root_dir));
net::TestServer server(net::TestServer::TYPE_WS,
net::TestServer::kLocalhost,
FilePath(FILE_PATH_LITERAL("net/data/websocket")));
ASSERT_TRUE(server.Start());
uint16_t port = server.host_port_pair().port();
FilePath http_document_root;
ASSERT_TRUE(ui_test_utils::GetRelativeBuildDirectory(&http_document_root));
RunHTTPTestServer(http_document_root, test_case,
......
# Copyright (c) 2012 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
import struct
from mod_pywebsocket import stream
def web_socket_do_extra_handshake(_request):
pass
def web_socket_transfer_data(request):
line = request.ws_stream.receive_message()
if line is None:
return
if line == '-':
data = ''
elif line == '--':
data = 'X'
else:
code, reason = line.split(' ', 1)
data = struct.pack('!H', int(code)) + reason.encode('utf-8')
request.connection.write(stream.create_close_frame(data))
# Copyright (c) 2012 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
_GOODBYE_MESSAGE = u'Goodbye'
def web_socket_do_extra_handshake(_request):
pass # Always accept.
def web_socket_transfer_data(request):
while True:
line = request.ws_stream.receive_message()
if line is None:
return
if isinstance(line, unicode):
request.ws_stream.send_message(line, binary=False)
if line == _GOODBYE_MESSAGE:
return
else:
request.ws_stream.send_message(line, binary=True)
def web_socket_passive_closing_handshake(request):
return request.ws_close_code, request.ws_close_reason
# Copyright (c) 2012 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
_GOODBYE_MESSAGE = u'Goodbye'
def web_socket_do_extra_handshake(request):
request.ws_extension_processors = []
def web_socket_transfer_data(request):
while True:
line = request.ws_stream.receive_message()
if line is None:
return
if isinstance(line, unicode):
request.ws_stream.send_message(line, binary=False)
if line == _GOODBYE_MESSAGE:
return
else:
request.ws_stream.send_message(line, binary=True)
......@@ -2,7 +2,7 @@
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
def web_socket_do_extra_handshake(request):
def web_socket_do_extra_handshake(_request):
pass # Always accept.
......
# Copyright (c) 2012 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
import cgi
from mod_pywebsocket import msgutil
def web_socket_do_extra_handshake(request):
r = request.ws_resource.split('?', 1)
if len(r) == 1:
return
param = cgi.parse_qs(r[1])
if 'protocol' in param:
request.ws_protocol = param['protocol'][0]
def web_socket_transfer_data(request):
msgutil.send_message(request, request.ws_protocol)
......@@ -34,15 +34,13 @@
// These servers are provided by pywebsocket server side handlers in
// LayoutTests/http/tests/websocket/tests/hybi/*_wsh.
// pywebsocket server itself is launched in ppapi_ui_test.cc.
const char kEchoServerURL[] = "websocket/tests/hybi/echo-with-no-extension";
const char kEchoServerURL[] = "echo-with-no-extension";
const char kCloseServerURL[] = "websocket/tests/hybi/close";
const char kCloseServerURL[] = "close";
const char kCloseWithCodeAndReasonServerURL[] =
"websocket/tests/hybi/close-code-and-reason";
const char kCloseWithCodeAndReasonServerURL[] = "close-code-and-reason";
const char kProtocolTestServerURL[] =
"websocket/tests/hybi/protocol-test?protocol=";
const char kProtocolTestServerURL[] = "protocol-test?protocol=";
const char* const kInvalidURLs[] = {
"http://www.google.com/invalid_scheme",
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment