tst_qhighdpi: Write screen config to temporary directory

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 <morten.sorvig@qt.io>
(cherry picked from commit fd68f894b969b016201e032ba23dac431c19b90a)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
Tor Arne Vestbø 2024-06-17 10:32:35 +02:00 committed by Qt Cherry-pick Bot
parent b361fd6021
commit 71e77398bb

View File

@ -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()