diff options
author | panoskorovesis <panoskorovesis@outlook.com> | 2021-06-15 11:35:52 +0300 |
---|---|---|
committer | Tomaž Vajngerl <quikee@gmail.com> | 2021-06-16 08:25:03 +0200 |
commit | 4550170f7bfb115876e1ac9758864040aba5cd21 (patch) | |
tree | 02997131eb6c59e756d8f23a129d832d847ae1ad /vcl/qa/cppunit/svm | |
parent | 240c6557898de6a7777b2b2055d1c133a803b396 (diff) |
Add MapMode cppunit test to vcl.
The test creates multiple MapModes (relative and non-relative) with
custom and default attributes, which then checks.
Change-Id: Iaed461ece9cc044b5b271456a6bac10b1533062a
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/117232
Tested-by: Jenkins
Reviewed-by: Tomaž Vajngerl <quikee@gmail.com>
Diffstat (limited to 'vcl/qa/cppunit/svm')
-rw-r--r-- | vcl/qa/cppunit/svm/data/mapmode.svm | bin | 0 -> 336 bytes | |||
-rw-r--r-- | vcl/qa/cppunit/svm/svmtest.cxx | 56 |
2 files changed, 54 insertions, 2 deletions
diff --git a/vcl/qa/cppunit/svm/data/mapmode.svm b/vcl/qa/cppunit/svm/data/mapmode.svm Binary files differnew file mode 100644 index 000000000000..4f74a336e6ef --- /dev/null +++ b/vcl/qa/cppunit/svm/data/mapmode.svm diff --git a/vcl/qa/cppunit/svm/svmtest.cxx b/vcl/qa/cppunit/svm/svmtest.cxx index 02fbcdb5c04f..76725de14603 100644 --- a/vcl/qa/cppunit/svm/svmtest.cxx +++ b/vcl/qa/cppunit/svm/svmtest.cxx @@ -20,6 +20,7 @@ #include <vcl/lineinfo.hxx> #include <vcl/virdev.hxx> #include <vcl/pngwrite.hxx> +#include <tools/fract.hxx> #include <bitmap/BitmapWriteAccess.hxx> @@ -160,7 +161,7 @@ class SvmTest : public test::BootstrapFixture, public XmlTestTools void checkTextAlign(const GDIMetaFile& rMetaFile); void testTextAlign(); - //void checkMapMode(const GDIMetaFile& rMetaFile); + void checkMapMode(const GDIMetaFile& rMetaFile); void testMapMode(); //void checkFont(const GDIMetaFile& rMetaFile); @@ -1834,8 +1835,59 @@ void SvmTest::testTextAlign() checkTextAlign(readFile(u"textalign.svm")); } +void SvmTest::checkMapMode(const GDIMetaFile& rMetafile) +{ + xmlDocUniquePtr pDoc = dumpMeta(rMetafile); + + assertXPathAttrs(pDoc, "/metafile/mapmode[1]", { + {"mapunit", "MapPixel"}, + {"x", "0"}, + {"y", "0"}, + {"scalex", "(1/1)"}, + {"scaley", "(1/1)"} + }); + + assertXPathAttrs(pDoc, "/metafile/mapmode[2]", { + {"mapunit", "Map100thInch"}, + {"x", "0"}, + {"y", "1"}, + {"scalex", "(1/2)"}, + {"scaley", "(2/3)"} + }); + + assertXPathAttrs(pDoc, "/metafile/mapmode[3]", { + {"mapunit", "MapRelative"}, + {"x", "0"}, + {"y", "-1"}, + {"scalex", "(25/12)"}, + {"scaley", "(25/16)"} + }); +} + void SvmTest::testMapMode() -{} +{ + GDIMetaFile aGDIMetafile; + ScopedVclPtrInstance<VirtualDevice> pVirtualDev; + setupBaseVirtualDevice(*pVirtualDev, aGDIMetafile); + + MapMode aMapMode; + + pVirtualDev->SetMapMode(aMapMode); + + MapMode aMapMode1(MapUnit::Map100thInch); + aMapMode1.SetOrigin(Point(0, 1)); + aMapMode1.SetScaleX(Fraction(1, 2)); + aMapMode1.SetScaleY(Fraction(2, 3)); + + pVirtualDev->SetMetafileMapMode(aMapMode1, false); + + MapMode aMapMode2; + pVirtualDev->SetMetafileMapMode(aMapMode2, true); + + checkMapMode(writeAndReadStream(aGDIMetafile)); + checkMapMode(readFile(u"mapmode.svm")); +} + void SvmTest::testFont() {} |