aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorAlbert Astals Cid <albert.astals@canonical.com>2014-07-23 15:40:42 +0200
committerAlbert Astals Cid <albert.astals@canonical.com>2014-07-28 15:07:19 +0200
commit8454a21b837ccf3968f6dbc56ed4f06d60d63c8f (patch)
treee88906c30471ccc9cbde60c4f1572f332798cb88 /tests
parentdb7d66077e92e1ea4231d09c67bb14536e792cd6 (diff)
Flickable: Cancel interaction on interactive changes
Otherwise if you have a listview with a flickable inside with a mouseare inside the pressed is never set to false if you make the interactive property of the outer list depend on the moving of the inner flickable. This makes that when later you change currentIndex of the list and you have StrictlyEnforceRange set, the list won't move because it still thinks it is pressed Change-Id: I2c2021f486fc0a31840c3f2199bc7cb76dc01e3e Reviewed-by: Martin Jones <martin.jones@jollamobile.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/qmltest/listview/tst_listview.qml41
1 files changed, 41 insertions, 0 deletions
diff --git a/tests/auto/qmltest/listview/tst_listview.qml b/tests/auto/qmltest/listview/tst_listview.qml
index 03be57909f..069b62a726 100644
--- a/tests/auto/qmltest/listview/tst_listview.qml
+++ b/tests/auto/qmltest/listview/tst_listview.qml
@@ -108,6 +108,33 @@ Item {
property int createdDelegates: 0
}
+ ListView
+ {
+ id: listInteractiveCurrentIndexEnforce
+ width: 600
+ height: 600
+
+ snapMode: ListView.SnapOneItem
+ orientation: ListView.Horizontal
+ interactive: !currentItem.moving
+ highlightRangeMode: ListView.StrictlyEnforceRange
+
+ model: 4
+
+ focus: true
+ Keys.onPressed: if (event.key == Qt.Key_K) currentIndex = currentIndex + 1;
+
+ delegate: Flickable {
+ width: 600
+ height: 600
+ contentWidth: 600
+ contentHeight: 1200
+
+ MouseArea { anchors.fill: parent }
+ Rectangle { anchors.fill: parent; color: index == 0 ? "red" : index == 1 ? "green" : index == 2 ? "blue" : "white" }
+ }
+ }
+
Component {
id: delegateModelAfterCreateComponent
Rectangle {
@@ -272,5 +299,19 @@ Item {
listViewDelegateModelAfterCreate.model = 40;
verify(listViewDelegateModelAfterCreate.createdDelegates > 0);
}
+
+ function test_listInteractiveCurrentIndexEnforce() {
+ mousePress(listInteractiveCurrentIndexEnforce, 10, 50);
+ mouseMove(listInteractiveCurrentIndexEnforce, 10, 40);
+ mouseMove(listInteractiveCurrentIndexEnforce, 10, 30);
+ mouseMove(listInteractiveCurrentIndexEnforce, 10, 20);
+ mouseMove(listInteractiveCurrentIndexEnforce, 10, 10);
+ compare(listInteractiveCurrentIndexEnforce.interactive, false);
+ mouseRelease(listInteractiveCurrentIndexEnforce, 10, 10);
+ tryCompare(listInteractiveCurrentIndexEnforce, "interactive", true);
+ keyClick("k");
+ compare(listInteractiveCurrentIndexEnforce.currentIndex, 1);
+ tryCompare(listInteractiveCurrentIndexEnforce, "contentX", listInteractiveCurrentIndexEnforce.width);
+ }
}
}