diff options
author | Simon Hausmann <simon.hausmann@nokia.com> | 2009-10-01 16:10:22 (GMT) |
---|---|---|
committer | Simon Hausmann <simon.hausmann@nokia.com> | 2009-10-01 16:10:22 (GMT) |
commit | 30d9101ecabeb0778c829c3578f1fcf5ec276a8c (patch) | |
tree | d6d67506c2bae71bf967845ff503e02dd41372ae /tests | |
parent | 6ee282013b82b5f46fa972296b801eab55c614c1 (diff) | |
parent | 984fe9ebfc6d9582d21bcf1d09cb0578fd163f54 (diff) | |
download | Qt-30d9101ecabeb0778c829c3578f1fcf5ec276a8c.zip Qt-30d9101ecabeb0778c829c3578f1fcf5ec276a8c.tar.gz Qt-30d9101ecabeb0778c829c3578f1fcf5ec276a8c.tar.bz2 |
Merge branch '4.5' of scm.dev.nokia.troll.no:qt/qt into 4.6
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/qwidget/tst_qwidget.cpp | 82 |
1 files changed, 82 insertions, 0 deletions
diff --git a/tests/auto/qwidget/tst_qwidget.cpp b/tests/auto/qwidget/tst_qwidget.cpp index e4608b2..22aedc5 100644 --- a/tests/auto/qwidget/tst_qwidget.cpp +++ b/tests/auto/qwidget/tst_qwidget.cpp @@ -355,6 +355,7 @@ private slots: void maskedUpdate(); #if defined(Q_WS_WIN) || defined(Q_WS_X11) || defined(Q_WS_QWS) void syntheticEnterLeave(); + void taskQTBUG_4055_sendSyntheticEnterLeave(); #endif void windowFlags(); void initialPosForDontShowOnScreenWidgets(); @@ -8977,6 +8978,87 @@ void tst_QWidget::syntheticEnterLeave() QCOMPARE(window.numEnterEvents, 0); QCOMPARE(child1->numEnterEvents, 1); } + +void tst_QWidget::taskQTBUG_4055_sendSyntheticEnterLeave() +{ + class SELParent : public QWidget + { + public: + SELParent(QWidget *parent = 0): QWidget(parent) { } + + void mousePressEvent(QMouseEvent *) { child->show(); } + QWidget *child; + }; + + class SELChild : public QWidget + { + public: + SELChild(QWidget *parent = 0) : QWidget(parent), numEnterEvents(0), numMouseMoveEvents(0) {} + void enterEvent(QEvent *) { ++numEnterEvents; } + void mouseMoveEvent(QMouseEvent *event) + { + QCOMPARE(event->button(), Qt::NoButton); + QCOMPARE(event->buttons(), Qt::MouseButtons(Qt::NoButton)); + ++numMouseMoveEvents; + } + void reset() { numEnterEvents = numMouseMoveEvents = 0; } + int numEnterEvents, numMouseMoveEvents; + }; + + SELParent parent; + parent.resize(200, 200); + SELChild child(&parent); + child.resize(200, 200); + parent.show(); + #ifdef Q_WS_X11 + qt_x11_wait_for_window_manager(&parent); + #endif + QTest::qWait(100); + + QCursor::setPos(child.mapToGlobal(QPoint(100, 100))); + QTest::qWait(100); + // Make sure the cursor has entered the child. + QVERIFY(child.numEnterEvents > 0); + + child.hide(); + child.reset(); + child.show(); + + // Make sure the child gets enter event and no mouse move event. + QCOMPARE(child.numEnterEvents, 1); + QCOMPARE(child.numMouseMoveEvents, 0); + + child.hide(); + child.reset(); + child.setMouseTracking(true); + child.show(); + + // Make sure the child gets enter event and mouse move event. + // Note that we verify event->button() and event->buttons() + // in SELChild::mouseMoveEvent(). + QCOMPARE(child.numEnterEvents, 1); + QCOMPARE(child.numMouseMoveEvents, 1); + + // Sending synthetic enter/leave trough the parent's mousePressEvent handler. + parent.child = &child; + + child.hide(); + child.reset(); + QTest::mouseClick(&parent, Qt::LeftButton); + + // Make sure the child gets enter event and one mouse move event. + QCOMPARE(child.numEnterEvents, 1); + QCOMPARE(child.numMouseMoveEvents, 1); + + child.hide(); + child.reset(); + child.setMouseTracking(false); + QTest::mouseClick(&parent, Qt::LeftButton); + + // Make sure the child gets enter event and no mouse move event. + QCOMPARE(child.numEnterEvents, 1); + QCOMPARE(child.numMouseMoveEvents, 0); + } #endif void tst_QWidget::windowFlags() |