diff options
author | Jan Arve Sæther <jan-arve.saether@qt.io> | 2017-10-05 15:31:24 +0200 |
---|---|---|
committer | Shawn Rutledge <shawn.rutledge@qt.io> | 2017-10-05 15:42:13 +0000 |
commit | 526fb971ae9a2a6c8fce27883d9c62a9ea16bcdf (patch) | |
tree | 9eb2525c98b9f77bdf24782a76b706e26bbcc954 /tests | |
parent | 49e74cf274be7cf2633af89f81ac4fcbfe174d7d (diff) |
Add test for verifying that event is pre-accepted for event filtering
Change-Id: I718bbc8dd617b52e0150a3c29cf34323383c620b
Task-number: QTBUG-62631
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/quick/qquickwindow/tst_qquickwindow.cpp | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/tests/auto/quick/qquickwindow/tst_qquickwindow.cpp b/tests/auto/quick/qquickwindow/tst_qquickwindow.cpp index d4b505a74a..2d03849981 100644 --- a/tests/auto/quick/qquickwindow/tst_qquickwindow.cpp +++ b/tests/auto/quick/qquickwindow/tst_qquickwindow.cpp @@ -3037,6 +3037,7 @@ public: , m_eventAccepts(true) , m_filterReturns(true) , m_filterAccepts(true) + , m_filterNotPreAccepted(false) { QSizeF psize(parent->width(), parent->height()); psize -= QSizeF(20, 20); @@ -3048,6 +3049,14 @@ public: void setFilterReturns(bool filterReturns) { m_filterReturns = filterReturns; } void setFilterAccepts(bool accepts) { m_filterAccepts = accepts; } void setEventAccepts(bool accepts) { m_eventAccepts = accepts; } + + /*! + * \internal + * + * returns false if any of the calls to childMouseEventFilter had the wrong + * preconditions. If all calls had the expected precondition, returns true. + */ + bool testFilterPreConditions() const { return !m_filterNotPreAccepted; } static QVector<DeliveryRecord> &deliveryList() { return m_deliveryList; } static QSet<QEvent::Type> &includedEventTypes() { @@ -3063,6 +3072,8 @@ protected: appendEvent(this, i, e); switch (e->type()) { case QEvent::MouseButtonPress: + if (!e->isAccepted()) + m_filterNotPreAccepted = true; e->setAccepted(m_filterAccepts); // qCDebug(lcTests) << objectName() << i->objectName(); return m_filterReturns; @@ -3102,6 +3113,7 @@ private: bool m_eventAccepts; bool m_filterReturns; bool m_filterAccepts; + bool m_filterNotPreAccepted; // list of (filtering-parent . receiver) pairs static DeliveryRecordVector m_expectedDeliveryList; @@ -3340,6 +3352,10 @@ void tst_qquickwindow::testChildMouseEventFilter() QCOMPARE(actualNames.toString(), expectedNames.toString()); } + for (EventItem *item : r) { + QVERIFY(item->testFilterPreConditions()); + } + // "restore" mouse state QTest::mouseRelease(&window, Qt::LeftButton, 0, mousePos); } |