[Libreoffice-commits] online.git: test/helpers.hpp test/httpwserror.cpp
Ashod Nakashian
ashod.nakashian at collabora.co.uk
Mon Jan 16 01:45:21 UTC 2017
test/helpers.hpp | 12 ++++++------
test/httpwserror.cpp | 4 ++--
2 files changed, 8 insertions(+), 8 deletions(-)
New commits:
commit 8cbf478bfe2e8b947f42f02b8224d71cd9ef1f6b
Author: Ashod Nakashian <ashod.nakashian at collabora.co.uk>
Date: Sun Jan 15 12:15:11 2017 -0500
wsd: improved getErrorCode
Change-Id: I89b36b5e69cbbe05ac7b1730633d695bc5185823
Reviewed-on: https://gerrit.libreoffice.org/33117
Reviewed-by: Ashod Nakashian <ashnakash at gmail.com>
Tested-by: Ashod Nakashian <ashnakash at gmail.com>
diff --git a/test/helpers.hpp b/test/helpers.hpp
index fce1cfd..4dd8f86 100644
--- a/test/helpers.hpp
+++ b/test/helpers.hpp
@@ -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
diff --git a/test/httpwserror.cpp b/test/httpwserror.cpp
index e624e46..3ed8421 100644
--- a/test/httpwserror.cpp
+++ b/test/httpwserror.cpp
@@ -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();
More information about the Libreoffice-commits
mailing list