diff options
author | J-P Nurmi <jpnurmi@qt.io> | 2018-03-08 16:32:59 +0100 |
---|---|---|
committer | J-P Nurmi <jpnurmi@qt.io> | 2018-03-09 09:08:42 +0000 |
commit | 031a1e89e1baa952225c0f036b605f591f554e9b (patch) | |
tree | 1eba28f4fa525482223a021d6b1ba7885a7d9a22 /tests/auto/qquickdrawer/tst_qquickdrawer.cpp | |
parent | 0dbfa219e704dbccadff9f305817bfd4ef37905b (diff) |
QQuickDrawer: fix draggingv5.11.0-beta2
Make sure to respect keepMouse|TouchGrab. This fixes dragging
a horizontal Slider inside a Drawer on the left or right edge,
for example.
Task-number: QTBUG-66637
Change-Id: Ie3688744741378694f96abc608dad2630ecd1fb0
Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
Diffstat (limited to 'tests/auto/qquickdrawer/tst_qquickdrawer.cpp')
-rw-r--r-- | tests/auto/qquickdrawer/tst_qquickdrawer.cpp | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/tests/auto/qquickdrawer/tst_qquickdrawer.cpp b/tests/auto/qquickdrawer/tst_qquickdrawer.cpp index 60c5b189..bba1cf45 100644 --- a/tests/auto/qquickdrawer/tst_qquickdrawer.cpp +++ b/tests/auto/qquickdrawer/tst_qquickdrawer.cpp @@ -106,6 +106,9 @@ private slots: void nonModal_data(); void nonModal(); + void slider_data(); + void slider(); + private: struct TouchDeviceDeleter { @@ -1257,6 +1260,58 @@ void tst_QQuickDrawer::nonModal() QVERIFY(closedSpy.wait()); } +void tst_QQuickDrawer::slider_data() +{ + QTest::addColumn<bool>("mouse"); + QTest::newRow("mouse") << true; + QTest::newRow("touch") << false; +} + +void tst_QQuickDrawer::slider() +{ + QFETCH(bool, mouse); + + QQuickApplicationHelper helper(this, QStringLiteral("slider.qml")); + QQuickWindow *window = helper.window; + window->show(); + QVERIFY(QTest::qWaitForWindowActive(window)); + + QQuickDrawer *drawer = window->property("drawer").value<QQuickDrawer *>(); + QVERIFY(drawer); + + QQuickSlider *slider = window->property("slider").value<QQuickSlider *>(); + QVERIFY(slider); + + QCOMPARE(slider->value(), 1.0); + QCOMPARE(drawer->position(), 1.0); + + const qreal y = slider->height() / 2; + const QPoint from(slider->width() - 1, y); + const QPoint to(1, y); + + if (mouse) + QTest::mousePress(window, Qt::LeftButton, Qt::NoModifier, from); + else + QTest::touchEvent(window, touchDevice.data()).press(0, from); + + int distance = qAbs(from.x() - to.x()); + for (int dx = 2; dx < distance; dx += 2) { + if (mouse) + QTest::mouseMove(window, from - QPoint(dx, 0)); + else + QTest::touchEvent(window, touchDevice.data()).move(0, from - QPoint(dx, 0)); + QTest::qWait(1); // avoid infinite velocity + } + + QCOMPARE(slider->value(), 0.0); + QCOMPARE(drawer->position(), 1.0); + + if (mouse) + QTest::mouseRelease(window, Qt::LeftButton, Qt::NoModifier, to); + else + QTest::touchEvent(window, touchDevice.data()).release(0, to); +} + QTEST_QUICKCONTROLS_MAIN(tst_QQuickDrawer) #include "tst_qquickdrawer.moc" |