From 0b6e5504afc05bb3dbb16275efb0faaa50abc412 Mon Sep 17 00:00:00 2001 From: Fabian Kosmale Date: Mon, 1 Mar 2021 20:25:51 +0100 Subject: tests: Do not delete device prematurely The delivery agent expects the device to live longer than itself. Pick-to: 6.1 Change-Id: I3c837633f2c4a91f5b370df4d486a01b2ee05f13 Reviewed-by: Shawn Rutledge --- tests/auto/focus/tst_focus.cpp | 5 ++--- tests/auto/qquickpopup/tst_qquickpopup.cpp | 2 +- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/tests/auto/focus/tst_focus.cpp b/tests/auto/focus/tst_focus.cpp index b3f7c9a1..06c57efe 100644 --- a/tests/auto/focus/tst_focus.cpp +++ b/tests/auto/focus/tst_focus.cpp @@ -144,6 +144,7 @@ void tst_focus::policy() QFETCH(QString, name); QQmlEngine engine; + QScopedPointer device(QTest::createTouchDevice()); QQmlComponent component(&engine); component.setData(QString("import QtQuick.Controls; ApplicationWindow { width: 100; height: 100; %1 { anchors.fill: parent } }").arg(name).toUtf8(), QUrl()); @@ -160,8 +161,6 @@ void tst_focus::policy() window->requestActivate(); QVERIFY(QTest::qWaitForWindowActive(window.data())); - QScopedPointer device(QTest::createTouchDevice()); - control->setFocusPolicy(Qt::NoFocus); QCOMPARE(control->focusPolicy(), Qt::NoFocus); @@ -340,6 +339,7 @@ void tst_focus::scope() QQmlComponent component(&engine); component.setData(QString("import QtQuick; import QtQuick.Controls; ApplicationWindow { property alias child: child; width: 100; height: 100; %1 { anchors.fill: parent; Item { id: child; width: 10; height: 10 } } }").arg(name).toUtf8(), QUrl()); + QScopedPointer device(QTest::createTouchDevice()); QScopedPointer window(qobject_cast(component.create())); QVERIFY2(window, qPrintable(component.errorString())); @@ -356,7 +356,6 @@ void tst_focus::scope() window->requestActivate(); QVERIFY(QTest::qWaitForWindowActive(window.data())); - QScopedPointer device(QTest::createTouchDevice()); child->forceActiveFocus(); QVERIFY(child->hasActiveFocus()); diff --git a/tests/auto/qquickpopup/tst_qquickpopup.cpp b/tests/auto/qquickpopup/tst_qquickpopup.cpp index c02b47fc..442b99fa 100644 --- a/tests/auto/qquickpopup/tst_qquickpopup.cpp +++ b/tests/auto/qquickpopup/tst_qquickpopup.cpp @@ -215,6 +215,7 @@ void tst_QQuickPopup::overlay() QFETCH(bool, modal); QFETCH(bool, dim); + QScopedPointer device(QTest::createTouchDevice()); QQuickApplicationHelper helper(this, source); QVERIFY2(helper.ready, helper.failureMessage()); @@ -305,7 +306,6 @@ void tst_QQuickPopup::overlay() QVERIFY(popup->isVisible()); QVERIFY(overlay->isVisible()); - QScopedPointer device(QTest::createTouchDevice()); QTest::touchEvent(window, device.data()).press(0, QPoint(1, 1)); QCOMPARE(overlayPressedSignal.count(), ++overlayPressCount); -- cgit v1.2.3