diff options
author | Morten Johan Sørvig <morten.sorvig@qt.io> | 2020-12-23 11:53:14 +0100 |
---|---|---|
committer | Morten Johan Sørvig <morten.sorvig@qt.io> | 2021-01-22 14:27:27 +0000 |
commit | 3a1773dd7625e1bd727c5e851b8a84125fddb9e8 (patch) | |
tree | bf88800a076bc06dcee429a4b7ff6731d2255243 /tests/auto/gui | |
parent | df912d08c314138afebddf7f727916303cb11c90 (diff) |
High-DPI: Test application startup with no screens
Initialize the offscreen platform plugin with no screens,
create QGuiApplication object.
Not much of the high-dpi related Qt API can be used
in this configuration, but at least Qt should not crash
on startup.
Task-number: QTBUG-71034
Change-Id: I6620843c3bd8b692c5c2419b1ba290e16175ba5b
Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
Diffstat (limited to 'tests/auto/gui')
-rw-r--r-- | tests/auto/gui/kernel/qhighdpi/tst_qhighdpi.cpp | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/tests/auto/gui/kernel/qhighdpi/tst_qhighdpi.cpp b/tests/auto/gui/kernel/qhighdpi/tst_qhighdpi.cpp index 13cdce6b12..09bf8439c8 100644 --- a/tests/auto/gui/kernel/qhighdpi/tst_qhighdpi.cpp +++ b/tests/auto/gui/kernel/qhighdpi/tst_qhighdpi.cpp @@ -43,11 +43,13 @@ private: // helpers QJsonArray createStandardScreens(const QList<qreal> &dpiValues); QGuiApplication *createOffscreenApplication(const QByteArray &jsonConfig); QGuiApplication *createStandardOffscreenApp(const QList<qreal> &dpiValues); + QGuiApplication *createStandardOffscreenApp(const QJsonArray &screens); static void standardScreenDpiTestData(); private slots: void initTestCase(); void qhighdpiscaling_data(); void qhighdpiscaling(); + void noscreens(); void screenDpiAndDpr_data(); void screenDpiAndDpr(); void screenAt_data(); @@ -142,6 +144,11 @@ QGuiApplication *tst_QHighDpi::createOffscreenApplication(const QByteArray &json QGuiApplication *tst_QHighDpi::createStandardOffscreenApp(const QList<qreal> &dpiValues) { QJsonArray screens = createStandardScreens(dpiValues); + return createStandardOffscreenApp(screens); +} + +QGuiApplication *tst_QHighDpi::createStandardOffscreenApp(const QJsonArray &screens) +{ QJsonObject config { {"synchronousWindowSystemEvents", true}, {"windowFrameMargins", false}, @@ -216,6 +223,15 @@ void tst_QHighDpi::screenDpiAndDpr() } } +void tst_QHighDpi::noscreens() +{ + // Create application object with a no-screens configuration (should not crash) + QJsonArray noScreens; + std::unique_ptr<QGuiApplication> app(createStandardOffscreenApp(noScreens)); + + QCOMPARE(qApp->devicePixelRatio(), 1); +} + void tst_QHighDpi::screenAt_data() { standardScreenDpiTestData(); |