[Libreoffice-commits] online.git: loolwsd/ChildSession.cpp loolwsd/LOKitHelper.hpp loolwsd/protocol.txt loolwsd/test

Ashod Nakashian ashod.nakashian at collabora.co.uk
Wed Jul 27 15:55:27 UTC 2016


 loolwsd/ChildSession.cpp        |    2 +-
 loolwsd/LOKitHelper.hpp         |    3 ++-
 loolwsd/protocol.txt            |    2 +-
 loolwsd/test/TileCacheTests.cpp |    5 +++--
 loolwsd/test/helpers.hpp        |    6 ++++--
 loolwsd/test/httpwstest.cpp     |   15 ++++++++-------
 6 files changed, 19 insertions(+), 14 deletions(-)

New commits:
commit d56f9a0386eed52a9a09ea87a5d9a40db94285e3
Author: Ashod Nakashian <ashod.nakashian at collabora.co.uk>
Date:   Tue Jul 26 08:03:46 2016 -0400

    loolwsd: status now includes the view-ID of the client
    
    Change-Id: Iac1cd806ac24ff3956624513946921020d248664
    Reviewed-on: https://gerrit.libreoffice.org/27585
    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 faf8c89..3413948 100644
--- a/loolwsd/ChildSession.cpp
+++ b/loolwsd/ChildSession.cpp
@@ -981,7 +981,7 @@ bool ChildSession::mouseEvent(const char* /*buffer*/, int /*length*/, StringToke
 
 bool ChildSession::unoCommand(const char* /*buffer*/, int /*length*/, StringTokenizer& tokens)
 {
-    if (tokens.count() == 1)
+    if (tokens.count() <= 1)
     {
         sendTextFrame("error: cmd=uno kind=syntax");
         return false;
diff --git a/loolwsd/LOKitHelper.hpp b/loolwsd/LOKitHelper.hpp
index 00e13b9..f05bddd 100644
--- a/loolwsd/LOKitHelper.hpp
+++ b/loolwsd/LOKitHelper.hpp
@@ -120,7 +120,8 @@ namespace LOKitHelper
         long width, height;
         loKitDocument->pClass->getDocumentSize(loKitDocument, &width, &height);
         oss << " width=" << width
-            << " height=" << height;
+            << " height=" << height
+            << " viewid=" << loKitDocument->pClass->getView(loKitDocument);
 
         if (type == LOK_DOCTYPE_SPREADSHEET || type == LOK_DOCTYPE_PRESENTATION)
         {
diff --git a/loolwsd/protocol.txt b/loolwsd/protocol.txt
index e25dbf2..fc566eb 100644
--- a/loolwsd/protocol.txt
+++ b/loolwsd/protocol.txt
@@ -266,7 +266,7 @@ nextmessage: size=<byteSize>
     must be handled by clients that cannot (like those using Poco
     1.6.0, like the "loadtest" program in the loolwsd sources).
 
-status: type=<typeName> parts=<numberOfParts> current=<currentPartNumber> width=<width> height=<height> [partNames]
+status: type=<typeName> parts=<numberOfParts> current=<currentPartNumber> width=<width> height=<height> viewid=<viewId> [partNames]
 
     <typeName> is 'text, 'spreadsheet', 'presentation', 'drawing' or 'other. Others are numbers.
     if the document has multiple parts and those have names, part names follow separated by '\n'
diff --git a/loolwsd/test/TileCacheTests.cpp b/loolwsd/test/TileCacheTests.cpp
index 0af1f9b..6c0ba64 100644
--- a/loolwsd/test/TileCacheTests.cpp
+++ b/loolwsd/test/TileCacheTests.cpp
@@ -348,6 +348,7 @@ void TileCacheTests::testLoad12ods()
         int docSheets = 0;
         int docHeight = 0;
         int docWidth = 0;
+        int docViewId = -1;
 
         std::string response;
 
@@ -365,7 +366,7 @@ void TileCacheTests::testLoad12ods()
         sendTextFrame(socket, "status");
         getResponseMessage(socket, "status:", response, false);
         CPPUNIT_ASSERT_MESSAGE("did not receive a status: message as expected", !response.empty());
-        getDocSize(response, "spreadsheet", docSheet, docSheets, docWidth, docHeight);
+        getDocSize(response, "spreadsheet", docSheet, docSheets, docWidth, docHeight, docViewId);
 
         checkBlackTiles(socket, docSheet, docWidth, docWidth);
     }
@@ -723,7 +724,7 @@ void TileCacheTests::checkTiles(Poco::Net::WebSocket& socket, const std::string&
 
         std::cout << "status: " << response << std::endl;
         Poco::StringTokenizer tokens(line, " ", Poco::StringTokenizer::TOK_IGNORE_EMPTY | Poco::StringTokenizer::TOK_TRIM);
-        CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(5), tokens.count());
+        CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(6), tokens.count());
 
         // Expected format is something like 'type= parts= current= width= height='.
         text = tokens[0].substr(type.size());
diff --git a/loolwsd/test/helpers.hpp b/loolwsd/test/helpers.hpp
index 53a868a..ce21613 100644
--- a/loolwsd/test/helpers.hpp
+++ b/loolwsd/test/helpers.hpp
@@ -417,10 +417,10 @@ void SocketProcessor(const std::string& name,
 
 inline
 void getDocSize(const std::string& message, const std::string& type,
-                int& part, int& parts, int& width, int& height)
+                int& part, int& parts, int& width, int& height, int& viewid)
 {
     Poco::StringTokenizer tokens(message, " ", Poco::StringTokenizer::TOK_IGNORE_EMPTY | Poco::StringTokenizer::TOK_TRIM);
-    CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(5), tokens.count());
+    CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(6), tokens.count());
 
     // Expected format is something like 'type= parts= current= width= height='.
     const std::string text = tokens[0].substr(std::string("type=").size());
@@ -428,11 +428,13 @@ void getDocSize(const std::string& message, const std::string& type,
     part = std::stoi(tokens[2].substr(std::string("current=").size()));
     width = std::stoi(tokens[3].substr(std::string("width=").size()));
     height = std::stoi(tokens[4].substr(std::string("height=").size()));
+    viewid = std::stoi(tokens[5].substr(std::string("viewid=").size()));
     CPPUNIT_ASSERT_EQUAL(type, text);
     CPPUNIT_ASSERT(parts > 0);
     CPPUNIT_ASSERT(part >= 0);
     CPPUNIT_ASSERT(width > 0);
     CPPUNIT_ASSERT(height > 0);
+    CPPUNIT_ASSERT(viewid >= 0);
 }
 
 inline
diff --git a/loolwsd/test/httpwstest.cpp b/loolwsd/test/httpwstest.cpp
index baf7766..c2c94bb 100644
--- a/loolwsd/test/httpwstest.cpp
+++ b/loolwsd/test/httpwstest.cpp
@@ -340,7 +340,7 @@ void HTTPWSTest::loadDoc(const std::string& documentURL)
                     {
                         const auto status = msg.substr(prefix.length());
                         // Might be too strict, consider something flexible instread.
-                        CPPUNIT_ASSERT_EQUAL(std::string("type=text parts=1 current=0 width=12808 height=16408"), status);
+                        CPPUNIT_ASSERT_EQUAL(std::string("type=text parts=1 current=0 width=12808 height=16408 viewid=0"), status);
                     }
                     else if (msg.find("editlock") == 0)
                     {
@@ -615,7 +615,7 @@ void HTTPWSTest::testExcelLoad()
 
         // Expected format is something like 'status: type=text parts=2 current=0 width=12808 height=1142'.
         Poco::StringTokenizer tokens(status, " ", Poco::StringTokenizer::TOK_IGNORE_EMPTY | Poco::StringTokenizer::TOK_TRIM);
-        CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(6), tokens.count());
+        CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(7), tokens.count());
     }
     catch (const Poco::Exception& exc)
     {
@@ -719,7 +719,7 @@ void HTTPWSTest::testRenderingOptions()
 
         // Expected format is something like 'status: type=text parts=2 current=0 width=12808 height=1142'.
         Poco::StringTokenizer tokens(status, " ", Poco::StringTokenizer::TOK_IGNORE_EMPTY | Poco::StringTokenizer::TOK_TRIM);
-        CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(6), tokens.count());
+        CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(7), tokens.count());
 
         const std::string token = tokens[5];
         const std::string prefix = "height=";
