diff options
author | Andy Shaw <andy.shaw@qt.io> | 2020-11-24 09:35:39 +0100 |
---|---|---|
committer | Andy Shaw <andy.shaw@qt.io> | 2020-11-24 21:49:54 +0100 |
commit | 8302ca22f42f984a16187fae209bdc1d79bc18da (patch) | |
tree | c30adc4bad47abcb44a78e35e85948b43e03fe03 /tests/auto/gui | |
parent | 116c2115f84ec2f5f12b5d7680cd83ceeef72a6e (diff) |
Return a QString() if the families list is empty
Fixes: QTBUG-88781
Change-Id: Iafed2be29e2e0c3029e832986ba58d19446214eb
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Diffstat (limited to 'tests/auto/gui')
-rw-r--r-- | tests/auto/gui/text/qfont/tst_qfont.cpp | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/tests/auto/gui/text/qfont/tst_qfont.cpp b/tests/auto/gui/text/qfont/tst_qfont.cpp index 2e87cc8e50..09214c256e 100644 --- a/tests/auto/gui/text/qfont/tst_qfont.cpp +++ b/tests/auto/gui/text/qfont/tst_qfont.cpp @@ -756,6 +756,7 @@ void tst_QFont::setFamilies_data() if (standardFont.isEmpty()) QSKIP("No default font available on the system"); + QTest::newRow("emptyFamily") << (QStringList()) << QString(); QTest::newRow("standard") << (QStringList() << standardFont) << standardFont; QTest::newRow("weird") << (QStringList() << weirdFont) << weirdFont; QTest::newRow("standard-weird") << (QStringList() << standardFont << weirdFont) << standardFont; @@ -773,7 +774,8 @@ void tst_QFont::setFamilies() QVERIFY(weirdFontId != -1); QFont f; f.setFamilies(families); - QCOMPARE(QFontInfo(f).family(), chosenFamilyName); + if (!chosenFamilyName.isEmpty()) // Only check when it is not empty + QCOMPARE(QFontInfo(f).family(), chosenFamilyName); QFontDatabase::removeApplicationFont(weirdFontId); } @@ -792,6 +794,7 @@ void tst_QFont::setFamiliesAndFamily_data() const QString timesFont(QLatin1String("Times")); const QString nonExistFont(QLatin1String("NonExistentFont")); + QTest::newRow("emptyFamily") << (QStringList()) << QString() << QString(); QTest::newRow("firstInFamilies") << (QStringList() << defaultFont << timesFont) << weirdFont << defaultFont; QTest::newRow("secondInFamilies") << (QStringList() << nonExistFont << weirdFont) << defaultFont << weirdFont; QTest::newRow("family") << (QStringList() << nonExistFont) << defaultFont << defaultFont; @@ -809,7 +812,8 @@ void tst_QFont::setFamiliesAndFamily() QFont f; f.setFamily(family); f.setFamilies(families); - QCOMPARE(QFontInfo(f).family(), chosenFamilyName); + if (!family.isEmpty()) // Only check when it is not empty + QCOMPARE(QFontInfo(f).family(), chosenFamilyName); QFontDatabase::removeApplicationFont(weirdFontId); } |