tst_QLineEdit: use qWaitForWindowFocused() on Wayland to fix some tests
QTest::qWaitForWindowActive() isn't supported on Wayland, however in these tests what's required is a specific widget having keyboard focus. Pick-to: 6.7 Change-Id: Ib47431351f60f4ee31d67563ce1892dc2e8149eb Reviewed-by: Liang Qi <liang.qi@qt.io> (cherry picked from commit 3d3faa128508b6eb5fd656330cf3be0097844abb) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
parent
b64e918c85
commit
8d99b980e6
@ -1937,9 +1937,6 @@ public:
|
|||||||
|
|
||||||
void tst_QLineEdit::noCursorBlinkWhenReadOnly()
|
void tst_QLineEdit::noCursorBlinkWhenReadOnly()
|
||||||
{
|
{
|
||||||
if (QGuiApplication::platformName().startsWith(QLatin1String("wayland"), Qt::CaseInsensitive))
|
|
||||||
QSKIP("Wayland: This fails. Figure out why.");
|
|
||||||
|
|
||||||
int cursorFlashTime = QApplication::cursorFlashTime();
|
int cursorFlashTime = QApplication::cursorFlashTime();
|
||||||
if (cursorFlashTime == 0)
|
if (cursorFlashTime == 0)
|
||||||
return;
|
return;
|
||||||
@ -1947,7 +1944,8 @@ void tst_QLineEdit::noCursorBlinkWhenReadOnly()
|
|||||||
centerOnScreen(&le);
|
centerOnScreen(&le);
|
||||||
le.show();
|
le.show();
|
||||||
le.setFocus();
|
le.setFocus();
|
||||||
QVERIFY(QTest::qWaitForWindowActive(&le));
|
QVERIFY(QTest::qWaitForWindowFocused(&le));
|
||||||
|
QVERIFY(le.hasFocus());
|
||||||
le.updates = 0;
|
le.updates = 0;
|
||||||
QTest::qWait(cursorFlashTime);
|
QTest::qWait(cursorFlashTime);
|
||||||
QVERIFY(le.updates > 0);
|
QVERIFY(le.updates > 0);
|
||||||
@ -3307,9 +3305,6 @@ void tst_QLineEdit::readOnlyStyleOption()
|
|||||||
|
|
||||||
void tst_QLineEdit::validateOnFocusOut()
|
void tst_QLineEdit::validateOnFocusOut()
|
||||||
{
|
{
|
||||||
if (QGuiApplication::platformName().startsWith(QLatin1String("wayland"), Qt::CaseInsensitive))
|
|
||||||
QSKIP("Wayland: This fails. Figure out why.");
|
|
||||||
|
|
||||||
QLineEdit *testWidget = ensureTestWidget();
|
QLineEdit *testWidget = ensureTestWidget();
|
||||||
QSignalSpy editingFinishedSpy(testWidget, SIGNAL(editingFinished()));
|
QSignalSpy editingFinishedSpy(testWidget, SIGNAL(editingFinished()));
|
||||||
testWidget->setValidator(new QIntValidator(100, 999, testWidget));
|
testWidget->setValidator(new QIntValidator(100, 999, testWidget));
|
||||||
@ -3323,7 +3318,7 @@ void tst_QLineEdit::validateOnFocusOut()
|
|||||||
centerOnScreen(testWidget);
|
centerOnScreen(testWidget);
|
||||||
testWidget->show();
|
testWidget->show();
|
||||||
testWidget->activateWindow();
|
testWidget->activateWindow();
|
||||||
QVERIFY(QTest::qWaitForWindowActive(testWidget));
|
QVERIFY(QTest::qWaitForWindowFocused(testWidget));
|
||||||
QVERIFY(testWidget->hasFocus());
|
QVERIFY(testWidget->hasFocus());
|
||||||
|
|
||||||
QTest::keyPress(testWidget, '0');
|
QTest::keyPress(testWidget, '0');
|
||||||
@ -3711,9 +3706,6 @@ void tst_QLineEdit::task180999_focus()
|
|||||||
|
|
||||||
void tst_QLineEdit::task174640_editingFinished()
|
void tst_QLineEdit::task174640_editingFinished()
|
||||||
{
|
{
|
||||||
if (QGuiApplication::platformName().startsWith(QLatin1String("wayland"), Qt::CaseInsensitive))
|
|
||||||
QSKIP("Wayland: This fails. Figure out why.");
|
|
||||||
|
|
||||||
QWidget mw;
|
QWidget mw;
|
||||||
QVBoxLayout *layout = new QVBoxLayout(&mw);
|
QVBoxLayout *layout = new QVBoxLayout(&mw);
|
||||||
QLineEdit *le1 = new QLineEdit(&mw);
|
QLineEdit *le1 = new QLineEdit(&mw);
|
||||||
@ -3723,8 +3715,7 @@ void tst_QLineEdit::task174640_editingFinished()
|
|||||||
|
|
||||||
mw.show();
|
mw.show();
|
||||||
mw.activateWindow();
|
mw.activateWindow();
|
||||||
QVERIFY(QTest::qWaitForWindowActive(&mw));
|
QVERIFY(QTest::qWaitForWindowFocused(&mw));
|
||||||
QCOMPARE(&mw, QApplication::activeWindow());
|
|
||||||
|
|
||||||
QSignalSpy editingFinishedSpy(le1, SIGNAL(editingFinished()));
|
QSignalSpy editingFinishedSpy(le1, SIGNAL(editingFinished()));
|
||||||
|
|
||||||
@ -3817,8 +3808,6 @@ void tst_QLineEdit::task210502_caseInsensitiveInlineCompletion()
|
|||||||
#ifdef Q_OS_ANDROID
|
#ifdef Q_OS_ANDROID
|
||||||
QSKIP("QCompleter does not work on Android, see QTBUG-77174");
|
QSKIP("QCompleter does not work on Android, see QTBUG-77174");
|
||||||
#endif
|
#endif
|
||||||
if (QGuiApplication::platformName().startsWith(QLatin1String("wayland"), Qt::CaseInsensitive))
|
|
||||||
QSKIP("Wayland: This fails. Figure out why.");
|
|
||||||
|
|
||||||
QString completion("ABCD");
|
QString completion("ABCD");
|
||||||
QStringList completions;
|
QStringList completions;
|
||||||
@ -3829,9 +3818,9 @@ void tst_QLineEdit::task210502_caseInsensitiveInlineCompletion()
|
|||||||
completer.setCompletionMode(QCompleter::InlineCompletion);
|
completer.setCompletionMode(QCompleter::InlineCompletion);
|
||||||
lineEdit.setCompleter(&completer);
|
lineEdit.setCompleter(&completer);
|
||||||
lineEdit.show();
|
lineEdit.show();
|
||||||
QVERIFY(QTest::qWaitForWindowActive(&lineEdit));
|
|
||||||
lineEdit.setFocus();
|
lineEdit.setFocus();
|
||||||
QTRY_VERIFY(lineEdit.hasFocus());
|
QVERIFY(QTest::qWaitForWindowFocused(&lineEdit));
|
||||||
|
QVERIFY(lineEdit.hasFocus());
|
||||||
QTest::keyPress(&lineEdit, 'a');
|
QTest::keyPress(&lineEdit, 'a');
|
||||||
QTest::keyPress(&lineEdit, Qt::Key_Return);
|
QTest::keyPress(&lineEdit, Qt::Key_Return);
|
||||||
QCOMPARE(lineEdit.text(), completion);
|
QCOMPARE(lineEdit.text(), completion);
|
||||||
@ -3916,9 +3905,6 @@ void tst_QLineEdit::task233101_cursorPosAfterInputMethod()
|
|||||||
|
|
||||||
void tst_QLineEdit::task241436_passwordEchoOnEditRestoreEchoMode()
|
void tst_QLineEdit::task241436_passwordEchoOnEditRestoreEchoMode()
|
||||||
{
|
{
|
||||||
if (QGuiApplication::platformName().startsWith(QLatin1String("wayland"), Qt::CaseInsensitive))
|
|
||||||
QSKIP("Wayland: This fails. Figure out why.");
|
|
||||||
|
|
||||||
QStyleOptionFrame opt;
|
QStyleOptionFrame opt;
|
||||||
QLineEdit *testWidget = ensureTestWidget();
|
QLineEdit *testWidget = ensureTestWidget();
|
||||||
const int passwordCharacter = testWidget->style()->styleHint(QStyle::SH_LineEdit_PasswordCharacter, &opt, testWidget);
|
const int passwordCharacter = testWidget->style()->styleHint(QStyle::SH_LineEdit_PasswordCharacter, &opt, testWidget);
|
||||||
@ -3929,7 +3915,7 @@ void tst_QLineEdit::task241436_passwordEchoOnEditRestoreEchoMode()
|
|||||||
testWidget->setFocus();
|
testWidget->setFocus();
|
||||||
centerOnScreen(testWidget);
|
centerOnScreen(testWidget);
|
||||||
testWidget->show();
|
testWidget->show();
|
||||||
QVERIFY(QTest::qWaitForWindowActive(testWidget));
|
QVERIFY(QTest::qWaitForWindowFocused(testWidget));
|
||||||
QVERIFY(testWidget->hasFocus());
|
QVERIFY(testWidget->hasFocus());
|
||||||
|
|
||||||
QTest::keyPress(testWidget, '0');
|
QTest::keyPress(testWidget, '0');
|
||||||
@ -3967,9 +3953,6 @@ void tst_QLineEdit::task248948_redoRemovedSelection()
|
|||||||
|
|
||||||
void tst_QLineEdit::taskQTBUG_4401_enterKeyClearsPassword()
|
void tst_QLineEdit::taskQTBUG_4401_enterKeyClearsPassword()
|
||||||
{
|
{
|
||||||
if (QGuiApplication::platformName().startsWith(QLatin1String("wayland"), Qt::CaseInsensitive))
|
|
||||||
QSKIP("Wayland: This fails. Figure out why.");
|
|
||||||
|
|
||||||
QString password("Wanna guess?");
|
QString password("Wanna guess?");
|
||||||
|
|
||||||
QLineEdit *testWidget = ensureTestWidget();
|
QLineEdit *testWidget = ensureTestWidget();
|
||||||
@ -3979,7 +3962,8 @@ void tst_QLineEdit::taskQTBUG_4401_enterKeyClearsPassword()
|
|||||||
testWidget->selectAll();
|
testWidget->selectAll();
|
||||||
centerOnScreen(testWidget);
|
centerOnScreen(testWidget);
|
||||||
testWidget->show();
|
testWidget->show();
|
||||||
QVERIFY(QTest::qWaitForWindowActive(testWidget));
|
QVERIFY(QTest::qWaitForWindowFocused(testWidget));
|
||||||
|
QVERIFY(testWidget->hasFocus());
|
||||||
|
|
||||||
QTest::keyPress(testWidget, Qt::Key_Enter);
|
QTest::keyPress(testWidget, Qt::Key_Enter);
|
||||||
QTRY_COMPARE(testWidget->text(), password);
|
QTRY_COMPARE(testWidget->text(), password);
|
||||||
@ -4060,10 +4044,9 @@ void tst_QLineEdit::taskQTBUG_7395_readOnlyShortcut()
|
|||||||
le.addAction(&action);
|
le.addAction(&action);
|
||||||
|
|
||||||
le.show();
|
le.show();
|
||||||
QVERIFY(QTest::qWaitForWindowExposed(&le));
|
|
||||||
QVERIFY(QTest::qWaitForWindowActive(&le));
|
|
||||||
le.setFocus();
|
le.setFocus();
|
||||||
QTRY_VERIFY(le.hasFocus());
|
QVERIFY(QTest::qWaitForWindowFocused(&le));
|
||||||
|
QVERIFY(le.hasFocus());
|
||||||
|
|
||||||
QTest::keyClick(static_cast<QWidget *>(0), Qt::Key_P);
|
QTest::keyClick(static_cast<QWidget *>(0), Qt::Key_P);
|
||||||
QCOMPARE(spy.size(), 1);
|
QCOMPARE(spy.size(), 1);
|
||||||
@ -4082,9 +4065,9 @@ void tst_QLineEdit::QTBUG697_paletteCurrentColorGroup()
|
|||||||
le.setPalette(p);
|
le.setPalette(p);
|
||||||
|
|
||||||
le.show();
|
le.show();
|
||||||
QVERIFY(QTest::qWaitForWindowActive(&le));
|
|
||||||
le.setFocus();
|
le.setFocus();
|
||||||
QTRY_VERIFY(le.hasFocus());
|
QVERIFY(QTest::qWaitForWindowFocused(&le));
|
||||||
|
QVERIFY(le.hasFocus());
|
||||||
le.selectAll();
|
le.selectAll();
|
||||||
|
|
||||||
QImage img(le.size(),QImage::Format_ARGB32 );
|
QImage img(le.size(),QImage::Format_ARGB32 );
|
||||||
@ -4095,7 +4078,7 @@ void tst_QLineEdit::QTBUG697_paletteCurrentColorGroup()
|
|||||||
window.resize(100, 50);
|
window.resize(100, 50);
|
||||||
window.show();
|
window.show();
|
||||||
window.requestActivate();
|
window.requestActivate();
|
||||||
QVERIFY(QTest::qWaitForWindowActive(&window));
|
QVERIFY(QTest::qWaitForWindowFocused(&window));
|
||||||
le.render(&img);
|
le.render(&img);
|
||||||
QCOMPARE(img.pixel(10, le.height()/2), QColor(Qt::red).rgb());
|
QCOMPARE(img.pixel(10, le.height()/2), QColor(Qt::red).rgb());
|
||||||
}
|
}
|
||||||
@ -4915,9 +4898,6 @@ void tst_QLineEdit::shortcutOverrideOnReadonlyLineEdit_data()
|
|||||||
|
|
||||||
void tst_QLineEdit::shortcutOverrideOnReadonlyLineEdit()
|
void tst_QLineEdit::shortcutOverrideOnReadonlyLineEdit()
|
||||||
{
|
{
|
||||||
if (QGuiApplication::platformName().startsWith(QLatin1String("wayland"), Qt::CaseInsensitive))
|
|
||||||
QSKIP("Wayland: This fails. Figure out why.");
|
|
||||||
|
|
||||||
QFETCH(QKeySequence, keySequence);
|
QFETCH(QKeySequence, keySequence);
|
||||||
QFETCH(bool, shouldBeHandledByQLineEdit);
|
QFETCH(bool, shouldBeHandledByQLineEdit);
|
||||||
|
|
||||||
@ -4930,10 +4910,9 @@ void tst_QLineEdit::shortcutOverrideOnReadonlyLineEdit()
|
|||||||
QLineEdit *lineEdit = new QLineEdit(QStringLiteral("Test"), &widget);
|
QLineEdit *lineEdit = new QLineEdit(QStringLiteral("Test"), &widget);
|
||||||
lineEdit->setReadOnly(true);
|
lineEdit->setReadOnly(true);
|
||||||
lineEdit->setFocus();
|
lineEdit->setFocus();
|
||||||
|
|
||||||
widget.show();
|
widget.show();
|
||||||
|
QVERIFY(QTest::qWaitForWindowFocused(lineEdit));
|
||||||
QVERIFY(QTest::qWaitForWindowActive(&widget));
|
QVERIFY(lineEdit->hasFocus());
|
||||||
|
|
||||||
const int keySequenceCount = keySequence.count();
|
const int keySequenceCount = keySequence.count();
|
||||||
for (int i = 0; i < keySequenceCount; ++i) {
|
for (int i = 0; i < keySequenceCount; ++i) {
|
||||||
@ -5275,8 +5254,8 @@ void tst_QLineEdit::deleteWordByKeySequence()
|
|||||||
lineEdit->setSelection(selectionStart, selectionEnd - selectionStart);
|
lineEdit->setSelection(selectionStart, selectionEnd - selectionStart);
|
||||||
|
|
||||||
widget.show();
|
widget.show();
|
||||||
|
QVERIFY(QTest::qWaitForWindowFocused(&widget));
|
||||||
QVERIFY(QTest::qWaitForWindowActive(&widget));
|
QVERIFY(lineEdit->hasFocus());
|
||||||
|
|
||||||
QTestEventList keys;
|
QTestEventList keys;
|
||||||
addKeySequenceStandardKey(keys, key);
|
addKeySequenceStandardKey(keys, key);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user