[Libreoffice-commits] core.git: vcl/qa

panoskorovesis (via logerrit) logerrit at kemper.freedesktop.org
Wed Jun 16 06:25:42 UTC 2021


 vcl/qa/cppunit/svm/data/mapmode.svm |binary
 vcl/qa/cppunit/svm/svmtest.cxx      |   56 ++++++++++++++++++++++++++++++++++--
 2 files changed, 54 insertions(+), 2 deletions(-)

New commits:
commit 4550170f7bfb115876e1ac9758864040aba5cd21
Author:     panoskorovesis <panoskorovesis at outlook.com>
AuthorDate: Tue Jun 15 11:35:52 2021 +0300
Commit:     Tomaž Vajngerl <quikee at gmail.com>
CommitDate: Wed Jun 16 08:25:03 2021 +0200

    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 at gmail.com>

diff --git a/vcl/qa/cppunit/svm/data/mapmode.svm b/vcl/qa/cppunit/svm/data/mapmode.svm
new file mode 100644
index 000000000000..4f74a336e6ef
Binary files /dev/null and b/vcl/qa/cppunit/svm/data/mapmode.svm differ
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()
 {}
 


More information about the Libreoffice-commits mailing list