[Libreoffice-commits] online.git: loolwsd/test
Henry Castro
hcastro at collabora.com
Wed Sep 7 16:20:27 UTC 2016
loolwsd/test/data/viewcursor.odp |binary
loolwsd/test/helpers.hpp | 1
loolwsd/test/httpwstest.cpp | 51 +++++++++++++++++++++++++++++++++++++++
3 files changed, 51 insertions(+), 1 deletion(-)
New commits:
commit d4d764cee580c30ab5cc776118ea6008ca40c7f2
Author: Henry Castro <hcastro at collabora.com>
Date: Wed Sep 7 12:21:34 2016 -0400
loolwsd: test: invalidate view cursor
diff --git a/loolwsd/test/data/viewcursor.odp b/loolwsd/test/data/viewcursor.odp
new file mode 100755
index 0000000..a6a3561
Binary files /dev/null and b/loolwsd/test/data/viewcursor.odp differ
diff --git a/loolwsd/test/helpers.hpp b/loolwsd/test/helpers.hpp
index 0a7d003..2401243 100644
--- a/loolwsd/test/helpers.hpp
+++ b/loolwsd/test/helpers.hpp
@@ -448,7 +448,6 @@ void parseDocSize(const std::string& message, const std::string& type,
int& part, int& parts, int& width, int& height, int& viewid)
{
Poco::StringTokenizer tokens(message, " ", Poco::StringTokenizer::TOK_IGNORE_EMPTY | Poco::StringTokenizer::TOK_TRIM);
- CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(6), tokens.count());
// Expected format is something like 'type= parts= current= width= height='.
const std::string text = tokens[0].substr(std::string("type=").size());
diff --git a/loolwsd/test/httpwstest.cpp b/loolwsd/test/httpwstest.cpp
index f28c5d1..4af1fea 100644
--- a/loolwsd/test/httpwstest.cpp
+++ b/loolwsd/test/httpwstest.cpp
@@ -89,6 +89,7 @@ class HTTPWSTest : public CPPUNIT_NS::TestFixture
CPPUNIT_TEST(testStateUnoCommand);
CPPUNIT_TEST(testColumnRowResize);
CPPUNIT_TEST(testOptimalResize);
+ CPPUNIT_TEST(testInvalidateViewCursor);
CPPUNIT_TEST_SUITE_END();
@@ -126,6 +127,7 @@ class HTTPWSTest : public CPPUNIT_NS::TestFixture
void testStateUnoCommand();
void testColumnRowResize();
void testOptimalResize();
+ void testInvalidateViewCursor();
void loadDoc(const std::string& documentURL);
@@ -2121,6 +2123,55 @@ void HTTPWSTest::testOptimalResize()
}
}
+void HTTPWSTest::testInvalidateViewCursor()
+{
+ try
+ {
+ int docSlide = -1;
+ int docSlides = 0;
+ int docHeight = 0;
+ int docWidth = 0;
+ int docViewId = -1;
+
+ // Load a document
+ std::string documentPath, documentURL, response, text;
+ getDocumentPathAndURL("viewcursor.odp", documentPath, documentURL);
+
+ Poco::Net::HTTPRequest request(Poco::Net::HTTPRequest::HTTP_GET, documentURL);
+ Poco::Net::WebSocket socket1 = *connectLOKit(_uri, request, _response);
+
+ sendTextFrame(socket1, "load url=" + documentURL);
+ CPPUNIT_ASSERT_MESSAGE("cannot load the document " + documentURL, isDocumentLoaded(socket1));
+
+ // Check document size
+ sendTextFrame(socket1, "status");
+ getResponseMessage(socket1, "status:", response, false);
+ CPPUNIT_ASSERT_MESSAGE("did not receive a status: message as expected", !response.empty());
+ parseDocSize(response, "presentation", docSlide, docSlides, docWidth, docHeight, docViewId);
+
+ // Click to show a cursor
+ Poco::format(text, "mouse type=%s x=%d y=%d count=1 buttons=1 modifier=0", std::string("buttondown"), docWidth/2, docHeight/6);
+ sendTextFrame(socket1, text); text.clear();
+ Poco::format(text, "mouse type=%s x=%d y=%d count=1 buttons=1 modifier=0", std::string("buttonup"), docWidth/2, docHeight/6);
+ sendTextFrame(socket1, text);
+ getResponseMessage(socket1, "invalidatecursor:", response, false);
+ CPPUNIT_ASSERT_MESSAGE("did not receive a invalidatecursor: message as expected", !response.empty());
+
+ // Connect and load second view.
+ Poco::Net::WebSocket socket2 = *connectLOKit(_uri, request, _response);
+ sendTextFrame(socket2, "load url=" + documentURL);
+ CPPUNIT_ASSERT_MESSAGE("cannot load the document " + documentURL, isDocumentLoaded(socket2, "", true));
+
+ // Expected to receive invalidateviewcursor second view
+ getResponseMessage(socket2, "invalidateviewcursor:", response, false);
+ CPPUNIT_ASSERT_MESSAGE("did not receive a invalidateviewcursor: message as expected", !response.empty());
+ }
+ 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