summaryrefslogtreecommitdiffstats
path: root/tests/auto/gui
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/gui')
-rw-r--r--tests/auto/gui/kernel/qpalette/tst_qpalette.cpp31
-rw-r--r--tests/auto/gui/text/qrawfont/tst_qrawfont.cpp37
2 files changed, 67 insertions, 1 deletions
diff --git a/tests/auto/gui/kernel/qpalette/tst_qpalette.cpp b/tests/auto/gui/kernel/qpalette/tst_qpalette.cpp
index f43e8d8ee6..ca6f677ba6 100644
--- a/tests/auto/gui/kernel/qpalette/tst_qpalette.cpp
+++ b/tests/auto/gui/kernel/qpalette/tst_qpalette.cpp
@@ -39,6 +39,7 @@ private Q_SLOTS:
void roleValues();
void copySemantics();
void moveSemantics();
+ void setBrush();
};
void tst_QPalette::roleValues_data()
@@ -128,5 +129,35 @@ void tst_QPalette::moveSemantics()
#endif
}
+void tst_QPalette::setBrush()
+{
+ QPalette p(Qt::red);
+ const QPalette q = p;
+ QVERIFY(q.isCopyOf(p));
+
+ // Setting a different brush will detach
+ p.setBrush(QPalette::Disabled, QPalette::Button, Qt::green);
+ QVERIFY(!q.isCopyOf(p));
+ QVERIFY(q != p);
+
+ // Check we only changed what we said we would
+ for (int i = 0; i < QPalette::NColorGroups; i++)
+ for (int j = 0; j < QPalette::NColorRoles; j++) {
+ const auto g = QPalette::ColorGroup(i);
+ const auto r = QPalette::ColorRole(j);
+ const auto b = p.brush(g, r);
+ if (g == QPalette::Disabled && r == QPalette::Button)
+ QCOMPARE(b, QBrush(Qt::green));
+ else
+ QCOMPARE(b, q.brush(g, r));
+ }
+
+ const QPalette pp = p;
+ QVERIFY(pp.isCopyOf(p));
+ // Setting the same brush won't detach
+ p.setBrush(QPalette::Disabled, QPalette::Button, Qt::green);
+ QVERIFY(pp.isCopyOf(p));
+}
+
QTEST_MAIN(tst_QPalette)
#include "tst_qpalette.moc"
diff --git a/tests/auto/gui/text/qrawfont/tst_qrawfont.cpp b/tests/auto/gui/text/qrawfont/tst_qrawfont.cpp
index 3cf108ed62..37f94d0278 100644
--- a/tests/auto/gui/text/qrawfont/tst_qrawfont.cpp
+++ b/tests/auto/gui/text/qrawfont/tst_qrawfont.cpp
@@ -90,6 +90,9 @@ private slots:
void rawFontFromInvalidData();
void kernedAdvances();
+
+ void fallbackFontsOrder();
+
private:
QString testFont;
QString testFontBoldItalic;
@@ -887,7 +890,7 @@ void tst_QRawFont::unsupportedWritingSystem()
QCOMPARE(rawFont.familyName(), QString::fromLatin1("QtBidiTestFont"));
QCOMPARE(rawFont.pixelSize(), 12.0);
- QString arabicText = QFontDatabase::writingSystemSample(QFontDatabase::Arabic);
+ QString arabicText = QFontDatabase::writingSystemSample(QFontDatabase::Arabic).simplified().remove(QLatin1Char(' '));
QTextLayout layout;
layout.setFont(font);
@@ -1009,6 +1012,38 @@ void tst_QRawFont::kernedAdvances()
QVERIFY(FUZZY_LTEQ(qAbs(advances.at(0).x() - expectedAdvanceWidth), errorMargin));
}
+void tst_QRawFont::fallbackFontsOrder()
+{
+ QFontDatabase fontDatabase;
+ int id = fontDatabase.addApplicationFont(testFont);
+
+ QFont font("QtBidiTestFont");
+ font.setPixelSize(12.0);
+
+ QString arabicText = QFontDatabase::writingSystemSample(QFontDatabase::Arabic);
+
+ // If this fails, then the writing system sample has changed and we need to create
+ // a new text containing both a space and Arabic characters.
+ QVERIFY(arabicText.contains(QLatin1Char(' ')));
+
+ QTextLayout layout;
+ layout.setFont(font);
+ layout.setText(arabicText);
+ layout.setCacheEnabled(true);
+ layout.beginLayout();
+ layout.createLine();
+ layout.endLayout();
+
+ QList<QGlyphRun> glyphRuns = layout.glyphRuns();
+
+ // Since QtBidiTestFont does not support Arabic nor the space, both should map to
+ // the same font. If this fails, it is an indication that the list of fallbacks fonts
+ // is not sorted by writing system support.
+ QCOMPARE(glyphRuns.size(), 1);
+
+ fontDatabase.removeApplicationFont(id);
+}
+
#endif // QT_NO_RAWFONT
QTEST_MAIN(tst_QRawFont)