aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto
diff options
context:
space:
mode:
authorJ-P Nurmi <jpnurmi@qt.io>2016-11-22 17:13:03 +0100
committerJ-P Nurmi <jpnurmi@qt.io>2016-11-25 14:36:49 +0000
commite33443d9b8de1917d8d3b85f185bbb75b78dc448 (patch)
treeea3c80200476d61dc5601564ab858eb4eb1683c6 /tests/auto
parentd705558a28e013aea904214deb8f35c708b61ac3 (diff)
Add SwipeDelegate::swipe.open()
This allows nice tricks, such as opening the swipe on click to expose more details for clicked delegates. [ChangeLog][Controls][SwipeDelegate] Added swipe.open(side) method that can be used to programmatically open the side item on the specified side, which can be either SwipeDelegate.Left or SwipeDelegate.Right. Change-Id: I64000e41ef62e04bf11a3819e03353c3ae4690cb Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
Diffstat (limited to 'tests/auto')
-rw-r--r--tests/auto/controls/data/tst_swipedelegate.qml62
1 files changed, 62 insertions, 0 deletions
diff --git a/tests/auto/controls/data/tst_swipedelegate.qml b/tests/auto/controls/data/tst_swipedelegate.qml
index c2e99df1..47aba3d5 100644
--- a/tests/auto/controls/data/tst_swipedelegate.qml
+++ b/tests/auto/controls/data/tst_swipedelegate.qml
@@ -1450,4 +1450,66 @@ TestCase {
control.destroy();
}
+
+ function test_side() {
+ compare(SwipeDelegate.Left, 1.0);
+ compare(SwipeDelegate.Right, -1.0);
+ }
+
+ function test_open_side_data() {
+ return [
+ { tag: "left", side: SwipeDelegate.Left, position: 1, complete: true, left: greenLeftComponent, right: null, behind: null },
+ { tag: "right", side: SwipeDelegate.Right, position: -1, complete: true, left: null, right: redRightComponent, behind: null },
+ { tag: "behind,left", side: SwipeDelegate.Left, position: 1, complete: true, left: null, right: null, behind: greenLeftComponent },
+ { tag: "behind,right", side: SwipeDelegate.Right, position: -1, complete: true, left: null, right: null, behind: redRightComponent },
+ { tag: "left,behind", side: SwipeDelegate.Left, position: 1, complete: true, left: null, right: null, behind: greenLeftComponent },
+ { tag: "right,behind", side: SwipeDelegate.Right, position: -1, complete: true, left: null, right: null, behind: redRightComponent },
+ { tag: "left,null", side: SwipeDelegate.Left, position: 0, complete: false, left: null, right: null, behind: null },
+ { tag: "right,null", side: SwipeDelegate.Right, position: 0, complete: false, left: null, right: null, behind: null },
+ { tag: "invalid", side: 0, position: 0, complete: false, left: greenLeftComponent, right: null, behind: null }
+ ]
+ }
+
+ function test_open_side(data) {
+ var control = emptySwipeDelegateComponent.createObject(testCase, {"swipe.left": data.left, "swipe.right": data.right, "swipe.behind": data.behind});
+ verify(control);
+
+ control.swipe.open(data.side);
+ compare(control.swipe.position, data.position);
+ compare(control.swipe.complete, data.complete);
+
+ control.destroy();
+ }
+
+ Component {
+ id: openSwipeDelegateComponent
+
+ SwipeDelegate {
+ text: "SwipeDelegate"
+ width: 150
+
+ onClicked: swipe.open(SwipeDelegate.Right)
+
+ swipe.right: Item {
+ width: parent.width
+ height: parent.height
+ }
+ }
+ }
+
+ function test_open() {
+ var control = openSwipeDelegateComponent.createObject(testCase);
+ verify(control);
+
+ mouseClick(control);
+ compare(control.swipe.position, SwipeDelegate.Right);
+ tryCompare(control.background, "x", -control.background.width);
+
+ // Swiping after opening should work as normal.
+ swipe(control, SwipeDelegate.Right, 0.0);
+ compare(control.swipe.position, 0.0);
+ tryCompare(control.background, "x", 0);
+
+ control.destroy();
+ }
}