aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorAndy Shaw <andy.shaw@qt.io>2020-08-18 13:48:50 +0200
committerAndy Shaw <andy.shaw@qt.io>2020-09-11 09:58:28 +0200
commit97d2d271233246ed8a0d8930c9110603bf7b03bd (patch)
tree87cb98ab1432042c256e17f9e7529a3f392f84e4 /tests
parentbb333700054e4c1e699d907e67f4e6be498968a1 (diff)
Update the text when the inputted value is out of range
When the inputted value is out of range but it would be fixed to the previous value then it would not update the text correctly to show the corrected value. This ensures that it is updated as appropriate. Before it would check if the value had actually changed after it had been fixed to the corrected value. So if it was corrected to the original value then it would not see it as having changed. Additionally the displayText also has the original text before the change, so we have to force through an update to ensure the contentItem's text is updated too. Change-Id: Ic38787d0803ab59cd998f4e2871c613f1642e764 Pick-to: 5.15 Fixes: QTBUG-85719 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/controls/data/tst_spinbox.qml25
1 files changed, 25 insertions, 0 deletions
diff --git a/tests/auto/controls/data/tst_spinbox.qml b/tests/auto/controls/data/tst_spinbox.qml
index 5898ff52..8934543d 100644
--- a/tests/auto/controls/data/tst_spinbox.qml
+++ b/tests/auto/controls/data/tst_spinbox.qml
@@ -686,4 +686,29 @@ TestCase {
verify(control)
compare(control.up.indicator.s, "this is the one");
}
+
+ function test_valueEnterFromOutsideRange() {
+ // Check that changing from 2 to 99 goes to 98 then changing to 99 puts it back to 98
+ var control = createTemporaryObject(spinBox, testCase, {from: 2, to: 98, value: 2, editable: true})
+ verify(control)
+
+ control.forceActiveFocus()
+ verify(control.activeFocus)
+
+ keyClick(Qt.Key_Backspace)
+ keyClick(Qt.Key_Backspace)
+ keyClick(Qt.Key_9)
+ keyClick(Qt.Key_9)
+ keyClick(Qt.Key_Return)
+ compare(control.value, 98)
+ compare(control.displayText, "98")
+ compare(control.contentItem.text, "98")
+
+ keyClick(Qt.Key_Backspace)
+ keyClick(Qt.Key_9)
+ keyClick(Qt.Key_Return)
+ compare(control.value, 98)
+ compare(control.displayText, "98")
+ compare(control.contentItem.text, "98")
+ }
}