diff options
author | J-P Nurmi <jpnurmi@qt.io> | 2018-03-01 17:15:42 +0100 |
---|---|---|
committer | J-P Nurmi <jpnurmi@qt.io> | 2018-03-01 18:40:19 +0100 |
commit | b6d847ac5bb0e32f928f616cee03d323aab33e55 (patch) | |
tree | 40541ea1f8fff70cfd09ff2eecfdf783e8ea5257 /tests/auto/font | |
parent | d9ba3c909ec071f3be4f3e44d0c2d66b04811c7c (diff) | |
parent | b4db69eee6dc2f381b24aa24586171dbaf8d116e (diff) |
Merge remote-tracking branch 'origin/5.11' into dev
Conflicts:
src/quickcontrols2/qquicktheme.cpp
Change-Id: I874011d32a379bf982f760c39c46d3a25e2452d6
Diffstat (limited to 'tests/auto/font')
-rw-r--r-- | tests/auto/font/tst_font.cpp | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/tests/auto/font/tst_font.cpp b/tests/auto/font/tst_font.cpp index f3f9dbf5..65dd4971 100644 --- a/tests/auto/font/tst_font.cpp +++ b/tests/auto/font/tst_font.cpp @@ -38,6 +38,7 @@ #include "../shared/visualtestutil.h" #include <QtGui/qfont.h> +#include <QtGui/qpa/qplatformtheme.h> #include <QtGui/private/qguiapplication_p.h> #include <QtQml/qqmlengine.h> #include <QtQml/qqmlcomponent.h> @@ -53,6 +54,8 @@ class tst_font : public QQmlDataTest Q_OBJECT private slots: + void systemFont(); + void font_data(); void font(); @@ -66,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"); |