summaryrefslogtreecommitdiffstats
path: root/tests/auto/widgets/dialogs
diff options
context:
space:
mode:
authorTor Arne Vestbø <tor.arne.vestbo@qt.io>2023-01-09 13:40:16 +0100
committerTor Arne Vestbø <tor.arne.vestbo@qt.io>2023-01-09 14:14:49 +0100
commit349fda471e0df473f38f59c2baae688959d6d273 (patch)
treed3aa5a2e430f8f39b4d234829187fc69ffebfc8b /tests/auto/widgets/dialogs
parent08b71d8619e2ad3dae8790e498860d3ced2b0851 (diff)
Fix QErrorMessage test when using native dialogs
When the test is showing the error message over and over, it's not waiting for the native dialog to actually become visible, and as a result, hiding it has no effect and won't result in a call to processResponse, where we got rid of the native dialog. To fix this we explicitly release the native dialog when encountering this corner case. Add logic to QErrorMessage to test both native and non native dialogs. Pick-to: 6.5 Change-Id: I19ac3f463997aed1e66f646fdfcbb4d2459116d1 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Diffstat (limited to 'tests/auto/widgets/dialogs')
-rw-r--r--tests/auto/widgets/dialogs/qerrormessage/CMakeLists.txt1
-rw-r--r--tests/auto/widgets/dialogs/qerrormessage/tst_qerrormessage.cpp22
2 files changed, 23 insertions, 0 deletions
diff --git a/tests/auto/widgets/dialogs/qerrormessage/CMakeLists.txt b/tests/auto/widgets/dialogs/qerrormessage/CMakeLists.txt
index ba4ea75b79..1cb63beea9 100644
--- a/tests/auto/widgets/dialogs/qerrormessage/CMakeLists.txt
+++ b/tests/auto/widgets/dialogs/qerrormessage/CMakeLists.txt
@@ -12,6 +12,7 @@ qt_internal_add_test(tst_qerrormessage
tst_qerrormessage.cpp
LIBRARIES
Qt::Gui
+ Qt::GuiPrivate
Qt::Widgets
)
diff --git a/tests/auto/widgets/dialogs/qerrormessage/tst_qerrormessage.cpp b/tests/auto/widgets/dialogs/qerrormessage/tst_qerrormessage.cpp
index 97dad396e5..5cae8263dc 100644
--- a/tests/auto/widgets/dialogs/qerrormessage/tst_qerrormessage.cpp
+++ b/tests/auto/widgets/dialogs/qerrormessage/tst_qerrormessage.cpp
@@ -5,16 +5,38 @@
#include <QDebug>
#include <QCheckBox>
+#include <qpa/qplatformtheme.h>
+#include <private/qguiapplication_p.h>
+
class tst_QErrorMessage : public QObject
{
Q_OBJECT
private slots:
+ void initTestCase_data();
+ void init();
+
void dontShowAgain();
void dontShowCategoryAgain();
};
+void tst_QErrorMessage::initTestCase_data()
+{
+ QTest::addColumn<bool>("useNativeDialog");
+ QTest::newRow("widget") << false;
+ if (const QPlatformTheme *theme = QGuiApplicationPrivate::platformTheme()) {
+ if (theme->usePlatformNativeDialog(QPlatformTheme::MessageDialog))
+ QTest::newRow("native") << true;
+ }
+}
+
+void tst_QErrorMessage::init()
+{
+ QFETCH_GLOBAL(bool, useNativeDialog);
+ qApp->setAttribute(Qt::AA_DontUseNativeDialogs, !useNativeDialog);
+}
+
void tst_QErrorMessage::dontShowAgain()
{
QString plainString = QLatin1String("foo");