aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/controls
diff options
context:
space:
mode:
authorJ-P Nurmi <jpnurmi@qt.io>2017-04-27 14:58:12 +0200
committerJ-P Nurmi <jpnurmi@qt.io>2017-04-27 14:33:47 +0000
commitf9552a96a7c6f8ea58d8ea90cf3027cc0636bf64 (patch)
tree04bf9b2f73ca14c12370410624e376d9e525298c /tests/auto/controls
parentc96cdc8728361864f24c0f4612a9eee2215927f6 (diff)
Container: document and test current index management
Change-Id: I368dd50a4ded743826d6dc4d25dde379c98af20d Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
Diffstat (limited to 'tests/auto/controls')
-rw-r--r--tests/auto/controls/data/tst_container.qml36
1 files changed, 36 insertions, 0 deletions
diff --git a/tests/auto/controls/data/tst_container.qml b/tests/auto/controls/data/tst_container.qml
index 684f0931..049982fb 100644
--- a/tests/auto/controls/data/tst_container.qml
+++ b/tests/auto/controls/data/tst_container.qml
@@ -90,4 +90,40 @@ TestCase {
compare(control.implicitWidth, 210)
compare(control.implicitHeight, 220)
}
+
+ function test_currentIndex() {
+ var control1 = createTemporaryObject(container, testCase)
+ verify(control1)
+
+ var control2 = createTemporaryObject(container, testCase)
+ verify(control2)
+
+ compare(control1.currentIndex, -1)
+ compare(control2.currentIndex, -1)
+
+ for (var i = 0; i < 3; ++i) {
+ control1.addItem(rectangle.createObject(control1))
+ control2.addItem(rectangle.createObject(control2))
+ }
+
+ compare(control1.count, 3)
+ compare(control2.count, 3)
+ compare(control1.currentIndex, 0)
+ compare(control2.currentIndex, 0)
+
+ control1.currentIndex = Qt.binding(function() { return control2.currentIndex })
+ control2.currentIndex = Qt.binding(function() { return control1.currentIndex })
+
+ control1.setCurrentIndex(1)
+ compare(control1.currentIndex, 1)
+ compare(control2.currentIndex, 1)
+
+ control1.incrementCurrentIndex()
+ compare(control1.currentIndex, 2)
+ compare(control2.currentIndex, 2)
+
+ control2.decrementCurrentIndex()
+ compare(control1.currentIndex, 1)
+ compare(control2.currentIndex, 1)
+ }
}