[Libreoffice-commits] online.git: test/httpwstest.cpp test/Makefile.am test/UnitInsertDelete.cpp

Miklos Vajna (via logerrit) logerrit at kemper.freedesktop.org
Wed Dec 18 21:18:27 UTC 2019


 test/Makefile.am          |    4 
 test/UnitInsertDelete.cpp |  333 ++++++++++++++++++++++++++++++++++++++++++++++
 test/httpwstest.cpp       |  255 -----------------------------------
 3 files changed, 337 insertions(+), 255 deletions(-)

New commits:
commit 9680084f6bbbd929d9f259ed00ce6fedeccf160d
Author:     Miklos Vajna <vmiklos at collabora.com>
AuthorDate: Wed Dec 18 21:16:26 2019 +0100
Commit:     Miklos Vajna <vmiklos at collabora.com>
CommitDate: Wed Dec 18 22:18:08 2019 +0100

    Convert some insert/delete tests to a new-style one
    
    So that they are in-process, which means it's easier to debug when they
    fail.
    
    Change-Id: I4938d00337dead52345036f7b186f5a759f26b82
    Reviewed-on: https://gerrit.libreoffice.org/85427
    Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice at gmail.com>
    Reviewed-by: Miklos Vajna <vmiklos at collabora.com>

diff --git a/test/Makefile.am b/test/Makefile.am
index 532c28818..2c137f70b 100644
--- a/test/Makefile.am
+++ b/test/Makefile.am
@@ -34,6 +34,7 @@ noinst_LTLIBRARIES = \
 	unit-load.la \
 	unit-cursor.la \
 	unit-calc.la \
+	unit-insert-delete.la \
 	unit-wopi-loadencoded.la unit-wopi-temp.la
 
 MAGIC_TO_FORCE_SHLIB_CREATION = -rpath /dummy
@@ -161,6 +162,8 @@ unit_cursor_la_SOURCES = UnitCursor.cpp
 unit_cursor_la_LIBADD = $(CPPUNIT_LIBS)
 unit_calc_la_SOURCES = UnitCalc.cpp
 unit_calc_la_LIBADD = $(CPPUNIT_LIBS)
+unit_insert_delete_la_SOURCES = UnitInsertDelete.cpp
+unit_insert_delete_la_LIBADD = $(CPPUNIT_LIBS)
 
 if HAVE_LO_PATH
 SYSTEM_STAMP = @SYSTEMPLATE_PATH@/system_stamp
@@ -193,6 +196,7 @@ TESTS = unit-copy-paste.la unit-typing.la unit-convert.la unit-prefork.la unit-t
 	unit-load.la \
 	unit-cursor.la \
 	unit-calc.la \
+	unit-insert-delete.la \
 	unit-wopi-loadencoded.la unit-wopi-temp.la
 # TESTS = unit-client.la
 # TESTS += unit-admin.la
