diff options
author | J-P Nurmi <jpnurmi@qt.io> | 2016-09-03 23:41:28 +0200 |
---|---|---|
committer | J-P Nurmi <jpnurmi@qt.io> | 2016-09-05 11:03:47 +0000 |
commit | 0947ce01d0a82e1f4dbc7eee53b0e1f91a573b0b (patch) | |
tree | efdd5abfeca61cd44d7c6fbcfa325ff9244bd148 /tests | |
parent | 61ed2a96c7e87193d37b8b6f1ab03469e294ba41 (diff) |
Fix tst_Drawer::dragMargin()
The width of the window in the test is 400px, and the
width of the drawer is 200px. The default drag margin
equals to QStyleHints::startDragDistance(), which reports
19px on Linux installed on a Chromebook Pixel 2.
The test attempts to drag from (double drag margin):
2 x startDragDistance = 38px
to:
0.25 x width of the drawer = 50px
12px does not exceed the start drag distance of 19px, so the drawer
is not dragged even though the test expects it to be dragged to the
logical position of 0.25. Increase the dragged distance a bit to
exceed the threshold.
Change-Id: Id469533b08c4221430446a2d995e36b4ebdc0258
Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/drawer/tst_drawer.cpp | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/tests/auto/drawer/tst_drawer.cpp b/tests/auto/drawer/tst_drawer.cpp index 0b334387..3c128fbc 100644 --- a/tests/auto/drawer/tst_drawer.cpp +++ b/tests/auto/drawer/tst_drawer.cpp @@ -113,8 +113,8 @@ void tst_Drawer::dragMargin_data() QTest::newRow("left:0") << Qt::LeftEdge << qreal(0) << qreal(0) << qreal(0); QTest::newRow("left:-1") << Qt::LeftEdge << qreal(-1) << qreal(0) << qreal(0); - QTest::newRow("left:startDragDistance") << Qt::LeftEdge << qreal(QGuiApplication::styleHints()->startDragDistance()) << qreal(0.25) << qreal(0); - QTest::newRow("left:startDragDistance*2") << Qt::LeftEdge << qreal(QGuiApplication::styleHints()->startDragDistance() * 2) << qreal(0.25) << qreal(0); + QTest::newRow("left:startDragDistance") << Qt::LeftEdge << qreal(QGuiApplication::styleHints()->startDragDistance()) << qreal(0.45) << qreal(0); + QTest::newRow("left:startDragDistance*2") << Qt::LeftEdge << qreal(QGuiApplication::styleHints()->startDragDistance() * 2) << qreal(0.45) << qreal(0); QTest::newRow("right:0") << Qt::RightEdge << qreal(0) << qreal(0) << qreal(0); QTest::newRow("right:-1") << Qt::RightEdge << qreal(-1) << qreal(0) << qreal(0); @@ -143,20 +143,24 @@ void tst_Drawer::dragMargin() // drag from the left int leftX = qMax<int>(0, dragMargin); + int leftDistance = drawer->width() * 0.45; + QVERIFY(leftDistance > QGuiApplication::styleHints()->startDragDistance()); QTest::mousePress(window, Qt::LeftButton, Qt::NoModifier, QPoint(leftX, drawer->height() / 2)); - QTest::mouseMove(window, QPoint(drawer->width() * 0.25, drawer->height() / 2)); + QTest::mouseMove(window, QPoint(leftDistance, drawer->height() / 2)); QCOMPARE(drawer->position(), dragFromLeft); - QTest::mouseRelease(window, Qt::LeftButton, Qt::NoModifier, QPoint(drawer->width() * 0.25, drawer->height() / 2)); + QTest::mouseRelease(window, Qt::LeftButton, Qt::NoModifier, QPoint(leftDistance, drawer->height() / 2)); drawer->close(); QTRY_COMPARE(drawer->position(), qreal(0.0)); // drag from the right int rightX = qMin<int>(window->width() - 1, window->width() - dragMargin); + int rightDistance = drawer->width() * 0.75; + QVERIFY(rightDistance > QGuiApplication::styleHints()->startDragDistance()); QTest::mousePress(window, Qt::LeftButton, Qt::NoModifier, QPoint(rightX, drawer->height() / 2)); - QTest::mouseMove(window, QPoint(window->width() - drawer->width() * 0.75, drawer->height() / 2)); + QTest::mouseMove(window, QPoint(window->width() - rightDistance, drawer->height() / 2)); QCOMPARE(drawer->position(), dragFromRight); - QTest::mouseRelease(window, Qt::LeftButton, Qt::NoModifier, QPoint(window->width() - drawer->width() * 0.75, drawer->height() / 2)); + QTest::mouseRelease(window, Qt::LeftButton, Qt::NoModifier, QPoint(window->width() - rightDistance, drawer->height() / 2)); } void tst_Drawer::reposition() |