diff options
author | Qt Continuous Integration System <qt-info@nokia.com> | 2010-10-19 16:08:32 (GMT) |
---|---|---|
committer | Qt Continuous Integration System <qt-info@nokia.com> | 2010-10-19 16:08:32 (GMT) |
commit | 91e5c91cde03d36cf85e31de1f66d6552e621ccd (patch) | |
tree | a638ad415e5ead612cc96f729e4ce89c5f718a91 /tests/auto | |
parent | d28057dc6f282c2cc129eae40a4fb1555fef455c (diff) | |
parent | da4d5207f0a97d7e4fcc32e43a6a6e959c8f293a (diff) | |
download | Qt-91e5c91cde03d36cf85e31de1f66d6552e621ccd.zip Qt-91e5c91cde03d36cf85e31de1f66d6552e621ccd.tar.gz Qt-91e5c91cde03d36cf85e31de1f66d6552e621ccd.tar.bz2 |
Merge branch 'master' of scm.dev.nokia.troll.no:qt/oslo-staging-1 into master-integration
* 'master' of scm.dev.nokia.troll.no:qt/oslo-staging-1:
Make sure QGraphicsSceneHoverLeave event has non-null widget pointer.
Designer: Enable morphing into QTextBrowser.
Diffstat (limited to 'tests/auto')
-rw-r--r-- | tests/auto/qgraphicsview/tst_qgraphicsview.cpp | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/tests/auto/qgraphicsview/tst_qgraphicsview.cpp b/tests/auto/qgraphicsview/tst_qgraphicsview.cpp index af02c55..433cb26 100644 --- a/tests/auto/qgraphicsview/tst_qgraphicsview.cpp +++ b/tests/auto/qgraphicsview/tst_qgraphicsview.cpp @@ -244,6 +244,7 @@ private slots: void QTBUG_4151_clipAndIgnore(); void QTBUG_5859_exposedRect(); void QTBUG_7438_cursor(); + void hoverLeave(); public slots: void dummySlot() {} @@ -4394,5 +4395,59 @@ void tst_QGraphicsView::QTBUG_7438_cursor() #endif } +class GraphicsItemWithHover : public QGraphicsRectItem +{ +public: + GraphicsItemWithHover() + : receivedEnterEvent(false), receivedLeaveEvent(false), + enterWidget(0), leaveWidget(0) + { + setRect(0, 0, 100, 100); + setAcceptHoverEvents(true); + } + + bool sceneEvent(QEvent *event) + { + if (event->type() == QEvent::GraphicsSceneHoverEnter) { + receivedEnterEvent = true; + enterWidget = static_cast<QGraphicsSceneHoverEvent *>(event)->widget(); + } else if (event->type() == QEvent::GraphicsSceneHoverLeave) { + receivedLeaveEvent = true; + leaveWidget = static_cast<QGraphicsSceneHoverEvent *>(event)->widget(); + } + return QGraphicsRectItem::sceneEvent(event); + } + + bool receivedEnterEvent; + bool receivedLeaveEvent; + QWidget *enterWidget; + QWidget *leaveWidget; +}; + +void tst_QGraphicsView::hoverLeave() +{ + QGraphicsScene scene; + QGraphicsView view(&scene); + GraphicsItemWithHover *item = new GraphicsItemWithHover; + scene.addItem(item); + + // move the cursor out of the way + QCursor::setPos(1,1); + + view.show(); + QTest::qWaitForWindowShown(&view); + + QPoint pos = view.mapToGlobal(view.viewport()->mapToGlobal(view.mapFromScene(item->mapToScene(10, 10)))); + QCursor::setPos(pos); + QTest::qWait(200); + QVERIFY(item->receivedEnterEvent); + QCOMPARE(item->enterWidget, view.viewport()); + + QCursor::setPos(0,0); + QTest::qWait(200); + QVERIFY(item->receivedLeaveEvent); + QCOMPARE(item->leaveWidget, view.viewport()); +} + QTEST_MAIN(tst_QGraphicsView) #include "tst_qgraphicsview.moc" |