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

Tor Lillqvist tml at collabora.com
Thu Oct 6 09:16:03 UTC 2016


 loolwsd/test/httpwstest.cpp |   20 +++++---------------
 1 file changed, 5 insertions(+), 15 deletions(-)

New commits:
commit d7cabad884e2f1885c6df111a13d95027954812a
Author: Tor Lillqvist <tml at collabora.com>
Date:   Thu Oct 6 11:32:22 2016 +0300

    We don't care that much about the distinction of TEXT vs BINARY frames
    
    We shouldn't assert such details.
    
    protocol.txt says:
    
        The WebSocket distinction between 'text' and 'binary' frames has
        no meaning for us for messages that don't contain additional
        binary data; such messages can be either 'binary' or 'text' from
        the WebSocket point of view even if we require them (the single
        line) to be UTF-8. In other words, an implementation is free to
        send such a single-line message as a WebSocket 'binary' frame, and
        the receiving implementation must treat that equally as if it was
        a 'text' frame.

diff --git a/loolwsd/test/httpwstest.cpp b/loolwsd/test/httpwstest.cpp
index 69e9d6a..36d742a 100644
--- a/loolwsd/test/httpwstest.cpp
+++ b/loolwsd/test/httpwstest.cpp
@@ -255,25 +255,21 @@ void HTTPWSTest::testHandShake()
         char buffer[1024] = {0};
         int bytes = socket.receiveFrame(buffer, sizeof(buffer), flags);
         CPPUNIT_ASSERT_EQUAL(std::string("statusindicator: find"), std::string(buffer, bytes));
-        CPPUNIT_ASSERT_EQUAL(static_cast<int>(Poco::Net::WebSocket::FRAME_TEXT), flags & Poco::Net::WebSocket::FRAME_TEXT);
 
         bytes = socket.receiveFrame(buffer, sizeof(buffer), flags);
         if (bytes > 0 && !std::strstr(buffer, "error:"))
         {
             CPPUNIT_ASSERT_EQUAL(std::string("statusindicator: connect"), std::string(buffer, bytes));
-            CPPUNIT_ASSERT_EQUAL(static_cast<int>(Poco::Net::WebSocket::FRAME_TEXT), flags & Poco::Net::WebSocket::FRAME_TEXT);
 
             bytes = socket.receiveFrame(buffer, sizeof(buffer), flags);
             if (!std::strstr(buffer, "error:"))
             {
                 CPPUNIT_ASSERT_EQUAL(std::string("statusindicator: ready"), std::string(buffer, bytes));
-                CPPUNIT_ASSERT_EQUAL(static_cast<int>(Poco::Net::WebSocket::FRAME_TEXT), flags & Poco::Net::WebSocket::FRAME_TEXT);
             }
             else
             {
                 // check error message
                 CPPUNIT_ASSERT(std::strstr(buffer, SERVICE_UNAVALABLE_INTERNAL_ERROR) != nullptr);
-                CPPUNIT_ASSERT_EQUAL(static_cast<int>(Poco::Net::WebSocket::FRAME_TEXT), flags & Poco::Net::WebSocket::FRAME_TEXT);
 
                 // close frame message
                 bytes = socket.receiveFrame(buffer, sizeof(buffer), flags);
@@ -285,7 +281,6 @@ void HTTPWSTest::testHandShake()
         {
             // check error message
             CPPUNIT_ASSERT(std::strstr(buffer, SERVICE_UNAVALABLE_INTERNAL_ERROR) != nullptr);
-            CPPUNIT_ASSERT_EQUAL(static_cast<int>(Poco::Net::WebSocket::FRAME_TEXT), flags & Poco::Net::WebSocket::FRAME_TEXT);
 
             // close frame message
             bytes = socket.receiveFrame(buffer, sizeof(buffer), flags);
commit 7a3111632b41008fe8fbd0a597b4f74dc03ac97e
Author: Tor Lillqvist <tml at collabora.com>
Date:   Thu Oct 6 11:29:52 2016 +0300

    Prefer string literals to pointless variables

diff --git a/loolwsd/test/httpwstest.cpp b/loolwsd/test/httpwstest.cpp
index 00ecdfe..69e9d6a 100644
--- a/loolwsd/test/httpwstest.cpp
+++ b/loolwsd/test/httpwstest.cpp
@@ -239,7 +239,6 @@ void HTTPWSTest::testBadRequest()
 
 void HTTPWSTest::testHandShake()
 {
-    static const char* fail = "error:";
     try
     {
         std::string documentPath, documentURL;
@@ -252,26 +251,22 @@ void HTTPWSTest::testHandShake()
         Poco::Net::WebSocket socket(*session, request, response);
         socket.setReceiveTimeout(0);
 
-        std::string payload("statusindicator: find");
-
         int flags = 0;
         char buffer[1024] = {0};
         int bytes = socket.receiveFrame(buffer, sizeof(buffer), flags);
-        CPPUNIT_ASSERT_EQUAL(payload, std::string(buffer, bytes));
+        CPPUNIT_ASSERT_EQUAL(std::string("statusindicator: find"), std::string(buffer, bytes));
         CPPUNIT_ASSERT_EQUAL(static_cast<int>(Poco::Net::WebSocket::FRAME_TEXT), flags & Poco::Net::WebSocket::FRAME_TEXT);
 
         bytes = socket.receiveFrame(buffer, sizeof(buffer), flags);
-        if (bytes > 0 && !std::strstr(buffer, fail))
+        if (bytes > 0 && !std::strstr(buffer, "error:"))
         {
-            payload = "statusindicator: connect";
-            CPPUNIT_ASSERT_EQUAL(payload, std::string(buffer, bytes));
+            CPPUNIT_ASSERT_EQUAL(std::string("statusindicator: connect"), std::string(buffer, bytes));
             CPPUNIT_ASSERT_EQUAL(static_cast<int>(Poco::Net::WebSocket::FRAME_TEXT), flags & Poco::Net::WebSocket::FRAME_TEXT);
 
             bytes = socket.receiveFrame(buffer, sizeof(buffer), flags);
-            if (!std::strstr(buffer, fail))
+            if (!std::strstr(buffer, "error:"))
             {
-                payload = "statusindicator: ready";
-                CPPUNIT_ASSERT_EQUAL(payload, std::string(buffer, bytes));
+                CPPUNIT_ASSERT_EQUAL(std::string("statusindicator: ready"), std::string(buffer, bytes));
                 CPPUNIT_ASSERT_EQUAL(static_cast<int>(Poco::Net::WebSocket::FRAME_TEXT), flags & Poco::Net::WebSocket::FRAME_TEXT);
             }
             else


More information about the Libreoffice-commits mailing list