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>
This commit is contained in:
parent
aebff8de6c
commit
cfa2c53bc0
|
@ -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);
|
||||
|
|
Loading…
Reference in New Issue