aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/controls/data/tst_spinbox.qml
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/controls/data/tst_spinbox.qml')
-rw-r--r--tests/auto/controls/data/tst_spinbox.qml44
1 files changed, 44 insertions, 0 deletions
diff --git a/tests/auto/controls/data/tst_spinbox.qml b/tests/auto/controls/data/tst_spinbox.qml
index 5a3b1f29..9568da1a 100644
--- a/tests/auto/controls/data/tst_spinbox.qml
+++ b/tests/auto/controls/data/tst_spinbox.qml
@@ -570,4 +570,48 @@ TestCase {
verify(control)
compare(control.value, 1000)
}
+
+ Component {
+ id: sizeBox
+ SpinBox {
+ from: 0
+ to: items.length - 1
+
+ property var items: ["Small", "Medium", "Large"]
+
+ validator: RegExpValidator {
+ regExp: new RegExp("(Small|Medium|Large)", "i")
+ }
+
+ textFromValue: function(value) {
+ return items[value];
+ }
+
+ valueFromText: function(text) {
+ for (var i = 0; i < items.length; ++i) {
+ if (items[i].toLowerCase().indexOf(text.toLowerCase()) === 0)
+ return i
+ }
+ return sb.value
+ }
+ }
+ }
+
+ function test_textFromValue_data() {
+ return [
+ { tag: "default", component: spinBox, values: [0, 10, 99], displayTexts: ["0", "10", "99"] },
+ { tag: "custom", component: sizeBox, values: [0, 1, 2], displayTexts: ["Small", "Medium", "Large"] }
+ ]
+ }
+
+ function test_textFromValue(data) {
+ var control = createTemporaryObject(data.component, testCase)
+ verify(control)
+
+ for (var i = 0; i < data.values.length; ++i) {
+ control.value = data.values[i]
+ compare(control.value, data.values[i])
+ compare(control.displayText, data.displayTexts[i])
+ }
+ }
}