diff --git a/test/UnitInsertDelete.cpp b/test/UnitInsertDelete.cpp
new file mode 100644
index 000000000..485e43de8
--- /dev/null
+++ b/test/UnitInsertDelete.cpp
@@ -0,0 +1,333 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#include <memory>
+#include <ostream>
+#include <set>
+#include <string>
+
+#include <Poco/Exception.h>
+#include <Poco/RegularExpression.h>
+#include <Poco/URI.h>
+#include <cppunit/TestAssert.h>
+
+#include <Png.hpp>
+#include <Unit.hpp>
+#include <helpers.hpp>
+
+class LOOLWebSocket;
+
+namespace
+{
+void getPartHashCodes(const std::string& testname, const std::string& response,
+                      std::vector<std::string>& parts)
+{
+    std::string line;
+    std::istringstream istr(response);
+    std::getline(istr, line);
+
+    TST_LOG("Reading parts from [" << response << "].");
+
+    // Expected format is something like 'type= parts= current= width= height= viewid= [hiddenparts=]'.
+    std::vector<std::string> tokens(LOOLProtocol::tokenize(line, ' '));
+#if defined CPPUNIT_ASSERT_GREATEREQUAL
+    CPPUNIT_ASSERT_GREATEREQUAL(static_cast<size_t>(7), tokens.size());
+#else
+    CPPUNIT_ASSERT_MESSAGE("Expected at least 7 tokens.", static_cast<size_t>(7) <= tokens.size());
+#endif
+
+    const std::string type = tokens[0].substr(std::string("type=").size());
+    CPPUNIT_ASSERT_MESSAGE("Expected presentation or spreadsheet type to read part names/codes.",
+                           type == "presentation" || type == "spreadsheet");
+
+    const int totalParts = std::stoi(tokens[1].substr(std::string("parts=").size()));
+    TST_LOG("Status reports " << totalParts << " parts.");
+
+    Poco::RegularExpression endLine("[^\n\r]+");
+    Poco::RegularExpression number("^[0-9]+$");
+    Poco::RegularExpression::MatchVec matches;
+    int offset = 0;
+
+    parts.clear();
+    while (endLine.match(response, offset, matches) > 0)
+    {
+        CPPUNIT_ASSERT_EQUAL(1, (int)matches.size());
+        const std::string str = response.substr(matches[0].offset, matches[0].length);
+        if (number.match(str, 0))
+        {
+            parts.push_back(str);
+        }
+
+        offset = static_cast<int>(matches[0].offset + matches[0].length);
+    }
+
+    TST_LOG("Found " << parts.size() << " part names/codes.");
+
+    // Validate that Core is internally consistent when emitting status messages.
+    CPPUNIT_ASSERT_EQUAL(totalParts, (int)parts.size());
+}
+}
+
+/// Test suite for insertion/deletion.
+class UnitInsertDelete : public UnitWSD
+{
+    TestResult testInsertDelete();
+    TestResult testPasteBlank();
+    TestResult testGetTextSelection();
+    TestResult testCursorPosition();
+
+public:
+    void invokeTest() override;
+};
+
+UnitBase::TestResult UnitInsertDelete::testInsertDelete()
+{
+    const char* testname = "insertDelete ";
+    try
+    {
+        std::vector<std::string> parts;
+        std::string response;
+
+        // Load a document
+        std::string documentPath, documentURL;
+        helpers::getDocumentPathAndURL("insert-delete.odp", documentPath, documentURL, testname);
+
+        Poco::Net::HTTPRequest request(Poco::Net::HTTPRequest::HTTP_GET, documentURL);
+        Poco::URI uri(helpers::getTestServerURI());
+        Poco::Net::HTTPResponse httpResponse;
+        std::shared_ptr<LOOLWebSocket> socket
+            = helpers::connectLOKit(uri, request, httpResponse, testname);
+
+        helpers::sendTextFrame(socket, "load url=" + documentURL);
+        CPPUNIT_ASSERT_MESSAGE("cannot load the document " + documentURL,
+                               helpers::isDocumentLoaded(socket, testname));
+
+        // check total slides 1
+        TST_LOG("Expecting 1 slide.");
+        helpers::sendTextFrame(socket, "status");
+        response = helpers::getResponseString(socket, "status:", testname);
+        CPPUNIT_ASSERT_MESSAGE("did not receive a status: message as expected", !response.empty());
+        getPartHashCodes(testname, response.substr(7), parts);
+        CPPUNIT_ASSERT_EQUAL(1, (int)parts.size());
+
+        const std::string slide1Hash = parts[0];
+
+        // insert 10 slides
+        TST_LOG("Inserting 10 slides.");
+        for (size_t it = 1; it <= 10; it++)
+        {
+            helpers::sendTextFrame(socket, "uno .uno:InsertPage");
+            response = helpers::getResponseString(socket, "status:", testname);
+            CPPUNIT_ASSERT_MESSAGE("did not receive a status: message as expected",
+                                   !response.empty());
+            getPartHashCodes(testname, response.substr(7), parts);
+            CPPUNIT_ASSERT_EQUAL(it + 1, parts.size());
+        }
+
+        CPPUNIT_ASSERT_MESSAGE("Hash code of slide #1 changed after inserting extra slides.",
+                               parts[0] == slide1Hash);
+        const std::vector<std::string> parts_after_insert(parts.begin(), parts.end());
+
+        // delete 10 slides
+        TST_LOG("Deleting 10 slides.");
+        for (size_t it = 1; it <= 10; it++)
+        {
+            // Explicitly delete the nth slide.
+            helpers::sendTextFrame(socket, "setclientpart part=" + std::to_string(it));
+            helpers::sendTextFrame(socket, "uno .uno:DeletePage");
+            response = helpers::getResponseString(socket, "status:", testname);
+            CPPUNIT_ASSERT_MESSAGE("did not receive a status: message as expected",
+                                   !response.empty());
+            getPartHashCodes(testname, response.substr(7), parts);
+            CPPUNIT_ASSERT_EQUAL(11 - it, parts.size());
+        }
+
+        CPPUNIT_ASSERT_MESSAGE("Hash code of slide #1 changed after deleting extra slides.",
+                               parts[0] == slide1Hash);
+
+        // undo delete slides
+        TST_LOG("Undoing 10 slide deletes.");
+        for (size_t it = 1; it <= 10; it++)
+        {
+            helpers::sendTextFrame(socket, "uno .uno:Undo");
+            response = helpers::getResponseString(socket, "status:", testname);
+            CPPUNIT_ASSERT_MESSAGE("did not receive a status: message as expected",
+                                   !response.empty());
+            getPartHashCodes(testname, response.substr(7), parts);
+            CPPUNIT_ASSERT_EQUAL(it + 1, parts.size());
+        }
+
+        CPPUNIT_ASSERT_MESSAGE("Hash code of slide #1 changed after undoing slide delete.",
+                               parts[0] == slide1Hash);
+        const std::vector<std::string> parts_after_undo(parts.begin(), parts.end());
+        CPPUNIT_ASSERT_MESSAGE("Hash codes changed between deleting and undo.",
+                               parts_after_insert == parts_after_undo);
+
+        // redo inserted slides
+        TST_LOG("Redoing 10 slide deletes.");
+        for (size_t it = 1; it <= 10; it++)
+        {
+            helpers::sendTextFrame(socket, "uno .uno:Redo");
+            response = helpers::getResponseString(socket, "status:", testname);
+            CPPUNIT_ASSERT_MESSAGE("did not receive a status: message as expected",
+                                   !response.empty());
+            getPartHashCodes(testname, response.substr(7), parts);
+            CPPUNIT_ASSERT_EQUAL(11 - it, parts.size());
+        }
+
+        CPPUNIT_ASSERT_MESSAGE("Hash code of slide #1 changed after redoing slide delete.",
+                               parts[0] == slide1Hash);
+
+        // check total slides 1
+        TST_LOG("Expecting 1 slide.");
+        helpers::sendTextFrame(socket, "status");
+        response = helpers::getResponseString(socket, "status:", testname);
+        CPPUNIT_ASSERT_MESSAGE("did not receive a status: message as expected", !response.empty());
+        getPartHashCodes(testname, response.substr(7), parts);
+        CPPUNIT_ASSERT_EQUAL(1, (int)parts.size());
+    }
+    catch (const Poco::Exception& exc)
+    {
+        CPPUNIT_FAIL(exc.displayText());
+    }
+    return TestResult::Ok;
+}
+
+UnitBase::TestResult UnitInsertDelete::testPasteBlank()
+{
+    const char* testname = "pasteBlank ";
+    try
+    {
+        // Load a document and make it empty, then paste nothing into it.
+        Poco::URI uri(helpers::getTestServerURI());
+        std::shared_ptr<LOOLWebSocket> socket
+            = helpers::loadDocAndGetSocket("hello.odt", uri, testname);
+
+        helpers::deleteAll(socket, testname);
+
+        // Paste nothing into it.
+        helpers::sendTextFrame(socket, "paste mimetype=text/plain;charset=utf-8\n", testname);
+
+        // Check if the document contains the pasted text.
+        const std::string selection = helpers::getAllText(socket, testname);
+        CPPUNIT_ASSERT_EQUAL(std::string("textselectioncontent: "), selection);
+    }
+    catch (const Poco::Exception& exc)
+    {
+        CPPUNIT_FAIL(exc.displayText());
+    }
+    return TestResult::Ok;
+}
+
+UnitBase::TestResult UnitInsertDelete::testGetTextSelection()
+{
+    const char* testname = "getTextSelection ";
+    try
+    {
+        std::string documentPath, documentURL;
+        helpers::getDocumentPathAndURL("hello.odt", documentPath, documentURL, testname);
+
+        Poco::URI uri(helpers::getTestServerURI());
+        std::shared_ptr<LOOLWebSocket> socket
+            = helpers::loadDocAndGetSocket(uri, documentURL, testname);
+        std::shared_ptr<LOOLWebSocket> socket2
+            = helpers::loadDocAndGetSocket(uri, documentURL, testname);
+
+        static const std::string expected = "Hello world";
+        const std::string selection = helpers::getAllText(socket, testname, expected);
+        CPPUNIT_ASSERT_EQUAL("textselectioncontent: " + expected, selection);
+    }
+    catch (const Poco::Exception& exc)
+    {
+        CPPUNIT_FAIL(exc.displayText());
+    }
+    return TestResult::Ok;
+}
+
+UnitBase::TestResult UnitInsertDelete::testCursorPosition()
+{
+    try
+    {
+        const char* testname = "cursorPosition ";
+
+        // Load a document.
+        std::string docPath;
+        std::string docURL;
+        std::string response;
+
+        helpers::getDocumentPathAndURL("Example.odt", docPath, docURL, testname);
+        Poco::URI uri(helpers::getTestServerURI());
+        std::shared_ptr<LOOLWebSocket> socket0
+            = helpers::loadDocAndGetSocket(uri, docURL, testname);
+
+        // receive cursor position
+        response = helpers::getResponseString(socket0, "invalidatecursor:", testname);
+
+        Poco::JSON::Parser parser0;
+        const Poco::Dynamic::Var result0 = parser0.parse(response.substr(17));
+        const auto& command0 = result0.extract<Poco::JSON::Object::Ptr>();
+        CPPUNIT_ASSERT_MESSAGE("missing property rectangle", command0->has("rectangle"));
+
+        std::vector<std::string> cursorTokens(
+            LOOLProtocol::tokenize(command0->get("rectangle").toString(), ','));
+        CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(4), cursorTokens.size());
+
+        // Create second view
+        std::shared_ptr<LOOLWebSocket> socket1
+            = helpers::loadDocAndGetSocket(uri, docURL, testname);
+
+        //receive view cursor position
+        response = helpers::getResponseString(socket1, "invalidateviewcursor:", testname);
+
+        Poco::JSON::Parser parser;
+        const Poco::Dynamic::Var result = parser.parse(response.substr(21));
+        const auto& command = result.extract<Poco::JSON::Object::Ptr>();
+        CPPUNIT_ASSERT_MESSAGE("missing property rectangle", command->has("rectangle"));
+
+        std::vector<std::string> viewTokens(
+            LOOLProtocol::tokenize(command->get("rectangle").toString(), ','));
+        CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(4), viewTokens.size());
+
+        // check both cursor should be equal
+        CPPUNIT_ASSERT_EQUAL(cursorTokens[0], viewTokens[0]);
+        CPPUNIT_ASSERT_EQUAL(cursorTokens[1], viewTokens[1]);
+        CPPUNIT_ASSERT_EQUAL(cursorTokens[2], viewTokens[2]);
+        CPPUNIT_ASSERT_EQUAL(cursorTokens[3], viewTokens[3]);
+    }
+    catch (const Poco::Exception& exc)
+    {
+        CPPUNIT_FAIL(exc.displayText());
+    }
+    return TestResult::Ok;
+}
+
+void UnitInsertDelete::invokeTest()
+{
+    UnitBase::TestResult result = testInsertDelete();
+    if (result != TestResult::Ok)
+        exitTest(result);
+
+    result = testPasteBlank();
+    if (result != TestResult::Ok)
+        exitTest(result);
+
+    result = testGetTextSelection();
+    if (result != TestResult::Ok)
+        exitTest(result);
+
+    result = testCursorPosition();
+    if (result != TestResult::Ok)
+        exitTest(result);
+
+    exitTest(TestResult::Ok);
+}
+
+UnitBase* unit_create_wsd(void) { return new UnitInsertDelete(); }
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/test/httpwstest.cpp b/test/httpwstest.cpp
index b6f7057ae..5248664dd 100644
--- a/test/httpwstest.cpp
+++ b/test/httpwstest.cpp
@@ -40,16 +40,12 @@ class HTTPWSTest : public CPPUNIT_NS::TestFixture
     CPPUNIT_TEST_SUITE(HTTPWSTest);
 
     CPPUNIT_TEST(testCloseAfterClose);
