aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorLiang Qi <liang.qi@qt.io>2018-06-25 10:49:57 +0200
committerLiang Qi <liang.qi@qt.io>2018-06-25 10:49:57 +0200
commit66a781692a4d21ba4c8a124cb4be84e4e2ffa742 (patch)
tree4fe9261e26281ddb5f1444563cda53c8bf39d978 /tests
parent7fec7105b7f6119135aafd6f9ee609128125d594 (diff)
parentd5fbbddd7794265f24d392d33c4874ac756cb9c9 (diff)
Merge remote-tracking branch 'origin/5.11' into dev
Conflicts: src/imports/controls/imagine/TextArea.qml src/imports/controls/imagine/TextField.qml tests/auto/controls/data/tst_tumbler.qml Change-Id: I25a8228a4299fb7a53db70b7223663a1637ed933
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/controls/data/tst_tumbler.qml66
1 files changed, 66 insertions, 0 deletions
diff --git a/tests/auto/controls/data/tst_tumbler.qml b/tests/auto/controls/data/tst_tumbler.qml
index 46c73cfc..f62c62c2 100644
--- a/tests/auto/controls/data/tst_tumbler.qml
+++ b/tests/auto/controls/data/tst_tumbler.qml
@@ -1176,4 +1176,70 @@ TestCase {
+ " to have an y pos of " + expectedPos.y + " but it was " + actualPos.y)
}
}
+
+ Component {
+ id: setCurrentIndexOnImperativeModelChangeComponent
+
+ Tumbler {
+ onModelChanged: currentIndex = model - 2
+ }
+ }
+
+ function test_setCurrentIndexOnImperativeModelChange() {
+ var tumbler = createTemporaryObject(setCurrentIndexOnImperativeModelChangeComponent, testCase);
+ verify(tumbler);
+
+ tumbler.model = 4
+ compare(tumbler.count, 4);
+ tumblerView = findView(tumbler);
+ tryCompare(tumblerView, "count", 4);
+
+ // 4 - 2 = 2
+ compare(tumbler.currentIndex, 2);
+
+ ++tumbler.model;
+ compare(tumbler.count, 5);
+ compare(tumbler.wrap, true);
+ tumblerView = findView(tumbler);
+ tryCompare(tumblerView, "count", 5);
+ // 5 - 2 = 3
+ compare(tumbler.currentIndex, 3);
+ }
+
+ Component {
+ id: setCurrentIndexOnDeclarativeModelChangeComponent
+
+ Item {
+ property alias tumbler: tumbler
+
+ property int setting: 4
+
+ Tumbler {
+ id: tumbler
+ model: setting
+ onModelChanged: currentIndex = model - 2
+ }
+ }
+ }
+
+ function test_setCurrentIndexOnDeclarativeModelChange() {
+ var root = createTemporaryObject(setCurrentIndexOnDeclarativeModelChangeComponent, testCase);
+ verify(root);
+
+ var tumbler = root.tumbler;
+ compare(tumbler.count, 4);
+ compare(tumbler.wrap, false);
+ tumblerView = findView(tumbler);
+ tryCompare(tumblerView, "count", 4);
+ // 4 - 2 = 2
+ compare(tumbler.currentIndex, 2);
+
+ ++root.setting;
+ compare(tumbler.count, 5);
+ compare(tumbler.wrap, true);
+ tumblerView = findView(tumbler);
+ tryCompare(tumblerView, "count", 5);
+ // 5 - 2 = 3
+ compare(tumbler.currentIndex, 3);
+ }
}