diff options
author | Thierry Bastian <thierry.bastian@nokia.com> | 2009-11-25 14:35:42 (GMT) |
---|---|---|
committer | Thierry Bastian <thierry.bastian@nokia.com> | 2009-11-25 14:38:20 (GMT) |
commit | c5eea852c73bab203541a08757be2c3cf9a18c1c (patch) | |
tree | 5e6e51973b464292aabffe8ac4a8351d8c75e06d /tests/auto/qspinbox | |
parent | e4710b39900023796aa785f84ea2ec6a725662d9 (diff) | |
download | Qt-c5eea852c73bab203541a08757be2c3cf9a18c1c.zip Qt-c5eea852c73bab203541a08757be2c3cf9a18c1c.tar.gz Qt-c5eea852c73bab203541a08757be2c3cf9a18c1c.tar.bz2 |
Make the spinbox and doublespinbox better accept intermediate input
Task-number: QTBUG-5008
Reviewed-by: ogoffart
Diffstat (limited to 'tests/auto/qspinbox')
-rw-r--r-- | tests/auto/qspinbox/tst_qspinbox.cpp | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/tests/auto/qspinbox/tst_qspinbox.cpp b/tests/auto/qspinbox/tst_qspinbox.cpp index 2389060..d2fe2ac 100644 --- a/tests/auto/qspinbox/tst_qspinbox.cpp +++ b/tests/auto/qspinbox/tst_qspinbox.cpp @@ -146,6 +146,8 @@ private slots: void sizeHint(); + void taskQTBUG_5008_textFromValueAndValidate(); + public slots: void valueChangedHelper(const QString &); void valueChangedHelper(int); @@ -1004,5 +1006,37 @@ void tst_QSpinBox::sizeHint() delete widget; } +void tst_QSpinBox::taskQTBUG_5008_textFromValueAndValidate() +{ + class DecoratedSpinBox : public QSpinBox + { + friend class tst_QSpinBox; + public: + DecoratedSpinBox() + { + setLocale(QLocale::French); + setMaximum(100000000); + setValue(1000000); + } + + //we use the French delimiters here + QString textFromValue (int value) const + { + return locale().toString(value); + } + } spinbox; + spinbox.show(); + spinbox.activateWindow(); + spinbox.setFocus(); + QTest::qWaitForWindowShown(&spinbox); + QCOMPARE(spinbox.text(), spinbox.locale().toString(spinbox.value())); + spinbox.lineEdit()->setCursorPosition(2); //just after the first thousand separator + QTest::keyClick(0, Qt::Key_0); // let's insert a 0 + QCOMPARE(spinbox.value(), 10000000); //it's been multiplied by 10 + spinbox.clearFocus(); //make sure the value is correctly formatted + QCOMPARE(spinbox.text(), spinbox.locale().toString(spinbox.value())); +} + + QTEST_MAIN(tst_QSpinBox) #include "tst_qspinbox.moc" |