summaryrefslogtreecommitdiff
path: root/svgio/qa
diff options
context:
space:
mode:
authorXisco Fauli <anistenis@gmail.com>2016-04-14 23:44:38 +0200
committerXisco Faulí <anistenis@gmail.com>2016-04-15 08:05:10 +0000
commit3daee9953da215fb7c0740259dcb37713dd17cd1 (patch)
tree63e74cda2b38ffe9944d0b6432cf9639b512da83 /svgio/qa
parentc65f6dfb9fdc77ec9004339c1970e6950b0eab17 (diff)
SVG: Add unittest for ecc7f698b5f080530f006218fa3dd82da43d9abb
Change-Id: Icbfd60bd15196649011919e8dea064276e1964b0 Reviewed-on: https://gerrit.libreoffice.org/24097 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Xisco Faulí <anistenis@gmail.com>
Diffstat (limited to 'svgio/qa')
-rw-r--r--svgio/qa/cppunit/SvgImportTest.cxx17
-rw-r--r--svgio/qa/cppunit/data/maskText.svg26
2 files changed, 43 insertions, 0 deletions
diff --git a/svgio/qa/cppunit/SvgImportTest.cxx b/svgio/qa/cppunit/SvgImportTest.cxx
index 6ae57af10f88..e43c1b16ab27 100644
--- a/svgio/qa/cppunit/SvgImportTest.cxx
+++ b/svgio/qa/cppunit/SvgImportTest.cxx
@@ -59,6 +59,7 @@ class Test : public test::BootstrapFixture, public XmlTestTools
void testMaskingPath07b();
void test47446();
void test47446b();
+ void testMaskText();
Primitive2DSequence parseSvg(const char* aSource);
@@ -88,6 +89,7 @@ public:
CPPUNIT_TEST(testMaskingPath07b);
CPPUNIT_TEST(test47446);
CPPUNIT_TEST(test47446b);
+ CPPUNIT_TEST(testMaskText);
CPPUNIT_TEST_SUITE_END();
};
@@ -518,6 +520,21 @@ void Test::test47446b()
}
+void Test::testMaskText()
+{
+ //Check that mask is applied on text
+ Primitive2DSequence aSequenceMaskText = parseSvg("/svgio/qa/cppunit/data/maskText.svg");
+ CPPUNIT_ASSERT_EQUAL(1, (int)aSequenceMaskText.getLength());
+
+ Primitive2dXmlDump dumper;
+ xmlDocPtr pDocument = dumper.dumpAndParse(comphelper::sequenceToContainer<Primitive2DContainer>(aSequenceMaskText));
+
+ CPPUNIT_ASSERT (pDocument);
+
+ assertXPath(pDocument, "/primitive2D/transform/transform/polypolygoncolor", "color", "#000000");
+ assertXPath(pDocument, "/primitive2D/transform/transform/textsimpleportion", "text", "Black White");
+}
+
CPPUNIT_TEST_SUITE_REGISTRATION(Test);
}
diff --git a/svgio/qa/cppunit/data/maskText.svg b/svgio/qa/cppunit/data/maskText.svg
new file mode 100644
index 000000000000..7405f6a5697b
--- /dev/null
+++ b/svgio/qa/cppunit/data/maskText.svg
@@ -0,0 +1,26 @@
+<?xml version="1.0"?>
+<svg width="200" height="80"
+ viewBox="0 0 200 80" version="1.1"
+ xmlns="http://www.w3.org/2000/svg"
+ xmlns:xlink="http://www.w3.org/1999/xlink">
+
+ <defs>
+ <mask id="myMask"
+ x="0" y="0" width="200" height="80">
+ <rect x="0" y="0" width="100" height="80" fill="white"/>
+ </mask>
+
+ <text id="Text" x="100" y="48"
+ font-size="26" font-weight="bold" text-anchor="middle">
+ Black White
+ </text>
+ </defs>
+
+ <!-- Draw black rectangle in the background -->
+ <rect x="100" y="10" width="95" height="60" />
+
+ <!-- Draw the text string twice. First, the white text without mask.
+ Second, the black text with the mask applied-->
+ <use xlink:href="#Text" fill="white"/>
+ <use xlink:href="#Text" fill="black" mask="url(#myMask)"/>
+</svg>