aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/controls/data/tst_dialog.qml
diff options
context:
space:
mode:
authorMitch Curtis <mitch.curtis@qt.io>2020-07-27 09:55:37 +0200
committerMitch Curtis <mitch.curtis@qt.io>2020-09-02 17:06:50 +0200
commit0d3b8f832aad04c255dac64588b2693f2119cc0c (patch)
tree14150f63a8c34d9b50fc76a3b9001435b0f39b87 /tests/auto/controls/data/tst_dialog.qml
parent0e516bc9638d7b5ade38d356a304473af6adbc48 (diff)
Dialog: emit accepted()/rejected() before closed()
Before this patch, the documentation stated the following for e.g. accept(): "Closes the dialog and emits the accepted() signal." In practice, styles that have enter and/or exit transitions for Dialog result in closed() being emitted after accepted() (and rejected()). As there is no way to guarantee this particular order, we should be consistent and swap it around so that accepted()/rejected() are emitted first. [ChangeLog][Important Behavior Changes] Dialog's accepted() and rejected() signals are now emitted before closed() when calling done(), accept() and reject(). Fixes: QTBUG-85748 Change-Id: I706dda8de28c350d65e3188787af8f66a2c5f07d Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Diffstat (limited to 'tests/auto/controls/data/tst_dialog.qml')
-rw-r--r--tests/auto/controls/data/tst_dialog.qml27
1 files changed, 25 insertions, 2 deletions
diff --git a/tests/auto/controls/data/tst_dialog.qml b/tests/auto/controls/data/tst_dialog.qml
index 53d27fd3..f8bf5bb5 100644
--- a/tests/auto/controls/data/tst_dialog.qml
+++ b/tests/auto/controls/data/tst_dialog.qml
@@ -49,6 +49,7 @@
****************************************************************************/
import QtQuick
+import QtQuick.Window
import QtTest
import QtQuick.Controls
import QtQuick.Templates as T
@@ -84,6 +85,10 @@ TestCase {
SignalSpy { }
}
+ function init() {
+ tryCompare(testCase.Window.window, "active", true)
+ }
+
function test_defaults() {
var control = createTemporaryObject(dialog, testCase)
verify(control)
@@ -105,16 +110,20 @@ TestCase {
var acceptedSpy = createTemporaryObject(signalSpy, testCase, {target: control, signalName: "accepted"})
verify(acceptedSpy.valid)
+
+ var closedSpy = createTemporaryObject(signalSpy, testCase, {target: control, signalName: "closed"})
+ verify(closedSpy.valid)
+
control.accept()
compare(acceptedSpy.count, 1)
compare(control.result, Dialog.Accepted)
tryCompare(control, "visible", false)
+ compare(acceptedSpy.count, 1)
+ compare(closedSpy.count, 1)
}
function test_reject() {
- skip("QTBUG-62549, QTBUG-62628")
-
var control = createTemporaryObject(dialog, testCase)
var openedSpy = createTemporaryObject(signalSpy, testCase, {target: control, signalName: "opened"})
@@ -127,11 +136,17 @@ TestCase {
var rejectedSpy = createTemporaryObject(signalSpy, testCase, {target: control, signalName: "rejected"})
verify(rejectedSpy.valid)
+
+ var closedSpy = createTemporaryObject(signalSpy, testCase, {target: control, signalName: "closed"})
+ verify(closedSpy.valid)
+
control.reject()
compare(rejectedSpy.count, 1)
compare(control.result, Dialog.Rejected)
tryCompare(control, "visible", false)
+ compare(rejectedSpy.count, 1)
+ compare(closedSpy.count, 1)
// Check that rejected() is emitted when CloseOnEscape is triggered.
control.x = 10
@@ -145,9 +160,12 @@ TestCase {
keyPress(Qt.Key_Escape)
compare(rejectedSpy.count, 2)
tryCompare(control, "visible", false)
+ compare(rejectedSpy.count, 2)
+ compare(closedSpy.count, 2)
keyRelease(Qt.Key_Escape)
compare(rejectedSpy.count, 2)
+ compare(closedSpy.count, 2)
// Check that rejected() is emitted when CloseOnPressOutside is triggered.
control.closePolicy = Popup.CloseOnPressOutside
@@ -157,9 +175,12 @@ TestCase {
mousePress(testCase, 1, 1)
compare(rejectedSpy.count, 3)
tryCompare(control, "visible", false)
+ compare(rejectedSpy.count, 3)
+ compare(closedSpy.count, 3)
mouseRelease(testCase, 1, 1)
compare(rejectedSpy.count, 3)
+ compare(closedSpy.count, 3)
// Check that rejected() is emitted when CloseOnReleaseOutside is triggered.
// For this, we need to make the dialog modal, because the overlay won't accept
@@ -176,6 +197,8 @@ TestCase {
mouseRelease(testCase, 1, 1)
compare(rejectedSpy.count, 4)
tryCompare(control, "visible", false)
+ compare(rejectedSpy.count, 4)
+ compare(closedSpy.count, 4)
}
function test_buttonBox_data() {