From 526fb971ae9a2a6c8fce27883d9c62a9ea16bcdf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Arve=20S=C3=A6ther?= Date: Thu, 5 Oct 2017 15:31:24 +0200 Subject: Add test for verifying that event is pre-accepted for event filtering Change-Id: I718bbc8dd617b52e0150a3c29cf34323383c620b Task-number: QTBUG-62631 Reviewed-by: Shawn Rutledge --- tests/auto/quick/qquickwindow/tst_qquickwindow.cpp | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'tests/auto/quick/qquickwindow/tst_qquickwindow.cpp') 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 &deliveryList() { return m_deliveryList; } static QSet &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); } -- cgit v1.2.3