[Libreoffice-commits] online.git: Branch 'distro/collabora/collabora-online-4' - test/helpers.hpp test/httpwstest.cpp
Libreoffice Gerrit user
logerrit at kemper.freedesktop.org
Fri May 3 12:07:09 UTC 2019
test/helpers.hpp | 24 ++++++++++++++++++++++++
test/httpwstest.cpp | 12 ++++++------
2 files changed, 30 insertions(+), 6 deletions(-)
New commits:
commit a932ac3c392bed7a95393cfe0f5333e84cb7c7f9
Author: Michael Meeks <michael.meeks at collabora.com>
AuthorDate: Thu May 2 16:14:12 2019 +0100
Commit: Jan Holesovsky <kendy at collabora.com>
CommitDate: Fri May 3 14:06:51 2019 +0200
tests: make SVG comparison tests much more helpful.
Dump the SVG we actually get as a .new file for easy upgrade and
comparison on mismatch.
Change-Id: I607a97ff27a9bf480524efc31877e46d74c5ee3d
Reviewed-on: https://gerrit.libreoffice.org/71680
Reviewed-by: Jan Holesovsky <kendy at collabora.com>
Tested-by: Jan Holesovsky <kendy at collabora.com>
diff --git a/test/helpers.hpp b/test/helpers.hpp
index 07e02a386..2c2ebdec4 100644
--- a/test/helpers.hpp
+++ b/test/helpers.hpp
@@ -643,6 +643,30 @@ inline void getServerVersion(std::shared_ptr<LOOLWebSocket>& socket,
}
+inline bool svgMatch(const char *testname, const std::vector<char> &response, const char *templateFile)
+{
+ const std::vector<char> expectedSVG = helpers::readDataFromFile(templateFile);
+ if (expectedSVG != response)
+ {
+ TST_LOG_BEGIN("Svg mismatch: response is\n");
+ if(response.empty())
+ TST_LOG_APPEND("<empty>");
+ else
+ TST_LOG_APPEND(std::string(response.data(), response.size()));
+ TST_LOG_APPEND("\nvs. expected (from '" << templateFile << "' :\n");
+ TST_LOG_APPEND(std::string(expectedSVG.data(), expectedSVG.size()));
+ std::string newName = templateFile;
+ newName += ".new";
+ TST_LOG_APPEND("Updated template writing to: " << newName << "\n");
+ TST_LOG_END;
+ FILE *of = fopen(Poco::Path(TDOC, newName).toString().c_str(), "w");
+ fwrite(response.data(), response.size(), 1, of);
+ fclose(of);
+ return false;
+ }
+ return true;
+}
+
#endif
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/test/httpwstest.cpp b/test/httpwstest.cpp
index 1a9a94430..7352a9574 100644
--- a/test/httpwstest.cpp
+++ b/test/httpwstest.cpp
@@ -2729,6 +2729,7 @@ void HTTPWSTest::testRenderShapeSelectionImpress()
std::shared_ptr<LOOLWebSocket> socket = loadDocAndGetSocket(_uri, documentURL, testname);
sendTextFrame(socket, "uno .uno:SelectAll", testname);
+ std::this_thread::sleep_for(std::chrono::milliseconds(250));
sendTextFrame(socket, "rendershapeselection mimetype=image/svg+xml", testname);
std::vector<char> responseSVG = getResponseMessage(socket, "shapeselectioncontent:", testname);
CPPUNIT_ASSERT(!responseSVG.empty());
@@ -2736,8 +2737,7 @@ void HTTPWSTest::testRenderShapeSelectionImpress()
if (it != responseSVG.end())
responseSVG.erase(responseSVG.begin(), ++it);
- const std::vector<char> expectedSVG = helpers::readDataFromFile("shapes_impress.svg");
- CPPUNIT_ASSERT(expectedSVG == responseSVG);
+ CPPUNIT_ASSERT(svgMatch(testname, responseSVG, "shapes_impress.svg"));
}
catch (const Poco::Exception& exc)
{
@@ -2757,6 +2757,7 @@ void HTTPWSTest::testRenderShapeSelectionWriter()
// Select the shape with SHIFT + F4
sendKeyPress(socket, 0, 771 | skShift, testname);
+ std::this_thread::sleep_for(std::chrono::milliseconds(250));
sendTextFrame(socket, "rendershapeselection mimetype=image/svg+xml", testname);
std::vector<char> responseSVG = getResponseMessage(socket, "shapeselectioncontent:", testname);
CPPUNIT_ASSERT(!responseSVG.empty());
@@ -2764,8 +2765,7 @@ void HTTPWSTest::testRenderShapeSelectionWriter()
if (it != responseSVG.end())
responseSVG.erase(responseSVG.begin(), ++it);
- const std::vector<char> expectedSVG = helpers::readDataFromFile("shape_writer.svg");
- CPPUNIT_ASSERT(expectedSVG == responseSVG);
+ CPPUNIT_ASSERT(svgMatch(testname, responseSVG, "shapes_writer.svg"));
}
catch (const Poco::Exception& exc)
{
@@ -2785,6 +2785,7 @@ void HTTPWSTest::testRenderShapeSelectionWriterImage()
// Select the shape with SHIFT + F4
sendKeyPress(socket, 0, 771 | skShift, testname);
+ std::this_thread::sleep_for(std::chrono::milliseconds(250));
sendTextFrame(socket, "rendershapeselection mimetype=image/svg+xml", testname);
std::vector<char> responseSVG = getResponseMessage(socket, "shapeselectioncontent:", testname);
CPPUNIT_ASSERT(!responseSVG.empty());
@@ -2792,8 +2793,7 @@ void HTTPWSTest::testRenderShapeSelectionWriterImage()
if (it != responseSVG.end())
responseSVG.erase(responseSVG.begin(), ++it);
- const std::vector<char> expectedSVG = helpers::readDataFromFile("non_shape_writer_image.svg");
- CPPUNIT_ASSERT(expectedSVG == responseSVG);
+ CPPUNIT_ASSERT(svgMatch(testname, responseSVG, "non_shape_writer_image.svg"));
}
catch (const Poco::Exception& exc)
{
More information about the Libreoffice-commits
mailing list