aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto
diff options
context:
space:
mode:
authorGabriel de Dietrich <gabriel.dedietrich@theqtcompany.com>2015-04-29 12:47:38 +0200
committerJ-P Nurmi <jpnurmi@theqtcompany.com>2015-04-29 14:34:30 +0000
commite661fa1057641092428b5cb2db74b2f3a9496331 (patch)
tree7e80ccf771f0fd05d38f3ba43dbbf6773215f604 /tests/auto
parent758ecffe6450e3e64282161eeaa5f76fb8b158c3 (diff)
QQuickButton: Add canceled signal
We now support the following pattern: 1. Press the mouse button => emit pressed 2. Move the mouse cursor outside the button => pressed = false 3. Release the mouse button => emit canceled Note that getting the mouse grabbed away by another item, at any stage, will also emit the canceled signal. Change-Id: I97e485327370ea47943dfef75553000cee449a01 Reviewed-by: J-P Nurmi <jpnurmi@theqtcompany.com>
Diffstat (limited to 'tests/auto')
-rw-r--r--tests/auto/controls/data/tst_button.qml21
1 files changed, 18 insertions, 3 deletions
diff --git a/tests/auto/controls/data/tst_button.qml b/tests/auto/controls/data/tst_button.qml
index c721518d..f4ada30c 100644
--- a/tests/auto/controls/data/tst_button.qml
+++ b/tests/auto/controls/data/tst_button.qml
@@ -61,6 +61,11 @@ TestCase {
}
SignalSpy {
+ id: canceledSpy
+ signalName: "canceled"
+ }
+
+ SignalSpy {
id: clickedSpy
signalName: "clicked"
}
@@ -112,21 +117,25 @@ TestCase {
pressedChangedSpy.target = control
releasedSpy.target = control
+ canceledSpy.target = control
clickedSpy.target = control
verify(pressedChangedSpy.valid)
verify(releasedSpy.valid)
+ verify(canceledSpy.valid)
verify(clickedSpy.valid)
// check
mousePress(control, control.width / 2, control.height / 2, Qt.LeftButton)
compare(pressedChangedSpy.count, 1)
compare(releasedSpy.count, 0)
+ compare(canceledSpy.count, 0)
compare(clickedSpy.count, 0)
compare(control.pressed, true)
mouseRelease(control, control.width / 2, control.height / 2, Qt.LeftButton)
compare(pressedChangedSpy.count, 2)
compare(releasedSpy.count, 1)
+ compare(canceledSpy.count, 0)
compare(clickedSpy.count, 1)
compare(control.pressed, false)
@@ -134,12 +143,14 @@ TestCase {
mousePress(control, control.width / 2, control.height / 2, Qt.LeftButton)
compare(pressedChangedSpy.count, 3)
compare(releasedSpy.count, 1)
+ compare(canceledSpy.count, 0)
compare(clickedSpy.count, 1)
compare(control.pressed, true)
mouseRelease(control, control.width / 2, control.height / 2, Qt.LeftButton)
compare(pressedChangedSpy.count, 4)
compare(releasedSpy.count, 2)
+ compare(canceledSpy.count, 0)
compare(clickedSpy.count, 2)
compare(control.pressed, false)
@@ -147,6 +158,7 @@ TestCase {
mousePress(control, control.width / 2, control.height / 2, Qt.LeftButton)
compare(pressedChangedSpy.count, 5)
compare(releasedSpy.count, 2)
+ compare(canceledSpy.count, 0)
compare(clickedSpy.count, 2)
compare(control.pressed, true)
@@ -155,20 +167,23 @@ TestCase {
mouseRelease(control, control.width * 2, control.height * 2, Qt.LeftButton)
compare(pressedChangedSpy.count, 6)
- compare(releasedSpy.count, 3)
+ compare(releasedSpy.count, 2)
+ compare(canceledSpy.count, 1)
compare(clickedSpy.count, 2)
compare(control.pressed, false)
// right button
mousePress(control, control.width / 2, control.height / 2, Qt.RightButton)
compare(pressedChangedSpy.count, 6)
- compare(releasedSpy.count, 3)
+ compare(releasedSpy.count, 2)
+ compare(canceledSpy.count, 1)
compare(clickedSpy.count, 2)
compare(control.pressed, false)
mouseRelease(control, control.width / 2, control.height / 2, Qt.RightButton)
compare(pressedChangedSpy.count, 6)
- compare(releasedSpy.count, 3)
+ compare(releasedSpy.count, 2)
+ compare(canceledSpy.count, 1)
compare(clickedSpy.count, 2)
compare(control.pressed, false)