@@ -1259,9 +1259,9 @@ void HTTPWSTest::getPartHashCodes(const std::string status,
 
     std::cerr << "Reading parts from [" << status << "]." << std::endl;
 
-    // Expected format is something like 'type= parts= current= width= height='.
+    // Expected format is something like 'type= parts= current= width= height= viewid='.
     Poco::StringTokenizer tokens(line, " ", Poco::StringTokenizer::TOK_IGNORE_EMPTY | Poco::StringTokenizer::TOK_TRIM);
-    CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(5), tokens.count());
+    CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(6), tokens.count());
 
     const auto type = tokens[0].substr(std::string("type=").size());
     CPPUNIT_ASSERT_MESSAGE("Expected presentation or spreadsheet type to read part names/codes.",
@@ -1327,6 +1327,7 @@ void HTTPWSTest::testLimitCursor( std::function<void(const std::shared_ptr<Poco:
     int docSheets = 0;
     int docHeight = 0;
     int docWidth = 0;
+    int docViewId = -1;
     int newSheet = -1;
     int newSheets = 0;
     int newHeight = 0;
@@ -1349,7 +1350,7 @@ void HTTPWSTest::testLimitCursor( std::function<void(const std::shared_ptr<Poco:
     sendTextFrame(socket, "status");
     getResponseMessage(socket, "status:", response, false);
     CPPUNIT_ASSERT_MESSAGE("did not receive a status: message as expected", !response.empty());
-    getDocSize(response, "spreadsheet", docSheet, docSheets, docWidth, docHeight);
+    getDocSize(response, "spreadsheet", docSheet, docSheets, docWidth, docHeight, docViewId);
 
     // Send an arrow key to initialize the CellCursor, otherwise we get "EMPTY".
     sendTextFrame(socket, "key type=input char=0 key=1027");
@@ -1368,7 +1369,7 @@ void HTTPWSTest::testLimitCursor( std::function<void(const std::shared_ptr<Poco:
     // filter messages, and expect to receive new document size
     getResponseMessage(socket, "status:", response, false);
     CPPUNIT_ASSERT_MESSAGE("did not receive a status: message as expected", !response.empty());
-    getDocSize(response, "spreadsheet", newSheet, newSheets, newWidth, newHeight);
+    getDocSize(response, "spreadsheet", newSheet, newSheets, newWidth, newHeight, docViewId);
 
     CPPUNIT_ASSERT_EQUAL(docSheets, newSheets);
     CPPUNIT_ASSERT_EQUAL(docSheet, newSheet);


More information about the Libreoffice-commits mailing list