summaryrefslogtreecommitdiffstats
path: root/tests/auto/widgets/dialogs/qmessagebox/tst_qmessagebox.cpp
diff options
context:
space:
mode:
authorTor Arne Vestbø <tor.arne.vestbo@qt.io>2021-09-03 18:28:00 +0200
committerVolker Hilsheimer <volker.hilsheimer@qt.io>2021-09-04 23:09:30 +0200
commit2262744ad00524384f1ee02cdec20cf36a3b5947 (patch)
tree52c0c1f607c5c7bf42f745d0aafa374076f21481 /tests/auto/widgets/dialogs/qmessagebox/tst_qmessagebox.cpp
parent673ed80fa42a77c92256388d8dff03a3c1651941 (diff)
QMessageBox: Reset clickedButton for each invocation of the dialog
When showing a messagebox that has already been show we don't want to keep around the clicked button of the previous invocation. Pick-to: 6.2 Change-Id: Ib6f6293d40ab338c550ea344094db871ccf45c46 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
Diffstat (limited to 'tests/auto/widgets/dialogs/qmessagebox/tst_qmessagebox.cpp')
-rw-r--r--tests/auto/widgets/dialogs/qmessagebox/tst_qmessagebox.cpp23
1 files changed, 23 insertions, 0 deletions
diff --git a/tests/auto/widgets/dialogs/qmessagebox/tst_qmessagebox.cpp b/tests/auto/widgets/dialogs/qmessagebox/tst_qmessagebox.cpp
index 4210c428ec..b67f15458c 100644
--- a/tests/auto/widgets/dialogs/qmessagebox/tst_qmessagebox.cpp
+++ b/tests/auto/widgets/dialogs/qmessagebox/tst_qmessagebox.cpp
@@ -50,6 +50,7 @@ private slots:
void sanityTest();
void defaultButton();
void escapeButton();
+ void clickedButton();
void button();
void statics();
void about();
@@ -302,6 +303,28 @@ void tst_QMessageBox::escapeButton()
QVERIFY(msgBox3.clickedButton() == msgBox3.button(QMessageBox::Ok)); // auto detected
}
+void tst_QMessageBox::clickedButton()
+{
+ QMessageBox msgBox;
+ msgBox.addButton(QMessageBox::Yes);
+ msgBox.addButton(QMessageBox::No);
+ msgBox.addButton(QMessageBox::Retry);
+
+ QVERIFY(!msgBox.clickedButton());
+
+ for (int i = 0; i < 2; ++i) {
+ QAbstractButton *clickedButtonAfterExex = nullptr;
+ QTimer::singleShot(100, [&] {
+ clickedButtonAfterExex = msgBox.clickedButton();
+ msgBox.close();
+ });
+ msgBox.exec();
+
+ QVERIFY(!clickedButtonAfterExex);
+ QVERIFY(msgBox.clickedButton());
+ }
+}
+
void tst_QMessageBox::statics()
{
QMessageBox::StandardButton (*statics[4])(QWidget *, const QString &,