From 239b8f6ee869dbe1f27ec4fa5d5247eff502c47b Mon Sep 17 00:00:00 2001 From: Shawn Rutledge Date: Wed, 31 Jan 2018 20:05:38 +0100 Subject: stabilize and standardize tst_qquickwidget In tst_qquickwidget::enterLeave(), start with the cursor outside the same as we do in QtQuick tests: move the window first, then position the cursor to the right of it and downwards (because the window might not necessarily go where you want it to). Don't hard-code 5000ms timeout on qWaitForWindowExposed(): it's the default anyway. Task-number: QTBUG-64397 Change-Id: I67e4566c2c7f9e361a79e3a091436c3391f39786 Reviewed-by: Mitch Curtis Reviewed-by: Shawn Rutledge --- tests/auto/quickwidgets/qquickwidget/BLACKLIST | 2 -- .../quickwidgets/qquickwidget/tst_qquickwidget.cpp | 34 +++++++++++----------- 2 files changed, 17 insertions(+), 19 deletions(-) delete mode 100644 tests/auto/quickwidgets/qquickwidget/BLACKLIST (limited to 'tests') diff --git a/tests/auto/quickwidgets/qquickwidget/BLACKLIST b/tests/auto/quickwidgets/qquickwidget/BLACKLIST deleted file mode 100644 index 6594a22472..0000000000 --- a/tests/auto/quickwidgets/qquickwidget/BLACKLIST +++ /dev/null @@ -1,2 +0,0 @@ -[enterLeave] -osx diff --git a/tests/auto/quickwidgets/qquickwidget/tst_qquickwidget.cpp b/tests/auto/quickwidgets/qquickwidget/tst_qquickwidget.cpp index 7163e3cebf..f007decc73 100644 --- a/tests/auto/quickwidgets/qquickwidget/tst_qquickwidget.cpp +++ b/tests/auto/quickwidgets/qquickwidget/tst_qquickwidget.cpp @@ -151,7 +151,7 @@ void tst_qquickwidget::showHide() childView->setSource(testFileUrl("rectangle.qml")); window.show(); - QVERIFY(QTest::qWaitForWindowExposed(&window, 5000)); + QVERIFY(QTest::qWaitForWindowExposed(&window)); QVERIFY(childView->quickWindow()->isVisible()); QVERIFY(childView->quickWindow()->visibility() != QWindow::Hidden); @@ -167,13 +167,13 @@ void tst_qquickwidget::reparentAfterShow() QQuickWidget *childView = new QQuickWidget(&window); childView->setSource(testFileUrl("rectangle.qml")); window.show(); - QVERIFY(QTest::qWaitForWindowExposed(&window, 5000)); + QVERIFY(QTest::qWaitForWindowExposed(&window)); QScopedPointer toplevelView(new QQuickWidget); toplevelView->setParent(&window); toplevelView->setSource(testFileUrl("rectangle.qml")); toplevelView->show(); - QVERIFY(QTest::qWaitForWindowExposed(&window, 5000)); + QVERIFY(QTest::qWaitForWindowExposed(&window)); } void tst_qquickwidget::changeGeometry() @@ -184,7 +184,7 @@ void tst_qquickwidget::changeGeometry() childView->setSource(testFileUrl("rectangle.qml")); window.show(); - QVERIFY(QTest::qWaitForWindowExposed(&window, 5000)); + QVERIFY(QTest::qWaitForWindowExposed(&window)); childView->setGeometry(100,100,100,100); } @@ -331,7 +331,7 @@ void tst_qquickwidget::readback() view->setSource(testFileUrl("rectangle.qml")); view->show(); - QVERIFY(QTest::qWaitForWindowExposed(view.data(), 5000)); + QVERIFY(QTest::qWaitForWindowExposed(view.data())); QImage img = view->grabFramebuffer(); QVERIFY(!img.isNull()); @@ -367,7 +367,7 @@ void tst_qquickwidget::renderingSignals() QCOMPARE(afterRenderingSpy.size(), 0); widget.show(); - QVERIFY(QTest::qWaitForWindowExposed(&widget, 5000)); + QVERIFY(QTest::qWaitForWindowExposed(&widget)); QTRY_VERIFY(beforeRenderingSpy.size() > 0); QTRY_VERIFY(beforeSyncSpy.size() > 0); @@ -399,9 +399,9 @@ void tst_qquickwidget::reparentToNewWindow() QQuickWidget *qqw = new QQuickWidget(&window1); qqw->setSource(testFileUrl("rectangle.qml")); window1.show(); - QVERIFY(QTest::qWaitForWindowExposed(&window1, 5000)); + QVERIFY(QTest::qWaitForWindowExposed(&window1)); window2.show(); - QVERIFY(QTest::qWaitForWindowExposed(&window2, 5000)); + QVERIFY(QTest::qWaitForWindowExposed(&window2)); QSignalSpy afterRenderingSpy(qqw->quickWindow(), &QQuickWindow::afterRendering); qqw->setParent(&window2); @@ -442,7 +442,7 @@ void tst_qquickwidget::keyEvents() KeyHandlingWidget widget; widget.setSource(testFileUrl("rectangle.qml")); widget.show(); - QVERIFY(QTest::qWaitForWindowExposed(widget.window(), 5000)); + QVERIFY(QTest::qWaitForWindowExposed(widget.window())); // Note: send the event to the QWindow, not the QWidget, in order // to simulate the full event processing chain. @@ -470,7 +470,7 @@ void tst_qquickwidget::shortcuts() KeyHandlingWidget widget; widget.setSource(testFileUrl("rectangle.qml")); widget.show(); - QVERIFY(QTest::qWaitForWindowExposed(widget.window(), 5000)); + QVERIFY(QTest::qWaitForWindowExposed(widget.window())); // Send to the widget, verify that the QQuickWindow sees it. @@ -487,14 +487,14 @@ void tst_qquickwidget::enterLeave() { QQuickWidget view; view.setSource(testFileUrl("enterleave.qml")); + view.move(100, 100); - // Ensure it is not inside the window first - QCursor::setPos(QPoint(50, 50)); - QTRY_VERIFY(QCursor::pos() == QPoint(50, 50)); + // Ensure the cursor is away from the window first + QPoint outside = view.geometry().topRight() + QPoint(100, 100); + QCursor::setPos(outside); - view.move(100, 100); view.show(); - QVERIFY(QTest::qWaitForWindowExposed(&view, 5000)); + QVERIFY(QTest::qWaitForWindowExposed(&view)); QQuickItem *rootItem = view.rootObject(); QVERIFY(rootItem); @@ -503,7 +503,7 @@ void tst_qquickwidget::enterLeave() QCursor::setPos(view.pos() + QPoint(50, 50)); QTRY_VERIFY(rootItem->property("hasMouse").toBool()); // Now check the leave - QCursor::setPos(view.pos() - QPoint(50, 50)); + QCursor::setPos(outside); QTRY_VERIFY(!rootItem->property("hasMouse").toBool()); } @@ -515,7 +515,7 @@ void tst_qquickwidget::mouseEventWindowPos() quick->setSource(testFileUrl("mouse.qml")); quick->move(50, 50); widget.show(); - QVERIFY(QTest::qWaitForWindowExposed(&widget, 5000)); + QVERIFY(QTest::qWaitForWindowExposed(&widget)); QQuickItem *rootItem = quick->rootObject(); QVERIFY(rootItem); -- cgit v1.2.3