wsd: test: use LOG_TST in new-style tests

Change-Id: I0d4558d44bc6cb92ba820ae8471d7ed2528277fc
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
This commit is contained in:
Ashod Nakashian 2020-12-21 19:07:26 -05:00 committed by Henry Castro
parent 3b4add03ef
commit 64251966d5
2 changed files with 14 additions and 10 deletions

View file

@ -19,6 +19,7 @@
#include <Poco/URI.h>
#include <Poco/Timestamp.h>
#include <Poco/Util/LayeredConfiguration.h>
#include <sstream>
class WopiTestServer : public UnitWSD
{
@ -70,7 +71,7 @@ public:
_wopiSrc.clear();
Poco::URI::encode(wopiURL.toString(), ":/?", _wopiSrc);
LOG_INF("Connecting to the fake WOPI server: /lool/" << _wopiSrc << "/ws");
LOG_TST("Connecting to the fake WOPI server: /lool/" << _wopiSrc << "/ws");
_ws.reset(new UnitWebSocket("/lool/" + _wopiSrc + "/ws"));
assert(_ws.get());
@ -112,22 +113,21 @@ protected:
Poco::RegularExpression regInfo("/wopi/files/[0-9]");
Poco::RegularExpression regContent("/wopi/files/[0-9]/contents");
Log::StreamLogger logger = Log::info();
if (logger.enabled())
{
logger << "Fake wopi host request URI [" << uriReq.toString() << "]:\n";
std::ostringstream oss;
oss << "Fake wopi host request URI [" << uriReq.toString() << "]:\n";
for (const auto& pair : request)
{
logger << '\t' << pair.first << ": " << pair.second << " / ";
oss << '\t' << pair.first << ": " << pair.second << " / ";
}
LOG_END(logger, true);
LOG_TST(oss.str());
}
// CheckFileInfo
if (request.getMethod() == "GET" && regInfo.match(uriReq.getPath()))
{
LOG_INF("Fake wopi host request, handling CheckFileInfo: " << uriReq.getPath());
LOG_TST("Fake wopi host request, handling CheckFileInfo: " << uriReq.getPath());
assertCheckFileInfoRequest(request);
@ -167,7 +167,7 @@ protected:
// GetFile
else if (request.getMethod() == "GET" && regContent.match(uriReq.getPath()))
{
LOG_INF("Fake wopi host request, handling GetFile: " << uriReq.getPath());
LOG_TST("Fake wopi host request, handling GetFile: " << uriReq.getPath());
assertGetFileRequest(request);
@ -189,7 +189,7 @@ protected:
}
else if (request.getMethod() == "POST" && regInfo.match(uriReq.getPath()))
{
LOG_INF("Fake wopi host request, handling PutRelativeFile: " << uriReq.getPath());
LOG_TST("Fake wopi host request, handling PutRelativeFile: " << uriReq.getPath());
std::string wopiURL = helpers::getTestServerURI() + "/something wopi/files/1?access_token=anything&reuse_cookies=cook=well";
std::string content;
@ -223,7 +223,7 @@ protected:
}
else if (request.getMethod() == "POST" && regContent.match(uriReq.getPath()))
{
LOG_INF("Fake wopi host request, handling PutFile: " << uriReq.getPath());
LOG_TST("Fake wopi host request, handling PutFile: " << uriReq.getPath());
std::string wopiTimestamp = request.get("X-LOOL-WOPI-Timestamp");
if (!wopiTimestamp.empty())

View file

@ -74,6 +74,10 @@ inline void tstLog(const std::ostringstream& stream) { writeTestLog(stream.str()
TST_LOG_END_X(oss_log_name); \
} while (false)
/// Used by the "old-style" tests. FIXME: Unify.
#define TST_LOG(X) TST_LOG_NAME(testname, X)
/// Used by the "new-style" tests. FIXME: Unify.
#define LOG_TST(X) TST_LOG_NAME(getTestname(), X)
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */