[Libreoffice-commits] online.git: loolwsd/test
Henry Castro
hcvcastro at gmail.com
Wed May 4 20:20:17 UTC 2016
loolwsd/test/httpwstest.cpp | 61 ++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 61 insertions(+)
New commits:
commit 4d52c200c52c1bc6f3bce7ff93709994aa005491
Author: Henry Castro <hcvcastro at gmail.com>
Date: Wed May 4 16:19:47 2016 -0400
loolwsd: test: add testSlideShow
diff --git a/loolwsd/test/httpwstest.cpp b/loolwsd/test/httpwstest.cpp
index 6057dbc..73878b1 100644
--- a/loolwsd/test/httpwstest.cpp
+++ b/loolwsd/test/httpwstest.cpp
@@ -77,6 +77,7 @@ class HTTPWSTest : public CPPUNIT_NS::TestFixture
CPPUNIT_TEST(testPasswordProtectedDocumentWithCorrectPasswordAgain);
CPPUNIT_TEST(testInsertDelete);
CPPUNIT_TEST(testEditLock);
+ CPPUNIT_TEST(testSlideShow);
// This should be the last test:
CPPUNIT_TEST(testNoExtraLoolKitsLeft);
@@ -103,6 +104,7 @@ class HTTPWSTest : public CPPUNIT_NS::TestFixture
void testInsertDelete();
void testNoExtraLoolKitsLeft();
void testEditLock();
+ void testSlideShow();
void loadDoc(const std::string& documentURL);
@@ -1101,6 +1103,65 @@ void HTTPWSTest::testEditLock()
}
}
+void HTTPWSTest::testSlideShow()
+{
+ try
+ {
+ const std::string jail = "jail=";
+ const std::string dir = "dir=";
+ const std::string name = "name=";
+ const std::string port = "port=";
+ const std::string id = "id=";
+
+ // Load a document
+ std::string documentPath, documentURL;
+ std::string 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));
+
+ // request slide show
+ sendTextFrame(socket, "downloadas name=slideshow.svg id=slideshow format=svg options=");
+ getResponseMessage(socket, "downloadas:", response, false);
+ CPPUNIT_ASSERT_MESSAGE("did not receive a downloadas: message as expected", !response.empty());
+ {
+ Poco::StringTokenizer tokens(response, " ", Poco::StringTokenizer::TOK_IGNORE_EMPTY | Poco::StringTokenizer::TOK_TRIM);
+ // "downloadas: jail= dir= name=slideshow.svg port= id=slideshow"
+ const std::string jail = tokens[0].substr(std::string("jail=").size());
+ const std::string dir = tokens[1].substr(std::string("dir=").size());
+ const std::string name = tokens[2].substr(std::string("name=").size());
+ const int port = std::stoi(tokens[3].substr(std::string("port=").size()));
+ const std::string id = tokens[4].substr(std::string("id=").size());
+ CPPUNIT_ASSERT(!jail.empty());
+ CPPUNIT_ASSERT(!dir.empty());
+ CPPUNIT_ASSERT_EQUAL(std::string("slideshow.svg"), name);
+ CPPUNIT_ASSERT_EQUAL(static_cast<int>(_uri.getPort()), port);
+ CPPUNIT_ASSERT_EQUAL(std::string("slideshow"), id);
+
+ const std::string path = "/" + jail + "/" + dir + "/" + name + "?mime_type=image/svg%2Bxml";
+ std::unique_ptr<Poco::Net::HTTPClientSession> session(helpers::createSession(_uri));
+ Poco::Net::HTTPRequest request(Poco::Net::HTTPRequest::HTTP_GET, path);
+ session->sendRequest(request);
+
+ Poco::Net::HTTPResponse response;
+ session->receiveResponse(response);
+ CPPUNIT_ASSERT_EQUAL(Poco::Net::HTTPResponse::HTTP_OK, response.getStatus());
+ CPPUNIT_ASSERT_EQUAL(std::string("image/svg+xml"), response.getContentType());
+
+ socket.shutdown();
+ Util::removeFile(documentPath);
+ }
+ }
+ 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