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

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


 loolwsd/test/httpwstest.cpp |   50 ++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 50 insertions(+)

New commits:
commit 4cba61525c31beee119c021d3075183a12d8b4f0
Author: Ashod Nakashian <ashod.nakashian at collabora.co.uk>
Date:   Mon May 9 00:48:30 2016 -0400

    loolwsd: test notification replay on re-activation
    
    Change-Id: I46471a2a3ecce219cf1b922aeebf0fdb02f66614
    Reviewed-on: https://gerrit.libreoffice.org/24783
    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 b1e6c5e..d760157 100644
--- a/loolwsd/test/httpwstest.cpp
+++ b/loolwsd/test/httpwstest.cpp
@@ -75,6 +75,7 @@ class HTTPWSTest : public CPPUNIT_NS::TestFixture
     CPPUNIT_TEST(testInsertDelete);
     CPPUNIT_TEST(testEditLock);
     CPPUNIT_TEST(testSlideShow);
+    CPPUNIT_TEST(testInactiveClient);
 
     CPPUNIT_TEST_SUITE_END();
 
@@ -99,6 +100,7 @@ class HTTPWSTest : public CPPUNIT_NS::TestFixture
     void testNoExtraLoolKitsLeft();
     void testEditLock();
     void testSlideShow();
+    void testInactiveClient();
 
     void loadDoc(const std::string& documentURL);
 
@@ -1129,6 +1131,54 @@ void HTTPWSTest::testSlideShow()
     }
 }
 
+void HTTPWSTest::testInactiveClient()
+{
+    try
+    {
+        std::string documentPath, documentURL;
+        getDocumentPathAndURL("hello.odt", documentPath, documentURL);
+        Poco::Net::HTTPRequest request(Poco::Net::HTTPRequest::HTTP_GET, documentURL);
+
+        auto socket1 = loadDocAndGetSocket(_uri, documentURL);
+        getResponseMessage(socket1, "invalidatetiles");
+
+        // Connect another and go inactive.
+        std::cerr << "Connecting second client." << std::endl;
+        auto socket2 = loadDocAndGetSocket(_uri, documentURL);
+        getResponseMessage(socket2, "status");
+        sendTextFrame(socket2, "userinactive");
+
+        // While second is inactive, make some changes.
+        sendTextFrame(socket1, "uno .uno:SelectAll");
+        sendTextFrame(socket1, "uno .uno:Delete");
+
+        // Activate second.
+        sendTextFrame(socket2, "useractive");
+        SocketProcessor("Second", socket2, [&](const std::string& msg)
+                {
+                    const auto token = LOOLProtocol::getFirstToken(msg);
+                    CPPUNIT_ASSERT_MESSAGE("unexpected message: " + msg,
+                                            token == "textselection:" ||
+                                            token == "textselectionstart:" ||
+                                            token == "textselectionend:" ||
+                                            token == "invalidatetiles:" ||
+                                            token == "invalidatecursor:" ||
+                                            token == "statechanged:");
+
+                    // End when we get state changed.
+                    return (token != "statechanged:");
+                });
+
+        std::cerr << "Second client finished." << std::endl;
+        socket1->shutdown();
+        socket2->shutdown();
+    }
+    catch (const Poco::Exception& exc)
+    {
+        CPPUNIT_FAIL(exc.displayText());
+    }
+}
+
 void HTTPWSTest::testNoExtraLoolKitsLeft()
 {
     const auto countNow = countLoolKitProcesses(_initialLoolKitCount);


More information about the Libreoffice-commits mailing list