From 71e77398bb87552bb5410bfd9bf6a8ae37a0f1f6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Mon, 17 Jun 2024 10:32:35 +0200 Subject: [PATCH] tst_qhighdpi: Write screen config to temporary directory MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Instead of build dir, where it can clash when multiple tests runs are being done from the same build dir in parallel. Due to the way platform plugin argument parsing works we can't pass the full file name of the config, as on Windows this would include C:, which QGuiApplication will split into two, thinking they are two different platform plugin arguments. Instead we chdir into the temp dir, and create the file there, passing the file name as a relative path as before. Change-Id: Ia4ea82280e35f4f52b7de74bbf53b2a48ecbaecd Reviewed-by: Morten Johan Sørvig (cherry picked from commit fd68f894b969b016201e032ba23dac431c19b90a) Reviewed-by: Qt Cherry-pick Bot --- tests/auto/gui/kernel/qhighdpi/tst_qhighdpi.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/tests/auto/gui/kernel/qhighdpi/tst_qhighdpi.cpp b/tests/auto/gui/kernel/qhighdpi/tst_qhighdpi.cpp index 85ab23620e3..69f0d31c49d 100644 --- a/tests/auto/gui/kernel/qhighdpi/tst_qhighdpi.cpp +++ b/tests/auto/gui/kernel/qhighdpi/tst_qhighdpi.cpp @@ -28,6 +28,7 @@ private: // helpers static QJsonObject offscreenConfiguration(); private slots: + void initTestCase(); void cleanup(); void qhighdpiscaling_data(); void qhighdpiscaling(); @@ -111,7 +112,6 @@ QGuiApplication *tst_QHighDpi::createOffscreenApplication(const QByteArray &json // Write offscreen platform config file QFile configFile(QLatin1String("qt-offscreen-test-config.json")); if (!configFile.open(QIODevice::WriteOnly | QIODevice::Truncate)) - qFatal("Failed to open test config file: %s", qPrintable(configFile.errorString())); configFile.resize(0); // truncate if (configFile.write(jsonConfig) == -1) qFatal("Could not write config file: %s", qPrintable(configFile.errorString())); @@ -152,6 +152,11 @@ QGuiApplication *tst_QHighDpi::createStandardOffscreenApp(const QJsonArray &scre return createOffscreenApplication(QJsonDocument(config).toJson()); } +void tst_QHighDpi::initTestCase() +{ + QDir::setCurrent(QDir::tempPath()); +} + /// Auto test begins void tst_QHighDpi::standardScreenDpiTestData()