[Libreoffice-commits] online.git: test/httpwstest.cpp

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Thu May 9 08:30:50 UTC 2019


 test/httpwstest.cpp |   27 +++++++++++++++++++++++++++
 1 file changed, 27 insertions(+)

New commits:
commit 0fbabb7a22b1213afe7e3f1b071c4c2876b20584
Author:     Miklos Vajna <vmiklos at collabora.com>
AuthorDate: Thu May 9 10:30:11 2019 +0200
Commit:     Miklos Vajna <vmiklos at collabora.com>
CommitDate: Thu May 9 10:30:11 2019 +0200

    test: fix HTTPWSTest::testRenderShapeSelectionWriter() failure with ...
    
    ... debug core.git.
    
    SVGActionWriter::ImplWriteActions() in core.git writes additional <desc>
    XML elements, guarded with a '#if OSL_DEBUG_LEVEL > 0' block.
    
    Filter these out, so the reference SVG will match both product and debug
    builds.
    
    Change-Id: Iba3fb25af206c70d5a4ff5801a934dcfd74704de

diff --git a/test/httpwstest.cpp b/test/httpwstest.cpp
index 687f46ae7..38524bd73 100644
--- a/test/httpwstest.cpp
+++ b/test/httpwstest.cpp
@@ -52,6 +52,31 @@
 
 using namespace helpers;
 
+namespace
+{
+/**
+ * Strips <desc>...</desc> strings from an SVG, some of which are only in debug builds, so breaks
+ * comparison with a fixed reference.
+ */
+void stripDescriptions(std::vector<char>& svg)
+{
+    while (true)
+    {
+        std::string startDesc("<desc>");
+        auto itStart = std::search(svg.begin(), svg.end(), startDesc.begin(), startDesc.end());
+        if (itStart == svg.end())
+            return;
+
+        std::string endDesc("</desc>");
+        auto itEnd = std::search(svg.begin(), svg.end(), endDesc.begin(), endDesc.end());
+        if (itEnd == svg.end())
+            return;
+
+        svg.erase(itStart, itEnd + endDesc.size());
+    }
+}
+}
+
 /// Tests the HTTP WebSocket API of loolwsd. The server has to be started manually before running this test.
 class HTTPWSTest : public CPPUNIT_NS::TestFixture
 {
@@ -2775,6 +2800,8 @@ void HTTPWSTest::testRenderShapeSelectionWriter()
         if (it != responseSVG.end())
             responseSVG.erase(responseSVG.begin(), ++it);
 
+        stripDescriptions(responseSVG);
+
         CPPUNIT_ASSERT(svgMatch(testname, responseSVG, "shapes_writer.svg"));
     }
     catch (const Poco::Exception& exc)


More information about the Libreoffice-commits mailing list