summaryrefslogtreecommitdiffstats
path: root/tests/auto/widgets/widgets/qspinbox
diff options
context:
space:
mode:
authorAllan Sandfeld Jensen <allan.jensen@digia.com>2014-09-08 16:22:29 +0200
committerAllan Sandfeld Jensen <allan.jensen@digia.com>2014-09-23 11:35:30 +0200
commitdfb4af1fd34a163495790a7896acafa56b86a8f1 (patch)
tree81d6d9a5b941aaa2f69d2fb0c178abcaf51d222f /tests/auto/widgets/widgets/qspinbox
parente8ef241d0f35704433ba331dee9578190a5c98a6 (diff)
Fix spin box with fine grained wheel events
Only step the value in the spin box when we have accumulated one wheel tick worth of wheel delta. Also fixes the obsolete contructors of QWheelEvent so they set the non obsolete properties. Change-Id: Ic6ea4b37afa8eec85a6ca7bdc0d919bf8fb02608 Reviewed-by: Shawn Rutledge <shawn.rutledge@digia.com>
Diffstat (limited to 'tests/auto/widgets/widgets/qspinbox')
-rw-r--r--tests/auto/widgets/widgets/qspinbox/tst_qspinbox.cpp32
1 files changed, 32 insertions, 0 deletions
diff --git a/tests/auto/widgets/widgets/qspinbox/tst_qspinbox.cpp b/tests/auto/widgets/widgets/qspinbox/tst_qspinbox.cpp
index 350ae23d8a..ac76c44b9b 100644
--- a/tests/auto/widgets/widgets/qspinbox/tst_qspinbox.cpp
+++ b/tests/auto/widgets/widgets/qspinbox/tst_qspinbox.cpp
@@ -82,6 +82,12 @@ public:
{
return QSpinBox::valueFromText(text);
}
+#ifndef QT_NO_WHEELEVENT
+ void wheelEvent(QWheelEvent *event)
+ {
+ QSpinBox::wheelEvent(event);
+ }
+#endif
QLineEdit *lineEdit() const { return QSpinBox::lineEdit(); }
};
@@ -148,6 +154,8 @@ private slots:
void setGroupSeparatorShown_data();
void setGroupSeparatorShown();
+ void wheelEvents();
+
public slots:
void valueChangedHelper(const QString &);
void valueChangedHelper(int);
@@ -1190,5 +1198,29 @@ void tst_QSpinBox::setGroupSeparatorShown()
QCOMPARE(spinBox.value()+1000, 33000);
}
+void tst_QSpinBox::wheelEvents()
+{
+#ifndef QT_NO_WHEELEVENT
+ SpinBox spinBox;
+ spinBox.setRange(-20, 20);
+ spinBox.setValue(0);
+
+ QWheelEvent wheelUp(QPointF(), QPointF(), QPoint(), QPoint(0, 120), 120, Qt::Vertical, Qt::NoButton, Qt::NoModifier);
+ spinBox.wheelEvent(&wheelUp);
+ QCOMPARE(spinBox.value(), 1);
+
+ QWheelEvent wheelDown(QPointF(), QPointF(), QPoint(), QPoint(0, -120), -120, Qt::Vertical, Qt::NoButton, Qt::NoModifier);
+ spinBox.wheelEvent(&wheelDown);
+ spinBox.wheelEvent(&wheelDown);
+ QCOMPARE(spinBox.value(), -1);
+
+ QWheelEvent wheelHalfUp(QPointF(), QPointF(), QPoint(), QPoint(0, 60), 60, Qt::Vertical, Qt::NoButton, Qt::NoModifier);
+ spinBox.wheelEvent(&wheelHalfUp);
+ QCOMPARE(spinBox.value(), -1);
+ spinBox.wheelEvent(&wheelHalfUp);
+ QCOMPARE(spinBox.value(), 0);
+#endif
+}
+
QTEST_MAIN(tst_QSpinBox)
#include "tst_qspinbox.moc"