aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJan Arve Sæther <jan-arve.saether@qt.io>2019-08-22 16:47:58 +0200
committerJan Arve Sæther <jan-arve.saether@qt.io>2019-08-28 09:35:12 +0200
commitcfa2c53bc085c775f8ea8dd907e7cd0538542816 (patch)
treeb8a561ebd90c0e1bd96a2b05d6e9ec6f4c2ab7a8
parentaebff8de6c7522b86c1c3c1d8a371a75073ffec8 (diff)
Make mouseSelection test more stable
QTestLib assumes that the double click interval is below 500ms. Therefore it adds a 500ms delay after all synthesized single- and doubleclick releases to prevent unintentional synthesizing of double click events. This has two unfortunate side-effects: 1. If the double click interval is smaller than 500 ms, it is not possible to synthesize a triple click. (Triple clicks are used for selecting paragraphs in text). This is why the workaround in the block (if clicks ==2) was needed. 2. If the double click interval is bigger than 500ms we might still accidentally trigger a double click event with two successive single click events, so it doesn't even work reliably for that case (!). Therefore, the hardcoded 500ms in QTestLib should probably be revisited. Anyway, to fix this test we therefore have to cancel the 500ms delta QTestLib adds in order to properly synthesize the triple click by adjusting the internal QTest::lastMouseTimestamp. Task-number: QTBUG-77389 Change-Id: Ic738f51b294270ddf99b6d91d256f6ec4b34d039 Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
-rw-r--r--tests/auto/quick/qquicktextedit/tst_qquicktextedit.cpp15
1 files changed, 6 insertions, 9 deletions
diff --git a/tests/auto/quick/qquicktextedit/tst_qquicktextedit.cpp b/tests/auto/quick/qquicktextedit/tst_qquicktextedit.cpp
index a9016be84a..facd63027e 100644
--- a/tests/auto/quick/qquicktextedit/tst_qquicktextedit.cpp
+++ b/tests/auto/quick/qquicktextedit/tst_qquicktextedit.cpp
@@ -2117,23 +2117,20 @@ void tst_qquicktextedit::mouseSelection()
QTest::mouseClick(&window, Qt::LeftButton, Qt::NoModifier, p1, moreThanDoubleClickInterval);
else if (clicks == 3)
QTest::mouseDClick(&window, Qt::LeftButton, Qt::NoModifier, p1, moreThanDoubleClickInterval);
+ // cancel the 500ms delta QTestLib adds in order to properly synthesize a triple click within the required interval
+ QTest::lastMouseTimestamp -= QTest::mouseDoubleClickInterval;
QTest::mousePress(&window, Qt::LeftButton, Qt::NoModifier, p1);
- if (clicks == 2) {
- // QTBUG-50022: Since qtbase commit beef975, QTestLib avoids generating
- // double click events by adding 500ms delta to release event timestamps.
- // Send a double click event by hand to ensure the correct sequence:
- // press, release, press, _dbl click_, move, release.
- QMouseEvent dblClickEvent(QEvent::MouseButtonDblClick, p1, Qt::LeftButton, Qt::LeftButton, Qt::NoModifier);
- QGuiApplication::sendEvent(textEditObject, &dblClickEvent);
- }
QTest::mouseMove(&window, p2);
QTest::mouseRelease(&window, Qt::LeftButton, Qt::NoModifier, p2);
QTRY_COMPARE(textEditObject->selectedText(), selectedText);
// Clicking and shift to clicking between the same points should select the same text.
textEditObject->setCursorPosition(0);
- if (clicks > 1)
+ if (clicks > 1) {
QTest::mouseDClick(&window, Qt::LeftButton, Qt::NoModifier, p1);
+ // cancel the 500ms delta QTestLib adds in order to properly synthesize a triple click within the required interval
+ QTest::lastMouseTimestamp -= QTest::mouseDoubleClickInterval;
+ }
if (clicks != 2)
QTest::mouseClick(&window, Qt::LeftButton, Qt::NoModifier, p1);
QTest::mouseClick(&window, Qt::LeftButton, Qt::ShiftModifier, p2);