-    CPPUNIT_TEST(testGetTextSelection);
     CPPUNIT_TEST(testSaveOnDisconnect);
     CPPUNIT_TEST(testSavePassiveOnDisconnect);
     CPPUNIT_TEST(testReloadWhileDisconnecting);
-    CPPUNIT_TEST(testPasteBlank);
-    CPPUNIT_TEST(testInsertDelete);
     CPPUNIT_TEST(testInactiveClient);
     CPPUNIT_TEST(testFontList);
     CPPUNIT_TEST(testGraphicInvalidate);
-    CPPUNIT_TEST(testCursorPosition);
     CPPUNIT_TEST(testAlertAllUsers);
     CPPUNIT_TEST(testViewInfoMsg);
     CPPUNIT_TEST(testUndoConflict);
@@ -57,24 +53,16 @@ class HTTPWSTest : public CPPUNIT_NS::TestFixture
     CPPUNIT_TEST_SUITE_END();
 
     void testCloseAfterClose();
-    void testGetTextSelection();
     void testSaveOnDisconnect();
     void testSavePassiveOnDisconnect();
     void testReloadWhileDisconnecting();
-    void testPasteBlank();
-    void testInsertDelete();
     void testInactiveClient();
     void testFontList();
     void testGraphicInvalidate();
