Android: Unblacklist testQuickSelectionWithMouse test from tst_QLineEdit
Test was failing on Android because of three issues: 1. Mouse selection does not work well with Android, especially when predictive text is enabled. After changes in de5ae6917c819ff23f7d9c5742b50b15e0824877 commit, mouse selection on Android needs ImhNoPredictiveText to be set for correct handling. 2. Test sends mouse press events on center position of the QLineEdit. On some devices, the text would sometimes end before this center position. To avoid this situation the width is set directly. 3. Android expects the mouse click to be released before the next click. If it doesn't, the next selection won't work properly This commit fixes all those issues and unblacklists testQuickSelectionWithMouse test Fixes: QTBUG-87417 Fixes: QTQAINFRA-6896 Pick-to: 6.8 Change-Id: Id19850446954196a077047e250ea24a91ae7255e Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io> (cherry picked from commit 1b02900ffe02980cb3e69c60ca415fd694cd773a) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
parent
1c32faa784
commit
b579f48790
@ -1,3 +0,0 @@
|
||||
# QTBUG-87417
|
||||
[testQuickSelectionWithMouse]
|
||||
android
|
@ -5009,8 +5009,32 @@ void tst_QLineEdit::testQuickSelectionWithMouse()
|
||||
|
||||
QLineEdit lineEdit;
|
||||
lineEdit.setText(text);
|
||||
#ifdef Q_OS_ANDROID
|
||||
// Mouse selection does not work well with Android, especially when predictive text is enabled.
|
||||
// That is why Mouse selection works when ImhNoPredictiveText is set
|
||||
lineEdit.setInputMethodHints(Qt::ImhNoPredictiveText);
|
||||
#endif
|
||||
|
||||
auto mouseReleaseIfNeeded = [&lineEdit](QPoint p) {
|
||||
#ifdef Q_OS_ANDROID
|
||||
// Android expects that mouse click will be released before next click.
|
||||
// If it will not happen, the next selection will not work correctly
|
||||
QTest::mouseRelease(lineEdit.windowHandle(), Qt::LeftButton, Qt::NoModifier, p);
|
||||
#else
|
||||
Q_UNUSED(lineEdit);
|
||||
Q_UNUSED(p);
|
||||
#endif
|
||||
};
|
||||
|
||||
lineEdit.show();
|
||||
|
||||
// Test sends mouse press events on center position of the lineEdit.
|
||||
// We need to make sure that the text does not already ended before center position,
|
||||
// We are adding adittional some extra pixels to make sure text that will not move when selecting
|
||||
QFontMetrics metrics(lineEdit.font());
|
||||
const int widthForWholeText = metrics.horizontalAdvance(lineEdit.text());
|
||||
lineEdit.setFixedWidth(widthForWholeText + 20);
|
||||
|
||||
const QPoint center = lineEdit.contentsRect().center();
|
||||
|
||||
// Normal mouse selection from left to right, y doesn't change.
|
||||
@ -5019,6 +5043,7 @@ void tst_QLineEdit::testQuickSelectionWithMouse()
|
||||
qCDebug(lcTests) << "Selected text:" << lineEdit.selectedText();
|
||||
QVERIFY(!lineEdit.selectedText().isEmpty());
|
||||
QVERIFY(!lineEdit.selectedText().endsWith(suffix));
|
||||
mouseReleaseIfNeeded(center + QPoint(20, 0));
|
||||
|
||||
// Normal mouse selection from left to right, y change is below threshold.
|
||||
QTest::mousePress(lineEdit.windowHandle(), Qt::LeftButton, Qt::NoModifier, center);
|
||||
@ -5026,6 +5051,7 @@ void tst_QLineEdit::testQuickSelectionWithMouse()
|
||||
qCDebug(lcTests) << "Selected text:" << lineEdit.selectedText();
|
||||
QVERIFY(!lineEdit.selectedText().isEmpty());
|
||||
QVERIFY(!lineEdit.selectedText().endsWith(suffix));
|
||||
mouseReleaseIfNeeded(center + QPoint(20, 5));
|
||||
|
||||
// Normal mouse selection from right to left, y doesn't change.
|
||||
QTest::mousePress(lineEdit.windowHandle(), Qt::LeftButton, Qt::NoModifier, center);
|
||||
@ -5033,6 +5059,7 @@ void tst_QLineEdit::testQuickSelectionWithMouse()
|
||||
qCDebug(lcTests) << "Selected text:" << lineEdit.selectedText();
|
||||
QVERIFY(!lineEdit.selectedText().isEmpty());
|
||||
QVERIFY(!lineEdit.selectedText().startsWith(prefix));
|
||||
mouseReleaseIfNeeded(center + QPoint(-20, 0));
|
||||
|
||||
// Normal mouse selection from right to left, y change is below threshold.
|
||||
QTest::mousePress(lineEdit.windowHandle(), Qt::LeftButton, Qt::NoModifier, center);
|
||||
@ -5040,6 +5067,7 @@ void tst_QLineEdit::testQuickSelectionWithMouse()
|
||||
qCDebug(lcTests) << "Selected text:" << lineEdit.selectedText();
|
||||
QVERIFY(!lineEdit.selectedText().isEmpty());
|
||||
QVERIFY(!lineEdit.selectedText().startsWith(prefix));
|
||||
mouseReleaseIfNeeded(center + QPoint(-20, -5));
|
||||
|
||||
const int offset = QGuiApplication::styleHints()->mouseQuickSelectionThreshold() + 1;
|
||||
|
||||
@ -5048,12 +5076,14 @@ void tst_QLineEdit::testQuickSelectionWithMouse()
|
||||
QTest::mouseMove(lineEdit.windowHandle(), center + QPoint(1, offset));
|
||||
qCDebug(lcTests) << "Selected text:" << lineEdit.selectedText();
|
||||
QVERIFY(lineEdit.selectedText().endsWith(suffix));
|
||||
mouseReleaseIfNeeded(center + QPoint(1, offset));
|
||||
|
||||
// Select the whole left half.
|
||||
QTest::mousePress(lineEdit.windowHandle(), Qt::LeftButton, Qt::NoModifier, center);
|
||||
QTest::mouseMove(lineEdit.windowHandle(), center + QPoint(1, -offset));
|
||||
qCDebug(lcTests) << "Selected text:" << lineEdit.selectedText();
|
||||
QVERIFY(lineEdit.selectedText().startsWith(prefix));
|
||||
mouseReleaseIfNeeded(center + QPoint(1, -offset));
|
||||
|
||||
// Normal selection -> quick selection -> back to normal selection.
|
||||
QTest::mousePress(lineEdit.windowHandle(), Qt::LeftButton, Qt::NoModifier, center);
|
||||
@ -5070,6 +5100,7 @@ void tst_QLineEdit::testQuickSelectionWithMouse()
|
||||
QEXPECT_FAIL("", "Currently fails on gcc-armv7, needs investigation.", Continue);
|
||||
#endif
|
||||
QCOMPARE(lineEdit.selectedText(), partialSelection);
|
||||
mouseReleaseIfNeeded(center + QPoint(20, 0));
|
||||
|
||||
lineEdit.setLayoutDirection(Qt::RightToLeft);
|
||||
|
||||
@ -5077,11 +5108,13 @@ void tst_QLineEdit::testQuickSelectionWithMouse()
|
||||
QTest::mousePress(lineEdit.windowHandle(), Qt::LeftButton, Qt::NoModifier, center);
|
||||
QTest::mouseMove(lineEdit.windowHandle(), center + QPoint(1, offset));
|
||||
QVERIFY(lineEdit.selectedText().startsWith(prefix));
|
||||
mouseReleaseIfNeeded(center + QPoint(1, offset));
|
||||
|
||||
// Select the whole right half (RTL layout).
|
||||
QTest::mousePress(lineEdit.windowHandle(), Qt::LeftButton, Qt::NoModifier, center);
|
||||
QTest::mouseMove(lineEdit.windowHandle(), center + QPoint(1, -offset));
|
||||
QVERIFY(lineEdit.selectedText().endsWith(suffix));
|
||||
mouseReleaseIfNeeded(center + QPoint(1, -offset));
|
||||
}
|
||||
|
||||
void tst_QLineEdit::inputRejected()
|
||||
|
Loading…
x
Reference in New Issue
Block a user