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

New commits:
commit d6306c5388b3d4bf964463020fd2c68898b54b0a
Author:     Ashod Nakashian <ashod.nakash...@collabora.co.uk>
AuthorDate: Sat Oct 19 12:32:43 2019 -0400
Commit:     Ashod Nakashian <ashnak...@gmail.com>
CommitDate: Tue Oct 29 02:31:01 2019 +0100

    test: improve getAllText to match an expected payload
    
    Change-Id: I4159f1e21f581ccdf90bcacf489580c8887931e5
    Reviewed-on: https://gerrit.libreoffice.org/81195
    Reviewed-by: Andras Timar <andras.ti...@collabora.com>
    Tested-by: Andras Timar <andras.ti...@collabora.com>
    (cherry picked from commit 9903229918d07eee2f6c1ad22ee5a287f4fd0884)
    Reviewed-on: https://gerrit.libreoffice.org/81571
    Reviewed-by: Ashod Nakashian <ashnak...@gmail.com>
    Tested-by: Ashod Nakashian <ashnak...@gmail.com>

diff --git a/test/helpers.hpp b/test/helpers.hpp
index 30d20d3d8..6084e3337 100644
--- a/test/helpers.hpp
+++ b/test/helpers.hpp
@@ -729,20 +729,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 d9a4727cf..a6e2c2f59 100644
--- a/test/httpwstest.cpp
+++ b/test/httpwstest.cpp
@@ -515,8 +515,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)
     {
@@ -580,7 +581,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)
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to