-    void testCursorPosition();
     void testAlertAllUsers();
     void testViewInfoMsg();
     void testUndoConflict();
 
-    void getPartHashCodes(const std::string& testname,
-                          const std::string& response,
-                          std::vector<std::string>& parts);
-
     std::string getFontList(const std::string& message);
 
 public:
@@ -164,27 +152,6 @@ void HTTPWSTest::testCloseAfterClose()
     }
 }
 
-void HTTPWSTest::testGetTextSelection()
-{
-    const char* testname = "getTextSelection ";
-    try
-    {
-        std::string documentPath, documentURL;
-        getDocumentPathAndURL("hello.odt", documentPath, documentURL, testname);
-
-        std::shared_ptr<LOOLWebSocket> socket = loadDocAndGetSocket(_uri, documentURL, testname);
-        std::shared_ptr<LOOLWebSocket> socket2 = loadDocAndGetSocket(_uri, documentURL, testname);
-
-        static const std::string expected = "Hello world";
-        const std::string selection = getAllText(socket, testname, expected);
-        CPPUNIT_ASSERT_EQUAL("textselectioncontent: " + expected, selection);
-    }
-    catch (const Poco::Exception& exc)
-    {
-        CPPUNIT_FAIL(exc.displayText());
-    }
-}
-
 void HTTPWSTest::testSaveOnDisconnect()
 {
     const char* testname = "saveOnDisconnect ";
@@ -359,128 +326,6 @@ void HTTPWSTest::testReloadWhileDisconnecting()
     }
 }
 
