diff options
author | Bea Lam <bea.lam@nokia.com> | 2009-11-19 05:06:49 (GMT) |
---|---|---|
committer | Bea Lam <bea.lam@nokia.com> | 2009-11-19 05:06:49 (GMT) |
commit | f9ee74e207f8604d0d94c5e83e50ae12492930c1 (patch) | |
tree | 11edcfd3ca1c84feb264039b526c0d3a520568c4 /tests/auto/qabstractscrollarea/tst_qabstractscrollarea.cpp | |
parent | a7493235a70f9e60d5d25d84b0782ee0a2e5c5fd (diff) | |
parent | 3e78ae2e6ec8df4b69845c936f6d4f6d43c15acc (diff) | |
download | Qt-f9ee74e207f8604d0d94c5e83e50ae12492930c1.zip Qt-f9ee74e207f8604d0d94c5e83e50ae12492930c1.tar.gz Qt-f9ee74e207f8604d0d94c5e83e50ae12492930c1.tar.bz2 |
Merge branch 'kinetic-declarativeui' of scm.dev.nokia.troll.no:qt/kinetic into kinetic-declarativeui
Diffstat (limited to 'tests/auto/qabstractscrollarea/tst_qabstractscrollarea.cpp')
-rw-r--r-- | tests/auto/qabstractscrollarea/tst_qabstractscrollarea.cpp | 97 |
1 files changed, 95 insertions, 2 deletions
diff --git a/tests/auto/qabstractscrollarea/tst_qabstractscrollarea.cpp b/tests/auto/qabstractscrollarea/tst_qabstractscrollarea.cpp index 5033a50..99a263b 100644 --- a/tests/auto/qabstractscrollarea/tst_qabstractscrollarea.cpp +++ b/tests/auto/qabstractscrollarea/tst_qabstractscrollarea.cpp @@ -71,6 +71,8 @@ private slots: void viewportCrash(); void task214488_layoutDirection_data(); void task214488_layoutDirection(); + void wheelEvent_data(); + void wheelEvent(); }; tst_QAbstractScrollArea::tst_QAbstractScrollArea() @@ -296,10 +298,10 @@ public: setAttribute(Qt::WA_DropSiteRegistered, true); - startTimer(2000); + startTimer(200); } - void timerEvent(QTimerEvent *event) + void timerEvent(QTimerEvent *) { // should not crash. (void)new QScrollArea(this); @@ -385,5 +387,96 @@ void tst_QAbstractScrollArea::patternBackground() QCOMPARE(image.pixel(QPoint(20,20)) , QColor(Qt::red).rgb()); } +Q_DECLARE_METATYPE(QWheelEvent *); + +void tst_QAbstractScrollArea::wheelEvent_data() +{ + QTest::addColumn<QSize>("widgetSize"); + QTest::addColumn<QPoint>("initialOffset"); + QTest::addColumn<QWheelEvent *>("event"); + QTest::addColumn<int>("movedX"); // -1 , 0 , or 1 + QTest::addColumn<int>("movedY"); + + QPoint pos(100,100); + int delta =-120; + + QTest::newRow("1") << QSize(600,600) << QPoint(50,50) + << new QWheelEvent(pos, delta, 0, 0, Qt::Horizontal) << 1 << 0; + + QTest::newRow("2") << QSize(600,600) << QPoint(50,50) + << new QWheelEvent(pos, delta, 0, 0, Qt::Vertical) << 0 << 1; + + QTest::newRow("3") << QSize(600,600) << QPoint(50,50) + << new QWheelEvent(pos, -delta, 0, 0, Qt::Horizontal) << -1 << 0; + + QTest::newRow("4") << QSize(600,600) << QPoint(50,50) + << new QWheelEvent(pos, -delta, 0, 0, Qt::Vertical) << 0 << -1; + + QTest::newRow("5") << QSize(20,600) << QPoint(0,50) + << new QWheelEvent(pos, delta, 0, 0, Qt::Horizontal) << 0 << 1; + + QTest::newRow("6") << QSize(20,600) << QPoint(0,50) + << new QWheelEvent(pos, delta, 0, 0, Qt::Vertical) << 0 << 1; + + QTest::newRow("7") << QSize(20,600) << QPoint(0,50) + << new QWheelEvent(pos, -delta, 0, 0, Qt::Horizontal) << 0 << -1; + + QTest::newRow("8") << QSize(20,600) << QPoint(0,50) + << new QWheelEvent(pos, -delta, 0, 0, Qt::Vertical) << 0 << -1; + + QTest::newRow("9") << QSize(600,20) << QPoint(50,0) + << new QWheelEvent(pos, delta, 0, 0, Qt::Horizontal) << 1 << 0; + + QTest::newRow("a") << QSize(600,20) << QPoint(50,0) + << new QWheelEvent(pos, delta, 0, 0, Qt::Vertical) << 1 << 0; + + QTest::newRow("b") << QSize(600,20) << QPoint(50,0) + << new QWheelEvent(pos, -delta, 0, 0, Qt::Horizontal) << -1 << 0; + + QTest::newRow("c") << QSize(600,20) << QPoint(50,0) + << new QWheelEvent(pos, -delta, 0, 0, Qt::Vertical) << -1 << 0; +} + + + + +void tst_QAbstractScrollArea::wheelEvent() +{ + QFETCH(QSize, widgetSize); + QFETCH(QPoint, initialOffset); + QFETCH(QWheelEvent *, event); + QFETCH(int, movedX); + QFETCH(int, movedY); + + QScrollArea scrollArea; + scrollArea.resize(200, 200); + QLabel widget("H e l l o"); + widget.resize(widgetSize); + scrollArea.setWidget(&widget); + scrollArea.show(); + QTest::qWait(20); + + scrollArea.verticalScrollBar()->setValue(initialOffset.y()); + scrollArea.horizontalScrollBar()->setValue(initialOffset.x()); + + QCOMPARE(scrollArea.verticalScrollBar()->value(), initialOffset.y()); + QCOMPARE(scrollArea.horizontalScrollBar()->value(), initialOffset.x()); + + QApplication::sendEvent(scrollArea.viewport(), event); + + if(movedX == 0) + QCOMPARE(scrollArea.horizontalScrollBar()->value(), initialOffset.x()); + else + QVERIFY(movedX * scrollArea.horizontalScrollBar()->value() > movedX * initialOffset.x()); + + if(movedY == 0) + QCOMPARE(scrollArea.verticalScrollBar()->value(), initialOffset.y()); + else + QVERIFY(movedY * scrollArea.verticalScrollBar()->value() > movedY * initialOffset.y()); + + delete event; +} + + QTEST_MAIN(tst_QAbstractScrollArea) #include "tst_qabstractscrollarea.moc" |