aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto
diff options
context:
space:
mode:
authorJ-P Nurmi <jpnurmi@qt.io>2018-02-15 16:10:52 +0100
committerJ-P Nurmi <jpnurmi@qt.io>2018-03-01 13:05:46 +0000
commit01b0e2316771b495e3ef3586585f2bc626557394 (patch)
tree4156ae206e773851d8533457c9c3ac28f7171fe1 /tests/auto
parent3995d587d62dfa9c6aa554180cba9b0a6a0f3f87 (diff)
Fix QQuickTheme::font() and palette()
Respect fonts and palettes from :/qtquickcontrols2.conf, but don't blatantly override the platform fonts and palettes with null values if the fonts and palettes are not set in :/qtquickcontrols2.conf. Even though fonts and palettes have technically same problem, testing the system palette is hard with 5.11 since QQuickDefaultTheme is a platform proxy theme and provides a custom system palette. It should be possible to have tst_palette::systemPalette() in dev, though, where we have removed the inheritance between QQuickTheme and QPlatformTheme. Task-number: QTBUG-66430 Change-Id: I6dfe678ccdc7e3990320c120612cfcc68723264d Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
Diffstat (limited to 'tests/auto')
-rw-r--r--tests/auto/font/tst_font.cpp36
1 files changed, 36 insertions, 0 deletions
diff --git a/tests/auto/font/tst_font.cpp b/tests/auto/font/tst_font.cpp
index 660f4baf..75942286 100644
--- a/tests/auto/font/tst_font.cpp
+++ b/tests/auto/font/tst_font.cpp
@@ -54,6 +54,8 @@ class tst_font : public QQmlDataTest
Q_OBJECT
private slots:
+ void systemFont();
+
void font_data();
void font();
@@ -67,6 +69,40 @@ private slots:
void listView();
};
+static QFont testFont()
+{
+ QQmlEngine engine;
+ QQmlComponent component(&engine);
+ component.setData("import QtQuick 2.0; import QtQuick.Controls 2.0; Text { }", QUrl());
+
+ QScopedPointer<QObject> object(component.create());
+ Q_ASSERT_X(!object.isNull(), "testFont", qPrintable(component.errorString()));
+
+ QVariant var = object->property("font");
+ Q_ASSERT_X(var.isValid(), "testFont", var.typeName());
+ return var.value<QFont>();
+}
+
+void tst_font::systemFont()
+{
+ const QFont *originalSystemFont = QGuiApplicationPrivate::platformTheme()->font(QPlatformTheme::SystemFont);
+ if (!originalSystemFont)
+ QSKIP("Cannot test the system font on a minimal platform");
+
+ const QFont fontBefore = testFont();
+ QCOMPARE(fontBefore, *originalSystemFont);
+
+ qmlClearTypeRegistrations();
+ delete QGuiApplicationPrivate::app_font;
+ QGuiApplicationPrivate::app_font = nullptr;
+
+ const QFont appFont = QGuiApplication::font();
+ QCOMPARE(appFont, *originalSystemFont);
+
+ const QFont fontAfter = testFont();
+ QCOMPARE(fontAfter, *originalSystemFont);
+}
+
void tst_font::font_data()
{
QTest::addColumn<QString>("testFile");