-void HTTPWSTest::testPasteBlank()
-{
-    const char* testname = "pasteBlank ";
-    try
-    {
-        // Load a document and make it empty, then paste nothing into it.
-        std::shared_ptr<LOOLWebSocket> socket = loadDocAndGetSocket("hello.odt", _uri, testname);
-
-        deleteAll(socket, testname);
-
-        // Paste nothing into it.
-        sendTextFrame(socket, "paste mimetype=text/plain;charset=utf-8\n", testname);
-
-        // Check if the document contains the pasted text.
-        const std::string selection = getAllText(socket, testname);
-        CPPUNIT_ASSERT_EQUAL(std::string("textselectioncontent: "), selection);
-    }
-    catch (const Poco::Exception& exc)
-    {
-        CPPUNIT_FAIL(exc.displayText());
-    }
-}
-
-void HTTPWSTest::testInsertDelete()
-{
-    const char* testname = "insertDelete ";
-    try
-    {
-        std::vector<std::string> parts;
-        std::string response;
-
-        // Load a document
-        std::string documentPath, documentURL;
-        getDocumentPathAndURL("insert-delete.odp", documentPath, documentURL, testname);
-
-        Poco::Net::HTTPRequest request(Poco::Net::HTTPRequest::HTTP_GET, documentURL);
-        std::shared_ptr<LOOLWebSocket> socket = connectLOKit(_uri, request, _response, testname);
-
-        sendTextFrame(socket, "load url=" + documentURL);
-        CPPUNIT_ASSERT_MESSAGE("cannot load the document " + documentURL, isDocumentLoaded(socket, testname));
-
-        // check total slides 1
-        TST_LOG("Expecting 1 slide.");
-        sendTextFrame(socket, "status");
-        response = getResponseString(socket, "status:", testname);
-        CPPUNIT_ASSERT_MESSAGE("did not receive a status: message as expected", !response.empty());
-        getPartHashCodes(testname, response.substr(7), parts);
-        CPPUNIT_ASSERT_EQUAL(1, (int)parts.size());
-
-        const std::string slide1Hash = parts[0];
-
-        // insert 10 slides
-        TST_LOG("Inserting 10 slides.");
-        for (size_t it = 1; it <= 10; it++)
-        {
-            sendTextFrame(socket, "uno .uno:InsertPage");
-            response = getResponseString(socket, "status:", testname);
-            CPPUNIT_ASSERT_MESSAGE("did not receive a status: message as expected", !response.empty());
-            getPartHashCodes(testname, response.substr(7), parts);
-            CPPUNIT_ASSERT_EQUAL(it + 1, parts.size());
-        }
-
-        CPPUNIT_ASSERT_MESSAGE("Hash code of slide #1 changed after inserting extra slides.", parts[0] == slide1Hash);
-        const std::vector<std::string> parts_after_insert(parts.begin(), parts.end());
-
-        // delete 10 slides
-        TST_LOG("Deleting 10 slides.");
-        for (size_t it = 1; it <= 10; it++)
-        {
-            // Explicitly delete the nth slide.
-            sendTextFrame(socket, "setclientpart part=" + std::to_string(it));
-            sendTextFrame(socket, "uno .uno:DeletePage");
-            response = getResponseString(socket, "status:", testname);
-            CPPUNIT_ASSERT_MESSAGE("did not receive a status: message as expected", !response.empty());
-            getPartHashCodes(testname, response.substr(7), parts);
-            CPPUNIT_ASSERT_EQUAL(11 - it, parts.size());
-        }
-
-        CPPUNIT_ASSERT_MESSAGE("Hash code of slide #1 changed after deleting extra slides.", parts[0] == slide1Hash);
-
-        // undo delete slides
-        TST_LOG("Undoing 10 slide deletes.");
-        for (size_t it = 1; it <= 10; it++)
-        {
-            sendTextFrame(socket, "uno .uno:Undo");
-            response = getResponseString(socket, "status:", testname);
-            CPPUNIT_ASSERT_MESSAGE("did not receive a status: message as expected", !response.empty());
-            getPartHashCodes(testname, response.substr(7), parts);
-            CPPUNIT_ASSERT_EQUAL(it + 1, parts.size());
-        }
-
-        CPPUNIT_ASSERT_MESSAGE("Hash code of slide #1 changed after undoing slide delete.", parts[0] == slide1Hash);
-        const std::vector<std::string> parts_after_undo(parts.begin(), parts.end());
-        CPPUNIT_ASSERT_MESSAGE("Hash codes changed between deleting and undo.", parts_after_insert == parts_after_undo);
-
-        // redo inserted slides
-        TST_LOG("Redoing 10 slide deletes.");
-        for (size_t it = 1; it <= 10; it++)
-        {
-            sendTextFrame(socket, "uno .uno:Redo");
-            response = getResponseString(socket, "status:", testname);
-            CPPUNIT_ASSERT_MESSAGE("did not receive a status: message as expected", !response.empty());
-            getPartHashCodes(testname, response.substr(7), parts);
-            CPPUNIT_ASSERT_EQUAL(11 - it, parts.size());
-        }
-
-        CPPUNIT_ASSERT_MESSAGE("Hash code of slide #1 changed after redoing slide delete.", parts[0] == slide1Hash);
-
-        // check total slides 1
-        TST_LOG("Expecting 1 slide.");
-        sendTextFrame(socket, "status");
-        response = getResponseString(socket, "status:", testname);
-        CPPUNIT_ASSERT_MESSAGE("did not receive a status: message as expected", !response.empty());
-        getPartHashCodes(testname, response.substr(7), parts);
-        CPPUNIT_ASSERT_EQUAL(1, (int)parts.size());
-    }
-    catch (const Poco::Exception& exc)
-    {
-        CPPUNIT_FAIL(exc.displayText());
-    }
-}
-
 void HTTPWSTest::testInactiveClient()
 {
     const char* testname = "inactiveClient ";
@@ -541,55 +386,6 @@ void HTTPWSTest::testInactiveClient()
     }
 }
 
