diff options
Diffstat (limited to 'tests/auto/applicationwindow/tst_applicationwindow.cpp')
-rw-r--r-- | tests/auto/applicationwindow/tst_applicationwindow.cpp | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/tests/auto/applicationwindow/tst_applicationwindow.cpp b/tests/auto/applicationwindow/tst_applicationwindow.cpp index 8256f16b..34493ea0 100644 --- a/tests/auto/applicationwindow/tst_applicationwindow.cpp +++ b/tests/auto/applicationwindow/tst_applicationwindow.cpp @@ -41,12 +41,14 @@ #include <QtQml/qqmlcontext.h> #include <QtQuick/qquickview.h> #include <QtQuick/private/qquickitem_p.h> +#include <QtGui/private/qguiapplication_p.h> #include <QtLabsTemplates/private/qquickapplicationwindow_p.h> #include <QtLabsTemplates/private/qquickoverlay_p.h> #include <QtLabsTemplates/private/qquickcontrol_p.h> #include <QtLabsTemplates/private/qquicklabel_p.h> #include <QtLabsTemplates/private/qquicktextarea_p.h> #include <QtLabsTemplates/private/qquicktextfield_p.h> +#include <QtLabsControls/private/qquickproxytheme_p.h> #include "../shared/util.h" #include "../shared/visualtestutil.h" @@ -65,6 +67,7 @@ private slots: void implicitFill(); void attachedProperties(); void font(); + void defaultFont(); void locale(); void activeFocusControl_data(); void activeFocusControl(); @@ -492,6 +495,36 @@ void tst_applicationwindow::font() QCOMPARE(item6->font(), font); } +class TestTheme : public QQuickProxyTheme +{ +public: + TestTheme(QPlatformTheme *theme) : QQuickProxyTheme(theme), m_font("Courier") + { QGuiApplicationPrivate::platform_theme = this; } + ~TestTheme() { QGuiApplicationPrivate::platform_theme = theme(); } + + const QFont *font(Font type = SystemFont) const Q_DECL_OVERRIDE + { + Q_UNUSED(type); + return &m_font; + } + + QFont m_font; +}; + +void tst_applicationwindow::defaultFont() +{ + TestTheme theme(QGuiApplicationPrivate::platform_theme); + + QQmlEngine engine; + QQmlComponent component(&engine); + component.setData("import Qt.labs.controls 1.0; ApplicationWindow { }", QUrl()); + + QScopedPointer<QQuickApplicationWindow> window; + window.reset(static_cast<QQuickApplicationWindow *>(component.create())); + QVERIFY(!window.isNull()); + QCOMPARE(window->font(), *theme.font()); +} + void tst_applicationwindow::locale() { QQmlEngine engine; |