aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/controls/data/tst_swipedelegate.qml
diff options
context:
space:
mode:
authorMitch Curtis <mitch.curtis@qt.io>2016-11-21 11:52:53 +0100
committerJ-P Nurmi <jpnurmi@qt.io>2016-11-25 14:36:47 +0000
commitd705558a28e013aea904214deb8f35c708b61ac3 (patch)
tree14d5a71088827523ce183a8c88b30a37c179352f /tests/auto/controls/data/tst_swipedelegate.qml
parent22769ac6a7667bf1d2d5b5e6421a15e4f6aadce1 (diff)
SwipeDelegate: Add swipe.enabled property
[ChangeLog][Controls][SwipeDelegate] Added swipe.enabled property to allow disabling of swiping. Task-number: QTBUG-57192 Change-Id: I733336690368ea3fb56a144a335a37e60a02f1b9 Reviewed-by: J-P Nurmi <jpnurmi@qt.io>
Diffstat (limited to 'tests/auto/controls/data/tst_swipedelegate.qml')
-rw-r--r--tests/auto/controls/data/tst_swipedelegate.qml83
1 files changed, 83 insertions, 0 deletions
diff --git a/tests/auto/controls/data/tst_swipedelegate.qml b/tests/auto/controls/data/tst_swipedelegate.qml
index 92f25e2a..c2e99df1 100644
--- a/tests/auto/controls/data/tst_swipedelegate.qml
+++ b/tests/auto/controls/data/tst_swipedelegate.qml
@@ -1367,4 +1367,87 @@ TestCase {
control.destroy();
}
+
+ Component {
+ id: swipeDelegateDisabledComponent
+
+ SwipeDelegate {
+ id: swipeDelegate
+ text: "SwipeDelegate"
+ width: parent.width
+ height: checked ? implicitHeight * 2 : implicitHeight
+ checkable: true
+
+ swipe.enabled: false
+ swipe.right: Label {
+ text: swipeDelegate.checked ? qsTr("Expanded") : qsTr("Collapsed")
+ width: parent.width
+ height: parent.height
+ padding: 12
+ color: "white"
+ verticalAlignment: Label.AlignVCenter
+ horizontalAlignment: Label.AlignRight
+ }
+ }
+ }
+
+ function test_swipeEnabled() {
+ var control = swipeDelegateDisabledComponent.createObject(testCase);
+
+ mousePress(control, control.width / 2, control.height / 2);
+ verify(control.pressed);
+ compare(control.swipe.position, 0.0);
+ verify(!control.swipe.complete);
+ verify(!control.swipe.leftItem);
+ verify(!control.swipe.rightItem);
+
+ // It shouldn't be possible to swipe.
+ var overDragDistance = Math.round(dragDistance * 1.1);
+ mouseMove(control, control.width / 2 - overDragDistance, control.height / 2);
+ verify(control.pressed);
+ compare(control.swipe.position, 0.0);
+ verify(!control.swipe.complete);
+ verify(!control.swipe.leftItem);
+ verify(!control.swipe.rightItem);
+
+ // Now move outside the right edge of the control and release.
+ mouseMove(control, control.width * 1.1, control.height / 2);
+ verify(control.pressed);
+ compare(control.swipe.position, 0.0);
+ verify(!control.swipe.complete);
+ verify(!control.swipe.leftItem);
+ verify(!control.swipe.rightItem);
+
+ mouseRelease(control, control.width / 2, control.height / 2);
+ verify(!control.pressed);
+ compare(control.swipe.position, 0.0);
+ verify(!control.swipe.complete);
+ verify(!control.swipe.leftItem);
+ verify(!control.swipe.rightItem);
+
+ // Now enabled swiping so that we can swipe to the left.
+ control.swipe.enabled = true;
+ swipe(control, 0, -1);
+ verify(control.swipe.complete);
+
+ // Now that the swipe is complete, disable swiping and then try to swipe again.
+ // It should stay at its position of -1.
+ control.swipe.enabled = false;
+
+ mousePress(control, control.width / 2, control.height / 2);
+ verify(control.pressed);
+ compare(control.swipe.position, -1.0);
+
+ mouseMove(control, control.width / 2 + overDragDistance, control.height / 2);
+ verify(control.pressed);
+ compare(control.swipe.position, -1.0);
+ verify(control.swipe.complete);
+
+ mouseRelease(control, control.width / 2 + overDragDistance, control.height / 2);
+ verify(!control.pressed);
+ compare(control.swipe.position, -1.0);
+ verify(control.swipe.complete);
+
+ control.destroy();
+ }
}