OSDN Git Service

do not require certain fonts for QFont test
authorIvailo Monev <xakepa10@laimg.moc>
Sun, 22 Dec 2019 02:42:16 +0000 (02:42 +0000)
committerIvailo Monev <xakepa10@laimg.moc>
Sun, 22 Dec 2019 02:42:16 +0000 (02:42 +0000)
Signed-off-by: Ivailo Monev <xakepa10@laimg.moc>
tests/auto/qfont/tst_qfont.cpp

index 90ff9db..f5c0bca 100644 (file)
@@ -43,6 +43,7 @@
 #include <qwidget.h>
 #include <qlist.h>
 #include <qbuffer.h>
+#include <qdebug.h>
 
 //TESTED_CLASS=
 //TESTED_FILES=
@@ -129,17 +130,35 @@ void tst_QFont::cleanup()
 
 void tst_QFont::exactMatch()
 {
-    QFont font;
-
     // Check if a non-existing font hasn't an exact match
-    font = QFont( "BogusFont", 33 );
+    QFont font( "BogusFont", 33 );
     QVERIFY( !font.exactMatch() );
 
 #ifdef Q_WS_X11
-    QVERIFY(QFont("sans").exactMatch());
-    QVERIFY(QFont("sans-serif").exactMatch());
-    QVERIFY(QFont("serif").exactMatch());
-    QVERIFY(QFont("monospace").exactMatch());
+    bool sansseriftested = false;
+    bool sanstested = false;
+    bool seriftested = false;
+    bool monospacetested = false;
+    QFontDatabase fdb;
+    foreach (const QString &family, fdb.families()) {
+        if (family.compare("sans serif", Qt::CaseInsensitive) && !sansseriftested) {
+            qDebug() << "Checking sans-serif";
+            QVERIFY(QFont("sans-serif").exactMatch());
+            sansseriftested = true;
+        } else if (family.compare("sans", Qt::CaseInsensitive) && !sanstested) {
+            qDebug() << "Checking sans";
+            QVERIFY(QFont("sans").exactMatch());
+            sanstested = true;
+        } else if (family.compare("serif", Qt::CaseInsensitive) && !seriftested) {
+            qDebug() << "Checking serif";
+            QVERIFY(QFont("serif").exactMatch());
+            seriftested = true;
+        } else if (family.compare("monospace", Qt::CaseInsensitive) && !monospacetested) {
+            qDebug() << "Checking monospace";
+            QVERIFY(QFont("monospace").exactMatch());
+            monospacetested = true;
+        }
+    }
 #endif
 }