test/helpers.hpp | 24 ++++++++++++++++++++++++ test/httpwstest.cpp | 12 ++++++------ 2 files changed, 30 insertions(+), 6 deletions(-)
New commits: commit 5406a25b24bd76cb3de907527153ebed15e8d26e Author: Michael Meeks <michael.me...@collabora.com> AuthorDate: Thu May 2 16:14:12 2019 +0100 Commit: Michael Meeks <michael.me...@collabora.com> CommitDate: Thu May 2 17:16:08 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/71681 Reviewed-by: Michael Meeks <michael.me...@collabora.com> Tested-by: Michael Meeks <michael.me...@collabora.com> diff --git a/test/helpers.hpp b/test/helpers.hpp index 592d61b0e..2445ef3d2 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 8a4f23c38..687f46ae7 100644 --- a/test/httpwstest.cpp +++ b/test/httpwstest.cpp @@ -2739,6 +2739,7 @@ void HTTPWSTest::testRenderShapeSelectionImpress() } 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()); @@ -2746,8 +2747,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) { @@ -2767,6 +2767,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()); @@ -2774,8 +2775,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) { @@ -2795,6 +2795,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()); @@ -2802,8 +2803,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) { _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits