[Libreoffice-commits] online.git: Branch 'distro/collabora/collabora-online-4-0' - test/helpers.hpp test/httpwstest.cpp

Ashod Nakashian (via logerrit) logerrit at kemper.freedesktop.org
Tue Oct 22 17:01:39 UTC 2019


 test/helpers.hpp    |   16 +++++++++++-----
 test/httpwstest.cpp |    7 ++++---
 2 files changed, 15 insertions(+), 8 deletions(-)

New commits:
commit 9903229918d07eee2f6c1ad22ee5a287f4fd0884
Author:     Ashod Nakashian <ashod.nakashian at collabora.co.uk>
AuthorDate: Sat Oct 19 12:32:43 2019 -0400
Commit:     Andras Timar <andras.timar at collabora.com>
CommitDate: Tue Oct 22 19:01:21 2019 +0200

    test: improve getAllText to match an expected payload
    
    Change-Id: I4159f1e21f581ccdf90bcacf489580c8887931e5
    Reviewed-on: https://gerrit.libreoffice.org/81195
    Reviewed-by: Andras Timar <andras.timar at collabora.com>
    Tested-by: Andras Timar <andras.timar at collabora.com>

diff --git a/test/helpers.hpp b/test/helpers.hpp
index caa3390e3..6dfd5315e 100644
--- a/test/helpers.hpp
+++ b/test/helpers.hpp
@@ -708,20 +708,26 @@ inline void deleteAll(const std::shared_ptr<LOOLWebSocket>& socket, const std::s
 }
 
 inline std::string getAllText(const std::shared_ptr<LOOLWebSocket>& socket,
-                              const std::string& testname, int retry = COMMAND_RETRY_COUNT)
+                              const std::string& testname,
+                              const std::string expected = std::string(),
+                              int retry = COMMAND_RETRY_COUNT)
 {
-    std::string text;
+    static const std::string prefix = "textselectioncontent: ";
+
     for (int i = 0; i < retry; ++i)
     {
         selectAll(socket, testname);
 
         sendTextFrame(socket, "gettextselection mimetype=text/plain;charset=utf-8", testname);
-        text = assertResponseString(socket, "textselectioncontent:", testname);
+        const std::string text = getResponseString(socket, prefix, testname);
         if (!text.empty())
-            break;
+        {
+            if (expected.empty() || (prefix + expected) == text)
+                return text;
+        }
     }
 
-    return text;
+    return std::string();
 }
 
 }
diff --git a/test/httpwstest.cpp b/test/httpwstest.cpp
index d95c61a3a..8b3688166 100644
--- a/test/httpwstest.cpp
+++ b/test/httpwstest.cpp
@@ -701,8 +701,9 @@ void HTTPWSTest::testGetTextSelection()
         std::shared_ptr<LOOLWebSocket> socket = loadDocAndGetSocket(_uri, documentURL, testname);
         std::shared_ptr<LOOLWebSocket> socket2 = loadDocAndGetSocket(_uri, documentURL, testname);
 
-        const std::string selection = getAllText(socket, testname);
-        CPPUNIT_ASSERT_EQUAL(std::string("textselectioncontent: Hello world"), selection);
+        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)
     {
@@ -766,7 +767,7 @@ void HTTPWSTest::testSaveOnDisconnect()
         CPPUNIT_ASSERT_EQUAL(kitcount, countLoolKitProcesses(kitcount));
 
         // Check if the document contains the pasted text.
-        const std::string selection = getAllText(socket, testname);
+        const std::string selection = getAllText(socket, testname, text);
         CPPUNIT_ASSERT_EQUAL("textselectioncontent: " + text, selection);
     }
     catch (const Poco::Exception& exc)


More information about the Libreoffice-commits mailing list