diff options
author | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2022-04-05 11:37:58 +0200 |
---|---|---|
committer | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2022-04-05 13:19:26 +0200 |
commit | 3aaa33d1bf82394c4744ad777f7e3763984411c9 (patch) | |
tree | 0ec31ca47dfea1c0834d26785158672345a14988 /tests/auto | |
parent | 3aef2f03c7e9e6fa5fe1e48c044a26a679a680c7 (diff) |
Avoid crash due to QWindow being changed under us
QTest::keyClick sends two events to the same QWindow with a wait
in between. The QWindow can become invalid during that wait, so avoid
using this method.
Task-number: QTBUG-102253
Change-Id: I67d27d2bba8dd73d5918e8205e7250443799b2be
Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
Diffstat (limited to 'tests/auto')
-rw-r--r-- | tests/auto/widgets/qwebengineview/tst_qwebengineview.cpp | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/tests/auto/widgets/qwebengineview/tst_qwebengineview.cpp b/tests/auto/widgets/qwebengineview/tst_qwebengineview.cpp index 70d719e78..fefb7d9e5 100644 --- a/tests/auto/widgets/qwebengineview/tst_qwebengineview.cpp +++ b/tests/auto/widgets/qwebengineview/tst_qwebengineview.cpp @@ -1460,17 +1460,21 @@ void tst_QWebEngineView::keyboardFocusAfterPopup() QTRY_COMPARE(QApplication::focusWidget(), window.lineEdit); // Trigger QCompleter's popup and select the first suggestion. - QTest::keyClick(QApplication::focusWindow(), Qt::Key_T); + QTest::keyPress(QApplication::focusWindow(), Qt::Key_T); + QTest::keyRelease(QApplication::focusWindow(), Qt::Key_T); QTRY_VERIFY(QApplication::activePopupWidget()); - QTest::keyClick(QApplication::focusWindow(), Qt::Key_Down); - QTest::keyClick(QApplication::focusWindow(), Qt::Key_Enter); + QTest::keyPress(QApplication::focusWindow(), Qt::Key_Down); + QTest::keyRelease(QApplication::focusWindow(), Qt::Key_Down); + QTest::keyPress(QApplication::focusWindow(), Qt::Key_Enter); + QTest::keyRelease(QApplication::focusWindow(), Qt::Key_Enter); // Due to FocusOnNavigationEnabled, focus should now move to the webView. QTRY_COMPARE(QApplication::focusWidget(), window.webView->focusProxy()); // Keyboard events sent to the window should go to the <input> element. QVERIFY(loadFinishedSpy.count() || loadFinishedSpy.wait()); - QTest::keyClick(QApplication::focusWindow(), Qt::Key_X); + QTest::keyPress(QApplication::focusWindow(), Qt::Key_X); + QTest::keyRelease(QApplication::focusWindow(), Qt::Key_X); QTRY_COMPARE(evaluateJavaScriptSync(window.webView->page(), "document.getElementById('input1').value").toString(), QStringLiteral("x")); } |