[Libreoffice-commits] online.git: test/UnitTyping.cpp

Michael Meeks (via logerrit) logerrit at kemper.freedesktop.org
Mon Feb 10 22:23:22 UTC 2020


 test/UnitTyping.cpp |   62 +++++++++++++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 61 insertions(+), 1 deletion(-)

New commits:
commit 10caa82b0a2c90d8b7ee1c05ca9a928815c6873c
Author:     Michael Meeks <michael.meeks at collabora.com>
AuthorDate: Mon Feb 3 22:55:52 2020 +0100
Commit:     Michael Meeks <michael.meeks at collabora.com>
CommitDate: Mon Feb 10 23:23:04 2020 +0100

    tdf#130382 - unit test for core fix for text input ordering issue.
    
    Requires the relevant core commit.
    
    Change-Id: I1b89c476ed6900bd0c5d981d125824c4bc2bf6da
    Reviewed-on: https://gerrit.libreoffice.org/c/online/+/87930
    Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice at gmail.com>
    Reviewed-by: Michael Meeks <michael.meeks at collabora.com>

diff --git a/test/UnitTyping.cpp b/test/UnitTyping.cpp
index e3f6263a9..63835e3b4 100644
--- a/test/UnitTyping.cpp
+++ b/test/UnitTyping.cpp
@@ -12,6 +12,7 @@
 #include <config.h>
 
 #include <random>
+#include <iostream>
 
 #include <Exceptions.hpp>
 #include <Log.hpp>
@@ -52,7 +53,66 @@ public:
 
     TestResult testWriterTyping()
     {
-//        const char* testname = "writerMultiViewEdit ";
+        const char* testname = "writerCompositionTest ";
+        std::string serverURL = LOOLWSD::getServerURL();
+        const Poco::URI uri(serverURL);
+
+        LOG_TRC("test writer typing");
+
+        // Load a doc with the cursor saved at a top row.
+        std::string documentPath, documentURL;
+        helpers::getDocumentPathAndURL(
+            "empty.odt", documentPath, documentURL, testname);
+
+        std::shared_ptr<LOOLWebSocket> socket = helpers::loadDocAndGetSocket(uri, documentURL, testname);
+
+        static const char *commands[] = {
+            "key type=up char=0 key=17",
+            "textinput id=0 type=input text=%E3%84%98",
+            "textinput id=0 type=end text=%E3%84%98",
+            "key type=up char=0 key=519",
+
+            "textinput id=0 type=input text=%E3%84%9C",
+            "textinput id=0 type=end text=%E3%84%9C",
+            "key type=up char=0 key=522",
+
+            "textinput id=0 type=input text=%CB%8B",
+            "textinput id=0 type=end text=%CB%8B",
+            "key type=up char=0 key=260",
+
+            // replace with the complete character
+            "removetextcontext id=0 before=3 after=0",
+            "textinput id=0 type=input text=%E6%B8%AC",
+            "textinput id=0 type=end text=%E6%B8%AC",
+            "key type=up char=0 key=259"
+        };
+        static const unsigned char correct[] = {
+            0xe6, 0xb8, 0xac
+        };
+
+        // Feed the keystrokes ...
+        for (const char *str : commands)
+            sendTextFrame(socket, str, testname);
+
+        // extract their text
+        sendTextFrame(socket, "uno .uno:SelectAll", testname);
+        sendTextFrame(socket, "gettextselection mimetype=text/plain;charset=utf-8", testname);
+
+        LOG_TRC("Waiting for test selection:");
+        const char response[] = "textselectioncontent:";
+        const int responseLen = sizeof(response) - 1;
+        std::string result = getResponseString(
+            socket, response, testname, 5000 /* 5 secs */);
+
+        LOG_TRC("length " << result.length() << " vs. " << (responseLen + 4));
+        if (strncmp(result.c_str(), response, responseLen) ||
+            result.length() < responseLen + 4 ||
+            strncmp(result.c_str() + responseLen + 1, (const char *)correct, 3))
+        {
+            Util::dumpHex(std::cerr, "Error: wrong textselectioncontent:", "", result);
+            return TestResult::Failed;
+        }
+
         return TestResult::Ok;
     }
 


More information about the Libreoffice-commits mailing list