aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/controls/data/tst_tumbler.qml
diff options
context:
space:
mode:
authorMitch Curtis <mitch.curtis@qt.io>2016-06-23 14:02:01 +0200
committerJ-P Nurmi <jpnurmi@qt.io>2016-06-28 18:18:20 +0000
commitdcdca64258fe10ffd8dd0617c2799610325b310d (patch)
treef774913901ed2b194f287f15e5c5c3a3d5ad7ef6 /tests/auto/controls/data/tst_tumbler.qml
parentfa8cccf479610757aa7957b2062a6616e2ebc173 (diff)
Tumbler: test and document negative currentIndex
Change-Id: If56bad7c3dd6dea2898058d6fc5b0d88bcd202fe Reviewed-by: J-P Nurmi <jpnurmi@qt.io>
Diffstat (limited to 'tests/auto/controls/data/tst_tumbler.qml')
-rw-r--r--tests/auto/controls/data/tst_tumbler.qml33
1 files changed, 28 insertions, 5 deletions
diff --git a/tests/auto/controls/data/tst_tumbler.qml b/tests/auto/controls/data/tst_tumbler.qml
index c5f8e284..ec13665e 100644
--- a/tests/auto/controls/data/tst_tumbler.qml
+++ b/tests/auto/controls/data/tst_tumbler.qml
@@ -154,12 +154,21 @@ TestCase {
tryCompare(tumbler, "currentIndex", 2);
compare(tumblerView.currentIndex, 2);
- // PathView has 0 as its currentIndex in this case for some reason.
tumbler.model = null;
- tryCompare(tumbler, "currentIndex", 0);
+ tryCompare(tumbler, "currentIndex", -1);
tumbler.model = ["A", "B", "C"];
tryCompare(tumbler, "currentIndex", 0);
+
+ // Setting a negative current index should have no effect, because the model isn't empty.
+ tumbler.currentIndex = -1;
+ compare(tumbler.currentIndex, 0);
+
+ tumbler.model = 1;
+ compare(tumbler.currentIndex, 0);
+
+ tumbler.model = 0;
+ compare(tumbler.currentIndex, -1);
}
Component {
@@ -194,12 +203,25 @@ TestCase {
}
}
+ Component {
+ id: negativeCurrentIndexTumblerNoWrap
+
+ Tumbler {
+ model: 5
+ wrap: false
+ currentIndex: -1
+ visibleItemCount: 3
+ }
+ }
+
function test_currentIndexAtCreation_data() {
return [
- { tag: "wrap: true", currentIndex: 2, wrap: true, component: currentIndexTumbler },
- { tag: "wrap: false", currentIndex: 2, wrap: false, component: currentIndexTumblerNoWrap },
+ { tag: "wrap: true, currentIndex: 2", currentIndex: 2, wrap: true, component: currentIndexTumbler },
+ { tag: "wrap: false, currentIndex: 2", currentIndex: 2, wrap: false, component: currentIndexTumblerNoWrap },
// Order of property assignments shouldn't matter
- { tag: "wrap: false, reversed property assignment order", currentIndex: 2, wrap: false, component: currentIndexTumblerNoWrapReversedOrder }
+ { tag: "wrap: false, currentIndex: 2, reversed property assignment order",
+ currentIndex: 2, wrap: false, component: currentIndexTumblerNoWrapReversedOrder },
+ { tag: "wrap: false, currentIndex: -1", currentIndex: 0, wrap: false, component: negativeCurrentIndexTumblerNoWrap }
]
}
@@ -423,6 +445,7 @@ TestCase {
tumblerView = findView(tumbler);
compare(tumbler.count, 5);
compare(tumbler.currentIndex, 2);
+ compare(tumblerView.count, 5);
compare(tumblerView.currentIndex, 2);
}