aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/quick/examples/tst_examples.cpp36
-rw-r--r--tests/auto/quick/qquickflickable/qquickflickable.pro1
-rw-r--r--tests/auto/quick/qquickflickable/tst_qquickflickable.cpp185
-rw-r--r--tests/auto/quick/qquickgridview/tst_qquickgridview.cpp3
-rw-r--r--tests/auto/quick/qquickpathview/tst_qquickpathview.cpp148
-rw-r--r--tests/auto/quick/qquickwindow/data/showHideAnimate.qml5
-rw-r--r--tests/auto/quick/qquickwindow/qquickwindow.pro3
-rw-r--r--tests/auto/quick/qquickwindow/tst_qquickwindow.cpp89
8 files changed, 264 insertions, 206 deletions
diff --git a/tests/auto/quick/examples/tst_examples.cpp b/tests/auto/quick/examples/tst_examples.cpp
index 7055fb6e03..9c5fb88af2 100644
--- a/tests/auto/quick/examples/tst_examples.cpp
+++ b/tests/auto/quick/examples/tst_examples.cpp
@@ -82,11 +82,9 @@ private:
QStringList findQmlFiles(const QDir &);
QQmlEngine engine;
-
- QQuickWindow *window;
};
-tst_examples::tst_examples() : window(0)
+tst_examples::tst_examples()
{
// Add files to exclude here
excludedFiles << "examples/quick/canvas/tiger/tiger.qml"; // QTBUG-26528
@@ -94,7 +92,7 @@ tst_examples::tst_examples() : window(0)
// Add directories you want excluded here (don't add examples/, because they install to examples/qtdeclarative/)
excludedDirs << "shared"; //Not an example
- excludedDirs << "qtquick/text/fonts"; // QTBUG-21415
+ excludedDirs << "quick/text/fonts"; // QTBUG-29004
excludedDirs << "snippets/qml/path"; //No root QQuickItem
excludedDirs << "tutorials/gettingStartedQml"; //C++ example, but no cpp files in root dir
@@ -120,7 +118,6 @@ tst_examples::tst_examples() : window(0)
tst_examples::~tst_examples()
{
- delete window;
}
void tst_examples::init()
@@ -260,6 +257,9 @@ void tst_examples::sgexamples_data()
void tst_examples::sgexamples()
{
QFETCH(QString, file);
+ QQuickWindow window;
+ window.setPersistentOpenGLContext(true);
+ window.setPersistentSceneGraph(true);
QQmlComponent component(&engine, QUrl::fromLocalFile(file));
if (component.status() == QQmlComponent::Error)
@@ -272,13 +272,11 @@ void tst_examples::sgexamples()
component.completeCreate();
QVERIFY(root);
- if (!window) {
- window = new QQuickWindow();
- window->resize(240, 320);
- window->show();
- QVERIFY(QTest::qWaitForWindowExposed(window));
- }
- root->setParentItem(window->contentItem());
+ window.resize(240, 320);
+ window.show();
+ QVERIFY(QTest::qWaitForWindowExposed(&window));
+
+ root->setParentItem(window.contentItem());
component.completeCreate();
qApp->processEvents();
@@ -303,6 +301,8 @@ void tst_examples::sgsnippets_data()
void tst_examples::sgsnippets()
{
+ QQuickWindow window;
+
QFETCH(QString, file);
QQmlComponent component(&engine, QUrl::fromLocalFile(file));
@@ -316,13 +316,11 @@ void tst_examples::sgsnippets()
component.completeCreate();
QVERIFY(root);
- if (!window) {
- window = new QQuickWindow();
- window->resize(240, 320);
- window->show();
- QVERIFY(QTest::qWaitForWindowExposed(window));
- }
- root->setParentItem(window->contentItem());
+ window.resize(240, 320);
+ window.show();
+ QVERIFY(QTest::qWaitForWindowExposed(&window));
+
+ root->setParentItem(window.contentItem());
component.completeCreate();
qApp->processEvents();
diff --git a/tests/auto/quick/qquickflickable/qquickflickable.pro b/tests/auto/quick/qquickflickable/qquickflickable.pro
index f61a601130..67d5fc12f0 100644
--- a/tests/auto/quick/qquickflickable/qquickflickable.pro
+++ b/tests/auto/quick/qquickflickable/qquickflickable.pro
@@ -9,7 +9,6 @@ include (../shared/util.pri)
TESTDATA = data/*
-CONFIG += parallel_test
QT += core-private gui-private v8-private qml-private quick-private testlib
DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0
CONFIG+=insignificant_test
diff --git a/tests/auto/quick/qquickflickable/tst_qquickflickable.cpp b/tests/auto/quick/qquickflickable/tst_qquickflickable.cpp
index 662e86018c..5226434c14 100644
--- a/tests/auto/quick/qquickflickable/tst_qquickflickable.cpp
+++ b/tests/auto/quick/qquickflickable/tst_qquickflickable.cpp
@@ -208,10 +208,12 @@ void tst_qquickflickable::boundsBehavior()
void tst_qquickflickable::rebound()
{
- QQuickView *window = new QQuickView;
+ QScopedPointer<QQuickView> window(new QQuickView);
window->setSource(testFileUrl("rebound.qml"));
window->show();
+ QVERIFY(QTest::qWaitForWindowExposed(window.data()));
window->requestActivate();
+ QVERIFY(QTest::qWaitForWindowActive(window.data()));
QVERIFY(window->rootObject() != 0);
QQuickFlickable *flickable = qobject_cast<QQuickFlickable*>(window->rootObject());
@@ -227,7 +229,7 @@ void tst_qquickflickable::rebound()
QSignalSpy hMoveSpy(flickable, SIGNAL(movingHorizontallyChanged()));
// flick and test the transition is run
- flick(window, QPoint(20,20), QPoint(120,120), 200);
+ flick(window.data(), QPoint(20,20), QPoint(120,120), 200);
QTRY_COMPARE(window->rootObject()->property("transitionsStarted").toInt(), 2);
QCOMPARE(hMoveSpy.count(), 1);
@@ -257,14 +259,13 @@ void tst_qquickflickable::rebound()
#ifdef Q_OS_MAC
QSKIP("QTBUG-26696 - sometimes fails on Mac");
- delete window;
return;
#endif
// flick and trigger the transition multiple times
// (moving signals are emitted as soon as the first transition starts)
- flick(window, QPoint(20,20), QPoint(120,120), 200); // both x and y will bounce back
- flick(window, QPoint(20,120), QPoint(120,20), 200); // only x will bounce back
+ flick(window.data(), QPoint(20,20), QPoint(120,120), 200); // both x and y will bounce back
+ flick(window.data(), QPoint(20,120), QPoint(120,20), 200); // only x will bounce back
QVERIFY(flickable->isMoving());
QVERIFY(window->rootObject()->property("transitionsStarted").toInt() >= 1);
@@ -293,7 +294,7 @@ void tst_qquickflickable::rebound()
// (i.e. moving but transition->running = false)
window->rootObject()->setProperty("transitionEnabled", false);
- flick(window, QPoint(20,20), QPoint(120,120), 200);
+ flick(window.data(), QPoint(20,20), QPoint(120,120), 200);
QCOMPARE(window->rootObject()->property("transitionsStarted").toInt(), 0);
QCOMPARE(hMoveSpy.count(), 1);
QCOMPARE(vMoveSpy.count(), 1);
@@ -306,8 +307,6 @@ void tst_qquickflickable::rebound()
QCOMPARE(movementStartedSpy.count(), 1);
QCOMPARE(movementEndedSpy.count(), 1);
QCOMPARE(window->rootObject()->property("transitionsStarted").toInt(), 0);
-
- delete window;
}
void tst_qquickflickable::maximumFlickVelocity()
@@ -353,7 +352,9 @@ void tst_qquickflickable::pressDelay()
QScopedPointer<QQuickView> window(new QQuickView);
window->setSource(testFileUrl("pressDelay.qml"));
window->show();
+ QVERIFY(QTest::qWaitForWindowExposed(window.data()));
window->requestActivate();
+ QVERIFY(QTest::qWaitForWindowActive(window.data()));
QVERIFY(window->rootObject() != 0);
QQuickFlickable *flickable = qobject_cast<QQuickFlickable*>(window->rootObject());
@@ -392,7 +393,9 @@ void tst_qquickflickable::nestedPressDelay()
QScopedPointer<QQuickView> window(new QQuickView);
window->setSource(testFileUrl("nestedPressDelay.qml"));
window->show();
+ QVERIFY(QTest::qWaitForWindowExposed(window.data()));
window->requestActivate();
+ QVERIFY(QTest::qWaitForWindowActive(window.data()));
QVERIFY(window->rootObject() != 0);
QQuickFlickable *outer = qobject_cast<QQuickFlickable*>(window->rootObject());
@@ -501,7 +504,8 @@ void tst_qquickflickable::returnToBounds()
{
QFETCH(bool, setRebound);
- QQuickView *window = new QQuickView;
+ QScopedPointer<QQuickView> window(new QQuickView);
+
window->rootContext()->setContextProperty("setRebound", setRebound);
window->setSource(testFileUrl("resize.qml"));
QVERIFY(window->rootObject() != 0);
@@ -532,8 +536,6 @@ void tst_qquickflickable::returnToBounds()
QVERIFY(!rebound->running());
QCOMPARE(reboundSpy.count(), setRebound ? 2 : 0);
-
- delete window;
}
void tst_qquickflickable::returnToBounds_data()
@@ -546,10 +548,12 @@ void tst_qquickflickable::returnToBounds_data()
void tst_qquickflickable::wheel()
{
- QQuickView *window = new QQuickView;
+ QScopedPointer<QQuickView> window(new QQuickView);
window->setSource(testFileUrl("wheel.qml"));
window->show();
+ QVERIFY(QTest::qWaitForWindowExposed(window.data()));
window->requestActivate();
+ QVERIFY(QTest::qWaitForWindowActive(window.data()));
QVERIFY(window->rootObject() != 0);
QQuickFlickable *flick = window->rootObject()->findChild<QQuickFlickable*>("flick");
@@ -559,7 +563,7 @@ void tst_qquickflickable::wheel()
QPoint pos(200, 200);
QWheelEvent event(pos, window->mapToGlobal(pos), QPoint(), QPoint(0,-120), -120, Qt::Vertical, Qt::NoButton, Qt::NoModifier);
event.setAccepted(false);
- QGuiApplication::sendEvent(window, &event);
+ QGuiApplication::sendEvent(window.data(), &event);
}
QTRY_VERIFY(flick->contentY() > 0);
@@ -573,13 +577,11 @@ void tst_qquickflickable::wheel()
QWheelEvent event(pos, window->mapToGlobal(pos), QPoint(), QPoint(-120,0), -120, Qt::Horizontal, Qt::NoButton, Qt::NoModifier);
event.setAccepted(false);
- QGuiApplication::sendEvent(window, &event);
+ QGuiApplication::sendEvent(window.data(), &event);
}
QTRY_VERIFY(flick->contentX() > 0);
QVERIFY(flick->contentY() == 0);
-
- delete window;
}
void tst_qquickflickable::movingAndFlicking_data()
@@ -614,11 +616,12 @@ void tst_qquickflickable::movingAndFlicking()
const QPoint flickFrom(50, 200); // centre
- QQuickView *window = new QQuickView;
+ QScopedPointer<QQuickView> window(new QQuickView);
window->setSource(testFileUrl("flickable03.qml"));
window->show();
+ QVERIFY(QTest::qWaitForWindowExposed(window.data()));
window->requestActivate();
- QTest::qWaitForWindowActive(window);
+ QVERIFY(QTest::qWaitForWindowActive(window.data()));
QVERIFY(window->rootObject() != 0);
QQuickFlickable *flickable = qobject_cast<QQuickFlickable*>(window->rootObject());
@@ -637,9 +640,9 @@ void tst_qquickflickable::movingAndFlicking()
QSignalSpy flickEndSpy(flickable, SIGNAL(flickEnded()));
// do a flick that keeps the view within the bounds
- flick(window, flickFrom, flickToWithoutSnapBack, 200);
+ flick(window.data(), flickFrom, flickToWithoutSnapBack, 200);
- QVERIFY(flickable->isMoving());
+ QTRY_VERIFY(flickable->isMoving());
QCOMPARE(flickable->isMovingHorizontally(), horizontalEnabled);
QCOMPARE(flickable->isMovingVertically(), verticalEnabled);
QVERIFY(flickable->isFlicking());
@@ -693,9 +696,9 @@ void tst_qquickflickable::movingAndFlicking()
flickable->setContentX(0);
flickable->setContentY(0);
QTRY_VERIFY(!flickable->isMoving());
- flick(window, flickFrom, flickToWithSnapBack, 200);
+ flick(window.data(), flickFrom, flickToWithSnapBack, 10);
- QVERIFY(flickable->isMoving());
+ QTRY_VERIFY(flickable->isMoving());
QCOMPARE(flickable->isMovingHorizontally(), horizontalEnabled);
QCOMPARE(flickable->isMovingVertically(), verticalEnabled);
QVERIFY(flickable->isFlicking());
@@ -737,8 +740,6 @@ void tst_qquickflickable::movingAndFlicking()
QCOMPARE(flickable->contentX(), 0.0);
QCOMPARE(flickable->contentY(), 0.0);
-
- delete window;
}
@@ -774,11 +775,12 @@ void tst_qquickflickable::movingAndDragging()
const QPoint moveFrom(50, 200); // centre
- QQuickView *window = new QQuickView;
+ QScopedPointer<QQuickView> window(new QQuickView);
window->setSource(testFileUrl("flickable03.qml"));
window->show();
+ QVERIFY(QTest::qWaitForWindowExposed(window.data()));
window->requestActivate();
- QVERIFY(QTest::qWaitForWindowExposed(window));
+ QVERIFY(QTest::qWaitForWindowActive(window.data()));
QVERIFY(window->rootObject() != 0);
QQuickFlickable *flickable = qobject_cast<QQuickFlickable*>(window->rootObject());
@@ -797,10 +799,10 @@ void tst_qquickflickable::movingAndDragging()
QSignalSpy moveEndSpy(flickable, SIGNAL(movementEnded()));
// start the drag
- QTest::mousePress(window, Qt::LeftButton, 0, moveFrom);
- QTest::mouseMove(window, moveFrom + moveByWithoutSnapBack);
- QTest::mouseMove(window, moveFrom + moveByWithoutSnapBack*2);
- QTest::mouseMove(window, moveFrom + moveByWithoutSnapBack*3);
+ QTest::mousePress(window.data(), Qt::LeftButton, 0, moveFrom);
+ QTest::mouseMove(window.data(), moveFrom + moveByWithoutSnapBack);
+ QTest::mouseMove(window.data(), moveFrom + moveByWithoutSnapBack*2);
+ QTest::mouseMove(window.data(), moveFrom + moveByWithoutSnapBack*3);
QTRY_VERIFY(flickable->isMoving());
QCOMPARE(flickable->isMovingHorizontally(), horizontalEnabled);
@@ -819,7 +821,7 @@ void tst_qquickflickable::movingAndDragging()
QCOMPARE(moveStartSpy.count(), 1);
QCOMPARE(dragStartSpy.count(), 1);
- QTest::mouseRelease(window, Qt::LeftButton, 0, moveFrom + moveByWithoutSnapBack*3);
+ QTest::mouseRelease(window.data(), Qt::LeftButton, 0, moveFrom + moveByWithoutSnapBack*3);
QVERIFY(!flickable->isDragging());
QVERIFY(!flickable->isDraggingHorizontally());
@@ -868,10 +870,10 @@ void tst_qquickflickable::movingAndDragging()
flickable->setContentX(0);
flickable->setContentY(0);
QTRY_VERIFY(!flickable->isMoving());
- QTest::mousePress(window, Qt::LeftButton, 0, moveFrom);
- QTest::mouseMove(window, moveFrom + moveByWithSnapBack);
- QTest::mouseMove(window, moveFrom + moveByWithSnapBack*2);
- QTest::mouseMove(window, moveFrom + moveByWithSnapBack*3);
+ QTest::mousePress(window.data(), Qt::LeftButton, 0, moveFrom);
+ QTest::mouseMove(window.data(), moveFrom + moveByWithSnapBack);
+ QTest::mouseMove(window.data(), moveFrom + moveByWithSnapBack*2);
+ QTest::mouseMove(window.data(), moveFrom + moveByWithSnapBack*3);
QVERIFY(flickable->isMoving());
QCOMPARE(flickable->isMovingHorizontally(), horizontalEnabled);
@@ -892,7 +894,7 @@ void tst_qquickflickable::movingAndDragging()
QCOMPARE(dragStartSpy.count(), 1);
QCOMPARE(dragEndSpy.count(), 0);
- QTest::mouseRelease(window, Qt::LeftButton, 0, moveFrom + moveByWithSnapBack*3);
+ QTest::mouseRelease(window.data(), Qt::LeftButton, 0, moveFrom + moveByWithSnapBack*3);
// should now start snapping back to bounds (moving but not dragging)
QVERIFY(flickable->isMoving());
@@ -935,17 +937,16 @@ void tst_qquickflickable::movingAndDragging()
QCOMPARE(flickable->contentX(), 0.0);
QCOMPARE(flickable->contentY(), 0.0);
-
- delete window;
}
void tst_qquickflickable::flickOnRelease()
{
- QQuickView *window = new QQuickView;
+ QScopedPointer<QQuickView> window(new QQuickView);
window->setSource(testFileUrl("flickable03.qml"));
window->show();
+ QVERIFY(QTest::qWaitForWindowExposed(window.data()));
window->requestActivate();
- QVERIFY(QTest::qWaitForWindowExposed(window));
+ QVERIFY(QTest::qWaitForWindowActive(window.data()));
QVERIFY(window->rootObject() != 0);
QQuickFlickable *flickable = qobject_cast<QQuickFlickable*>(window->rootObject());
@@ -958,9 +959,9 @@ void tst_qquickflickable::flickOnRelease()
// underlying drivers will hopefully provide a pre-calculated velocity
// (based on more data than what the UI gets), thus making this use case
// working even with small movements.
- QTest::mousePress(window, Qt::LeftButton, 0, QPoint(50, 300));
- QTest::mouseMove(window, QPoint(50, 10), 10);
- QTest::mouseRelease(window, Qt::LeftButton, 0, QPoint(50, 10), 10);
+ QTest::mousePress(window.data(), Qt::LeftButton, 0, QPoint(50, 300));
+ QTest::mouseMove(window.data(), QPoint(50, 10), 10);
+ QTest::mouseRelease(window.data(), Qt::LeftButton, 0, QPoint(50, 10), 10);
QCOMPARE(vFlickSpy.count(), 1);
@@ -972,17 +973,16 @@ void tst_qquickflickable::flickOnRelease()
#endif
// Stop on a full pixel after user interaction
QCOMPARE(flickable->contentY(), (qreal)qRound(flickable->contentY()));
-
- delete window;
}
void tst_qquickflickable::pressWhileFlicking()
{
- QQuickView *window = new QQuickView;
+ QScopedPointer<QQuickView> window(new QQuickView);
window->setSource(testFileUrl("flickable03.qml"));
window->show();
+ QVERIFY(QTest::qWaitForWindowExposed(window.data()));
window->requestActivate();
- QVERIFY(QTest::qWaitForWindowExposed(window));
+ QVERIFY(QTest::qWaitForWindowActive(window.data()));
QVERIFY(window->rootObject() != 0);
QQuickFlickable *flickable = qobject_cast<QQuickFlickable*>(window->rootObject());
@@ -997,7 +997,7 @@ void tst_qquickflickable::pressWhileFlicking()
// flick then press while it is still moving
// flicking == false, moving == true;
- flick(window, QPoint(20,190), QPoint(20, 50), 200);
+ flick(window.data(), QPoint(20,190), QPoint(20, 50), 200);
QVERIFY(flickable->verticalVelocity() > 0.0);
QVERIFY(flickable->isFlicking());
QVERIFY(flickable->isFlickingVertically());
@@ -1012,77 +1012,76 @@ void tst_qquickflickable::pressWhileFlicking()
QCOMPARE(hFlickSpy.count(), 0);
QCOMPARE(flickSpy.count(), 1);
- QTest::mousePress(window, Qt::LeftButton, 0, QPoint(20, 50));
+ QTest::mousePress(window.data(), Qt::LeftButton, 0, QPoint(20, 50));
QTRY_VERIFY(!flickable->isFlicking());
QVERIFY(!flickable->isFlickingVertically());
QVERIFY(flickable->isMoving());
QVERIFY(flickable->isMovingVertically());
- QTest::mouseRelease(window, Qt::LeftButton, 0, QPoint(20,50));
+ QTest::mouseRelease(window.data(), Qt::LeftButton, 0, QPoint(20,50));
QVERIFY(!flickable->isFlicking());
QVERIFY(!flickable->isFlickingVertically());
QTRY_VERIFY(!flickable->isMoving());
QVERIFY(!flickable->isMovingVertically());
// Stop on a full pixel after user interaction
QCOMPARE(flickable->contentX(), (qreal)qRound(flickable->contentX()));
-
- delete window;
}
void tst_qquickflickable::disabled()
{
- QQuickView *window = new QQuickView;
+ QScopedPointer<QQuickView> window(new QQuickView);
window->setSource(testFileUrl("disabled.qml"));
window->show();
+ QVERIFY(QTest::qWaitForWindowExposed(window.data()));
window->requestActivate();
+ QVERIFY(QTest::qWaitForWindowActive(window.data()));
QVERIFY(window->rootObject() != 0);
QQuickFlickable *flick = window->rootObject()->findChild<QQuickFlickable*>("flickable");
QVERIFY(flick != 0);
- QTest::mousePress(window, Qt::LeftButton, 0, QPoint(50, 90));
+ QTest::mousePress(window.data(), Qt::LeftButton, 0, QPoint(50, 90));
- QTest::mouseMove(window, QPoint(50, 80));
- QTest::mouseMove(window, QPoint(50, 70));
- QTest::mouseMove(window, QPoint(50, 60));
+ QTest::mouseMove(window.data(), QPoint(50, 80));
+ QTest::mouseMove(window.data(), QPoint(50, 70));
+ QTest::mouseMove(window.data(), QPoint(50, 60));
QVERIFY(flick->isMoving() == false);
- QTest::mouseRelease(window, Qt::LeftButton, 0, QPoint(50, 60));
+ QTest::mouseRelease(window.data(), Qt::LeftButton, 0, QPoint(50, 60));
// verify that mouse clicks on other elements still work (QTBUG-20584)
- QTest::mousePress(window, Qt::LeftButton, 0, QPoint(50, 10));
- QTest::mouseRelease(window, Qt::LeftButton, 0, QPoint(50, 10));
+ QTest::mousePress(window.data(), Qt::LeftButton, 0, QPoint(50, 10));
+ QTest::mouseRelease(window.data(), Qt::LeftButton, 0, QPoint(50, 10));
QTRY_VERIFY(window->rootObject()->property("clicked").toBool() == true);
-
- delete window;
}
void tst_qquickflickable::flickVelocity()
{
- QQuickView *window = new QQuickView;
+ QScopedPointer<QQuickView> window(new QQuickView);
window->setSource(testFileUrl("flickable03.qml"));
window->show();
+ QVERIFY(QTest::qWaitForWindowExposed(window.data()));
window->requestActivate();
+ QVERIFY(QTest::qWaitForWindowActive(window.data()));
QVERIFY(window->rootObject() != 0);
QQuickFlickable *flickable = qobject_cast<QQuickFlickable*>(window->rootObject());
QVERIFY(flickable != 0);
// flick up
- flick(window, QPoint(20,190), QPoint(20, 50), 200);
+ flick(window.data(), QPoint(20,190), QPoint(20, 50), 200);
QVERIFY(flickable->verticalVelocity() > 0.0);
QTRY_VERIFY(flickable->verticalVelocity() == 0.0);
// flick down
- flick(window, QPoint(20,10), QPoint(20, 140), 200);
- QVERIFY(flickable->verticalVelocity() < 0.0);
+ flick(window.data(), QPoint(20,10), QPoint(20, 140), 200);
+ QTRY_VERIFY(flickable->verticalVelocity() < 0.0);
QTRY_VERIFY(flickable->verticalVelocity() == 0.0);
#ifdef Q_OS_MAC
QSKIP("boost doesn't work on OS X");
- delete window;
return;
#endif
@@ -1090,17 +1089,15 @@ void tst_qquickflickable::flickVelocity()
QQuickFlickablePrivate *fp = QQuickFlickablePrivate::get(flickable);
bool boosted = false;
for (int i = 0; i < 6; ++i) {
- flick(window, QPoint(20,390), QPoint(20, 50), 100);
+ flick(window.data(), QPoint(20,390), QPoint(20, 50), 100);
boosted |= fp->flickBoost > 1.0;
}
QVERIFY(boosted);
// Flick in opposite direction -> boost cancelled.
- flick(window, QPoint(20,10), QPoint(20, 340), 200);
+ flick(window.data(), QPoint(20,10), QPoint(20, 340), 200);
QTRY_VERIFY(flickable->verticalVelocity() < 0.0);
QVERIFY(fp->flickBoost == 1.0);
-
- delete window;
}
void tst_qquickflickable::margins()
@@ -1164,20 +1161,22 @@ void tst_qquickflickable::margins()
void tst_qquickflickable::cancelOnMouseGrab()
{
- QQuickView *window = new QQuickView;
+ QScopedPointer<QQuickView> window(new QQuickView);
window->setSource(testFileUrl("cancel.qml"));
window->show();
+ QVERIFY(QTest::qWaitForWindowExposed(window.data()));
window->requestActivate();
+ QVERIFY(QTest::qWaitForWindowActive(window.data()));
QVERIFY(window->rootObject() != 0);
QQuickFlickable *flickable = qobject_cast<QQuickFlickable*>(window->rootObject());
QVERIFY(flickable != 0);
- QTest::mousePress(window, Qt::LeftButton, 0, QPoint(10, 10));
+ QTest::mousePress(window.data(), Qt::LeftButton, 0, QPoint(10, 10));
// drag out of bounds
- QTest::mouseMove(window, QPoint(50, 50));
- QTest::mouseMove(window, QPoint(100, 100));
- QTest::mouseMove(window, QPoint(150, 150));
+ QTest::mouseMove(window.data(), QPoint(50, 50));
+ QTest::mouseMove(window.data(), QPoint(100, 100));
+ QTest::mouseMove(window.data(), QPoint(150, 150));
QVERIFY(flickable->contentX() != 0);
QVERIFY(flickable->contentY() != 0);
@@ -1193,56 +1192,54 @@ void tst_qquickflickable::cancelOnMouseGrab()
QTRY_VERIFY(!flickable->isMoving());
QTRY_VERIFY(!flickable->isDragging());
- QTest::mouseRelease(window, Qt::LeftButton, 0, QPoint(50, 10));
+ QTest::mouseRelease(window.data(), Qt::LeftButton, 0, QPoint(50, 10));
- delete window;
}
void tst_qquickflickable::clickAndDragWhenTransformed()
{
- QQuickView *view = new QQuickView;
+ QScopedPointer<QQuickView> view(new QQuickView);
view->setSource(testFileUrl("transformedFlickable.qml"));
view->show();
+ QVERIFY(QTest::qWaitForWindowExposed(view.data()));
view->requestActivate();
- QVERIFY(QTest::qWaitForWindowExposed(view));
+ QVERIFY(QTest::qWaitForWindowActive(view.data()));
QVERIFY(view->rootObject() != 0);
QQuickFlickable *flickable = view->rootObject()->findChild<QQuickFlickable*>("flickable");
QVERIFY(flickable != 0);
// click outside child rect
- QTest::mousePress(view, Qt::LeftButton, 0, QPoint(190, 190));
+ QTest::mousePress(view.data(), Qt::LeftButton, 0, QPoint(190, 190));
QTest::qWait(10);
QCOMPARE(flickable->property("itemPressed").toBool(), false);
- QTest::mouseRelease(view, Qt::LeftButton, 0, QPoint(190, 190));
+ QTest::mouseRelease(view.data(), Qt::LeftButton, 0, QPoint(190, 190));
// click inside child rect
- QTest::mousePress(view, Qt::LeftButton, 0, QPoint(200, 200));
+ QTest::mousePress(view.data(), Qt::LeftButton, 0, QPoint(200, 200));
QTest::qWait(10);
QCOMPARE(flickable->property("itemPressed").toBool(), true);
- QTest::mouseRelease(view, Qt::LeftButton, 0, QPoint(200, 200));
+ QTest::mouseRelease(view.data(), Qt::LeftButton, 0, QPoint(200, 200));
const int threshold = qApp->styleHints()->startDragDistance();
// drag outside bounds
- QTest::mousePress(view, Qt::LeftButton, 0, QPoint(160, 160));
+ QTest::mousePress(view.data(), Qt::LeftButton, 0, QPoint(160, 160));
QTest::qWait(10);
- QTest::mouseMove(view, QPoint(160 + threshold * 2, 160));
- QTest::mouseMove(view, QPoint(160 + threshold * 3, 160));
+ QTest::mouseMove(view.data(), QPoint(160 + threshold * 2, 160));
+ QTest::mouseMove(view.data(), QPoint(160 + threshold * 3, 160));
QCOMPARE(flickable->isDragging(), false);
QCOMPARE(flickable->property("itemPressed").toBool(), false);
- QTest::mouseRelease(view, Qt::LeftButton, 0, QPoint(180, 160));
+ QTest::mouseRelease(view.data(), Qt::LeftButton, 0, QPoint(180, 160));
// drag inside bounds
- QTest::mousePress(view, Qt::LeftButton, 0, QPoint(200, 140));
+ QTest::mousePress(view.data(), Qt::LeftButton, 0, QPoint(200, 140));
QTest::qWait(10);
- QTest::mouseMove(view, QPoint(200 + threshold * 2, 140));
- QTest::mouseMove(view, QPoint(200 + threshold * 3, 140));
+ QTest::mouseMove(view.data(), QPoint(200 + threshold * 2, 140));
+ QTest::mouseMove(view.data(), QPoint(200 + threshold * 3, 140));
QCOMPARE(flickable->isDragging(), true);
QCOMPARE(flickable->property("itemPressed").toBool(), false);
- QTest::mouseRelease(view, Qt::LeftButton, 0, QPoint(220, 140));
-
- delete view;
+ QTest::mouseRelease(view.data(), Qt::LeftButton, 0, QPoint(220, 140));
}
void tst_qquickflickable::flickTwiceUsingTouches()
diff --git a/tests/auto/quick/qquickgridview/tst_qquickgridview.cpp b/tests/auto/quick/qquickgridview/tst_qquickgridview.cpp
index 802cc0a4c9..93ffbca3e5 100644
--- a/tests/auto/quick/qquickgridview/tst_qquickgridview.cpp
+++ b/tests/auto/quick/qquickgridview/tst_qquickgridview.cpp
@@ -2871,7 +2871,8 @@ void tst_QQuickGridView::enforceRange_rightToLeft()
ctxt->setContextProperty("testTopToBottom", QVariant(true));
window->setSource(testFileUrl("gridview-enforcerange.qml"));
- qApp->processEvents();
+ window->show();
+ QTRY_VERIFY(window->isExposed());
QVERIFY(window->rootObject() != 0);
QQuickGridView *gridview = findItem<QQuickGridView>(window->rootObject(), "grid");
diff --git a/tests/auto/quick/qquickpathview/tst_qquickpathview.cpp b/tests/auto/quick/qquickpathview/tst_qquickpathview.cpp
index a7e0f2feb4..a78625c58e 100644
--- a/tests/auto/quick/qquickpathview/tst_qquickpathview.cpp
+++ b/tests/auto/quick/qquickpathview/tst_qquickpathview.cpp
@@ -198,7 +198,7 @@ void tst_QQuickPathView::initValues()
void tst_QQuickPathView::items()
{
- QQuickView *window = createView();
+ QScopedPointer<QQuickView> window(createView());
QaimModel model;
model.addItem("Fred", "12345");
@@ -237,8 +237,6 @@ void tst_QQuickPathView::items()
offset.setX(pathview->highlightItem()->width()/2);
offset.setY(pathview->highlightItem()->height()/2);
QCOMPARE(pathview->highlightItem()->position() + offset, start);
-
- delete window;
}
void tst_QQuickPathView::pathview2()
@@ -349,7 +347,7 @@ void tst_QQuickPathView::insertModel()
QFETCH(qreal, offset);
QFETCH(int, currentIndex);
- QQuickView *window = createView();
+ QScopedPointer<QQuickView> window(createView());
window->show();
QaimModel model;
@@ -387,8 +385,6 @@ void tst_QQuickPathView::insertModel()
QTRY_COMPARE(pathview->offset(), offset);
QCOMPARE(pathview->currentIndex(), currentIndex);
-
- delete window;
}
void tst_QQuickPathView::removeModel_data()
@@ -443,7 +439,8 @@ void tst_QQuickPathView::removeModel()
QFETCH(qreal, offset);
QFETCH(int, currentIndex);
- QQuickView *window = createView();
+ QScopedPointer<QQuickView> window(createView());
+
window->show();
QaimModel model;
@@ -477,8 +474,6 @@ void tst_QQuickPathView::removeModel()
QTRY_COMPARE(pathview->offset(), offset);
QCOMPARE(pathview->currentIndex(), currentIndex);
-
- delete window;
}
@@ -538,7 +533,7 @@ void tst_QQuickPathView::moveModel()
QFETCH(qreal, offset);
QFETCH(int, currentIndex);
- QQuickView *window = createView();
+ QScopedPointer<QQuickView> window(createView());
window->show();
QaimModel model;
@@ -572,8 +567,6 @@ void tst_QQuickPathView::moveModel()
QTRY_COMPARE(pathview->offset(), offset);
QCOMPARE(pathview->currentIndex(), currentIndex);
-
- delete window;
}
void tst_QQuickPathView::consecutiveModelChanges_data()
@@ -639,7 +632,7 @@ void tst_QQuickPathView::consecutiveModelChanges()
QFETCH(qreal, offset);
QFETCH(int, currentIndex);
- QQuickView *window = createView();
+ QScopedPointer<QQuickView> window(createView());
window->show();
QaimModel model;
@@ -703,7 +696,6 @@ void tst_QQuickPathView::consecutiveModelChanges()
QCOMPARE(pathview->currentIndex(), currentIndex);
- delete window;
}
void tst_QQuickPathView::path()
@@ -755,7 +747,7 @@ void tst_QQuickPathView::path()
void tst_QQuickPathView::dataModel()
{
- QQuickView *window = createView();
+ QScopedPointer<QQuickView> window(createView());
window->show();
QQmlContext *ctxt = window->rootContext();
@@ -864,13 +856,12 @@ void tst_QQuickPathView::dataModel()
model.removeItem(model.count()-1);
QCOMPARE(pathview->currentIndex(), model.count()-1);
- delete window;
delete testObject;
}
void tst_QQuickPathView::pathMoved()
{
- QQuickView *window = createView();
+ QScopedPointer<QQuickView> window(createView());
window->show();
QaimModel model;
@@ -925,7 +916,6 @@ void tst_QQuickPathView::pathMoved()
window->rootObject()->setProperty("delegateScale", 1.2);
QTRY_COMPARE(firstItem->position() + offset, start);
- delete window;
}
void tst_QQuickPathView::offset_data()
@@ -959,7 +949,7 @@ void tst_QQuickPathView::offset()
void tst_QQuickPathView::setCurrentIndex()
{
- QQuickView *window = createView();
+ QScopedPointer<QQuickView> window(createView());
window->show();
QaimModel model;
@@ -1102,12 +1092,11 @@ void tst_QQuickPathView::setCurrentIndex()
QCOMPARE(pathview->currentItem(), firstItem);
QCOMPARE(firstItem->property("onPath"), QVariant(true));
- delete window;
}
void tst_QQuickPathView::resetModel()
{
- QQuickView *window = createView();
+ QScopedPointer<QQuickView> window(createView());
QStringList strings;
strings << "one" << "two" << "three";
@@ -1142,12 +1131,11 @@ void tst_QQuickPathView::resetModel()
QCOMPARE(display->text(), strings.at(i));
}
- delete window;
}
void tst_QQuickPathView::propertyChanges()
{
- QQuickView *window = createView();
+ QScopedPointer<QQuickView> window(createView());
QVERIFY(window);
window->setSource(testFileUrl("propertychanges.qml"));
@@ -1184,12 +1172,11 @@ void tst_QQuickPathView::propertyChanges()
pathView->setMaximumFlickVelocity(1000);
QCOMPARE(maximumFlickVelocitySpy.count(), 1);
- delete window;
}
void tst_QQuickPathView::pathChanges()
{
- QQuickView *window = createView();
+ QScopedPointer<QQuickView> window(createView());
QVERIFY(window);
window->setSource(testFileUrl("propertychanges.qml"));
@@ -1246,12 +1233,11 @@ void tst_QQuickPathView::pathChanges()
pathAttribute->setName("scale");
QCOMPARE(nameSpy.count(),1);
- delete window;
}
void tst_QQuickPathView::componentChanges()
{
- QQuickView *window = createView();
+ QScopedPointer<QQuickView> window(createView());
QVERIFY(window);
window->setSource(testFileUrl("propertychanges.qml"));
@@ -1269,12 +1255,11 @@ void tst_QQuickPathView::componentChanges()
pathView->setDelegate(&delegateComponent);
QCOMPARE(delegateSpy.count(),1);
- delete window;
}
void tst_QQuickPathView::modelChanges()
{
- QQuickView *window = createView();
+ QScopedPointer<QQuickView> window(createView());
QVERIFY(window);
window->setSource(testFileUrl("propertychanges.qml"));
@@ -1304,12 +1289,11 @@ void tst_QQuickPathView::modelChanges()
QCOMPARE(pathView->currentIndex(), 0);
QCOMPARE(currentIndexSpy.count(), 1);
- delete window;
}
void tst_QQuickPathView::pathUpdateOnStartChanged()
{
- QQuickView *window = createView();
+ QScopedPointer<QQuickView> window(createView());
QVERIFY(window);
window->setSource(testFileUrl("pathUpdateOnStartChanged.qml"));
@@ -1326,17 +1310,16 @@ void tst_QQuickPathView::pathUpdateOnStartChanged()
QCOMPARE(item->x(), path->startX() - item->width() / 2.0);
QCOMPARE(item->y(), path->startY() - item->height() / 2.0);
- delete window;
}
void tst_QQuickPathView::package()
{
- QQuickView *window = createView();
+ QScopedPointer<QQuickView> window(createView());
QVERIFY(window);
window->setSource(testFileUrl("pathview_package.qml"));
window->show();
window->requestActivate();
- QVERIFY(QTest::qWaitForWindowActive(window));
+ QVERIFY(QTest::qWaitForWindowActive(window.data()));
QQuickPathView *pathView = window->rootObject()->findChild<QQuickPathView*>("photoPathView");
QVERIFY(pathView);
@@ -1349,13 +1332,12 @@ void tst_QQuickPathView::package()
QVERIFY(item);
QVERIFY(item->scale() != 1.0);
- delete window;
}
//QTBUG-13017
void tst_QQuickPathView::emptyModel()
{
- QQuickView *window = createView();
+ QScopedPointer<QQuickView> window(createView());
QStringListModel model;
@@ -1370,7 +1352,6 @@ void tst_QQuickPathView::emptyModel()
QCOMPARE(pathview->offset(), qreal(0.0));
- delete window;
}
void tst_QQuickPathView::closed()
@@ -1397,7 +1378,7 @@ void tst_QQuickPathView::closed()
// QTBUG-14239
void tst_QQuickPathView::pathUpdate()
{
- QQuickView *window = createView();
+ QScopedPointer<QQuickView> window(createView());
QVERIFY(window);
window->setSource(testFileUrl("pathUpdate.qml"));
@@ -1408,7 +1389,6 @@ void tst_QQuickPathView::pathUpdate()
QVERIFY(item);
QCOMPARE(item->x(), 150.0);
- delete window;
}
void tst_QQuickPathView::visualDataModel()
@@ -1449,12 +1429,12 @@ void tst_QQuickPathView::undefinedPath()
void tst_QQuickPathView::mouseDrag()
{
- QQuickView *window = createView();
+ QScopedPointer<QQuickView> window(createView());
window->setSource(testFileUrl("dragpath.qml"));
window->show();
window->requestActivate();
- QVERIFY(QTest::qWaitForWindowActive(window));
- QCOMPARE(window, qGuiApp->focusWindow());
+ QVERIFY(QTest::qWaitForWindowActive(window.data()));
+ QCOMPARE(window.data(), qGuiApp->focusWindow());
QQuickPathView *pathview = qobject_cast<QQuickPathView*>(window->rootObject());
QVERIFY(pathview != 0);
@@ -1468,12 +1448,12 @@ void tst_QQuickPathView::mouseDrag()
int current = pathview->currentIndex();
- QTest::mousePress(window, Qt::LeftButton, 0, QPoint(10,100));
+ QTest::mousePress(window.data(), Qt::LeftButton, 0, QPoint(10,100));
QTest::qWait(100);
{
QMouseEvent mv(QEvent::MouseMove, QPoint(30,100), Qt::LeftButton, Qt::LeftButton,Qt::NoModifier);
- QGuiApplication::sendEvent(window, &mv);
+ QGuiApplication::sendEvent(window.data(), &mv);
}
// first move beyond threshold does not trigger drag
QVERIFY(!pathview->isMoving());
@@ -1487,7 +1467,7 @@ void tst_QQuickPathView::mouseDrag()
{
QMouseEvent mv(QEvent::MouseMove, QPoint(90,100), Qt::LeftButton, Qt::LeftButton,Qt::NoModifier);
- QGuiApplication::sendEvent(window, &mv);
+ QGuiApplication::sendEvent(window.data(), &mv);
}
// next move beyond threshold does trigger drag
QVERIFY(pathview->isMoving());
@@ -1501,7 +1481,7 @@ void tst_QQuickPathView::mouseDrag()
QVERIFY(pathview->currentIndex() != current);
- QTest::mouseRelease(window, Qt::LeftButton, 0, QPoint(40,100));
+ QTest::mouseRelease(window.data(), Qt::LeftButton, 0, QPoint(40,100));
QVERIFY(!pathview->isDragging());
QCOMPARE(draggingSpy.count(), 2);
QCOMPARE(dragStartedSpy.count(), 1);
@@ -1510,12 +1490,11 @@ void tst_QQuickPathView::mouseDrag()
QTRY_COMPARE(moveEndedSpy.count(), 1);
QCOMPARE(moveStartedSpy.count(), 1);
- delete window;
}
void tst_QQuickPathView::treeModel()
{
- QQuickView *window = createView();
+ QScopedPointer<QQuickView> window(createView());
window->show();
QStandardItemModel model;
@@ -1538,18 +1517,17 @@ void tst_QQuickPathView::treeModel()
QTRY_VERIFY(item = findItem<QQuickText>(pathview, "wrapper", 0));
QTRY_COMPARE(item->text(), QLatin1String("Row 2 Child Item"));
- delete window;
}
void tst_QQuickPathView::changePreferredHighlight()
{
- QQuickView *window = createView();
+ QScopedPointer<QQuickView> window(createView());
window->setGeometry(0,0,400,200);
window->setSource(testFileUrl("dragpath.qml"));
window->show();
window->requestActivate();
- QVERIFY(QTest::qWaitForWindowActive(window));
- QCOMPARE(window, qGuiApp->focusWindow());
+ QVERIFY(QTest::qWaitForWindowActive(window.data()));
+ QCOMPARE(window.data(), qGuiApp->focusWindow());
QQuickPathView *pathview = qobject_cast<QQuickPathView*>(window->rootObject());
QVERIFY(pathview != 0);
@@ -1573,7 +1551,6 @@ void tst_QQuickPathView::changePreferredHighlight()
QTRY_COMPARE(firstItem->position() + offset, start);
QCOMPARE(pathview->currentIndex(), 0);
- delete window;
}
void tst_QQuickPathView::creationContext()
@@ -1594,7 +1571,7 @@ void tst_QQuickPathView::creationContext()
// QTBUG-21320
void tst_QQuickPathView::currentOffsetOnInsertion()
{
- QQuickView *window = createView();
+ QScopedPointer<QQuickView> window(createView());
window->show();
QaimModel model;
@@ -1667,12 +1644,11 @@ void tst_QQuickPathView::currentOffsetOnInsertion()
// verify that current item (item 1) is still at offset 0.5
QCOMPARE(item->position() + offset, start);
- delete window;
}
void tst_QQuickPathView::asynchronous()
{
- QQuickView *window = createView();
+ QScopedPointer<QQuickView> window(createView());
window->show();
QQmlIncubationController controller;
window->engine()->setIncubationController(&controller);
@@ -1723,7 +1699,6 @@ void tst_QQuickPathView::asynchronous()
QCOMPARE(curItem->position() + offset, itemPos);
}
- delete window;
}
void tst_QQuickPathView::missingPercent()
@@ -1738,12 +1713,12 @@ void tst_QQuickPathView::missingPercent()
void tst_QQuickPathView::cancelDrag()
{
- QQuickView *window = createView();
+ QScopedPointer<QQuickView> window(createView());
window->setSource(testFileUrl("dragpath.qml"));
window->show();
window->requestActivate();
- QVERIFY(QTest::qWaitForWindowActive(window));
- QCOMPARE(window, qGuiApp->focusWindow());
+ QVERIFY(QTest::qWaitForWindowActive(window.data()));
+ QCOMPARE(window.data(), qGuiApp->focusWindow());
QQuickPathView *pathview = qobject_cast<QQuickPathView*>(window->rootObject());
QVERIFY(pathview != 0);
@@ -1753,10 +1728,10 @@ void tst_QQuickPathView::cancelDrag()
QSignalSpy dragEndedSpy(pathview, SIGNAL(dragEnded()));
// drag between snap points
- QTest::mousePress(window, Qt::LeftButton, 0, QPoint(10,100));
+ QTest::mousePress(window.data(), Qt::LeftButton, 0, QPoint(10,100));
QTest::qWait(100);
- QTest::mouseMove(window, QPoint(30, 100));
- QTest::mouseMove(window, QPoint(85, 100));
+ QTest::mouseMove(window.data(), QPoint(30, 100));
+ QTest::mouseMove(window.data(), QPoint(85, 100));
QTRY_VERIFY(pathview->offset() != qFloor(pathview->offset()));
QTRY_VERIFY(pathview->isMoving());
@@ -1777,25 +1752,24 @@ void tst_QQuickPathView::cancelDrag()
QCOMPARE(dragStartedSpy.count(), 1);
QCOMPARE(dragEndedSpy.count(), 1);
- QTest::mouseRelease(window, Qt::LeftButton, 0, QPoint(40,100));
+ QTest::mouseRelease(window.data(), Qt::LeftButton, 0, QPoint(40,100));
- delete window;
}
void tst_QQuickPathView::maximumFlickVelocity()
{
- QQuickView *window = createView();
+ QScopedPointer<QQuickView> window(createView());
window->setSource(testFileUrl("dragpath.qml"));
window->show();
window->requestActivate();
- QVERIFY(QTest::qWaitForWindowActive(window));
- QCOMPARE(window, qGuiApp->focusWindow());
+ QVERIFY(QTest::qWaitForWindowActive(window.data()));
+ QCOMPARE(window.data(), qGuiApp->focusWindow());
QQuickPathView *pathview = qobject_cast<QQuickPathView*>(window->rootObject());
QVERIFY(pathview != 0);
pathview->setMaximumFlickVelocity(700);
- flick(window, QPoint(200,10), QPoint(10,10), 180);
+ flick(window.data(), QPoint(200,10), QPoint(10,10), 180);
QVERIFY(pathview->isMoving());
QVERIFY(pathview->isFlicking());
QTRY_VERIFY_WITH_TIMEOUT(!pathview->isMoving(), 50000);
@@ -1804,7 +1778,7 @@ void tst_QQuickPathView::maximumFlickVelocity()
pathview->setOffset(0.);
pathview->setMaximumFlickVelocity(300);
- flick(window, QPoint(200,10), QPoint(10,10), 180);
+ flick(window.data(), QPoint(200,10), QPoint(10,10), 180);
QVERIFY(pathview->isMoving());
QVERIFY(pathview->isFlicking());
QTRY_VERIFY_WITH_TIMEOUT(!pathview->isMoving(), 50000);
@@ -1813,7 +1787,7 @@ void tst_QQuickPathView::maximumFlickVelocity()
pathview->setOffset(0.);
pathview->setMaximumFlickVelocity(500);
- flick(window, QPoint(200,10), QPoint(10,10), 180);
+ flick(window.data(), QPoint(200,10), QPoint(10,10), 180);
QVERIFY(pathview->isMoving());
QVERIFY(pathview->isFlicking());
QTRY_VERIFY_WITH_TIMEOUT(!pathview->isMoving(), 50000);
@@ -1824,14 +1798,13 @@ void tst_QQuickPathView::maximumFlickVelocity()
QVERIFY(dist3 > dist2);
QVERIFY(dist2 < dist1);
- delete window;
}
void tst_QQuickPathView::snapToItem()
{
QFETCH(bool, enforceRange);
- QQuickView *window = createView();
+ QScopedPointer<QQuickView> window(createView());
window->setSource(testFileUrl("panels.qml"));
QQuickPathView *pathview = window->rootObject()->findChild<QQuickPathView*>("view");
QVERIFY(pathview != 0);
@@ -1843,7 +1816,7 @@ void tst_QQuickPathView::snapToItem()
QSignalSpy snapModeSpy(pathview, SIGNAL(snapModeChanged()));
- flick(window, QPoint(200,10), QPoint(10,10), 180);
+ flick(window.data(), QPoint(200,10), QPoint(10,10), 180);
QVERIFY(pathview->isMoving());
QTRY_VERIFY(!pathview->isMoving());
@@ -1855,7 +1828,6 @@ void tst_QQuickPathView::snapToItem()
else
QVERIFY(pathview->currentIndex() == currentIndex);
- delete window;
}
void tst_QQuickPathView::snapToItem_data()
@@ -1870,12 +1842,12 @@ void tst_QQuickPathView::snapOneItem()
{
QFETCH(bool, enforceRange);
- QQuickView *window = createView();
+ QScopedPointer<QQuickView> window(createView());
window->setSource(testFileUrl("panels.qml"));
window->show();
window->requestActivate();
- QVERIFY(QTest::qWaitForWindowActive(window));
- QCOMPARE(window, qGuiApp->focusWindow());
+ QVERIFY(QTest::qWaitForWindowActive(window.data()));
+ QCOMPARE(window.data(), qGuiApp->focusWindow());
QQuickPathView *pathview = window->rootObject()->findChild<QQuickPathView*>("view");
QVERIFY(pathview != 0);
@@ -1891,7 +1863,7 @@ void tst_QQuickPathView::snapOneItem()
int currentIndex = pathview->currentIndex();
double startOffset = pathview->offset();
- flick(window, QPoint(200,10), QPoint(10,10), 180);
+ flick(window.data(), QPoint(200,10), QPoint(10,10), 180);
QVERIFY(pathview->isMoving());
QTRY_VERIFY(!pathview->isMoving());
@@ -1904,7 +1876,6 @@ void tst_QQuickPathView::snapOneItem()
else
QVERIFY(pathview->currentIndex() == currentIndex);
- delete window;
}
void tst_QQuickPathView::snapOneItem_data()
@@ -1924,12 +1895,12 @@ void tst_QQuickPathView::positionViewAtIndex()
QFETCH(QQuickPathView::PositionMode, mode);
QFETCH(qreal, offset);
- QQuickView *window = createView();
+ QScopedPointer<QQuickView> window(createView());
window->setSource(testFileUrl("pathview3.qml"));
window->show();
window->requestActivate();
- QVERIFY(QTest::qWaitForWindowActive(window));
- QCOMPARE(window, qGuiApp->focusWindow());
+ QVERIFY(QTest::qWaitForWindowActive(window.data()));
+ QCOMPARE(window.data(), qGuiApp->focusWindow());
QQuickPathView *pathview = qobject_cast<QQuickPathView*>(window->rootObject());
QVERIFY(pathview != 0);
@@ -1945,7 +1916,6 @@ void tst_QQuickPathView::positionViewAtIndex()
QCOMPARE(pathview->offset(), offset);
- delete window;
}
void tst_QQuickPathView::positionViewAtIndex_data()
@@ -1988,12 +1958,12 @@ void tst_QQuickPathView::indexAt_itemAt()
QFETCH(qreal, y);
QFETCH(int, index);
- QQuickView *window = createView();
+ QScopedPointer<QQuickView> window(createView());
window->setSource(testFileUrl("pathview3.qml"));
window->show();
window->requestActivate();
- QVERIFY(QTest::qWaitForWindowActive(window));
- QCOMPARE(window, qGuiApp->focusWindow());
+ QVERIFY(QTest::qWaitForWindowActive(window.data()));
+ QCOMPARE(window.data(), qGuiApp->focusWindow());
QQuickPathView *pathview = qobject_cast<QQuickPathView*>(window->rootObject());
QVERIFY(pathview != 0);
@@ -2006,7 +1976,6 @@ void tst_QQuickPathView::indexAt_itemAt()
QCOMPARE(pathview->indexAt(x,y), index);
QVERIFY(pathview->itemAt(x,y) == item);
- delete window;
}
void tst_QQuickPathView::indexAt_itemAt_data()
@@ -2024,7 +1993,7 @@ void tst_QQuickPathView::indexAt_itemAt_data()
void tst_QQuickPathView::cacheItemCount()
{
- QQuickView *window = createView();
+ QScopedPointer<QQuickView> window(createView());
window->setSource(testFileUrl("pathview3.qml"));
window->show();
@@ -2098,7 +2067,6 @@ void tst_QQuickPathView::cacheItemCount()
controller.incubateWhile(&b);
}
- delete window;
}
QTEST_MAIN(tst_QQuickPathView)
diff --git a/tests/auto/quick/qquickwindow/data/showHideAnimate.qml b/tests/auto/quick/qquickwindow/data/showHideAnimate.qml
new file mode 100644
index 0000000000..e83910c5a5
--- /dev/null
+++ b/tests/auto/quick/qquickwindow/data/showHideAnimate.qml
@@ -0,0 +1,5 @@
+import QtQuick 2.0
+
+Item {
+ NumberAnimation on opacity { from: 0; to: 1; duration: 100; loops: Animation.Infinite }
+}
diff --git a/tests/auto/quick/qquickwindow/qquickwindow.pro b/tests/auto/quick/qquickwindow/qquickwindow.pro
index 9ae63a9ef1..59d96429db 100644
--- a/tests/auto/quick/qquickwindow/qquickwindow.pro
+++ b/tests/auto/quick/qquickwindow/qquickwindow.pro
@@ -13,6 +13,7 @@ TESTDATA = data/*
OTHER_FILES += \
data/AnimationsWhileHidden.qml \
- data/Headless.qml
+ data/Headless.qml \
+ data/showHideAnimate.qml
DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0
diff --git a/tests/auto/quick/qquickwindow/tst_qquickwindow.cpp b/tests/auto/quick/qquickwindow/tst_qquickwindow.cpp
index f7fc549069..3e907a5204 100644
--- a/tests/auto/quick/qquickwindow/tst_qquickwindow.cpp
+++ b/tests/auto/quick/qquickwindow/tst_qquickwindow.cpp
@@ -312,6 +312,11 @@ private slots:
void ownershipRootItem();
+ void hideThenDelete_data();
+ void hideThenDelete();
+
+ void showHideAnimate();
+
#ifndef QT_NO_CURSOR
void cursor();
#endif
@@ -945,6 +950,8 @@ void tst_qquickwindow::headless()
QScopedPointer<QObject> cleanup(created);
QQuickWindow* window = qobject_cast<QQuickWindow*>(created);
+ window->setPersistentOpenGLContext(false);
+ window->setPersistentSceneGraph(false);
QVERIFY(window);
window->show();
@@ -1212,6 +1219,88 @@ void tst_qquickwindow::cursor()
}
#endif
+void tst_qquickwindow::hideThenDelete_data()
+{
+ QTest::addColumn<bool>("persistentSG");
+ QTest::addColumn<bool>("persistentGL");
+
+ QTest::newRow("persistent:SG=false,GL=false") << false << false;
+ QTest::newRow("persistent:SG=true,GL=false") << true << false;
+ QTest::newRow("persistent:SG=false,GL=true") << false << true;
+ QTest::newRow("persistent:SG=true,GL=true") << true << true;
+}
+
+void tst_qquickwindow::hideThenDelete()
+{
+ if (QGuiApplication::platformName() == QStringLiteral("xcb")) {
+ QSKIP("For some obscure reason this test fails in CI only");
+ return;
+ }
+
+ QFETCH(bool, persistentSG);
+ QFETCH(bool, persistentGL);
+
+ QSignalSpy *openglDestroyed = 0;
+ QSignalSpy *sgInvalidated = 0;
+
+ {
+ QQuickWindow window;
+ window.setColor(Qt::red);
+
+ window.setPersistentSceneGraph(persistentSG);
+ window.setPersistentOpenGLContext(persistentGL);
+
+ window.resize(400, 300);
+ window.show();
+
+ QTest::qWaitForWindowExposed(&window);
+
+ openglDestroyed = new QSignalSpy(window.openglContext(), SIGNAL(aboutToBeDestroyed()));
+ sgInvalidated = new QSignalSpy(&window, SIGNAL(sceneGraphInvalidated()));
+
+ window.hide();
+
+ QTRY_VERIFY(!window.isExposed());
+
+ if (!persistentSG) {
+ QVERIFY(sgInvalidated->size() > 0);
+ if (!persistentGL)
+ QVERIFY(openglDestroyed->size() > 0);
+ else
+ QVERIFY(openglDestroyed->size() == 0);
+ } else {
+ QVERIFY(sgInvalidated->size() == 0);
+ QVERIFY(openglDestroyed->size() == 0);
+ }
+ }
+
+ QVERIFY(sgInvalidated->size() > 0);
+ QVERIFY(openglDestroyed->size() > 0);
+}
+
+void tst_qquickwindow::showHideAnimate()
+{
+ // This test tries to mimick a bug triggered in the qquickanimatedimage test
+ // A window is shown, then removed again before it is exposed. This left
+ // traces in the render loop which prevent other animations from running
+ // later on.
+ {
+ QQuickWindow window;
+ window.resize(400, 300);
+ window.show();
+ }
+
+ QQmlEngine engine;
+ QQmlComponent component(&engine);
+ component.loadUrl(testFileUrl("showHideAnimate.qml"));
+ QQuickItem* created = qobject_cast<QQuickItem *>(component.create());
+
+ QVERIFY(created);
+
+ QTRY_VERIFY(created->opacity() > 0.5);
+ QTRY_VERIFY(created->opacity() < 0.5);
+}
+
QTEST_MAIN(tst_qquickwindow)
#include "tst_qquickwindow.moc"