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

Ashod Nakashian ashod.nakashian at collabora.co.uk
Mon Aug 22 04:38:46 UTC 2016


 loolwsd/test/helpers.hpp    |    6 ++++++
 loolwsd/test/httpwstest.cpp |   27 +++++++++++++++++++++++++++
 2 files changed, 33 insertions(+)

New commits:
commit b9a2d7fcafd412b8eb8b8c6b4e9b1fede658d49b
Author: Ashod Nakashian <ashod.nakashian at collabora.co.uk>
Date:   Wed Aug 17 23:52:55 2016 -0400

    loolwsd: unit-test misbehaving client that connects without loading
    
    Change-Id: I1cef429a9310450c1b317f65475536db5d8a8306
    Reviewed-on: https://gerrit.libreoffice.org/28289
    Reviewed-by: Ashod Nakashian <ashnakash at gmail.com>
    Tested-by: Ashod Nakashian <ashnakash at gmail.com>

diff --git a/loolwsd/test/helpers.hpp b/loolwsd/test/helpers.hpp
index 61bcb89..43eebff 100644
--- a/loolwsd/test/helpers.hpp
+++ b/loolwsd/test/helpers.hpp
@@ -156,6 +156,12 @@ bool isDocumentLoaded(Poco::Net::WebSocket& ws, const std::string& name = "", bo
 }
 
 inline
+bool isDocumentLoaded(std::shared_ptr<Poco::Net::WebSocket>& ws, const std::string& name = "", bool isView = false)
+{
+    return isDocumentLoaded(*ws, name, isView);
+}
+
+inline
 Poco::Net::HTTPClientSession* createSession(const Poco::URI& uri)
 {
 #if ENABLE_SSL
diff --git a/loolwsd/test/httpwstest.cpp b/loolwsd/test/httpwstest.cpp
index df97acd..73c4f2c 100644
--- a/loolwsd/test/httpwstest.cpp
+++ b/loolwsd/test/httpwstest.cpp
@@ -60,6 +60,7 @@ class HTTPWSTest : public CPPUNIT_NS::TestFixture
     CPPUNIT_TEST(testBadRequest);
     CPPUNIT_TEST(testHandShake);
     CPPUNIT_TEST(testCloseAfterClose);
+    CPPUNIT_TEST(testConnectNoLoad);
     CPPUNIT_TEST(testLoad);
     CPPUNIT_TEST(testBadLoad);
     CPPUNIT_TEST(testReload);
@@ -94,6 +95,7 @@ class HTTPWSTest : public CPPUNIT_NS::TestFixture
     void testBadRequest();
     void testHandShake();
     void testCloseAfterClose();
+    void testConnectNoLoad();
     void testLoad();
     void testBadLoad();
     void testReload();
@@ -365,6 +367,31 @@ void HTTPWSTest::loadDoc(const std::string& documentURL)
     }
 }
 
+void HTTPWSTest::testConnectNoLoad()
+{
+    std::string documentPath, documentURL;
+    getDocumentPathAndURL("hello.odt", documentPath, documentURL);
+
+    Poco::Net::HTTPRequest request(Poco::Net::HTTPRequest::HTTP_GET, documentURL);
+    auto socket = connectLOKit(_uri, request, _response);
+    CPPUNIT_ASSERT_MESSAGE("Failed to connect.", socket);
+    socket.reset();
+
+    // Connect and load first view.
+    auto socket1 = connectLOKit(_uri, request, _response);
+    CPPUNIT_ASSERT_MESSAGE("Failed to connect.", socket1);
+    sendTextFrame(socket1, "load url=" + documentURL);
+    CPPUNIT_ASSERT_MESSAGE("cannot load the document " + documentURL, isDocumentLoaded(socket1));
+
+    // Connect but don't load second view.
+    auto socket2 = connectLOKit(_uri, request, _response);
+    CPPUNIT_ASSERT_MESSAGE("Failed to connect.", socket2);
+    socket2.reset();
+
+    sendTextFrame(socket1, "status");
+    assertResponseLine(socket1, "status:");
+}
+
 void HTTPWSTest::testLoad()
 {
     std::string documentPath, documentURL;


More information about the Libreoffice-commits mailing list