From 97d2d271233246ed8a0d8930c9110603bf7b03bd Mon Sep 17 00:00:00 2001 From: Andy Shaw Date: Tue, 18 Aug 2020 13:48:50 +0200 Subject: 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 Reviewed-by: Mitch Curtis --- tests/auto/controls/data/tst_spinbox.qml | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'tests/auto') 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") + } } -- cgit v1.2.3