[Libreoffice-commits] online.git: loolwsd/test

Ashod Nakashian ashod.nakashian at collabora.co.uk
Sat May 14 13:30:17 UTC 2016


 loolwsd/test/httpwstest.cpp |   32 +++++++++++---------------------
 1 file changed, 11 insertions(+), 21 deletions(-)

New commits:
commit 66549a68729d21f22421f20267aaa282daef22c9
Author: Ashod Nakashian <ashod.nakashian at collabora.co.uk>
Date:   Fri May 13 13:47:21 2016 -0400

    loolwsd: improve testLargePaste
    
    Change-Id: I789effb1b634c6cde04f936e1f1bc3a0a0868a69
    Reviewed-on: https://gerrit.libreoffice.org/24991
    Reviewed-by: Ashod Nakashian <ashnakash at gmail.com>
    Tested-by: Ashod Nakashian <ashnakash at gmail.com>

diff --git a/loolwsd/test/httpwstest.cpp b/loolwsd/test/httpwstest.cpp
index de1e66c..2515ed0 100644
--- a/loolwsd/test/httpwstest.cpp
+++ b/loolwsd/test/httpwstest.cpp
@@ -665,32 +665,22 @@ void HTTPWSTest::testLargePaste()
         sendTextFrame(socket, "uno .uno:Delete");
 
         // Paste some text into it.
-        std::ifstream documentStream(documentPath);
-        std::string documentContents((std::istreambuf_iterator<char>(documentStream)), std::istreambuf_iterator<char>());
+        std::ostringstream oss;
+        for (auto i = 0; i < 1000; ++i)
+        {
+            oss << Util::encodeId(Util::rng::getNext(), 6);
+        }
+        const auto documentContents = oss.str();
+        std::cerr << "Pasting " << documentContents.size() << " characters into document." << std::endl;
         sendTextFrame(socket, "paste mimetype=text/html\n" + documentContents);
 
         // Check if the server is still alive.
         // This resulted first in a hang, as respose for the message never arrived, then a bit later in a Poco::TimeoutException.
+        sendTextFrame(socket, "uno .uno:SelectAll");
         sendTextFrame(socket, "gettextselection mimetype=text/plain;charset=utf-8");
-        std::string selection;
-        int flags;
-        int n;
-        do
-        {
-            char buffer[READ_BUFFER_SIZE];
-            n = socket.receiveFrame(buffer, sizeof(buffer), flags);
-            if (n > 0 && (flags & Poco::Net::WebSocket::FRAME_OP_BITMASK) != Poco::Net::WebSocket::FRAME_OP_CLOSE)
-            {
-                std::cout << "Received message length " << n << ": " << LOOLProtocol::getAbbreviatedMessage(buffer, n) << '\n';
-                std::string line = LOOLProtocol::getFirstLine(buffer, n);
-                std::string prefix = "textselectioncontent: ";
-                if (line.find(prefix) == 0)
-                    break;
-            }
-        }
-        while (n > 0 && (flags & Poco::Net::WebSocket::FRAME_OP_BITMASK) != Poco::Net::WebSocket::FRAME_OP_CLOSE);
-        socket.shutdown();
-        Util::removeFile(documentPath);
+        const auto selection = assertResponseLine(socket, "textselectioncontent:");
+        CPPUNIT_ASSERT_MESSAGE("Pasted text was either corrupted or couldn't be read back",
+                               "textselectioncontent: " + documentContents == selection);
     }
     catch (const Poco::Exception& exc)
     {


More information about the Libreoffice-commits mailing list