-void HTTPWSTest::getPartHashCodes(const std::string& testname,
-                                  const std::string& response,
-                                  std::vector<std::string>& parts)
-{
-    std::string line;
-    std::istringstream istr(response);
-    std::getline(istr, line);
-
-    TST_LOG("Reading parts from [" << response << "].");
-
-    // Expected format is something like 'type= parts= current= width= height= viewid= [hiddenparts=]'.
-    std::vector<std::string> tokens(LOOLProtocol::tokenize(line, ' '));
-#if defined CPPUNIT_ASSERT_GREATEREQUAL
-    CPPUNIT_ASSERT_GREATEREQUAL(static_cast<size_t>(7), tokens.size());
-#else
-    CPPUNIT_ASSERT_MESSAGE("Expected at least 7 tokens.", static_cast<size_t>(7) <= tokens.size());
-#endif
-
-    const std::string type = tokens[0].substr(std::string("type=").size());
-    CPPUNIT_ASSERT_MESSAGE("Expected presentation or spreadsheet type to read part names/codes.",
-                           type == "presentation" || type == "spreadsheet");
-
-    const int totalParts = std::stoi(tokens[1].substr(std::string("parts=").size()));
-    TST_LOG("Status reports " << totalParts << " parts.");
-
-    Poco::RegularExpression endLine("[^\n\r]+");
-    Poco::RegularExpression number("^[0-9]+$");
-    Poco::RegularExpression::MatchVec matches;
-    int offset = 0;
-
-    parts.clear();
-    while (endLine.match(response, offset, matches) > 0)
-    {
-        CPPUNIT_ASSERT_EQUAL(1, (int)matches.size());
-        const std::string str = response.substr(matches[0].offset, matches[0].length);
-        if (number.match(str, 0))
-        {
-            parts.push_back(str);
-        }
-
-        offset = static_cast<int>(matches[0].offset + matches[0].length);
-    }
-
-    TST_LOG("Found " << parts.size() << " part names/codes.");
-
-    // Validate that Core is internally consistent when emitting status messages.
-    CPPUNIT_ASSERT_EQUAL(totalParts, (int)parts.size());
-}
-
 std::string HTTPWSTest::getFontList(const std::string& message)
 {
     Poco::JSON::Parser parser;
@@ -650,57 +446,6 @@ void HTTPWSTest::testGraphicInvalidate()
     }
 }
 
