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

Ashod Nakashian ashod.nakashian at collabora.co.uk
Mon May 9 05:31:20 UTC 2016


 loolwsd/test/httpwstest.cpp |   24 +++++++++++++++++++++++-
 1 file changed, 23 insertions(+), 1 deletion(-)

New commits:
commit 1ab1511a0e65f16b141a48dcb861c5366b1df44b
Author: Ashod Nakashian <ashod.nakashian at collabora.co.uk>
Date:   Mon May 9 01:18:55 2016 -0400

    loolwsd: improved auto-save tests
    
    Change-Id: If24b5e4cb585ffc59d31583cb10dfa3e57dc3056
    Reviewed-on: https://gerrit.libreoffice.org/24787
    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 d760157..9432fb7 100644
--- a/loolwsd/test/httpwstest.cpp
+++ b/loolwsd/test/httpwstest.cpp
@@ -399,6 +399,7 @@ void HTTPWSTest::testSaveOnDisconnect()
     std::string documentPath, documentURL;
     getDocumentPathAndURL("hello.odt", documentPath, documentURL);
 
+    int kitcount = -1;
     try
     {
         // Load a document and get its status.
@@ -408,14 +409,26 @@ void HTTPWSTest::testSaveOnDisconnect()
         sendTextFrame(socket, "load url=" + documentURL);
         CPPUNIT_ASSERT_MESSAGE("cannot load the document " + documentURL, isDocumentLoaded(socket));
 
+        Poco::Net::WebSocket socket2 = *connectLOKit(_uri, request, _response);
+        sendTextFrame(socket2, "load url=" + documentURL);
+        CPPUNIT_ASSERT_MESSAGE("cannot load the document " + documentURL, isDocumentLoaded(socket2));
+        sendTextFrame(socket2, "userinactive");
+
         sendTextFrame(socket, "uno .uno:SelectAll");
         sendTextFrame(socket, "uno .uno:Delete");
         sendTextFrame(socket, "paste mimetype=text/plain;charset=utf-8\naaa bbb ccc");
 
+        // Closing connection too fast might not flush buffers.
+        // Often nothing more than the SelectAll reaches the server before
+        // the socket is closed, when the doc is not even modified yet.
+        getResponseMessage(socket, "statechanged");
         std::cerr << "Closing connection after pasting." << std::endl;
 
+        kitcount = getLoolKitProcessCount();
+
         // Shutdown abruptly.
         socket.shutdown();
+        socket2.shutdown();
     }
     catch (const Poco::Exception& exc)
     {
@@ -423,7 +436,7 @@ void HTTPWSTest::testSaveOnDisconnect()
     }
 
     // Allow time to save and destroy before we connect again.
-    sleep(5);
+    testNoExtraLoolKitsLeft();
     std::cerr << "Loading again." << std::endl;
     try
     {
@@ -435,6 +448,9 @@ void HTTPWSTest::testSaveOnDisconnect()
         sendTextFrame(socket, "status");
         CPPUNIT_ASSERT_MESSAGE("cannot load the document " + documentURL, isDocumentLoaded(socket));
 
+        // Should have no new instances.
+        CPPUNIT_ASSERT_EQUAL(kitcount, countLoolKitProcesses(kitcount));
+
         // Check if the document contains the pasted text.
         sendTextFrame(socket, "uno .uno:SelectAll");
         sendTextFrame(socket, "gettextselection mimetype=text/plain;charset=utf-8");
@@ -488,6 +504,12 @@ void HTTPWSTest::testReloadWhileDisconnecting()
         sendTextFrame(socket, "uno .uno:Delete");
         sendTextFrame(socket, "paste mimetype=text/plain;charset=utf-8\naaa bbb ccc");
 
+        // Closing connection too fast might not flush buffers.
+        // Often nothing more than the SelectAll reaches the server before
+        // the socket is closed, when the doc is not even modified yet.
+        getResponseMessage(socket, "statechanged");
+        std::cerr << "Closing connection after pasting." << std::endl;
+
         kitcount = getLoolKitProcessCount();
 
         // Shutdown abruptly.


More information about the Libreoffice-commits mailing list