summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorEskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>2020-12-02 14:42:16 +0100
committerEskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>2020-12-07 23:11:58 +0100
commit28df0d61e5e2b015f6e72ca7f64fc3c535ace119 (patch)
treed32c2518c4f2a0a99b79b8fd5697fde3773648e1 /tests
parentf4152d268e842961597b53819f2821df9804e303 (diff)
Fix tst_QFontDatabase::aliases failure with ambiguous font
If the first font in the families list happens to have been disambiguated because of duplicates, two things went wrong: 1. hasFamily() would return false for the font family, because it does not disambiguate when checking for the family name and only checks if the families list contains the exact string. 2. Adding aliases to the full disambiguated string is not supported, only the family name. The first issue has been reported separately as QTBUG-89068. The test failure is fixed by just avoiding the fonts that are ambiguous in the test, as it really doesn't matter which font we pick. Fixes: QTBUG-89008 Change-Id: I829778c2e7bb6090475c34dcf9cdce58862729d6 Reviewed-by: Liang Qi <liang.qi@qt.io> (cherry picked from commit 34fa01be82065241cd9a369ae49749422d8e7831)
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/gui/text/qfontdatabase/tst_qfontdatabase.cpp12
1 files changed, 11 insertions, 1 deletions
diff --git a/tests/auto/gui/text/qfontdatabase/tst_qfontdatabase.cpp b/tests/auto/gui/text/qfontdatabase/tst_qfontdatabase.cpp
index 12e8083622..bbb7276bfb 100644
--- a/tests/auto/gui/text/qfontdatabase/tst_qfontdatabase.cpp
+++ b/tests/auto/gui/text/qfontdatabase/tst_qfontdatabase.cpp
@@ -309,7 +309,17 @@ void tst_QFontDatabase::aliases()
QFontDatabase db;
const QStringList families = db.families();
QVERIFY(!families.isEmpty());
- const QString firstFont = families.front();
+ QString firstFont;
+ for (int i = 0; i < families.size(); ++i) {
+ if (!families.at(i).contains('[')) {
+ firstFont = families.at(i);
+ break;
+ }
+ }
+
+ if (firstFont.isEmpty())
+ QSKIP("Skipped because there are no unambiguous font families on the system.");
+
QVERIFY(db.hasFamily(firstFont));
const QString alias = QStringLiteral("AliasToFirstFont") + firstFont;
QVERIFY(!db.hasFamily(alias));