[Libreoffice-commits] online.git: 2 commits - loolwsd/ChildSession.cpp loolwsd/test
Ashod Nakashian
ashod.nakashian at collabora.co.uk
Mon Nov 7 06:28:52 UTC 2016
loolwsd/ChildSession.cpp | 40 ++++++++++++++++++++--------------------
loolwsd/test/helpers.hpp | 13 +++++++++++++
loolwsd/test/httpwstest.cpp | 9 ++++++---
3 files changed, 39 insertions(+), 23 deletions(-)
New commits:
commit f63fbef5604f18f536c4d045bebbf281bda1aaa0
Author: Ashod Nakashian <ashod.nakashian at collabora.co.uk>
Date: Sat Nov 5 17:29:38 2016 -0400
loolwsd: ChildSession logs updated
Change-Id: I5675c5b79fc96ab34605b68b0fe05c5fe90e92db
Reviewed-on: https://gerrit.libreoffice.org/30624
Reviewed-by: Ashod Nakashian <ashnakash at gmail.com>
Tested-by: Ashod Nakashian <ashnakash at gmail.com>
diff --git a/loolwsd/ChildSession.cpp b/loolwsd/ChildSession.cpp
index 7cfb7ee..d27c91e 100644
--- a/loolwsd/ChildSession.cpp
+++ b/loolwsd/ChildSession.cpp
@@ -42,12 +42,12 @@ ChildSession::ChildSession(const std::string& id,
_viewId(-1),
_isDocLoaded(false)
{
- Log::info("ChildSession ctor [" + getName() + "].");
+ LOG_INF("ChildSession ctor [" << getName() << "].");
}
ChildSession::~ChildSession()
{
- Log::info("~ChildSession dtor [" + getName() + "].");
+ LOG_INF("~ChildSession dtor [" << getName() << "].");
disconnect();
}
@@ -64,7 +64,7 @@ void ChildSession::disconnect()
}
else
{
- Log::warn("Skipping unload on incomplete view.");
+ LOG_WRN("Skipping unload on incomplete view.");
}
LOOLSession::disconnect();
@@ -84,7 +84,7 @@ bool ChildSession::_handleInput(const char *buffer, int length)
if (tokens.count() > 0 && tokens[0] == "useractive" && _loKitDocument != nullptr)
{
- Log::debug("Handling message after inactivity of " + std::to_string(getInactivityMS()) + "ms.");
+ LOG_DBG("Handling message after inactivity of " << getInactivityMS() << "ms.");
setIsActive(true);
// Client is getting active again.
@@ -123,7 +123,7 @@ bool ChildSession::_handleInput(const char *buffer, int length)
loKitCallback(LOK_CALLBACK_STATE_CHANGED, pair.second);
}
- Log::debug("Finished replaying messages.");
+ LOG_TRC("Finished replaying messages.");
}
if (tokens[0] == "dummymsg")
@@ -313,12 +313,12 @@ bool ChildSession::loadDocument(const char * /*buffer*/, int /*length*/, StringT
_loKitDocument = _docManager.onLoad(getId(), _jailedFilePath, _userName, _docPassword, renderOpts, _haveDocPassword);
if (!_loKitDocument || _viewId < 0)
{
- Log::error("Failed to get LoKitDocument instance.");
+ LOG_ERR("Failed to get LoKitDocument instance.");
return false;
}
- Log::info() << "Created new view with viewid: [" << _viewId << + "] for username: [" << _userName
- << "] in session: [" << getId() << "]." << Log::end;
+ LOG_INF("Created new view with viewid: [" << _viewId << + "] for username: [" <<
+ _userName << "] in session: [" << getId() << "].");
auto lockLokDoc(_loKitDocument->getLock());
@@ -331,11 +331,11 @@ bool ChildSession::loadDocument(const char * /*buffer*/, int /*length*/, StringT
}
// Respond by the document status
- Log::debug("Sending status after loading view " + std::to_string(_viewId) + ".");
+ LOG_DBG("Sending status after loading view " << _viewId << ".");
const auto status = LOKitHelper::documentStatus(_loKitDocument->get());
if (status.empty() || !sendTextFrame("status: " + status))
{
- Log::error("Failed to get/forward document status [" + status + "].");
+ LOG_ERR("Failed to get/forward document status [" << status << "].");
return false;
}
@@ -349,7 +349,7 @@ bool ChildSession::loadDocument(const char * /*buffer*/, int /*length*/, StringT
// Inform everyone (including this one) about updated view info
_docManager.notifyViewInfo(viewIds);
- Log::info("Loaded session " + getId());
+ LOG_INF("Loaded session " << getId());
return true;
}
@@ -383,7 +383,7 @@ bool ChildSession::sendFontRendering(const char* /*buffer*/, int /*length*/, Str
ptrFont = _loKitDocument->renderFont(decodedFont.c_str(), &width, &height);
}
- Log::trace("renderFont [" + font + "] rendered in " + std::to_string(timestamp.elapsed()/1000.) + "ms");
+ LOG_TRC("renderFont [" << font << "] rendered in " << (timestamp.elapsed()/1000.) << "ms");
if (!ptrFont ||
!png::encodeBufferToPNG(ptrFont, width, height, output, LOK_TILEMODE_RGBA))
@@ -409,7 +409,7 @@ bool ChildSession::getStatus(const char* /*buffer*/, int /*length*/)
if (status.empty())
{
- Log::error("Failed to get document status.");
+ LOG_ERR("Failed to get document status.");
return false;
}
@@ -945,17 +945,17 @@ bool ChildSession::setPage(const char* /*buffer*/, int /*length*/, StringTokeniz
void ChildSession::loKitCallback(const int nType, const std::string& rPayload)
{
const auto typeName = LOKitHelper::kitCallbackTypeToString(nType);
- Log::trace() << "CallbackWorker::callback [" << getName() << "]: "
- << typeName << " [" << rPayload << "]." << Log::end;
+ LOG_TRC("CallbackWorker::callback [" << getName() << "]: " <<
+ typeName << " [" << rPayload << "].");
if (isCloseFrame())
{
- Log::trace("Skipping callback [" + typeName + "] on closing session " + getName());
+ LOG_TRC("Skipping callback [" << typeName << "] on closing session " << getName());
return;
}
else if (isDisconnected())
{
- Log::trace("Skipping callback [" + typeName + "] on disconnected session " + getName());
+ LOG_TRC("Skipping callback [" << typeName << "] on disconnected session " << getName());
return;
}
else if (!isActive())
@@ -998,7 +998,7 @@ void ChildSession::loKitCallback(const int nType, const std::string& rPayload)
// Pass save notifications through.
if (nType != LOK_CALLBACK_UNO_COMMAND_RESULT || rPayload.find(".uno:Save") == std::string::npos)
{
- Log::trace("Skipping callback [" + typeName + "] on inactive session " + getName());
+ LOG_TRC("Skipping callback [" << typeName << "] on inactive session " << getName());
return;
}
}
@@ -1094,7 +1094,7 @@ void ChildSession::loKitCallback(const int nType, const std::string& rPayload)
break;
case LOK_CALLBACK_ERROR:
{
- Log::error("CALLBACK_ERROR: " + rPayload);
+ LOG_ERR("CALLBACK_ERROR: " << rPayload);
Parser parser;
Poco::Dynamic::Var var = parser.parse(rPayload);
Object::Ptr object = var.extract<Object::Ptr>();
@@ -1140,7 +1140,7 @@ void ChildSession::loKitCallback(const int nType, const std::string& rPayload)
sendTextFrame("redlinetablemodified: " + rPayload);
break;
default:
- Log::error("Unknown callback event (" + std::to_string(nType) + "): " + rPayload);
+ LOG_ERR("Unknown callback event (" << nType << "): " << rPayload);
}
}
commit a537acf7d641d6e7817a1921d2f82e71ad996ac7
Author: Ashod Nakashian <ashod.nakashian at collabora.co.uk>
Date: Sat Nov 5 17:26:39 2016 -0400
loolwsd: add genRandomString and use it to test SaveOnDisconnect
Change-Id: I3e60579032882b921ee7c833a78e8d87e79e1360
Reviewed-on: https://gerrit.libreoffice.org/30623
Reviewed-by: Ashod Nakashian <ashnakash at gmail.com>
Tested-by: Ashod Nakashian <ashnakash at gmail.com>
diff --git a/loolwsd/test/helpers.hpp b/loolwsd/test/helpers.hpp
index ace1f32..b6d6d78 100644
--- a/loolwsd/test/helpers.hpp
+++ b/loolwsd/test/helpers.hpp
@@ -69,6 +69,19 @@ std::vector<char> genRandomData(const size_t size)
}
inline
+std::string genRandomString(const size_t size)
+{
+ std::string text;
+ text.reserve(size);
+ for (size_t i = 0; i < size; ++i)
+ {
+ text += static_cast<char>('!' + Util::rng::getNext() % 95);
+ }
+
+ return text;
+}
+
+inline
std::vector<char> readDataFromFile(const std::string& filename)
{
std::ifstream ifs(Poco::Path(TDOC, filename).toString(), std::ios::binary);
diff --git a/loolwsd/test/httpwstest.cpp b/loolwsd/test/httpwstest.cpp
index cafeabb..bbb4d61 100644
--- a/loolwsd/test/httpwstest.cpp
+++ b/loolwsd/test/httpwstest.cpp
@@ -437,6 +437,9 @@ void HTTPWSTest::testSaveOnDisconnect()
{
const auto testname = "saveOnDisconnect ";
+ const auto text = helpers::genRandomString(40);
+ std::cerr << "Test string: [" << text << "]." << std::endl;
+
std::string documentPath, documentURL;
getDocumentPathAndURL("hello.odt", documentPath, documentURL);
@@ -450,13 +453,13 @@ void HTTPWSTest::testSaveOnDisconnect()
sendTextFrame(socket, "uno .uno:SelectAll", testname);
sendTextFrame(socket, "uno .uno:Delete", testname);
- sendTextFrame(socket, "paste mimetype=text/plain;charset=utf-8\naaa bbb ccc", testname);
+ sendTextFrame(socket, "paste mimetype=text/plain;charset=utf-8\n" + text, testname);
// Check if the document contains the pasted text.
sendTextFrame(socket, "uno .uno:SelectAll", testname);
sendTextFrame(socket, "gettextselection mimetype=text/plain;charset=utf-8", testname);
const auto selection = assertResponseString(socket, "textselectioncontent:", testname);
- CPPUNIT_ASSERT_EQUAL(std::string("textselectioncontent: aaa bbb ccc"), selection);
+ CPPUNIT_ASSERT_EQUAL("textselectioncontent: " + text, selection);
// Closing connection too fast might not flush buffers.
// Often nothing more than the SelectAll reaches the server before
@@ -490,7 +493,7 @@ void HTTPWSTest::testSaveOnDisconnect()
sendTextFrame(socket, "uno .uno:SelectAll", testname);
sendTextFrame(socket, "gettextselection mimetype=text/plain;charset=utf-8", testname);
const auto selection = assertResponseString(socket, "textselectioncontent:", testname);
- CPPUNIT_ASSERT_EQUAL(std::string("textselectioncontent: aaa bbb ccc"), selection);
+ CPPUNIT_ASSERT_EQUAL("textselectioncontent: " + text, selection);
}
catch (const Poco::Exception& exc)
{
More information about the Libreoffice-commits
mailing list