summaryrefslogtreecommitdiffstats
path: root/tests/auto/widgets/kernel
diff options
context:
space:
mode:
authorTor Arne Vestbø <tor.arne.vestbo@qt.io>2021-02-12 14:28:18 +0100
committerTor Arne Vestbø <tor.arne.vestbo@qt.io>2021-02-15 14:20:08 +0100
commit09cc63d425dabfa37b406e7eb1cee627c2eabb67 (patch)
tree13c38cb0c546c585cf04f9030eca58dc11a061b8 /tests/auto/widgets/kernel
parent170239364406b70593f822544b705d816afd86e3 (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 Pick-to: 6.1 6.0 5.15 Change-Id: If53a86548002b739df0c0a7153d6244924a4a205 Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
Diffstat (limited to 'tests/auto/widgets/kernel')
-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 f2c668c153..8216cfbab0 100644
--- a/tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp
+++ b/tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp
@@ -1525,6 +1525,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())));