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>bb10
parent
df912d08c3
commit
3a1773dd76
|
|
@ -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();
|
||||
|
|
|
|||
Loading…
Reference in New Issue