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

panoskorovesis (via logerrit) logerrit at kemper.freedesktop.org
Wed Jun 23 06:56:21 UTC 2021


 vcl/CppunitTest_vcl_svm_test.mk  |    2 +
 vcl/qa/cppunit/svm/data/font.svm |binary
 vcl/qa/cppunit/svm/svmtest.cxx   |   40 +++++++++++++++++++++++++++++++++++++--
 3 files changed, 40 insertions(+), 2 deletions(-)

New commits:
commit 2ab2f24951c7f490cc170533c1e08a61a8dc3104
Author:     panoskorovesis <panoskorovesis at outlook.com>
AuthorDate: Thu Jun 17 15:12:35 2021 +0300
Commit:     Tomaž Vajngerl <quikee at gmail.com>
CommitDate: Wed Jun 23 08:55:36 2021 +0200

    Add Font cppunit test to vcl.
    
    The test creates a Font, sets custom attributes for it and then
    tests them.
    
    Change-Id: Ib1427392674c7728180e1ad00621e56950d495ca
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/117155
    Tested-by: Jenkins
    Reviewed-by: Tomaž Vajngerl <quikee at gmail.com>

diff --git a/vcl/CppunitTest_vcl_svm_test.mk b/vcl/CppunitTest_vcl_svm_test.mk
index 727ed121e3f6..898cf28c8475 100644
--- a/vcl/CppunitTest_vcl_svm_test.mk
+++ b/vcl/CppunitTest_vcl_svm_test.mk
@@ -58,4 +58,6 @@ $(eval $(call gb_CppunitTest_use_components,vcl_svm_test,\
 
 $(eval $(call gb_CppunitTest_use_configuration,vcl_svm_test))
 
+$(eval $(call gb_CppunitTest_use_more_fonts,vcl_svm_test))
+
 # vim: set noet sw=4 ts=4:
diff --git a/vcl/qa/cppunit/svm/data/font.svm b/vcl/qa/cppunit/svm/data/font.svm
new file mode 100644
index 000000000000..301e9d3c18ba
Binary files /dev/null and b/vcl/qa/cppunit/svm/data/font.svm differ
diff --git a/vcl/qa/cppunit/svm/svmtest.cxx b/vcl/qa/cppunit/svm/svmtest.cxx
index de0e93363c84..605a8f5c8afd 100644
--- a/vcl/qa/cppunit/svm/svmtest.cxx
+++ b/vcl/qa/cppunit/svm/svmtest.cxx
@@ -166,7 +166,7 @@ class SvmTest : public test::BootstrapFixture, public XmlTestTools
     void checkMapMode(const GDIMetaFile& rMetaFile);
     void testMapMode();
 
-    //void checkFont(const GDIMetaFile& rMetaFile);
+    void checkFont(const GDIMetaFile& rMetaFile);
     void testFont();
 
     void checkPushPop(const GDIMetaFile& rMetaFile);
@@ -1890,8 +1890,44 @@ void SvmTest::testMapMode()
     checkMapMode(readFile(u"mapmode.svm"));
 }
 
+void SvmTest::checkFont(const GDIMetaFile& rMetafile)
+{
+    xmlDocUniquePtr pDoc = dumpMeta(rMetafile);
+    assertXPathAttrs(pDoc, "/metafile/font[1]", {
+        {"color", "#ffffff"},
+        {"fillcolor", "#ffffff"},
+        {"name", "Liberation Sans"},
+        {"stylename", "Regular"},
+        {"width", "12"},
+        {"height", "12"},
+        {"orientation", "50"},
+        {"weight", "thin"},
+        {"vertical", "true"},
+    });
+}
+
 void SvmTest::testFont()
-{}
+{
+#if HAVE_MORE_FONTS
+// Windows interprets Width differently causing build errors
+#if !defined(_WIN32)
+    GDIMetaFile aGDIMetaFile;
+    ScopedVclPtrInstance<VirtualDevice> pVirtualDev;
+    setupBaseVirtualDevice(*pVirtualDev, aGDIMetaFile);
+    vcl::Font aFont(FontFamily::FAMILY_SCRIPT, Size(15, 15));
+    aFont.SetWeight(FontWeight::WEIGHT_THIN);
+    aFont.SetFamilyName("Liberation Sans");
+    aFont.SetStyleName("Regular");
+    aFont.SetFontHeight(12);
+    aFont.SetAverageFontWidth(12);
+    aFont.SetVertical(true);
+    aFont.SetOrientation(Degree10(50));
+    pVirtualDev->SetFont(aFont);
+    checkFont(writeAndReadStream(aGDIMetaFile));
+    checkFont(readFile(u"font.svm"));
+#endif // _WIN32
+#endif
+}
 
 void SvmTest::checkPushPop(const GDIMetaFile& rMetaFile)
 {


More information about the Libreoffice-commits mailing list