wsd: improved getErrorCode

Change-Id: I89b36b5e69cbbe05ac7b1730633d695bc5185823
Reviewed-on: https://gerrit.libreoffice.org/33117
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
This commit is contained in:
Ashod Nakashian 2017-01-15 12:15:11 -05:00 committed by Ashod Nakashian
parent e0dcc7a972
commit 8cbf478bfe
2 changed files with 8 additions and 8 deletions

View file

@ -162,7 +162,7 @@ std::string const & getTestServerURI()
}
inline
int getErrorCode(LOOLWebSocket& ws, std::string& message)
int getErrorCode(LOOLWebSocket& ws, std::string& message, const std::string& testname = "")
{
int flags = 0;
int bytes = 0;
@ -170,13 +170,13 @@ int getErrorCode(LOOLWebSocket& ws, std::string& message)
Poco::Buffer<char> buffer(READ_BUFFER_SIZE);
message.clear();
Poco::Timespan timeout(5000000);
ws.setReceiveTimeout(timeout);
ws.setReceiveTimeout(Poco::Timespan(5000000));
do
{
bytes = ws.receiveFrame(buffer.begin(), READ_BUFFER_SIZE, flags);
std::cerr << testname << "Got " << LOOLProtocol::getAbbreviatedFrameDump(buffer.begin(), bytes, flags) << std::endl;
}
while ((flags & Poco::Net::WebSocket::FRAME_OP_BITMASK) != Poco::Net::WebSocket::FRAME_OP_CLOSE);
while (bytes > 0 && (flags & Poco::Net::WebSocket::FRAME_OP_BITMASK) != Poco::Net::WebSocket::FRAME_OP_CLOSE);
if (bytes > 0)
{
@ -189,9 +189,9 @@ int getErrorCode(LOOLWebSocket& ws, std::string& message)
}
inline
int getErrorCode(const std::shared_ptr<LOOLWebSocket>& ws, std::string& message)
int getErrorCode(const std::shared_ptr<LOOLWebSocket>& ws, std::string& message, const std::string& testname = "")
{
return getErrorCode(*ws, message);
return getErrorCode(*ws, message, testname);
}
inline

View file

@ -116,7 +116,7 @@ void HTTPWSError::testMaxDocuments()
assertResponseString(socket, "error:", testname);
std::string message;
const auto statusCode = getErrorCode(socket, message);
const auto statusCode = getErrorCode(socket, message, testname);
CPPUNIT_ASSERT_EQUAL(static_cast<int>(Poco::Net::WebSocket::WS_POLICY_VIOLATION), statusCode);
socket->shutdown();
@ -171,7 +171,7 @@ void HTTPWSError::testMaxConnections()
sendTextFrame(socketN, "load url=" + docURL, testname);
std::string message;
const auto statusCode = getErrorCode(socketN, message);
const auto statusCode = getErrorCode(socketN, message, testname);
CPPUNIT_ASSERT_EQUAL(static_cast<int>(Poco::Net::WebSocket::WS_POLICY_VIOLATION), statusCode);
socketN->shutdown();