aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJ-P Nurmi <jpnurmi@qt.io>2016-10-20 21:38:30 +0200
committerJ-P Nurmi <jpnurmi@qt.io>2016-10-24 10:39:01 +0000
commit55b9c7c1bdc7ccaf3126622e72843a3c247cbaf4 (patch)
treeb203d4011c1e12709ba04aed31ee985e52fc94e5
parentbb8ae2d0a0ff9f36ffaf4ba64b03bd2160c99cd2 (diff)
Make tst_qquicktextedit::mouseSelection() pass
Since qtbase commit beef975, QTestLib avoids generating accidental double click events by adding 500ms timestamp delta on release events. The test requires a press-and-drag-and-release type of sequence with double and triple clicks. The triple-click case is handled fine with QTest::mouseDClick() + press + move + release, but the double-click case is using QTest::mouseClick() + press + move + release and relies on the accidental double-click event generation that QTestLib now deliberately prevents. I can't think of a nice way to inject the move event in the middle of a double-click sequence generated by QTest::mouseDClick(), so we just send the missing double-click event by hand. We can also remove the QStyleHints::mouseDoubleClickInterval waits, which were there to prevent the aforementioned accidental double click events that can no longer happen. This reduces the total execution time of mouseSelection() by roughly 90%. Task-number: QTBUG-50022 Change-Id: I252e87d6a49ea86a44cfa347a29eebee12fd36d1 Reviewed-by: Mitch Curtis <mitch.curtis@qt.io> Reviewed-by: Frederik Gladhorn <frederik.gladhorn@qt.io>
-rw-r--r--tests/auto/quick/qquicktextedit/BLACKLIST2
-rw-r--r--tests/auto/quick/qquicktextedit/tst_qquicktextedit.cpp13
2 files changed, 8 insertions, 7 deletions
diff --git a/tests/auto/quick/qquicktextedit/BLACKLIST b/tests/auto/quick/qquicktextedit/BLACKLIST
deleted file mode 100644
index 492d81531a..0000000000
--- a/tests/auto/quick/qquicktextedit/BLACKLIST
+++ /dev/null
@@ -1,2 +0,0 @@
-[mouseSelection]
-*
diff --git a/tests/auto/quick/qquicktextedit/tst_qquicktextedit.cpp b/tests/auto/quick/qquicktextedit/tst_qquicktextedit.cpp
index 580c25b225..d007e7c98d 100644
--- a/tests/auto/quick/qquicktextedit/tst_qquicktextedit.cpp
+++ b/tests/auto/quick/qquicktextedit/tst_qquicktextedit.cpp
@@ -2006,12 +2006,18 @@ void tst_qquicktextedit::mouseSelection()
else if (clicks == 3)
QTest::mouseDClick(&window, Qt::LeftButton, Qt::NoModifier, p1);
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);
- QTest::qWait(QGuiApplication::styleHints()->mouseDoubleClickInterval() + 10);
-
// Clicking and shift to clicking between the same points should select the same text.
textEditObject->setCursorPosition(0);
if (clicks > 1)
@@ -2020,9 +2026,6 @@ void tst_qquicktextedit::mouseSelection()
QTest::mouseClick(&window, Qt::LeftButton, Qt::NoModifier, p1);
QTest::mouseClick(&window, Qt::LeftButton, Qt::ShiftModifier, p2);
QTRY_COMPARE(textEditObject->selectedText(), selectedText);
-
- // ### This is to prevent double click detection from carrying over to the next test.
- QTest::qWait(QGuiApplication::styleHints()->mouseDoubleClickInterval() + 10);
}
void tst_qquicktextedit::dragMouseSelection()