diff options
author | Andy Nichols <andy.nichols@nokia.com> | 2010-11-25 15:46:46 (GMT) |
---|---|---|
committer | Pierre Rossi <pierre.rossi@nokia.com> | 2010-11-25 15:48:15 (GMT) |
commit | 4ab5e3c6e2a7188d0b1f9ce57c461bb8f6d22cc9 (patch) | |
tree | 7b63749aa593b8978a6d522b2f932a61c3687e8d /tests/auto/qdial | |
parent | 985832eaf110d3decb32e7f984429e09e6bd6271 (diff) | |
download | Qt-4ab5e3c6e2a7188d0b1f9ce57c461bb8f6d22cc9.zip Qt-4ab5e3c6e2a7188d0b1f9ce57c461bb8f6d22cc9.tar.gz Qt-4ab5e3c6e2a7188d0b1f9ce57c461bb8f6d22cc9.tar.bz2 |
Allow QDial to wrap value when wrapping property is set.
QDial's wrapping property allows for 360 degree revolutions when using
the mouse. However whenever using the keyboard Up/Down/PageUp/PageDown
keys the QDial's value will stop at the minimum and maximum values.
This has been fixed to allow the bounds checker to account for the
wrapping property.
Merge-request: 2437
Reviewed-by: Pierre Rossi <pierre.rossi@nokia.com>
Diffstat (limited to 'tests/auto/qdial')
-rw-r--r-- | tests/auto/qdial/tst_qdial.cpp | 64 |
1 files changed, 64 insertions, 0 deletions
diff --git a/tests/auto/qdial/tst_qdial.cpp b/tests/auto/qdial/tst_qdial.cpp index 2428eae..92c2964 100644 --- a/tests/auto/qdial/tst_qdial.cpp +++ b/tests/auto/qdial/tst_qdial.cpp @@ -54,6 +54,7 @@ private slots: void getSetCheck(); void valueChanged(); void sliderMoved(); + void wrappingCheck(); }; // Testing get/set functions @@ -143,5 +144,68 @@ void tst_QDial::sliderMoved() } +void tst_QDial::wrappingCheck() +{ + //This tests if dial will wrap past the maximum value back to the minimum + //and vice versa when changing the value with a keypress + QDial dial; + dial.setMinimum(0); + dial.setMaximum(100); + dial.setSingleStep(1); + dial.setWrapping(true); + dial.setValue(99); + dial.show(); + + { //set value to maximum but do not wrap + QTest::keyPress(&dial, Qt::Key_Up); + QCOMPARE( dial.value(), 100); + } + + { //step up once more and wrap clockwise to minimum + 1 + QTest::keyPress(&dial, Qt::Key_Up); + QCOMPARE( dial.value(), 1); + } + + { //step down once, and wrap anti-clockwise to minimum, then again to maximum - 1 + QTest::keyPress(&dial, Qt::Key_Down); + QCOMPARE( dial.value(), 0); + + QTest::keyPress(&dial, Qt::Key_Down); + QCOMPARE( dial.value(), 99); + } + + { //when wrapping property is false no wrapping will occur + dial.setWrapping(false); + dial.setValue(100); + + QTest::keyPress(&dial, Qt::Key_Up); + QCOMPARE( dial.value(), 100); + + dial.setValue(0); + QTest::keyPress(&dial, Qt::Key_Down); + QCOMPARE( dial.value(), 0); + } + + { //When the step is really big or small, wrapping should still behave + dial.setWrapping(true); + dial.setValue(dial.minimum()); + dial.setSingleStep(305); + + QTest::keyPress(&dial, Qt::Key_Up); + QCOMPARE( dial.value(), 5); + + dial.setValue(dial.minimum()); + QTest::keyPress(&dial, Qt::Key_Down); + QCOMPARE( dial.value(), 95); + + dial.setMinimum(-30); + dial.setMaximum(-4); + dial.setSingleStep(200); + dial.setValue(dial.minimum()); + QTest::keyPress(&dial, Qt::Key_Down); + QCOMPARE( dial.value(), -22); + } +} + QTEST_MAIN(tst_QDial) #include "tst_qdial.moc" |