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

Henry Castro hcastro at collabora.com
Wed May 25 23:56:49 UTC 2016


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

New commits:
commit 39fe4e5580fa7fda76163ddd4d8a7a02889ec664
Author: Henry Castro <hcastro at collabora.com>
Date:   Wed May 25 19:57:35 2016 -0400

    loolwsd: test: add testFontList

diff --git a/loolwsd/test/httpwstest.cpp b/loolwsd/test/httpwstest.cpp
index 43bd94a..e1111a6 100644
--- a/loolwsd/test/httpwstest.cpp
+++ b/loolwsd/test/httpwstest.cpp
@@ -81,6 +81,7 @@ class HTTPWSTest : public CPPUNIT_NS::TestFixture
     CPPUNIT_TEST(testInsertAnnotationWriter);
     CPPUNIT_TEST(testEditAnnotationWriter);
     CPPUNIT_TEST(testInsertAnnotationCalc);
+    CPPUNIT_TEST(testFontList);
 
     CPPUNIT_TEST_SUITE_END();
 
@@ -111,6 +112,7 @@ class HTTPWSTest : public CPPUNIT_NS::TestFixture
     void testInsertAnnotationWriter();
     void testEditAnnotationWriter();
     void testInsertAnnotationCalc();
+    void testFontList();
 
     void loadDoc(const std::string& documentURL);
 
@@ -129,6 +131,9 @@ class HTTPWSTest : public CPPUNIT_NS::TestFixture
                                              int docWidth, int docHeight)> keyhandler,
                           std::function<void(int docWidth, int docHeight,
                                              int newWidth, int newHeight)> checkhandler);
+
+    std::string getFontList(const std::string& message);
+
 public:
     HTTPWSTest()
         : _uri(helpers::getTestServerURI())
@@ -1523,6 +1528,50 @@ void HTTPWSTest::testInsertAnnotationCalc()
     CPPUNIT_ASSERT_EQUAL(std::string("textselectioncontent: aaa bbb ccc"), res);
 }
 
+std::string HTTPWSTest::getFontList(const std::string& message)
+{
+    Poco::JSON::Parser parser;
+    std::cerr << " trace FontList " << message << std::endl;
+    const auto result = parser.parse(message);
+    const auto& command = result.extract<Poco::JSON::Object::Ptr>();
+    auto text = command->get("commandName").toString();
+    CPPUNIT_ASSERT_EQUAL(std::string(".uno:CharFontName"), text);
+    text = command->get("commandValues").toString();
+    return text;
+}
+
+void HTTPWSTest::testFontList()
+{
+    try
+    {
+        // Load a document
+        std::string documentPath, documentURL;
+        std::string text;
+        std::vector<char> response;
+
+        getDocumentPathAndURL("setclientpart.odp", documentPath, documentURL);
+        Poco::Net::HTTPRequest request(Poco::Net::HTTPRequest::HTTP_GET, documentURL);
+        Poco::Net::WebSocket socket = *connectLOKit(_uri, request, _response);
+
+        sendTextFrame(socket, "load url=" + documentURL);
+        CPPUNIT_ASSERT_MESSAGE("cannot load the document " + documentURL, isDocumentLoaded(socket));
+
+        sendTextFrame(socket, "commandvalues command=.uno:CharFontName");
+        response = getResponseMessage(socket, "commandvalues:", "testFontList ");
+        CPPUNIT_ASSERT_MESSAGE("did not receive a commandvalues: message as expected", !response.empty());
+
+        std::stringstream streamResponse;
+        std::copy(response.begin() + std::string("commandvalues:").length() + 1, response.end(), std::ostream_iterator<char>(streamResponse));
+        text = getFontList(streamResponse.str());
+        CPPUNIT_ASSERT(!text.empty());
+        std::cerr << "testFontNames : " << text << std::endl;
+    }
+    catch (const Poco::Exception& exc)
+    {
+        CPPUNIT_FAIL(exc.displayText());
+    }
+}
+
 CPPUNIT_TEST_SUITE_REGISTRATION(HTTPWSTest);
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */


More information about the Libreoffice-commits mailing list