summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorMichael Meeks <michael.meeks@collabora.com>2019-12-12 05:33:09 +0000
committerMichael Meeks <michael.meeks@collabora.com>2019-12-12 08:57:28 +0100
commitf95cc10438f0cc3d584a6badc33256eb548db4e3 (patch)
treec532cf199265022a1d0a6a15dfb9362459f8b667 /test
parent948b424abbb3ee493d148896492d18186e3507f2 (diff)
A new convert-to unit test, hopefully taking longer to load.
Change-Id: I8d8291e272a175ab3c846b692bb34b185b2b8278 Reviewed-on: https://gerrit.libreoffice.org/85008 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com> Reviewed-by: Michael Meeks <michael.meeks@collabora.com>
Diffstat (limited to 'test')
-rw-r--r--test/data/convert-to.xlsxbin0 -> 6056 bytes
-rw-r--r--test/integration-http-server.cpp40
2 files changed, 40 insertions, 0 deletions
diff --git a/test/data/convert-to.xlsx b/test/data/convert-to.xlsx
new file mode 100644
index 000000000..7af9e7063
--- /dev/null
+++ b/test/data/convert-to.xlsx
Binary files differ
diff --git a/test/integration-http-server.cpp b/test/integration-http-server.cpp
index c19c57904..a2ceaca92 100644
--- a/test/integration-http-server.cpp
+++ b/test/integration-http-server.cpp
@@ -51,6 +51,7 @@ class HTTPServerTest : public CPPUNIT_NS::TestFixture
CPPUNIT_TEST(testScriptsAndLinksGet);
CPPUNIT_TEST(testScriptsAndLinksPost);
CPPUNIT_TEST(testConvertTo);
+ CPPUNIT_TEST(testConvertTo2);
CPPUNIT_TEST(testConvertToWithForwardedClientIP);
CPPUNIT_TEST_SUITE_END();
@@ -62,6 +63,7 @@ class HTTPServerTest : public CPPUNIT_NS::TestFixture
void testScriptsAndLinksGet();
void testScriptsAndLinksPost();
void testConvertTo();
+ void testConvertTo2();
void testConvertToWithForwardedClientIP();
public:
@@ -375,6 +377,44 @@ void HTTPServerTest::testConvertTo()
CPPUNIT_ASSERT_EQUAL(expectedStream.str(), actualString);
}
+void HTTPServerTest::testConvertTo2()
+{
+ const std::string srcPath = FileUtil::getTempFilePath(TDOC, "convert-to.xlsx", "convertTo_");
+ std::unique_ptr<Poco::Net::HTTPClientSession> session(helpers::createSession(_uri));
+ session->setTimeout(Poco::Timespan(5, 0)); // 5 seconds.
+
+ Poco::Net::HTTPRequest request(Poco::Net::HTTPRequest::HTTP_POST, "/lool/convert-to");
+ Poco::Net::HTMLForm form;
+ form.setEncoding(Poco::Net::HTMLForm::ENCODING_MULTIPART);
+ form.set("format", "png");
+ form.addPart("data", new Poco::Net::FilePartSource(srcPath));
+ form.prepareSubmit(request);
+ try
+ {
+ form.write(session->sendRequest(request));
+ }
+ catch (const std::exception& ex)
+ {
+ // In case the server is still starting up.
+ sleep(2);
+ form.write(session->sendRequest(request));
+ }
+
+ Poco::Net::HTTPResponse response;
+ std::stringstream actualStream;
+ std::istream& responseStream = session->receiveResponse(response);
+ Poco::StreamCopier::copyStream(responseStream, actualStream);
+
+ // Remove the temp files.
+ FileUtil::removeFile(srcPath);
+
+ std::string actualString = actualStream.str();
+ CPPUNIT_ASSERT(actualString.size() >= 100);
+// CPPUNIT_ASSERT_EQUAL(actualString[0], 0x89);
+ CPPUNIT_ASSERT_EQUAL(actualString[1], 'P');
+ CPPUNIT_ASSERT_EQUAL(actualString[2], 'N');
+ CPPUNIT_ASSERT_EQUAL(actualString[3], 'G');
+}
void HTTPServerTest::testConvertToWithForwardedClientIP()
{