diff options
author | J-P Nurmi <jpnurmi@qt.io> | 2016-11-15 11:29:12 +0100 |
---|---|---|
committer | J-P Nurmi <jpnurmi@qt.io> | 2016-11-15 11:42:23 +0000 |
commit | 0e4ad6198a43c621538a95cf6f1a6ff5ddfed596 (patch) | |
tree | 196ca83e9d805c755530670005e6462ea8cee15f /tests | |
parent | 95d10ba1b2f5fd2662c3400293f3837266a92a4e (diff) |
Stabilize tst_drawer
The test was using QTRY_COMPARE to test that the logical position of
the drawer was 1.0, meaning that the drawer was assumed to be fully
open. Then the test continued with touch move events and tested the
logical position accordingly.
The problem was that waiting (QTRY_COMPARE) for the logical position
of 1.0 does not ensure that the open transition has been finished.
Fuzzy compare might return true just before the transition finishes.
We sent touch move events and tested the logical position accordingly,
while the open transition was still running. This way, the transition
ended up setting an unexpected position for the drawer in the middle
of the touch move event tests.
The solution is to wait for the opened() signal to ensure that the
transition has been finished, before continuing to test touch move
events.
Change-Id: Ia48f4cedc97c09bb1ee064f3b535ad4fc7ae5c71
Task-number: QTBUG-56061
Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/drawer/BLACKLIST | 2 | ||||
-rw-r--r-- | tests/auto/drawer/tst_drawer.cpp | 11 |
2 files changed, 9 insertions, 4 deletions
diff --git a/tests/auto/drawer/BLACKLIST b/tests/auto/drawer/BLACKLIST deleted file mode 100644 index 1b06b49c..00000000 --- a/tests/auto/drawer/BLACKLIST +++ /dev/null @@ -1,2 +0,0 @@ -[touch] -windows diff --git a/tests/auto/drawer/tst_drawer.cpp b/tests/auto/drawer/tst_drawer.cpp index 830f63b0..ab652466 100644 --- a/tests/auto/drawer/tst_drawer.cpp +++ b/tests/auto/drawer/tst_drawer.cpp @@ -714,6 +714,11 @@ void tst_Drawer::touch() QQuickDrawer *drawer = window->property("drawer").value<QQuickDrawer*>(); QVERIFY(drawer); + QSignalSpy drawerOpenedSpy(drawer, SIGNAL(opened())); + QSignalSpy drawerClosedSpy(drawer, SIGNAL(closed())); + QVERIFY(drawerOpenedSpy.isValid()); + QVERIFY(drawerClosedSpy.isValid()); + struct TouchDeviceDeleter { static inline void cleanup(QTouchDevice *device) @@ -732,7 +737,8 @@ void tst_Drawer::touch() QTest::touchEvent(window, device.data()).move(0, QPoint(100, 100)); QTRY_COMPARE(drawer->position(), 0.5); QTest::touchEvent(window, device.data()).release(0, QPoint(100, 100)); - QTRY_COMPARE(drawer->position(), 1.0); + QVERIFY(drawerOpenedSpy.wait()); + QCOMPARE(drawer->position(), 1.0); // drag to close QTest::touchEvent(window, device.data()).press(0, QPoint(300, 100)); @@ -744,7 +750,8 @@ void tst_Drawer::touch() QTest::touchEvent(window, device.data()).move(0, QPoint(100, 100)); QTRY_COMPARE(drawer->position(), 0.5); QTest::touchEvent(window, device.data()).release(0, QPoint(100, 100)); - QTRY_COMPARE(drawer->position(), 0.0); + QVERIFY(drawerClosedSpy.wait()); + QCOMPARE(drawer->position(), 0.0); } void tst_Drawer::grabber() |