[Libreoffice-commits] online.git: 4 commits - loolwsd/ChildSession.cpp loolwsd/ChildSession.hpp loolwsd/LOOLKit.cpp loolwsd/test
Henry Castro
hcastro at collabora.com
Sat Sep 17 22:15:57 UTC 2016
loolwsd/ChildSession.cpp | 1 -
loolwsd/ChildSession.hpp | 1 +
loolwsd/LOOLKit.cpp | 11 ++++++++++-
loolwsd/test/helpers.hpp | 12 ++++++------
loolwsd/test/httpwstest.cpp | 32 ++++++++++++++++++--------------
5 files changed, 35 insertions(+), 22 deletions(-)
New commits:
commit c6c20408495bf594e3020c26fde2dd57023c4a05
Author: Henry Castro <hcastro at collabora.com>
Date: Sat Sep 17 17:47:06 2016 -0400
loolwsd: test: log more info for each view
diff --git a/loolwsd/test/httpwstest.cpp b/loolwsd/test/httpwstest.cpp
index d511808..2fdba45 100644
--- a/loolwsd/test/httpwstest.cpp
+++ b/loolwsd/test/httpwstest.cpp
@@ -2130,7 +2130,7 @@ void HTTPWSTest::testOptimalResize()
}
}
-void HTTPWSTest::testEachView(const std::string& doc, const std::string& type, const std::string& protocol, const std::string& view)
+void HTTPWSTest::testEachView(const std::string& doc, const std::string& type, const std::string& protocol, const std::string& protocolView)
{
int docPart = -1;
int docParts = 0;
@@ -2141,6 +2141,9 @@ void HTTPWSTest::testEachView(const std::string& doc, const std::string& type, c
// 0..N Views
std::vector<std::shared_ptr<Poco::Net::WebSocket>> views;
+ const std::string view = "view %d -> ";
+ const std::string load = "view %d, cannot load the document ";
+ const std::string error = "view %d, did not receive a %s message as expected";
// Load a document
std::string documentPath, documentURL, response, text;
@@ -2150,21 +2153,21 @@ void HTTPWSTest::testEachView(const std::string& doc, const std::string& type, c
Poco::Net::WebSocket socket0 = *connectLOKit(_uri, request, _response);
sendTextFrame(socket0, "load url=" + documentURL);
- CPPUNIT_ASSERT_MESSAGE("cannot load the document " + documentURL, isDocumentLoaded(socket0));
+ CPPUNIT_ASSERT_MESSAGE(Poco::format(load, itView) + documentURL, isDocumentLoaded(socket0, Poco::format(view, itView)));
// Check document size
sendTextFrame(socket0, "status");
- getResponseMessage(socket0, "status:", response, false);
- CPPUNIT_ASSERT_MESSAGE("did not receive a status: message as expected", !response.empty());
+ getResponseMessage(socket0, "status:", response, false, Poco::format(view, itView));
+ CPPUNIT_ASSERT_MESSAGE(Poco::format(error, itView, std::string("status:")), !response.empty());
parseDocSize(response, type, docPart, docParts, docWidth, docHeight, docViewId);
- // Click to show a cursor
+ // Send click message
Poco::format(text, "mouse type=%s x=%d y=%d count=1 buttons=1 modifier=0", std::string("buttondown"), docWidth/2, docHeight/6);
sendTextFrame(socket0, text); text.clear();
Poco::format(text, "mouse type=%s x=%d y=%d count=1 buttons=1 modifier=0", std::string("buttonup"), docWidth/2, docHeight/6);
sendTextFrame(socket0, text);
- getResponseMessage(socket0, protocol, response, false);
- CPPUNIT_ASSERT_MESSAGE(Poco::format("did not receive a %s message as expected", protocol), !response.empty());
+ getResponseMessage(socket0, protocol, response, false, Poco::format(view, itView));
+ CPPUNIT_ASSERT_MESSAGE(Poco::format(error, itView, protocol), !response.empty());
// Connect 0..N Views, where N=10
for (itView = 0; itView < 10; ++itView)
@@ -2172,24 +2175,25 @@ void HTTPWSTest::testEachView(const std::string& doc, const std::string& type, c
views.emplace_back(connectLOKit(_uri, request, _response));
}
- const std::string error = Poco::format("did not receive a %s message as expected", view);
-
+ itView = 1;
// Load 0..N view
for (auto socketView : views)
{
sendTextFrame(*socketView, "load url=" + documentURL);
- CPPUNIT_ASSERT_MESSAGE("cannot load the document " + documentURL, isDocumentLoaded(*socketView, "", true));
+ CPPUNIT_ASSERT_MESSAGE(Poco::format(load, itView) + documentURL, isDocumentLoaded(*socketView, Poco::format(view, itView), true));
// Expected to receive response each view
- getResponseMessage(*socketView, view, response, false);
- CPPUNIT_ASSERT_MESSAGE(error, !response.empty());
+ getResponseMessage(*socketView, protocolView, response, false, Poco::format(view, itView));
+ CPPUNIT_ASSERT_MESSAGE(Poco::format(error, itView, protocolView), !response.empty());
+ ++itView;
}
+ itView = 0;
// main view should receive response each view
for (auto socketView : views)
{
- getResponseMessage(socket0, view, response, false);
- CPPUNIT_ASSERT_MESSAGE(error, !response.empty());
+ getResponseMessage(socket0, protocolView, response, false, Poco::format(view, itView));
+ CPPUNIT_ASSERT_MESSAGE(Poco::format(error, itView, protocolView), !response.empty());
}
}
commit a613025b0e48f85a15a08138ac7ce34c6fb44bef
Author: Henry Castro <hcastro at collabora.com>
Date: Sat Sep 17 17:20:52 2016 -0400
loolwsd: test: add view name verbose
diff --git a/loolwsd/test/helpers.hpp b/loolwsd/test/helpers.hpp
index d6b519d..32f009b 100644
--- a/loolwsd/test/helpers.hpp
+++ b/loolwsd/test/helpers.hpp
@@ -188,7 +188,7 @@ std::string getTestServerURI()
}
inline
-void getResponseMessage(Poco::Net::WebSocket& ws, const std::string& prefix, std::string& response, const bool isLine)
+void getResponseMessage(Poco::Net::WebSocket& ws, const std::string& prefix, std::string& response, const bool isLine, const std::string& name = "")
{
try
{
@@ -206,7 +206,7 @@ void getResponseMessage(Poco::Net::WebSocket& ws, const std::string& prefix, std
int bytes = ws.receiveFrame(buffer, sizeof(buffer), flags);
if (bytes > 0 && (flags & Poco::Net::WebSocket::FRAME_OP_BITMASK) != Poco::Net::WebSocket::FRAME_OP_CLOSE)
{
- std::cerr << "Got " << bytes << " bytes: " << LOOLProtocol::getAbbreviatedMessage(buffer, bytes) << std::endl;
+ std::cerr << name << "Got " << bytes << " bytes: " << LOOLProtocol::getAbbreviatedMessage(buffer, bytes) << std::endl;
const std::string message = isLine ?
LOOLProtocol::getFirstLine(buffer, bytes) :
std::string(buffer, bytes);
@@ -219,13 +219,13 @@ void getResponseMessage(Poco::Net::WebSocket& ws, const std::string& prefix, std
}
else
{
- std::cerr << "Got " << bytes << " bytes, flags: " << std::hex << flags << std::dec << '\n';
+ std::cerr << name << "Got " << bytes << " bytes, flags: " << std::hex << flags << std::dec << '\n';
}
retries = 10;
}
else
{
- std::cerr << "Timeout waiting for " << prefix << "\n";
+ std::cerr << name << "Timeout waiting for " << prefix << "\n";
--retries;
}
}
@@ -335,9 +335,9 @@ std::string assertResponseLine(T& ws, const std::string& prefix, const std::stri
}
inline
-void getResponseMessage(const std::shared_ptr<Poco::Net::WebSocket>& ws, const std::string& prefix, std::string& response, const bool isLine)
+void getResponseMessage(const std::shared_ptr<Poco::Net::WebSocket>& ws, const std::string& prefix, std::string& response, const bool isLine, const std::string& name = "")
{
- getResponseMessage(*ws, prefix, response, isLine);
+ getResponseMessage(*ws, prefix, response, isLine, name);
}
// Connecting to a Kit process is managed by document broker, that it does several
commit 7243e485d014e72bf8af3b0229b5bf91e0db9a07
Author: Henry Castro <hcastro at collabora.com>
Date: Sat Sep 17 17:52:54 2016 -0400
loolwsd: assign view id after loading
When session, it is not assigned, ViewCallback thread
will not enqueue the message
diff --git a/loolwsd/ChildSession.cpp b/loolwsd/ChildSession.cpp
index 93a2312..2e44eeb 100644
--- a/loolwsd/ChildSession.cpp
+++ b/loolwsd/ChildSession.cpp
@@ -326,7 +326,6 @@ bool ChildSession::loadDocument(const char * /*buffer*/, int /*length*/, StringT
if (_multiView)
{
std::ostringstream ossViewInfo;
- _viewId = _loKitDocument->getView();
const auto viewId = std::to_string(_viewId);
// Create a message object
diff --git a/loolwsd/ChildSession.hpp b/loolwsd/ChildSession.hpp
index e0b9df5..4cb7970 100644
--- a/loolwsd/ChildSession.hpp
+++ b/loolwsd/ChildSession.hpp
@@ -69,6 +69,7 @@ public:
bool getStatus(const char *buffer, int length);
bool getPartPageRectangles(const char *buffer, int length);
int getViewId() const { return _viewId; }
+ void setViewId(const int viewId) { _viewId = viewId; }
const std::string getViewUserName() const { return _userName; }
void loKitCallback(const int nType, const std::string& rPayload);
diff --git a/loolwsd/LOOLKit.cpp b/loolwsd/LOOLKit.cpp
index 65cab36..b8ae37c 100644
--- a/loolwsd/LOOLKit.cpp
+++ b/loolwsd/LOOLKit.cpp
@@ -1175,7 +1175,7 @@ private:
if (_multiView)
{
- viewId = _loKitDocument->getView();
+ session->setViewId((viewId = _loKitDocument->getView()));
_viewIdToCallbackDescr.emplace(viewId,
std::unique_ptr<CallbackDescriptor>(new CallbackDescriptor({ this, viewId })));
_loKitDocument->registerCallback(ViewCallback, _viewIdToCallbackDescr[viewId].get());
commit 722ca5daf5466401c596a41fa8e53407cf8223d2
Author: Henry Castro <hcastro at collabora.com>
Date: Sat Sep 17 18:10:01 2016 -0400
loolwsd: log: warn lost messages
diff --git a/loolwsd/LOOLKit.cpp b/loolwsd/LOOLKit.cpp
index e1b0a12..65cab36 100644
--- a/loolwsd/LOOLKit.cpp
+++ b/loolwsd/LOOLKit.cpp
@@ -846,6 +846,7 @@ private:
// Forward to the same view only.
// Demultiplexing is done by Core.
// TODO: replace with a map to be faster.
+ bool isFound = false;
for (auto& it : pDescr->Doc->_connections)
{
if (it.second->isRunning())
@@ -853,11 +854,19 @@ private:
auto session = it.second->getSession();
if (session && session->getViewId() == pDescr->ViewId)
{
+ isFound = true;
auto pNotif = new CallbackNotification(session, nType, payload);
pDescr->Doc->_callbackQueue.enqueueNotification(pNotif);
}
}
}
+
+ if (!isFound)
+ {
+ Log::warn() << "Document::ViewCallback. The message [" << pDescr->ViewId
+ << "] [" << LOKitHelper::kitCallbackTypeToString(nType)
+ << "] [" << payload << "] is not sent to Master Session." << Log::end;
+ }
}
static void DocumentCallback(const int nType, const char* pPayload, void* pData)
More information about the Libreoffice-commits
mailing list