summaryrefslogtreecommitdiffstats
path: root/tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp
diff options
context:
space:
mode:
authorTor Arne Vestbø <tor.arne.vestbo@qt.io>2021-02-12 14:28:18 +0100
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2021-02-16 11:58:03 +0000
commit3c7db6ce41e571741b72e51c37746b730648b5a6 (patch)
treee843a2da43751e71c96f48d49d6863b954da49b4 /tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp
parent2f0d44b40302f751dc9996e73c6f7fa035a29933 (diff)
tst_qapplication: Prevent desktopaware test from deactivating main test
Applications on macOS are automatically activated (put into the foreground), when launched from the Finder, or via 'open' on the command line. But when launched from the terminal, e.g. foo.app/Contents/MacOS/foo, the application will launch in the background (inactive). In Qt we override this behavior, activating the app even when launched from the terminal, as a convenience, as long as the application is a GUI application. Unfortunately this means that when tst_qapplication launches a subprocess that is a GUI app, it will steal activation from tst_qapplication, which in turn will break tests that later try to activate a window and check that the window is then active. The window will not be active until the application is active. We can work around it by preventing Qt from activating the application, but ideally we'd find a better solution to this, as we don't want to sprinkle overrides all over our tests. Fixes: QTBUG-90699 Change-Id: If53a86548002b739df0c0a7153d6244924a4a205 Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io> (cherry picked from commit 09cc63d425dabfa37b406e7eb1cee627c2eabb67) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
Diffstat (limited to 'tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp')
-rw-r--r--tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp5
1 files changed, 5 insertions, 0 deletions
diff --git a/tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp b/tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp
index 0aa915cc47..a8083be4ba 100644
--- a/tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp
+++ b/tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp
@@ -1520,6 +1520,11 @@ void tst_QApplication::desktopSettingsAware()
{
#if QT_CONFIG(process)
QProcess testProcess;
+#ifdef Q_OS_MACOS
+ QStringList environment = QProcess::systemEnvironment();
+ environment += QLatin1String("QT_MAC_DISABLE_FOREGROUND_APPLICATION_TRANSFORM=1");
+ testProcess.setEnvironment(environment);
+#endif
testProcess.start("desktopsettingsaware_helper");
QVERIFY2(testProcess.waitForStarted(),
qPrintable(QString::fromLatin1("Cannot start 'desktopsettingsaware_helper': %1").arg(testProcess.errorString())));