-void HTTPWSTest::testCursorPosition()
-{
-    try
-    {
-        const char* testname = "cursorPosition ";
-
-         // Load a document.
-        std::string docPath;
-        std::string docURL;
-        std::string response;
-
-        getDocumentPathAndURL("Example.odt", docPath, docURL, testname);
-        std::shared_ptr<LOOLWebSocket> socket0 = loadDocAndGetSocket(_uri, docURL, testname);
-
-        // receive cursor position
-        response = getResponseString(socket0, "invalidatecursor:", testname);
-
-        Poco::JSON::Parser parser0;
-        const Poco::Dynamic::Var result0 = parser0.parse(response.substr(17));
-        const auto& command0 = result0.extract<Poco::JSON::Object::Ptr>();
-        CPPUNIT_ASSERT_MESSAGE("missing property rectangle", command0->has("rectangle"));
-
-        std::vector<std::string> cursorTokens(LOOLProtocol::tokenize(command0->get("rectangle").toString(), ','));
-        CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(4), cursorTokens.size());
-
-        // Create second view
-        std::shared_ptr<LOOLWebSocket> socket1 = loadDocAndGetSocket(_uri, docURL, testname);
-
-        //receive view cursor position
-        response = getResponseString(socket1, "invalidateviewcursor:", testname);
-
-        Poco::JSON::Parser parser;
-        const Poco::Dynamic::Var result = parser.parse(response.substr(21));
-        const auto& command = result.extract<Poco::JSON::Object::Ptr>();
-        CPPUNIT_ASSERT_MESSAGE("missing property rectangle", command->has("rectangle"));
-
-        std::vector<std::string> viewTokens(LOOLProtocol::tokenize(command->get("rectangle").toString(), ','));
-        CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(4), viewTokens.size());
-
-        // check both cursor should be equal
-        CPPUNIT_ASSERT_EQUAL(cursorTokens[0], viewTokens[0]);
-        CPPUNIT_ASSERT_EQUAL(cursorTokens[1], viewTokens[1]);
-        CPPUNIT_ASSERT_EQUAL(cursorTokens[2], viewTokens[2]);
-        CPPUNIT_ASSERT_EQUAL(cursorTokens[3], viewTokens[3]);
-    }
-    catch (const Poco::Exception& exc)
-    {
-        CPPUNIT_FAIL(exc.displayText());
-    }
-}
-
 void HTTPWSTest::testAlertAllUsers()
 {
     // Load two documents, each in two sessions. Tell one session to fake a disk full


More information about the Libreoffice-commits mailing list