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>
This commit is contained in:
parent
2f0d44b403
commit
3c7db6ce41
@ -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())));
|
||||
|
Loading…
x
Reference in New Issue
Block a user