aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/quick
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/quick')
-rw-r--r--tests/auto/quick/examples/tst_examples.cpp36
-rw-r--r--tests/auto/quick/qquickanimations/qquickanimations.pro1
-rw-r--r--tests/auto/quick/qquickflickable/qquickflickable.pro1
-rw-r--r--tests/auto/quick/qquickflickable/tst_qquickflickable.cpp181
-rw-r--r--tests/auto/quick/qquickfocusscope/tst_qquickfocusscope.cpp1
-rw-r--r--tests/auto/quick/qquickgridview/tst_qquickgridview.cpp8
-rw-r--r--tests/auto/quick/qquickitem/tst_qquickitem.cpp8
-rw-r--r--tests/auto/quick/qquicklistview/tst_qquicklistview.cpp12
-rw-r--r--tests/auto/quick/qquickpathview/tst_qquickpathview.cpp152
-rw-r--r--tests/auto/quick/qquickpositioners/data/gridtest.qml6
-rw-r--r--tests/auto/quick/qquickpositioners/tst_qquickpositioners.cpp243
-rw-r--r--tests/auto/quick/qquicktextdocument/data/text.qml6
-rw-r--r--tests/auto/quick/qquicktextdocument/qquicktextdocument.pro15
-rw-r--r--tests/auto/quick/qquicktextdocument/tst_qquicktextdocument.cpp87
-rw-r--r--tests/auto/quick/qquicktextedit/tst_qquicktextedit.cpp2
-rw-r--r--tests/auto/quick/qquicktextinput/tst_qquicktextinput.cpp4
-rw-r--r--tests/auto/quick/qquickvisualdatamodel/tst_qquickvisualdatamodel.cpp264
-rw-r--r--tests/auto/quick/qquickwindow/data/focus.qml4
-rw-r--r--tests/auto/quick/qquickwindow/data/ownershipRootItem.qml2
-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.cpp192
-rw-r--r--tests/auto/quick/quick.pro1
23 files changed, 803 insertions, 431 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/qquickanimations/qquickanimations.pro b/tests/auto/quick/qquickanimations/qquickanimations.pro
index f3cf4832e5..747a2afdff 100644
--- a/tests/auto/quick/qquickanimations/qquickanimations.pro
+++ b/tests/auto/quick/qquickanimations/qquickanimations.pro
@@ -1,4 +1,5 @@
CONFIG += testcase
+mac:CONFIG+=insignificant_test # QTBUG-29062
TARGET = tst_qquickanimations
SOURCES += tst_qquickanimations.cpp
diff --git a/tests/auto/quick/qquickflickable/qquickflickable.pro b/tests/auto/quick/qquickflickable/qquickflickable.pro
index 95c703befe..67d5fc12f0 100644
--- a/tests/auto/quick/qquickflickable/qquickflickable.pro
+++ b/tests/auto/quick/qquickflickable/qquickflickable.pro
@@ -11,3 +11,4 @@ TESTDATA = data/*
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 57c4c12264..875ade45b8 100644
--- a/tests/auto/quick/qquickflickable/tst_qquickflickable.cpp
+++ b/tests/auto/quick/qquickflickable/tst_qquickflickable.cpp
@@ -210,10 +210,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());
@@ -229,7 +231,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);
@@ -259,14 +261,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);
@@ -295,7 +296,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);
@@ -308,8 +309,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()
@@ -355,7 +354,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());
@@ -394,7 +395,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());
@@ -503,7 +506,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);
@@ -534,8 +538,6 @@ void tst_qquickflickable::returnToBounds()
QVERIFY(!rebound->running());
QCOMPARE(reboundSpy.count(), setRebound ? 2 : 0);
-
- delete window;
}
void tst_qquickflickable::returnToBounds_data()
@@ -548,10 +550,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");
@@ -561,7 +565,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);
@@ -575,13 +579,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()
@@ -616,11 +618,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();
- QVERIFY(QTest::qWaitForWindowActive(window));
+ QVERIFY(QTest::qWaitForWindowActive(window.data()));
QVERIFY(window->rootObject() != 0);
QQuickFlickable *flickable = qobject_cast<QQuickFlickable*>(window->rootObject());
@@ -639,7 +642,7 @@ 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);
QTRY_VERIFY(flickable->isMoving());
QCOMPARE(flickable->isMovingHorizontally(), horizontalEnabled);
@@ -695,7 +698,7 @@ 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);
QTRY_VERIFY(flickable->isMoving());
QCOMPARE(flickable->isMovingHorizontally(), horizontalEnabled);
@@ -739,8 +742,6 @@ void tst_qquickflickable::movingAndFlicking()
QCOMPARE(flickable->contentX(), 0.0);
QCOMPARE(flickable->contentY(), 0.0);
-
- delete window;
}
@@ -776,11 +777,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());
@@ -799,10 +801,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);
@@ -821,7 +823,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());
@@ -870,10 +872,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);
@@ -894,7 +896,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());
@@ -937,17 +939,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());
@@ -960,9 +961,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);
@@ -974,17 +975,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());
@@ -999,7 +999,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);
QTRY_VERIFY(flickable->isFlicking());
QVERIFY(flickable->isFlickingVertically());
@@ -1014,77 +1014,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
@@ -1092,17 +1091,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()
@@ -1166,20 +1163,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);
@@ -1195,56 +1194,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/qquickfocusscope/tst_qquickfocusscope.cpp b/tests/auto/quick/qquickfocusscope/tst_qquickfocusscope.cpp
index 19059c55df..b350abe953 100644
--- a/tests/auto/quick/qquickfocusscope/tst_qquickfocusscope.cpp
+++ b/tests/auto/quick/qquickfocusscope/tst_qquickfocusscope.cpp
@@ -525,7 +525,6 @@ void tst_qquickfocusscope::canvasFocus()
QSignalSpy scope2ActiveFocusSpy(scope2, SIGNAL(activeFocusChanged(bool)));
QSignalSpy item2ActiveFocusSpy(item2, SIGNAL(activeFocusChanged(bool)));
- QEXPECT_FAIL("", "QTBUG-22415", Abort);
QCOMPARE(rootItem->hasFocus(), false);
QCOMPARE(rootItem->hasActiveFocus(), false);
QCOMPARE(scope1->hasFocus(), true);
diff --git a/tests/auto/quick/qquickgridview/tst_qquickgridview.cpp b/tests/auto/quick/qquickgridview/tst_qquickgridview.cpp
index 3c30f9e887..0c9788ab8e 100644
--- a/tests/auto/quick/qquickgridview/tst_qquickgridview.cpp
+++ b/tests/auto/quick/qquickgridview/tst_qquickgridview.cpp
@@ -51,8 +51,7 @@
#include <QtQuick/private/qquickitem_p.h>
#include <QtQuick/private/qquickgridview_p.h>
#include <QtQuick/private/qquicktext_p.h>
-#include <QtQuick/private/qquickvisualitemmodel_p.h>
-#include <QtQml/private/qquicklistmodel_p.h>
+#include <QtQml/private/qqmllistmodel_p.h>
#include "../../shared/util.h"
#include "../shared/viewtestutil.h"
#include "../shared/visualtestutil.h"
@@ -2435,7 +2434,7 @@ void tst_QQuickGridView::modelChanges()
QQuickGridView *gridView = window->rootObject()->findChild<QQuickGridView*>("gridView");
QTRY_VERIFY(gridView);
- QQuickListModel *alternateModel = window->rootObject()->findChild<QQuickListModel*>("alternateModel");
+ QQmlListModel *alternateModel = window->rootObject()->findChild<QQmlListModel*>("alternateModel");
QTRY_VERIFY(alternateModel);
QVariant modelVariant = QVariant::fromValue<QObject *>(alternateModel);
QSignalSpy modelSpy(gridView, SIGNAL(modelChanged()));
@@ -2871,7 +2870,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/qquickitem/tst_qquickitem.cpp b/tests/auto/quick/qquickitem/tst_qquickitem.cpp
index e237174eb1..a7343f686f 100644
--- a/tests/auto/quick/qquickitem/tst_qquickitem.cpp
+++ b/tests/auto/quick/qquickitem/tst_qquickitem.cpp
@@ -175,6 +175,8 @@ private:
};
void ensureFocus(QWindow *w) {
+ if (w->width() <=0 || w->height() <= 0)
+ w->setGeometry(100, 100, 400, 300);
w->show();
w->requestActivate();
QTest::qWaitForWindowActive(w);
@@ -270,10 +272,6 @@ void tst_qquickitem::simpleFocus()
QQuickWindow window;
ensureFocus(&window);
-#ifdef Q_OS_MAC
- QSKIP("QTBUG-24094: fails on Mac OS X 10.7");
-#endif
-
QTRY_VERIFY(QGuiApplication::focusWindow() == &window);
QQuickItem *l1c1 = new TestItem(window.contentItem());
@@ -732,7 +730,7 @@ void tst_qquickitem::focusSubItemInNonFocusScope()
QQuickView *view = new QQuickView;
view->setSource(testFileUrl("focusSubItemInNonFocusScope.qml"));
view->show();
- qApp->processEvents();
+ QTest::qWaitForWindowActive(view);
QQuickItem *dummyItem = view->rootObject()->findChild<QQuickItem *>("dummyItem");
QVERIFY(dummyItem);
diff --git a/tests/auto/quick/qquicklistview/tst_qquicklistview.cpp b/tests/auto/quick/qquicklistview/tst_qquicklistview.cpp
index c034fe83c8..65892ddd9b 100644
--- a/tests/auto/quick/qquicklistview/tst_qquicklistview.cpp
+++ b/tests/auto/quick/qquicklistview/tst_qquicklistview.cpp
@@ -48,8 +48,8 @@
#include <QtQml/qqmlincubator.h>
#include <QtQuick/private/qquicklistview_p.h>
#include <QtQuick/private/qquicktext_p.h>
-#include <QtQuick/private/qquickvisualitemmodel_p.h>
-#include <QtQml/private/qquicklistmodel_p.h>
+#include <QtQml/private/qqmlobjectmodel_p.h>
+#include <QtQml/private/qqmllistmodel_p.h>
#include "../../shared/util.h"
#include "../shared/viewtestutil.h"
#include "../shared/visualtestutil.h"
@@ -2768,7 +2768,7 @@ void tst_QQuickListView::itemList()
QQuickItem *contentItem = listview->contentItem();
QTRY_VERIFY(contentItem != 0);
- QQuickVisualItemModel *model = window->rootObject()->findChild<QQuickVisualItemModel*>("itemModel");
+ QQmlObjectModel *model = window->rootObject()->findChild<QQmlObjectModel*>("itemModel");
QTRY_VERIFY(model != 0);
QTRY_VERIFY(model->count() == 3);
@@ -2809,7 +2809,7 @@ void tst_QQuickListView::itemListFlicker()
QQuickItem *contentItem = listview->contentItem();
QTRY_VERIFY(contentItem != 0);
- QQuickVisualItemModel *model = window->rootObject()->findChild<QQuickVisualItemModel*>("itemModel");
+ QQmlObjectModel *model = window->rootObject()->findChild<QQmlObjectModel*>("itemModel");
QTRY_VERIFY(model != 0);
QTRY_VERIFY(model->count() == 3);
@@ -3258,7 +3258,7 @@ void tst_QQuickListView::modelChanges()
QQuickListView *listView = window->rootObject()->findChild<QQuickListView*>("listView");
QTRY_VERIFY(listView);
- QQuickListModel *alternateModel = window->rootObject()->findChild<QQuickListModel*>("alternateModel");
+ QQmlListModel *alternateModel = window->rootObject()->findChild<QQmlListModel*>("alternateModel");
QTRY_VERIFY(alternateModel);
QVariant modelVariant = QVariant::fromValue<QObject *>(alternateModel);
QSignalSpy modelSpy(listView, SIGNAL(modelChanged()));
@@ -4606,7 +4606,7 @@ void tst_QQuickListView::rightToLeft()
QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
- QQuickVisualItemModel *model = window->rootObject()->findChild<QQuickVisualItemModel*>("itemModel");
+ QQmlObjectModel *model = window->rootObject()->findChild<QQmlObjectModel*>("itemModel");
QTRY_VERIFY(model != 0);
QTRY_VERIFY(model->count() == 3);
diff --git a/tests/auto/quick/qquickpathview/tst_qquickpathview.cpp b/tests/auto/quick/qquickpathview/tst_qquickpathview.cpp
index 8821203902..f52939e628 100644
--- a/tests/auto/quick/qquickpathview/tst_qquickpathview.cpp
+++ b/tests/auto/quick/qquickpathview/tst_qquickpathview.cpp
@@ -50,7 +50,7 @@
#include <QtQuick/private/qquickpath_p.h>
#include <QtQuick/private/qquicktext_p.h>
#include <QtQuick/private/qquickrectangle_p.h>
-#include <QtQml/private/qquicklistmodel_p.h>
+#include <QtQml/private/qqmllistmodel_p.h>
#include <QtQml/private/qqmlvaluetype_p.h>
#include <QtGui/qstandarditemmodel.h>
#include <QStringListModel>
@@ -199,7 +199,7 @@ void tst_QQuickPathView::initValues()
void tst_QQuickPathView::items()
{
- QQuickView *window = createView();
+ QScopedPointer<QQuickView> window(createView());
QaimModel model;
model.addItem("Fred", "12345");
@@ -238,8 +238,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()
@@ -350,7 +348,7 @@ void tst_QQuickPathView::insertModel()
QFETCH(qreal, offset);
QFETCH(int, currentIndex);
- QQuickView *window = createView();
+ QScopedPointer<QQuickView> window(createView());
window->show();
QaimModel model;
@@ -388,8 +386,6 @@ void tst_QQuickPathView::insertModel()
QTRY_COMPARE(pathview->offset(), offset);
QCOMPARE(pathview->currentIndex(), currentIndex);
-
- delete window;
}
void tst_QQuickPathView::removeModel_data()
@@ -444,7 +440,8 @@ void tst_QQuickPathView::removeModel()
QFETCH(qreal, offset);
QFETCH(int, currentIndex);
- QQuickView *window = createView();
+ QScopedPointer<QQuickView> window(createView());
+
window->show();
QaimModel model;
@@ -478,8 +475,6 @@ void tst_QQuickPathView::removeModel()
QTRY_COMPARE(pathview->offset(), offset);
QCOMPARE(pathview->currentIndex(), currentIndex);
-
- delete window;
}
@@ -539,7 +534,7 @@ void tst_QQuickPathView::moveModel()
QFETCH(qreal, offset);
QFETCH(int, currentIndex);
- QQuickView *window = createView();
+ QScopedPointer<QQuickView> window(createView());
window->show();
QaimModel model;
@@ -573,8 +568,6 @@ void tst_QQuickPathView::moveModel()
QTRY_COMPARE(pathview->offset(), offset);
QCOMPARE(pathview->currentIndex(), currentIndex);
-
- delete window;
}
void tst_QQuickPathView::consecutiveModelChanges_data()
@@ -640,7 +633,7 @@ void tst_QQuickPathView::consecutiveModelChanges()
QFETCH(qreal, offset);
QFETCH(int, currentIndex);
- QQuickView *window = createView();
+ QScopedPointer<QQuickView> window(createView());
window->show();
QaimModel model;
@@ -704,7 +697,6 @@ void tst_QQuickPathView::consecutiveModelChanges()
QCOMPARE(pathview->currentIndex(), currentIndex);
- delete window;
}
void tst_QQuickPathView::path()
@@ -756,7 +748,7 @@ void tst_QQuickPathView::path()
void tst_QQuickPathView::dataModel()
{
- QQuickView *window = createView();
+ QScopedPointer<QQuickView> window(createView());
window->show();
QQmlContext *ctxt = window->rootContext();
@@ -865,13 +857,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;
@@ -926,7 +917,6 @@ void tst_QQuickPathView::pathMoved()
window->rootObject()->setProperty("delegateScale", 1.2);
QTRY_COMPARE(firstItem->position() + offset, start);
- delete window;
}
void tst_QQuickPathView::offset_data()
@@ -960,7 +950,7 @@ void tst_QQuickPathView::offset()
void tst_QQuickPathView::setCurrentIndex()
{
- QQuickView *window = createView();
+ QScopedPointer<QQuickView> window(createView());
window->show();
QaimModel model;
@@ -1103,12 +1093,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";
@@ -1143,12 +1132,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"));
@@ -1185,12 +1173,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"));
@@ -1247,12 +1234,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"));
@@ -1270,12 +1256,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"));
@@ -1284,7 +1269,7 @@ void tst_QQuickPathView::modelChanges()
pathView->setCurrentIndex(3);
QTRY_COMPARE(pathView->offset(), 6.0);
- QQuickListModel *alternateModel = window->rootObject()->findChild<QQuickListModel*>("alternateModel");
+ QQmlListModel *alternateModel = window->rootObject()->findChild<QQmlListModel*>("alternateModel");
QVERIFY(alternateModel);
QVariant modelVariant = QVariant::fromValue<QObject *>(alternateModel);
QSignalSpy modelSpy(pathView, SIGNAL(modelChanged()));
@@ -1305,12 +1290,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"));
@@ -1327,17 +1311,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);
@@ -1350,13 +1333,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;
@@ -1371,7 +1353,6 @@ void tst_QQuickPathView::emptyModel()
QCOMPARE(pathview->offset(), qreal(0.0));
- delete window;
}
void tst_QQuickPathView::emptyPath()
@@ -1411,7 +1392,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"));
@@ -1422,7 +1403,6 @@ void tst_QQuickPathView::pathUpdate()
QVERIFY(item);
QCOMPARE(item->x(), 150.0);
- delete window;
}
void tst_QQuickPathView::visualDataModel()
@@ -1463,12 +1443,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);
@@ -1482,12 +1462,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());
@@ -1501,7 +1481,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());
@@ -1515,7 +1495,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);
@@ -1524,12 +1504,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;
@@ -1552,18 +1531,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);
@@ -1587,7 +1565,6 @@ void tst_QQuickPathView::changePreferredHighlight()
QTRY_COMPARE(firstItem->position() + offset, start);
QCOMPARE(pathview->currentIndex(), 0);
- delete window;
}
void tst_QQuickPathView::creationContext()
@@ -1608,7 +1585,7 @@ void tst_QQuickPathView::creationContext()
// QTBUG-21320
void tst_QQuickPathView::currentOffsetOnInsertion()
{
- QQuickView *window = createView();
+ QScopedPointer<QQuickView> window(createView());
window->show();
QaimModel model;
@@ -1681,12 +1658,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);
@@ -1737,7 +1713,6 @@ void tst_QQuickPathView::asynchronous()
QCOMPARE(curItem->position() + offset, itemPos);
}
- delete window;
}
void tst_QQuickPathView::missingPercent()
@@ -1752,12 +1727,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);
@@ -1767,10 +1742,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());
@@ -1791,25 +1766,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);
@@ -1818,7 +1792,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);
@@ -1827,7 +1801,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);
@@ -1838,14 +1812,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);
@@ -1857,7 +1830,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());
@@ -1869,7 +1842,6 @@ void tst_QQuickPathView::snapToItem()
else
QVERIFY(pathview->currentIndex() == currentIndex);
- delete window;
}
void tst_QQuickPathView::snapToItem_data()
@@ -1884,12 +1856,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);
@@ -1905,7 +1877,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());
@@ -1918,7 +1890,6 @@ void tst_QQuickPathView::snapOneItem()
else
QVERIFY(pathview->currentIndex() == currentIndex);
- delete window;
}
void tst_QQuickPathView::snapOneItem_data()
@@ -1938,12 +1909,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);
@@ -1959,7 +1930,6 @@ void tst_QQuickPathView::positionViewAtIndex()
QCOMPARE(pathview->offset(), offset);
- delete window;
}
void tst_QQuickPathView::positionViewAtIndex_data()
@@ -2002,12 +1972,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);
@@ -2020,7 +1990,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()
@@ -2038,7 +2007,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();
@@ -2112,7 +2081,6 @@ void tst_QQuickPathView::cacheItemCount()
controller.incubateWhile(&b);
}
- delete window;
}
QTEST_MAIN(tst_QQuickPathView)
diff --git a/tests/auto/quick/qquickpositioners/data/gridtest.qml b/tests/auto/quick/qquickpositioners/data/gridtest.qml
index 50bec1377b..fbe0b22b15 100644
--- a/tests/auto/quick/qquickpositioners/data/gridtest.qml
+++ b/tests/auto/quick/qquickpositioners/data/gridtest.qml
@@ -1,11 +1,15 @@
-import QtQuick 2.0
+import QtQuick 2.1
Item {
width: 640
height: 480
property bool testRightToLeft: false
+ property int testHAlignment: Grid.AlignLeft;
+ property int testVAlignment: Grid.AlignTop;
Grid {
layoutDirection: testRightToLeft ? Qt.RightToLeft : Qt.LeftToRight
+ horizontalItemAlignment: testHAlignment
+ verticalItemAlignment: testVAlignment
objectName: "grid"
columns: 3
Rectangle {
diff --git a/tests/auto/quick/qquickpositioners/tst_qquickpositioners.cpp b/tests/auto/quick/qquickpositioners/tst_qquickpositioners.cpp
index 98999e540a..1f472a3f46 100644
--- a/tests/auto/quick/qquickpositioners/tst_qquickpositioners.cpp
+++ b/tests/auto/quick/qquickpositioners/tst_qquickpositioners.cpp
@@ -78,6 +78,8 @@ private slots:
void test_grid_animated();
void test_grid_animated_rightToLeft();
void test_grid_zero_columns();
+ void test_grid_H_alignment();
+ void test_grid_V_alignment();
void test_propertychanges();
void test_repeater();
void test_flow();
@@ -288,7 +290,7 @@ tst_qquickpositioners::tst_qquickpositioners()
void tst_qquickpositioners::test_horizontal()
{
- QQuickView *window = createView(testFile("horizontal.qml"));
+ QScopedPointer<QQuickView> window(createView(testFile("horizontal.qml")));
window->rootObject()->setProperty("testRightToLeft", false);
@@ -311,13 +313,11 @@ void tst_qquickpositioners::test_horizontal()
QQuickItem *row = window->rootObject()->findChild<QQuickItem*>("row");
QCOMPARE(row->width(), 110.0);
QCOMPARE(row->height(), 50.0);
-
- delete window;
}
void tst_qquickpositioners::test_horizontal_rtl()
{
- QQuickView *window = createView(testFile("horizontal.qml"));
+ QScopedPointer<QQuickView> window(createView(testFile("horizontal.qml")));
window->rootObject()->setProperty("testRightToLeft", true);
@@ -350,12 +350,11 @@ void tst_qquickpositioners::test_horizontal_rtl()
QCOMPARE(three->x(), 90.0);
QCOMPARE(three->y(), 0.0);
- delete window;
}
void tst_qquickpositioners::test_horizontal_spacing()
{
- QQuickView *window = createView(testFile("horizontal-spacing.qml"));
+ QScopedPointer<QQuickView> window(createView(testFile("horizontal-spacing.qml")));
window->rootObject()->setProperty("testRightToLeft", false);
@@ -379,12 +378,11 @@ void tst_qquickpositioners::test_horizontal_spacing()
QCOMPARE(row->width(), 130.0);
QCOMPARE(row->height(), 50.0);
- delete window;
}
void tst_qquickpositioners::test_horizontal_spacing_rightToLeft()
{
- QQuickView *window = createView(testFile("horizontal-spacing.qml"));
+ QScopedPointer<QQuickView> window(createView(testFile("horizontal-spacing.qml")));
window->rootObject()->setProperty("testRightToLeft", true);
@@ -408,12 +406,11 @@ void tst_qquickpositioners::test_horizontal_spacing_rightToLeft()
QCOMPARE(row->width(), 130.0);
QCOMPARE(row->height(), 50.0);
- delete window;
}
void tst_qquickpositioners::test_horizontal_animated()
{
- QQuickView *window = createView(testFile("horizontal-animated.qml"), false);
+ QScopedPointer<QQuickView> window(createView(testFile("horizontal-animated.qml"), false));
window->rootObject()->setProperty("testRightToLeft", false);
@@ -431,7 +428,7 @@ void tst_qquickpositioners::test_horizontal_animated()
QCOMPARE(two->x(), -100.0);
QCOMPARE(three->x(), -100.0);
- QVERIFY(QTest::qWaitForWindowExposed(window)); //It may not relayout until the next frame, so it needs to be drawn
+ QVERIFY(QTest::qWaitForWindowExposed(window.data())); //It may not relayout until the next frame, so it needs to be drawn
QQuickItem *row = window->rootObject()->findChild<QQuickItem*>("row");
QVERIFY(row);
@@ -462,12 +459,11 @@ void tst_qquickpositioners::test_horizontal_animated()
QTRY_COMPARE(two->x(), 50.0);
QTRY_COMPARE(three->x(), 100.0);
- delete window;
}
void tst_qquickpositioners::test_horizontal_animated_rightToLeft()
{
- QQuickView *window = createView(testFile("horizontal-animated.qml"), false);
+ QScopedPointer<QQuickView> window(createView(testFile("horizontal-animated.qml"), false));
window->rootObject()->setProperty("testRightToLeft", true);
@@ -485,7 +481,7 @@ void tst_qquickpositioners::test_horizontal_animated_rightToLeft()
QCOMPARE(two->x(), -100.0);
QCOMPARE(three->x(), -100.0);
- QVERIFY(QTest::qWaitForWindowExposed(window)); //It may not relayout until the next frame, so it needs to be drawn
+ QVERIFY(QTest::qWaitForWindowExposed(window.data())); //It may not relayout until the next frame, so it needs to be drawn
QQuickItem *row = window->rootObject()->findChild<QQuickItem*>("row");
QVERIFY(row);
@@ -518,12 +514,11 @@ void tst_qquickpositioners::test_horizontal_animated_rightToLeft()
QTRY_COMPARE(one->x(), 100.0);
QTRY_COMPARE(two->x(), 50.0);
- delete window;
}
void tst_qquickpositioners::test_horizontal_animated_disabled()
{
- QQuickView *window = createView(testFile("horizontal-animated-disabled.qml"));
+ QScopedPointer<QQuickView> window(createView(testFile("horizontal-animated-disabled.qml")));
QQuickRectangle *one = window->rootObject()->findChild<QQuickRectangle*>("one");
QVERIFY(one != 0);
@@ -556,7 +551,6 @@ void tst_qquickpositioners::test_horizontal_animated_disabled()
QTRY_COMPARE(two->x(), 50.0);
QTRY_COMPARE(three->x(), 100.0);
- delete window;
}
void tst_qquickpositioners::populateTransitions(const QString &positionerObjectName)
@@ -576,7 +570,8 @@ void tst_qquickpositioners::populateTransitions(const QString &positionerObjectN
QaimModel model_targetItems_transitionFrom;
QaimModel model_displacedItems_transitionVia;
- QQuickView *window = QQuickViewTestUtil::createView();
+ QScopedPointer<QQuickView> window(QQuickViewTestUtil::createView());
+
QQmlContext *ctxt = window->rootContext();
ctxt->setContextProperty("usePopulateTransition", usePopulateTransition);
ctxt->setContextProperty("enableAddTransition", true);
@@ -592,6 +587,7 @@ void tst_qquickpositioners::populateTransitions(const QString &positionerObjectN
QQuickItem *positioner = window->rootObject()->findChild<QQuickItem*>(positionerObjectName);
QVERIFY(positioner);
window->show();
+ QTest::qWaitForWindowExposed(window.data());
qApp->processEvents();
if (!dynamicallyPopulate && usePopulateTransition) {
@@ -627,8 +623,6 @@ void tst_qquickpositioners::populateTransitions(const QString &positionerObjectN
model.insertItem(0, "new item", "");
QTRY_COMPARE(window->rootObject()->property("addTransitionsDone").toInt(), 1);
QTRY_COMPARE(window->rootObject()->property("populateTransitionsDone").toInt(), 0);
-
- delete window;
}
void tst_qquickpositioners::populateTransitions_data()
@@ -657,7 +651,7 @@ void tst_qquickpositioners::addTransitions(const QString &positionerObjectName)
QaimModel model_targetItems_transitionFrom;
QaimModel model_displacedItems_transitionVia;
- QQuickView *window = QQuickViewTestUtil::createView();
+ QScopedPointer<QQuickView> window(QQuickViewTestUtil::createView());
QQmlContext *ctxt = window->rootContext();
ctxt->setContextProperty("usePopulateTransition", QVariant(false));
ctxt->setContextProperty("enableAddTransition", QVariant(true));
@@ -667,6 +661,7 @@ void tst_qquickpositioners::addTransitions(const QString &positionerObjectName)
ctxt->setContextProperty("displacedItems_transitionVia", displacedItems_transitionVia);
window->setSource(testFileUrl("transitions.qml"));
window->show();
+ QTest::qWaitForWindowExposed(window.data());
qApp->processEvents();
QQuickItem *positioner = window->rootObject()->findChild<QQuickItem*>(positionerObjectName);
@@ -733,8 +728,6 @@ void tst_qquickpositioners::addTransitions(const QString &positionerObjectName)
}
checkItemPositions(positioner, &model, window->rootObject()->property("incrementalSize").toInt());
-
- delete window;
}
void tst_qquickpositioners::addTransitions_data()
@@ -770,7 +763,7 @@ void tst_qquickpositioners::moveTransitions(const QString &positionerObjectName)
QaimModel model_targetItems_transitionFrom;
QaimModel model_displacedItems_transitionVia;
- QQuickView *window = QQuickViewTestUtil::createView();
+ QScopedPointer<QQuickView> window(QQuickViewTestUtil::createView());
QQmlContext *ctxt = window->rootContext();
ctxt->setContextProperty("usePopulateTransition", QVariant(false));
ctxt->setContextProperty("enableAddTransition", QVariant(false));
@@ -780,6 +773,7 @@ void tst_qquickpositioners::moveTransitions(const QString &positionerObjectName)
ctxt->setContextProperty("displacedItems_transitionVia", displacedItems_transitionVia);
window->setSource(testFileUrl("transitions.qml"));
window->show();
+ QTest::qWaitForWindowExposed(window.data());
qApp->processEvents();
QList<QPair<QString,QString> > expectedDisplacedValues = expectedDisplacedIndexes.getModelDataValues(model);
@@ -842,8 +836,6 @@ void tst_qquickpositioners::moveTransitions(const QString &positionerObjectName)
}
checkItemPositions(positioner, &model, window->rootObject()->property("incrementalSize").toInt());
-
- delete window;
}
void tst_qquickpositioners::moveTransitions_data()
@@ -929,7 +921,7 @@ void tst_qquickpositioners::checkItemPositions(QQuickItem *positioner, QaimModel
void tst_qquickpositioners::test_vertical()
{
- QQuickView *window = createView(testFile("vertical.qml"));
+ QScopedPointer<QQuickView> window(createView(testFile("vertical.qml")));
QQuickRectangle *one = window->rootObject()->findChild<QQuickRectangle*>("one");
QVERIFY(one != 0);
@@ -952,12 +944,11 @@ void tst_qquickpositioners::test_vertical()
QCOMPARE(column->height(), 80.0);
QCOMPARE(column->width(), 50.0);
- delete window;
}
void tst_qquickpositioners::test_vertical_spacing()
{
- QQuickView *window = createView(testFile("vertical-spacing.qml"));
+ QScopedPointer<QQuickView> window(createView(testFile("vertical-spacing.qml")));
QQuickRectangle *one = window->rootObject()->findChild<QQuickRectangle*>("one");
QVERIFY(one != 0);
@@ -979,12 +970,11 @@ void tst_qquickpositioners::test_vertical_spacing()
QCOMPARE(column->height(), 100.0);
QCOMPARE(column->width(), 50.0);
- delete window;
}
void tst_qquickpositioners::test_vertical_animated()
{
- QQuickView *window = createView(testFile("vertical-animated.qml"), false);
+ QScopedPointer<QQuickView> window(createView(testFile("vertical-animated.qml"), false));
//Note that they animate in
QQuickRectangle *one = window->rootObject()->findChild<QQuickRectangle*>("one");
@@ -999,7 +989,7 @@ void tst_qquickpositioners::test_vertical_animated()
QVERIFY(three != 0);
QCOMPARE(three->y(), -100.0);
- QVERIFY(QTest::qWaitForWindowExposed(window)); //It may not relayout until the next frame, so it needs to be drawn
+ QVERIFY(QTest::qWaitForWindowExposed(window.data())); //It may not relayout until the next frame, so it needs to be drawn
QQuickItem *column = window->rootObject()->findChild<QQuickItem*>("column");
QVERIFY(column);
@@ -1029,12 +1019,11 @@ void tst_qquickpositioners::test_vertical_animated()
QTRY_COMPARE(two->y(), 50.0);
QTRY_COMPARE(three->y(), 100.0);
- delete window;
}
void tst_qquickpositioners::test_grid()
{
- QQuickView *window = createView(testFile("gridtest.qml"));
+ QScopedPointer<QQuickView> window(createView(testFile("gridtest.qml")));
QQuickRectangle *one = window->rootObject()->findChild<QQuickRectangle*>("one");
QVERIFY(one != 0);
@@ -1063,12 +1052,11 @@ void tst_qquickpositioners::test_grid()
QCOMPARE(grid->width(), 100.0);
QCOMPARE(grid->height(), 100.0);
- delete window;
}
void tst_qquickpositioners::test_grid_topToBottom()
{
- QQuickView *window = createView(testFile("grid-toptobottom.qml"));
+ QScopedPointer<QQuickView> window(createView(testFile("grid-toptobottom.qml")));
QQuickRectangle *one = window->rootObject()->findChild<QQuickRectangle*>("one");
QVERIFY(one != 0);
@@ -1097,12 +1085,11 @@ void tst_qquickpositioners::test_grid_topToBottom()
QCOMPARE(grid->width(), 100.0);
QCOMPARE(grid->height(), 120.0);
- delete window;
}
void tst_qquickpositioners::test_grid_rightToLeft()
{
- QQuickView *window = createView(testFile("gridtest.qml"));
+ QScopedPointer<QQuickView> window(createView(testFile("gridtest.qml")));
window->rootObject()->setProperty("testRightToLeft", true);
@@ -1146,12 +1133,11 @@ void tst_qquickpositioners::test_grid_rightToLeft()
QCOMPARE(five->x(), 140.0);
QCOMPARE(five->y(), 50.0);
- delete window;
}
void tst_qquickpositioners::test_grid_spacing()
{
- QQuickView *window = createView(testFile("grid-spacing.qml"));
+ QScopedPointer<QQuickView> window(createView(testFile("grid-spacing.qml")));
QQuickRectangle *one = window->rootObject()->findChild<QQuickRectangle*>("one");
QVERIFY(one != 0);
@@ -1179,12 +1165,11 @@ void tst_qquickpositioners::test_grid_spacing()
QCOMPARE(grid->width(), 128.0);
QCOMPARE(grid->height(), 104.0);
- delete window;
}
void tst_qquickpositioners::test_grid_row_column_spacing()
{
- QQuickView *window = createView(testFile("grid-row-column-spacing.qml"));
+ QScopedPointer<QQuickView> window(createView(testFile("grid-row-column-spacing.qml")));
QQuickRectangle *one = window->rootObject()->findChild<QQuickRectangle*>("one");
QVERIFY(one != 0);
@@ -1212,12 +1197,11 @@ void tst_qquickpositioners::test_grid_row_column_spacing()
QCOMPARE(grid->width(), 142.0);
QCOMPARE(grid->height(), 107.0);
- delete window;
}
void tst_qquickpositioners::test_grid_animated()
{
- QQuickView *window = createView(testFile("grid-animated.qml"), false);
+ QScopedPointer<QQuickView> window(createView(testFile("grid-animated.qml"), false));
window->rootObject()->setProperty("testRightToLeft", false);
@@ -1247,7 +1231,7 @@ void tst_qquickpositioners::test_grid_animated()
QCOMPARE(five->x(), -100.0);
QCOMPARE(five->y(), -100.0);
- QVERIFY(QTest::qWaitForWindowExposed(window)); //It may not relayout until the next frame, so it needs to be drawn
+ QVERIFY(QTest::qWaitForWindowExposed(window.data())); //It may not relayout until the next frame, so it needs to be drawn
QQuickItem *grid = window->rootObject()->findChild<QQuickItem*>("grid");
QVERIFY(grid);
@@ -1297,12 +1281,11 @@ void tst_qquickpositioners::test_grid_animated()
QTRY_COMPARE(five->x(), 50.0);
QTRY_COMPARE(five->y(), 50.0);
- delete window;
}
void tst_qquickpositioners::test_grid_animated_rightToLeft()
{
- QQuickView *window = createView(testFile("grid-animated.qml"), false);
+ QScopedPointer<QQuickView> window(createView(testFile("grid-animated.qml"), false));
window->rootObject()->setProperty("testRightToLeft", true);
@@ -1332,7 +1315,7 @@ void tst_qquickpositioners::test_grid_animated_rightToLeft()
QCOMPARE(five->x(), -100.0);
QCOMPARE(five->y(), -100.0);
- QVERIFY(QTest::qWaitForWindowExposed(window)); //It may not relayout until the next frame, so it needs to be drawn
+ QVERIFY(QTest::qWaitForWindowExposed(window.data())); //It may not relayout until the next frame, so it needs to be drawn
QQuickItem *grid = window->rootObject()->findChild<QQuickItem*>("grid");
QVERIFY(grid);
@@ -1382,12 +1365,11 @@ void tst_qquickpositioners::test_grid_animated_rightToLeft()
QTRY_COMPARE(five->x(), 50.0);
QTRY_COMPARE(five->y(), 50.0);
- delete window;
}
void tst_qquickpositioners::test_grid_zero_columns()
{
- QQuickView *window = createView(testFile("gridzerocolumns.qml"));
+ QScopedPointer<QQuickView> window(createView(testFile("gridzerocolumns.qml")));
QQuickRectangle *one = window->rootObject()->findChild<QQuickRectangle*>("one");
QVERIFY(one != 0);
@@ -1415,12 +1397,133 @@ void tst_qquickpositioners::test_grid_zero_columns()
QCOMPARE(grid->width(), 170.0);
QCOMPARE(grid->height(), 60.0);
- delete window;
+}
+
+void tst_qquickpositioners::test_grid_H_alignment()
+{
+ QScopedPointer<QQuickView> window(createView(testFile("gridtest.qml")));
+
+ window->rootObject()->setProperty("testHAlignment", QQuickGrid::AlignHCenter);
+
+ QQuickRectangle *one = window->rootObject()->findChild<QQuickRectangle*>("one");
+ QVERIFY(one != 0);
+ QQuickRectangle *two = window->rootObject()->findChild<QQuickRectangle*>("two");
+ QVERIFY(two != 0);
+ QQuickRectangle *three = window->rootObject()->findChild<QQuickRectangle*>("three");
+ QVERIFY(three != 0);
+ QQuickRectangle *four = window->rootObject()->findChild<QQuickRectangle*>("four");
+ QVERIFY(four != 0);
+ QQuickRectangle *five = window->rootObject()->findChild<QQuickRectangle*>("five");
+ QVERIFY(five != 0);
+
+ QCOMPARE(one->x(), 0.0);
+ QCOMPARE(one->y(), 0.0);
+ QCOMPARE(two->x(), 50.0);
+ QCOMPARE(two->y(), 0.0);
+ QCOMPARE(three->x(), 70.0);
+ QCOMPARE(three->y(), 0.0);
+ QCOMPARE(four->x(), 0.0);
+ QCOMPARE(four->y(), 50.0);
+ QCOMPARE(five->x(), 55.0);
+ QCOMPARE(five->y(), 50.0);
+
+ QQuickItem *grid = window->rootObject()->findChild<QQuickItem*>("grid");
+ QCOMPARE(grid->width(), 100.0);
+ QCOMPARE(grid->height(), 100.0);
+
+ window->rootObject()->setProperty("testHAlignment", QQuickGrid::AlignRight);
+
+ QCOMPARE(one->x(), 0.0);
+ QCOMPARE(one->y(), 0.0);
+ QCOMPARE(two->x(), 50.0);
+ QCOMPARE(two->y(), 0.0);
+ QCOMPARE(three->x(), 70.0);
+ QCOMPARE(three->y(), 0.0);
+ QCOMPARE(four->x(), 0.0);
+ QCOMPARE(four->y(), 50.0);
+ QCOMPARE(five->x(), 60.0);
+ QCOMPARE(five->y(), 50.0);
+ QCOMPARE(grid->width(), 100.0);
+ QCOMPARE(grid->height(), 100.0);
+
+ window->rootObject()->setProperty("testRightToLeft", true);
+
+ QCOMPARE(one->x(), 50.0);
+ QCOMPARE(one->y(), 0.0);
+ QCOMPARE(two->x(), 30.0);
+ QCOMPARE(two->y(), 0.0);
+ QCOMPARE(three->x(), 0.0);
+ QCOMPARE(three->y(), 0.0);
+ QCOMPARE(four->x(), 50.0);
+ QCOMPARE(four->y(), 50.0);
+ QCOMPARE(five->x(), 30.0);
+ QCOMPARE(five->y(), 50.0);
+ QCOMPARE(grid->width(), 100.0);
+ QCOMPARE(grid->height(), 100.0);
+
+ window->rootObject()->setProperty("testHAlignment", QQuickGrid::AlignHCenter);
+
+ QCOMPARE(one->x(), 50.0);
+ QCOMPARE(one->y(), 0.0);
+ QCOMPARE(two->x(), 30.0);
+ QCOMPARE(two->y(), 0.0);
+ QCOMPARE(three->x(), 0.0);
+ QCOMPARE(three->y(), 0.0);
+ QCOMPARE(four->x(), 50.0);
+ QCOMPARE(four->y(), 50.0);
+ QCOMPARE(five->x(), 35.0);
+ QCOMPARE(five->y(), 50.0);
+ QCOMPARE(grid->width(), 100.0);
+ QCOMPARE(grid->height(), 100.0);
+
+}
+
+void tst_qquickpositioners::test_grid_V_alignment()
+{
+ QScopedPointer<QQuickView> window(createView(testFile("gridtest.qml")));
+
+ window->rootObject()->setProperty("testVAlignment", QQuickGrid::AlignVCenter);
+
+ QQuickRectangle *one = window->rootObject()->findChild<QQuickRectangle*>("one");
+ QVERIFY(one != 0);
+ QQuickRectangle *two = window->rootObject()->findChild<QQuickRectangle*>("two");
+ QVERIFY(two != 0);
+ QQuickRectangle *three = window->rootObject()->findChild<QQuickRectangle*>("three");
+ QVERIFY(three != 0);
+ QQuickRectangle *four = window->rootObject()->findChild<QQuickRectangle*>("four");
+ QVERIFY(four != 0);
+ QQuickRectangle *five = window->rootObject()->findChild<QQuickRectangle*>("five");
+ QVERIFY(five != 0);
+
+ QCOMPARE(one->x(), 0.0);
+ QCOMPARE(one->y(), 0.0);
+ QCOMPARE(two->x(), 50.0);
+ QCOMPARE(two->y(), 0.0);
+ QCOMPARE(three->x(), 70.0);
+ QCOMPARE(three->y(), 15.0);
+ QCOMPARE(four->x(), 0.0);
+ QCOMPARE(four->y(), 50.0);
+ QCOMPARE(five->x(), 50.0);
+ QCOMPARE(five->y(), 70.0);
+
+ window->rootObject()->setProperty("testVAlignment", QQuickGrid::AlignBottom);
+
+ QCOMPARE(one->x(), 0.0);
+ QCOMPARE(one->y(), 0.0);
+ QCOMPARE(two->x(), 50.0);
+ QCOMPARE(two->y(), 0.0);
+ QCOMPARE(three->x(), 70.0);
+ QCOMPARE(three->y(), 30.0);
+ QCOMPARE(four->x(), 0.0);
+ QCOMPARE(four->y(), 50.0);
+ QCOMPARE(five->x(), 50.0);
+ QCOMPARE(five->y(), 90.0);
+
}
void tst_qquickpositioners::test_propertychanges()
{
- QQuickView *window = createView(testFile("propertychangestest.qml"));
+ QScopedPointer<QQuickView> window(createView(testFile("propertychangestest.qml")));
QQuickGrid *grid = qobject_cast<QQuickGrid*>(window->rootObject());
QVERIFY(grid != 0);
@@ -1474,12 +1577,11 @@ void tst_qquickpositioners::test_propertychanges()
QCOMPARE(columnsSpy.count(),2);
QCOMPARE(rowsSpy.count(),2);
- delete window;
}
void tst_qquickpositioners::test_repeater()
{
- QQuickView *window = createView(testFile("repeatertest.qml"));
+ QScopedPointer<QQuickView> window(createView(testFile("repeatertest.qml")));
QQuickRectangle *one = findItem<QQuickRectangle>(window->contentItem(), "one");
QVERIFY(one != 0);
@@ -1497,12 +1599,11 @@ void tst_qquickpositioners::test_repeater()
QCOMPARE(three->x(), 100.0);
QCOMPARE(three->y(), 0.0);
- delete window;
}
void tst_qquickpositioners::test_flow()
{
- QQuickView *window = createView(testFile("flowtest.qml"));
+ QScopedPointer<QQuickView> window(createView(testFile("flowtest.qml")));
window->rootObject()->setProperty("testRightToLeft", false);
@@ -1533,12 +1634,11 @@ void tst_qquickpositioners::test_flow()
QCOMPARE(flow->width(), 90.0);
QCOMPARE(flow->height(), 120.0);
- delete window;
}
void tst_qquickpositioners::test_flow_rightToLeft()
{
- QQuickView *window = createView(testFile("flowtest.qml"));
+ QScopedPointer<QQuickView> window(createView(testFile("flowtest.qml")));
window->rootObject()->setProperty("testRightToLeft", true);
@@ -1569,12 +1669,11 @@ void tst_qquickpositioners::test_flow_rightToLeft()
QCOMPARE(flow->width(), 90.0);
QCOMPARE(flow->height(), 120.0);
- delete window;
}
void tst_qquickpositioners::test_flow_topToBottom()
{
- QQuickView *window = createView(testFile("flowtest-toptobottom.qml"));
+ QScopedPointer<QQuickView> window(createView(testFile("flowtest-toptobottom.qml")));
window->rootObject()->setProperty("testRightToLeft", false);
@@ -1622,12 +1721,11 @@ void tst_qquickpositioners::test_flow_topToBottom()
QCOMPARE(five->x(), 40.0);
QCOMPARE(five->y(), 50.0);
- delete window;
}
void tst_qquickpositioners::test_flow_resize()
{
- QQuickView *window = createView(testFile("flowtest.qml"));
+ QScopedPointer<QQuickView> window(createView(testFile("flowtest.qml")));
QQuickItem *root = qobject_cast<QQuickItem*>(window->rootObject());
QVERIFY(root);
@@ -1656,12 +1754,11 @@ void tst_qquickpositioners::test_flow_resize()
QTRY_COMPARE(five->x(), 50.0);
QTRY_COMPARE(five->y(), 50.0);
- delete window;
}
void tst_qquickpositioners::test_flow_resize_rightToLeft()
{
- QQuickView *window = createView(testFile("flowtest.qml"));
+ QScopedPointer<QQuickView> window(createView(testFile("flowtest.qml")));
QQuickItem *root = qobject_cast<QQuickItem*>(window->rootObject());
QVERIFY(root);
@@ -1690,12 +1787,11 @@ void tst_qquickpositioners::test_flow_resize_rightToLeft()
QCOMPARE(five->x(), 65.0);
QCOMPARE(five->y(), 50.0);
- delete window;
}
void tst_qquickpositioners::test_flow_implicit_resize()
{
- QQuickView *window = createView(testFile("flow-testimplicitsize.qml"));
+ QScopedPointer<QQuickView> window(createView(testFile("flow-testimplicitsize.qml")));
QVERIFY(window->rootObject() != 0);
QQuickFlow *flow = window->rootObject()->findChild<QQuickFlow*>("flow");
@@ -1719,7 +1815,6 @@ void tst_qquickpositioners::test_flow_implicit_resize()
QCOMPARE(flow->width(), 220.0);
QCOMPARE(flow->height(), 50.0);
- delete window;
}
void tst_qquickpositioners::test_conflictinganchors()
@@ -1836,10 +1931,10 @@ void tst_qquickpositioners::test_mirroring()
objectNames << "one" << "two" << "three" << "four" << "five";
foreach (const QString qmlFile, qmlFiles) {
- QQuickView *windowA = createView(testFile(qmlFile));
+ QScopedPointer<QQuickView> windowA(createView(testFile(qmlFile)));
QQuickItem *rootA = qobject_cast<QQuickItem*>(windowA->rootObject());
- QQuickView *windowB = createView(testFile(qmlFile));
+ QScopedPointer<QQuickView> windowB(createView(testFile(qmlFile)));
QQuickItem *rootB = qobject_cast<QQuickItem*>(windowB->rootObject());
rootA->setProperty("testRightToLeft", true); // layoutDirection: Qt.RightToLeft
@@ -1881,15 +1976,13 @@ void tst_qquickpositioners::test_mirroring()
QQuickItem *itemB = rootB->findChild<QQuickItem*>(objectName);
QTRY_COMPARE(itemA->x(), itemB->x());
}
- delete windowA;
- delete windowB;
}
}
void tst_qquickpositioners::test_allInvisible()
{
//QTBUG-19361
- QQuickView *window = createView(testFile("allInvisible.qml"));
+ QScopedPointer<QQuickView> window(createView(testFile("allInvisible.qml")));
QQuickItem *root = qobject_cast<QQuickItem*>(window->rootObject());
QVERIFY(root);
@@ -1908,7 +2001,7 @@ void tst_qquickpositioners::test_attachedproperties()
{
QFETCH(QString, filename);
- QQuickView *window = createView(filename);
+ QScopedPointer<QQuickView> window(createView(filename));
QVERIFY(window->rootObject() != 0);
QQuickRectangle *greenRect = window->rootObject()->findChild<QQuickRectangle *>("greenRect");
@@ -1940,7 +2033,6 @@ void tst_qquickpositioners::test_attachedproperties()
isLast = yellowRect->property("isLastItem").toBool();
QVERIFY(isLast == true);
- delete window;
}
void tst_qquickpositioners::test_attachedproperties_data()
@@ -1955,7 +2047,7 @@ void tst_qquickpositioners::test_attachedproperties_data()
void tst_qquickpositioners::test_attachedproperties_dynamic()
{
- QQuickView *window = createView(testFile("attachedproperties-dynamic.qml"));
+ QScopedPointer<QQuickView> window(createView(testFile("attachedproperties-dynamic.qml")));
QVERIFY(window->rootObject() != 0);
QQuickRow *row = window->rootObject()->findChild<QQuickRow *>("pos");
@@ -2006,7 +2098,6 @@ void tst_qquickpositioners::test_attachedproperties_dynamic()
QTRY_VERIFY(rect1->property("firstItem").toBool() == false);
QTRY_VERIFY(rect1->property("lastItem").toBool() == true);
- delete window;
}
QQuickView *tst_qquickpositioners::createView(const QString &filename, bool wait)
diff --git a/tests/auto/quick/qquicktextdocument/data/text.qml b/tests/auto/quick/qquicktextdocument/data/text.qml
new file mode 100644
index 0000000000..43a8c6bb82
--- /dev/null
+++ b/tests/auto/quick/qquicktextdocument/data/text.qml
@@ -0,0 +1,6 @@
+import QtQuick 2.1
+
+TextEdit {
+ text: ""
+}
+
diff --git a/tests/auto/quick/qquicktextdocument/qquicktextdocument.pro b/tests/auto/quick/qquicktextdocument/qquicktextdocument.pro
new file mode 100644
index 0000000000..e6bfdbd099
--- /dev/null
+++ b/tests/auto/quick/qquicktextdocument/qquicktextdocument.pro
@@ -0,0 +1,15 @@
+CONFIG += testcase
+TARGET = tst_qquicktextdocument
+macx:CONFIG -= app_bundle
+
+SOURCES += tst_qquicktextdocument.cpp
+
+include (../../shared/util.pri)
+
+TESTDATA = data/*
+
+CONFIG += parallel_test
+
+QT += core-private gui-private qml-private quick-private testlib
+DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0
+
diff --git a/tests/auto/quick/qquicktextdocument/tst_qquicktextdocument.cpp b/tests/auto/quick/qquicktextdocument/tst_qquicktextdocument.cpp
new file mode 100644
index 0000000000..717496cf0e
--- /dev/null
+++ b/tests/auto/quick/qquicktextdocument/tst_qquicktextdocument.cpp
@@ -0,0 +1,87 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <qtest.h>
+#include <QtTest/QtTest>
+#include <QtQuick/QQuickTextDocument>
+#include <QtQuick/QQuickItem>
+#include <QtQuick/private/qquicktextedit_p.h>
+#include <QtGui/QTextDocument>
+#include <QtGui/QTextDocumentWriter>
+#include <QtQml/QQmlEngine>
+#include <QtQml/QQmlComponent>
+#include "../../shared/util.h"
+
+class tst_qquicktextdocument : public QQmlDataTest
+{
+ Q_OBJECT
+private slots:
+ void textDocumentWriter();
+};
+
+QString text = QStringLiteral("foo bar");
+
+void tst_qquicktextdocument::textDocumentWriter()
+{
+ QQmlEngine e;
+ QQmlComponent c(&e, testFileUrl("text.qml"));
+ QObject* o = c.create();
+ QVERIFY(o);
+ QQuickTextEdit *edit = qobject_cast<QQuickTextEdit*>(o);
+ QVERIFY(edit);
+
+ QQuickTextDocument* quickDocument = qobject_cast<QQuickTextDocument*>(edit->property("textDocument").value<QObject*>());
+ QVERIFY(quickDocument->textDocument() != 0);
+
+ QBuffer output;
+ output.open(QBuffer::ReadWrite);
+ QVERIFY(output.buffer().isEmpty());
+
+ edit->setProperty("text", QVariant(text));
+ QTextDocumentWriter writer(&output, "plaintext");
+ QVERIFY(writer.write(quickDocument->textDocument()));
+ QCOMPARE(output.buffer(), text.toLatin1());
+ delete o;
+}
+
+QTEST_MAIN(tst_qquicktextdocument)
+
+#include "tst_qquicktextdocument.moc"
diff --git a/tests/auto/quick/qquicktextedit/tst_qquicktextedit.cpp b/tests/auto/quick/qquicktextedit/tst_qquicktextedit.cpp
index bf7539e449..c29c6c05d6 100644
--- a/tests/auto/quick/qquicktextedit/tst_qquicktextedit.cpp
+++ b/tests/auto/quick/qquicktextedit/tst_qquicktextedit.cpp
@@ -2225,6 +2225,7 @@ void tst_qquicktextedit::cursorDelegate()
QQuickView view(source);
view.show();
view.requestActivate();
+ QTest::qWaitForWindowActive(&view);
QQuickTextEdit *textEditObject = view.rootObject()->findChild<QQuickTextEdit*>("textEditObject");
QVERIFY(textEditObject != 0);
// Delegate creation is deferred until focus in or cursor visibility is forced.
@@ -2340,6 +2341,7 @@ void tst_qquicktextedit::remoteCursorDelegate()
view.setSource(testFileUrl("cursorTestRemote.qml"));
view.show();
view.requestActivate();
+ QTest::qWaitForWindowActive(&view);
QQuickTextEdit *textEditObject = view.rootObject()->findChild<QQuickTextEdit*>("textEditObject");
QVERIFY(textEditObject != 0);
diff --git a/tests/auto/quick/qquicktextinput/tst_qquicktextinput.cpp b/tests/auto/quick/qquicktextinput/tst_qquicktextinput.cpp
index 86a05c3d3b..8e63b6207f 100644
--- a/tests/auto/quick/qquicktextinput/tst_qquicktextinput.cpp
+++ b/tests/auto/quick/qquicktextinput/tst_qquicktextinput.cpp
@@ -2665,6 +2665,7 @@ void tst_qquicktextinput::cursorDelegate()
QQuickView view(source);
view.show();
view.requestActivate();
+ QTest::qWaitForWindowActive(&view);
QQuickTextInput *textInputObject = view.rootObject()->findChild<QQuickTextInput*>("textInputObject");
QVERIFY(textInputObject != 0);
// Delegate is created on demand, and so won't be available immediately. Focus in or
@@ -2774,7 +2775,7 @@ void tst_qquicktextinput::cursorDelegate()
void tst_qquicktextinput::remoteCursorDelegate()
{
TestHTTPServer server(SERVER_PORT);
- server.serveDirectory(dataDirectory());
+ server.serveDirectory(dataDirectory(), TestHTTPServer::Delay);
QQuickView view;
@@ -2784,6 +2785,7 @@ void tst_qquicktextinput::remoteCursorDelegate()
view.setSource(testFileUrl("cursorTestRemote.qml"));
view.show();
view.requestActivate();
+ QTest::qWaitForWindowActive(&view);
QQuickTextInput *textInputObject = view.rootObject()->findChild<QQuickTextInput*>("textInputObject");
QVERIFY(textInputObject != 0);
diff --git a/tests/auto/quick/qquickvisualdatamodel/tst_qquickvisualdatamodel.cpp b/tests/auto/quick/qquickvisualdatamodel/tst_qquickvisualdatamodel.cpp
index 74c557871f..f97b0f35a6 100644
--- a/tests/auto/quick/qquickvisualdatamodel/tst_qquickvisualdatamodel.cpp
+++ b/tests/auto/quick/qquickvisualdatamodel/tst_qquickvisualdatamodel.cpp
@@ -52,9 +52,9 @@
#include <QtQuick/qquickview.h>
#include <private/qquicklistview_p.h>
#include <QtQuick/private/qquicktext_p.h>
-#include <QtQuick/private/qquickvisualdatamodel_p.h>
+#include <QtQml/private/qqmldelegatemodel_p.h>
#include <private/qqmlvaluetype_p.h>
-#include <private/qquickchangeset_p.h>
+#include <private/qqmlchangeset_p.h>
#include <private/qqmlengine_p.h>
#include <math.h>
#include <QtGui/qstandarditemmodel.h>
@@ -360,21 +360,21 @@ public:
int indexCreated;
public Q_SLOTS:
- void initItem(int index, QQuickItem *item)
+ void initItem(int index, QObject *item)
{
- itemInitialized = item;
+ itemInitialized = qobject_cast<QQuickItem*>(item);
indexInitialized = index;
}
- void createdItem(int index, QQuickItem *item)
+ void createdItem(int index, QObject *item)
{
- itemCreated = item;
+ itemCreated = qobject_cast<QQuickItem*>(item);
indexCreated = index;
}
- void destroyingItem(QQuickItem *item)
+ void destroyingItem(QObject *item)
{
- itemDestroyed = item;
+ itemDestroyed = qobject_cast<QQuickItem*>(item);
}
};
@@ -452,9 +452,9 @@ private:
template <int N> void get_verify(
const SingleRoleModel &model,
- QQuickVisualDataModel *visualModel,
- QQuickVisualDataGroup *visibleItems,
- QQuickVisualDataGroup *selectedItems,
+ QQmlDelegateModel *visualModel,
+ QQmlDataGroup *visibleItems,
+ QQmlDataGroup *selectedItems,
const int (&mIndex)[N],
const int (&iIndex)[N],
const int (&vIndex)[N],
@@ -467,7 +467,7 @@ private:
QQmlEngine engine;
};
-Q_DECLARE_METATYPE(QQuickChangeSet)
+Q_DECLARE_METATYPE(QQmlChangeSet)
template <typename T> static T evaluate(QObject *scope, const QString &expression)
{
@@ -489,7 +489,7 @@ template <> void evaluate<void>(QObject *scope, const QString &expression)
void tst_qquickvisualdatamodel::initTestCase()
{
QQmlDataTest::initTestCase();
- qRegisterMetaType<QQuickChangeSet>();
+ qRegisterMetaType<QQmlChangeSet>();
qmlRegisterType<SingleRoleModel>("tst_qquickvisualdatamodel", 1, 0, "SingleRoleModel");
qmlRegisterType<DataObject>("tst_qquickvisualdatamodel", 1, 0, "DataObject");
@@ -517,7 +517,7 @@ void tst_qquickvisualdatamodel::rootIndex()
engine.rootContext()->setContextProperty("myModel", &model);
- QQuickVisualDataModel *obj = qobject_cast<QQuickVisualDataModel*>(c.create());
+ QQmlDelegateModel *obj = qobject_cast<QQmlDelegateModel*>(c.create());
QVERIFY(obj != 0);
QMetaObject::invokeMethod(obj, "setRoot");
@@ -611,7 +611,7 @@ void tst_qquickvisualdatamodel::childChanged()
QQuickItem *contentItem = listview->contentItem();
QVERIFY(contentItem != 0);
- QQuickVisualDataModel *vdm = listview->findChild<QQuickVisualDataModel*>("visualModel");
+ QQmlDelegateModel *vdm = listview->findChild<QQmlDelegateModel*>("visualModel");
vdm->setRootIndex(QVariant::fromValue(model.indexFromItem(model.item(1,0))));
QCOMPARE(listview->count(), 1);
@@ -922,7 +922,7 @@ void tst_qquickvisualdatamodel::noDelegate()
QQuickListView *listview = qobject_cast<QQuickListView*>(view.rootObject());
QVERIFY(listview != 0);
- QQuickVisualDataModel *vdm = listview->findChild<QQuickVisualDataModel*>("visualModel");
+ QQmlDelegateModel *vdm = listview->findChild<QQmlDelegateModel*>("visualModel");
QVERIFY(vdm != 0);
QCOMPARE(vdm->count(), 3);
@@ -1052,15 +1052,15 @@ void tst_qquickvisualdatamodel::qaimRowsMoved()
SingleRoleModel model(list);
engine.rootContext()->setContextProperty("myModel", &model);
- QQuickVisualDataModel *obj = qobject_cast<QQuickVisualDataModel*>(c.create());
+ QQmlDelegateModel *obj = qobject_cast<QQmlDelegateModel*>(c.create());
QVERIFY(obj != 0);
- QSignalSpy spy(obj, SIGNAL(modelUpdated(QQuickChangeSet,bool)));
+ QSignalSpy spy(obj, SIGNAL(modelUpdated(QQmlChangeSet,bool)));
model.emitMove(sourceFirst, sourceLast, destinationChild);
QCOMPARE(spy.count(), 1);
QCOMPARE(spy[0].count(), 2);
- QQuickChangeSet changeSet = spy[0][0].value<QQuickChangeSet>();
+ QQmlChangeSet changeSet = spy[0][0].value<QQmlChangeSet>();
QCOMPARE(changeSet.removes().count(), 1);
QCOMPARE(changeSet.removes().at(0).index, expectFrom);
QCOMPARE(changeSet.removes().at(0).count, expectCount);
@@ -1115,11 +1115,11 @@ void tst_qquickvisualdatamodel::subtreeRowsMoved()
QQmlComponent component(&engine, testFileUrl("visualdatamodel.qml"));
QScopedPointer<QObject> object(component.create());
- QQuickVisualDataModel *vdm = qobject_cast<QQuickVisualDataModel*>(object.data());
+ QQmlDelegateModel *vdm = qobject_cast<QQmlDelegateModel*>(object.data());
QVERIFY(vdm);
- QSignalSpy spy(vdm, SIGNAL(modelUpdated(QQuickChangeSet,bool)));
- QQuickChangeSet changeSet;
+ QSignalSpy spy(vdm, SIGNAL(modelUpdated(QQmlChangeSet,bool)));
+ QQmlChangeSet changeSet;
QCOMPARE(vdm->count(), 4);
@@ -1127,7 +1127,7 @@ void tst_qquickvisualdatamodel::subtreeRowsMoved()
model.move(QModelIndex(), 1, model.index(0, 0), 3, 2);
QCOMPARE(vdm->count(), 2);
QCOMPARE(spy.count(), 1);
- changeSet = spy.last().at(0).value<QQuickChangeSet>();
+ changeSet = spy.last().at(0).value<QQmlChangeSet>();
QCOMPARE(changeSet.removes().count(), 1);
QCOMPARE(changeSet.removes().at(0).index, 1);
QCOMPARE(changeSet.removes().at(0).count, 2);
@@ -1137,7 +1137,7 @@ void tst_qquickvisualdatamodel::subtreeRowsMoved()
model.move(model.index(0, 0), 4, QModelIndex(), 2, 1);
QCOMPARE(vdm->count(), 3);
QCOMPARE(spy.count(), 2);
- changeSet = spy.last().at(0).value<QQuickChangeSet>();
+ changeSet = spy.last().at(0).value<QQmlChangeSet>();
QCOMPARE(changeSet.removes().count(), 0);
QCOMPARE(changeSet.inserts().count(), 1);
QCOMPARE(changeSet.inserts().at(0).index, 2);
@@ -1147,11 +1147,11 @@ void tst_qquickvisualdatamodel::subtreeRowsMoved()
QCOMPARE(vdm->rootIndex().value<QModelIndex>(), model.index(2, 0));
QCOMPARE(vdm->count(), 3);
QCOMPARE(spy.count(), 4);
- changeSet = spy.at(2).at(0).value<QQuickChangeSet>();
+ changeSet = spy.at(2).at(0).value<QQmlChangeSet>();
QCOMPARE(changeSet.removes().count(), 1);
QCOMPARE(changeSet.removes().at(0).index, 0);
QCOMPARE(changeSet.removes().at(0).count, 3);
- changeSet = spy.last().at(0).value<QQuickChangeSet>();
+ changeSet = spy.last().at(0).value<QQmlChangeSet>();
QCOMPARE(changeSet.inserts().count(), 1);
QCOMPARE(changeSet.inserts().at(0).index, 0);
QCOMPARE(changeSet.inserts().at(0).count, 3);
@@ -1182,7 +1182,7 @@ void tst_qquickvisualdatamodel::subtreeRowsMoved()
QCOMPARE(vdm->rootIndex().value<QModelIndex>(), QModelIndex());
QCOMPARE(vdm->count(), 0);
QCOMPARE(spy.count(), 5);
- changeSet = spy.last().at(0).value<QQuickChangeSet>();
+ changeSet = spy.last().at(0).value<QQmlChangeSet>();
QCOMPARE(changeSet.removes().count(), 1);
QCOMPARE(changeSet.removes().at(0).index, 0);
QCOMPARE(changeSet.removes().at(0).count, 3);
@@ -1192,7 +1192,7 @@ void tst_qquickvisualdatamodel::subtreeRowsMoved()
QCOMPARE(vdm->rootIndex().value<QModelIndex>(), QModelIndex());
QCOMPARE(vdm->count(), 2);
QCOMPARE(spy.count(), 6);
- changeSet = spy.last().at(0).value<QQuickChangeSet>();
+ changeSet = spy.last().at(0).value<QQmlChangeSet>();
QCOMPARE(changeSet.removes().count(), 0);
QCOMPARE(changeSet.inserts().count(), 1);
QCOMPARE(changeSet.inserts().at(0).index, 0);
@@ -1211,17 +1211,17 @@ void tst_qquickvisualdatamodel::watchedRoles()
QQmlComponent component(&engine, testFileUrl("visualdatamodel.qml"));
QScopedPointer<QObject> object(component.create());
- QQuickVisualDataModel *vdm = qobject_cast<QQuickVisualDataModel*>(object.data());
+ QQmlDelegateModel *vdm = qobject_cast<QQmlDelegateModel*>(object.data());
QVERIFY(vdm);
// VisualDataModel doesn't initialize model data until the first item is requested.
- QQuickItem *item = vdm->item(0);
+ QQuickItem *item = qobject_cast<QQuickItem*>(vdm->object(0));
QVERIFY(item);
vdm->release(item);
QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete); // Ensure released items are deleted before test exits.
- QSignalSpy spy(vdm, SIGNAL(modelUpdated(QQuickChangeSet,bool)));
- QQuickChangeSet changeSet;
+ QSignalSpy spy(vdm, SIGNAL(modelUpdated(QQmlChangeSet,bool)));
+ QQmlChangeSet changeSet;
QCOMPARE(vdm->count(), 30);
@@ -1238,13 +1238,13 @@ void tst_qquickvisualdatamodel::watchedRoles()
emit model.dataChanged(model.index(0), model.index(4));
QCOMPARE(spy.count(), 1);
- changeSet = spy.last().at(0).value<QQuickChangeSet>();
+ changeSet = spy.last().at(0).value<QQmlChangeSet>();
QCOMPARE(changeSet.changes().at(0).index, 0);
QCOMPARE(changeSet.changes().at(0).count, 5);
emit model.dataChanged(model.index(1), model.index(6), QVector<int>() << QaimModel::Name);
QCOMPARE(spy.count(), 2);
- changeSet = spy.last().at(0).value<QQuickChangeSet>();
+ changeSet = spy.last().at(0).value<QQmlChangeSet>();
QCOMPARE(changeSet.changes().at(0).index, 1);
QCOMPARE(changeSet.changes().at(0).count, 6);
@@ -1255,7 +1255,7 @@ void tst_qquickvisualdatamodel::watchedRoles()
emit model.dataChanged(model.index(0), model.index(4));
QCOMPARE(spy.count(), 3);
- changeSet = spy.last().at(0).value<QQuickChangeSet>();
+ changeSet = spy.last().at(0).value<QQmlChangeSet>();
QCOMPARE(changeSet.changes().at(0).index, 0);
QCOMPARE(changeSet.changes().at(0).count, 5);
@@ -1264,7 +1264,7 @@ void tst_qquickvisualdatamodel::watchedRoles()
emit model.dataChanged(model.index(8), model.index(8), QVector<int>() << QaimModel::Number);
QCOMPARE(spy.count(), 4);
- changeSet = spy.last().at(0).value<QQuickChangeSet>();
+ changeSet = spy.last().at(0).value<QQmlChangeSet>();
QCOMPARE(changeSet.changes().at(0).index, 8);
QCOMPARE(changeSet.changes().at(0).count, 1);
@@ -1272,19 +1272,19 @@ void tst_qquickvisualdatamodel::watchedRoles()
emit model.dataChanged(model.index(0), model.index(4));
QCOMPARE(spy.count(), 5);
- changeSet = spy.last().at(0).value<QQuickChangeSet>();
+ changeSet = spy.last().at(0).value<QQmlChangeSet>();
QCOMPARE(changeSet.changes().at(0).index, 0);
QCOMPARE(changeSet.changes().at(0).count, 5);
emit model.dataChanged(model.index(1), model.index(6), QVector<int>() << QaimModel::Name);
QCOMPARE(spy.count(), 6);
- changeSet = spy.last().at(0).value<QQuickChangeSet>();
+ changeSet = spy.last().at(0).value<QQmlChangeSet>();
QCOMPARE(changeSet.changes().at(0).index, 1);
QCOMPARE(changeSet.changes().at(0).count, 6);
emit model.dataChanged(model.index(8), model.index(8), QVector<int>() << QaimModel::Number);
QCOMPARE(spy.count(), 7);
- changeSet = spy.last().at(0).value<QQuickChangeSet>();
+ changeSet = spy.last().at(0).value<QQmlChangeSet>();
QCOMPARE(changeSet.changes().at(0).index, 8);
QCOMPARE(changeSet.changes().at(0).count, 1);
}
@@ -1301,29 +1301,29 @@ void tst_qquickvisualdatamodel::hasModelChildren()
QQmlComponent component(&engine, testFileUrl("visualdatamodel.qml"));
QScopedPointer<QObject> object(component.create());
- QQuickVisualDataModel *vdm = qobject_cast<QQuickVisualDataModel*>(object.data());
+ QQmlDelegateModel *vdm = qobject_cast<QQmlDelegateModel*>(object.data());
QVERIFY(vdm);
QCOMPARE(vdm->count(), 4);
QQuickItem *item = 0;
- item = vdm->item(0);
+ item = qobject_cast<QQuickItem*>(vdm->object(0));
QVERIFY(item);
QCOMPARE(item->property("modelChildren").toBool(), true);
vdm->release(item);
- item = vdm->item(1);
+ item = qobject_cast<QQuickItem*>(vdm->object(1));
QVERIFY(item);
QCOMPARE(item->property("modelChildren").toBool(), false);
vdm->release(item);
- item = vdm->item(2);
+ item = qobject_cast<QQuickItem*>(vdm->object(2));
QVERIFY(item);
QCOMPARE(item->property("modelChildren").toBool(), true);
vdm->release(item);
- item = vdm->item(3);
+ item = qobject_cast<QQuickItem*>(vdm->object(3));
QVERIFY(item);
QCOMPARE(item->property("modelChildren").toBool(), false);
vdm->release(item);
@@ -1351,14 +1351,14 @@ void tst_qquickvisualdatamodel::setValue()
QQmlComponent component(&engine, testFileUrl("visualdatamodel.qml"));
QScopedPointer<QObject> object(component.create());
- QQuickVisualDataModel *vdm = qobject_cast<QQuickVisualDataModel*>(object.data());
+ QQmlDelegateModel *vdm = qobject_cast<QQmlDelegateModel*>(object.data());
QVERIFY(vdm);
QCOMPARE(vdm->count(), 3);
QQuickItem *item = 0;
- item = vdm->item(0);
+ item = qobject_cast<QQuickItem*>(vdm->object(0));
QVERIFY(item);
QCOMPARE(evaluate<QString>(item, "display"), QString("Row 1 Item"));
evaluate<void>(item, "display = 'Changed Item 1'");
@@ -1412,7 +1412,7 @@ void tst_qquickvisualdatamodel::remove()
QQuickItem *contentItem = listview->contentItem();
QVERIFY(contentItem != 0);
- QQuickVisualDataModel *visualModel = qobject_cast<QQuickVisualDataModel *>(qvariant_cast<QObject *>(listview->model()));
+ QQmlDelegateModel *visualModel = qobject_cast<QQmlDelegateModel *>(qvariant_cast<QObject *>(listview->model()));
QVERIFY(visualModel);
{
@@ -1521,7 +1521,7 @@ void tst_qquickvisualdatamodel::move()
QQuickItem *contentItem = listview->contentItem();
QVERIFY(contentItem != 0);
- QQuickVisualDataModel *visualModel = qobject_cast<QQuickVisualDataModel *>(qvariant_cast<QObject *>(listview->model()));
+ QQmlDelegateModel *visualModel = qobject_cast<QQmlDelegateModel *>(qvariant_cast<QObject *>(listview->model()));
QVERIFY(visualModel);
{
@@ -1710,13 +1710,13 @@ void tst_qquickvisualdatamodel::groups()
QQuickItem *contentItem = listview->contentItem();
QVERIFY(contentItem != 0);
- QQuickVisualDataModel *visualModel = listview->findChild<QQuickVisualDataModel *>("visualModel");
+ QQmlDelegateModel *visualModel = listview->findChild<QQmlDelegateModel *>("visualModel");
QVERIFY(visualModel);
- QQuickVisualDataGroup *visibleItems = listview->findChild<QQuickVisualDataGroup *>("visibleItems");
+ QQmlDataGroup *visibleItems = listview->findChild<QQmlDataGroup *>("visibleItems");
QVERIFY(visibleItems);
- QQuickVisualDataGroup *selectedItems = listview->findChild<QQuickVisualDataGroup *>("selectedItems");
+ QQmlDataGroup *selectedItems = listview->findChild<QQmlDataGroup *>("selectedItems");
QVERIFY(selectedItems);
const bool f = false;
@@ -1939,9 +1939,9 @@ void tst_qquickvisualdatamodel::groups()
template <int N> void tst_qquickvisualdatamodel::get_verify(
const SingleRoleModel &model,
- QQuickVisualDataModel *visualModel,
- QQuickVisualDataGroup *visibleItems,
- QQuickVisualDataGroup *selectedItems,
+ QQmlDelegateModel *visualModel,
+ QQmlDataGroup *visibleItems,
+ QQmlDataGroup *selectedItems,
const int (&mIndex)[N],
const int (&iIndex)[N],
const int (&vIndex)[N],
@@ -2030,13 +2030,13 @@ void tst_qquickvisualdatamodel::get()
QQuickItem *contentItem = listview->contentItem();
QVERIFY(contentItem != 0);
- QQuickVisualDataModel *visualModel = qobject_cast<QQuickVisualDataModel *>(qvariant_cast<QObject *>(listview->model()));
+ QQmlDelegateModel *visualModel = qobject_cast<QQmlDelegateModel *>(qvariant_cast<QObject *>(listview->model()));
QVERIFY(visualModel);
- QQuickVisualDataGroup *visibleItems = visualModel->findChild<QQuickVisualDataGroup *>("visibleItems");
+ QQmlDataGroup *visibleItems = visualModel->findChild<QQmlDataGroup *>("visibleItems");
QVERIFY(visibleItems);
- QQuickVisualDataGroup *selectedItems = visualModel->findChild<QQuickVisualDataGroup *>("selectedItems");
+ QQmlDataGroup *selectedItems = visualModel->findChild<QQmlDataGroup *>("selectedItems");
QVERIFY(selectedItems);
QV8Engine *v8Engine = QQmlEnginePrivate::getV8Engine(ctxt->engine());
@@ -2154,7 +2154,7 @@ void tst_qquickvisualdatamodel::get()
void tst_qquickvisualdatamodel::invalidGroups()
{
QUrl source = testFileUrl("groups-invalid.qml");
- QTest::ignoreMessage(QtWarningMsg, (source.toString() + ":12:9: QML VisualDataGroup: " + QQuickVisualDataGroup::tr("Group names must start with a lower case letter")).toUtf8());
+ QTest::ignoreMessage(QtWarningMsg, (source.toString() + ":12:9: QML VisualDataGroup: " + QQmlDataGroup::tr("Group names must start with a lower case letter")).toUtf8());
QQmlComponent component(&engine, source);
QScopedPointer<QObject> object(component.create());
@@ -2326,7 +2326,7 @@ void tst_qquickvisualdatamodel::create()
QQuickItem *contentItem = listview->contentItem();
QVERIFY(contentItem != 0);
- QQuickVisualDataModel *visualModel = qobject_cast<QQuickVisualDataModel *>(qvariant_cast<QObject *>(listview->model()));
+ QQmlDelegateModel *visualModel = qobject_cast<QQmlDelegateModel *>(qvariant_cast<QObject *>(listview->model()));
QVERIFY(visualModel);
QCOMPARE(listview->count(), 20);
@@ -2440,7 +2440,7 @@ void tst_qquickvisualdatamodel::incompleteModel()
QScopedPointer<QObject> object(component.beginCreate(engine.rootContext()));
- QQuickVisualDataModel *model = qobject_cast<QQuickVisualDataModel *>(object.data());
+ QQmlDelegateModel *model = qobject_cast<QQmlDelegateModel *>(object.data());
QVERIFY(model);
QSignalSpy itemsSpy(model->items(), SIGNAL(countChanged()));
@@ -3665,67 +3665,67 @@ void tst_qquickvisualdatamodel::warnings_data()
QTest::newRow("insert < 0")
<< testFileUrl("listmodelproperties.qml")
<< QString("items.insert(-2, {\"number\": \"eight\"})")
- << ("<Unknown File>: QML VisualDataGroup: " + QQuickVisualDataGroup::tr("insert: index out of range"))
+ << ("<Unknown File>: QML VisualDataGroup: " + QQmlDataGroup::tr("insert: index out of range"))
<< 4;
QTest::newRow("insert > length")
<< testFileUrl("listmodelproperties.qml")
<< QString("items.insert(8, {\"number\": \"eight\"})")
- << ("<Unknown File>: QML VisualDataGroup: " + QQuickVisualDataGroup::tr("insert: index out of range"))
+ << ("<Unknown File>: QML VisualDataGroup: " + QQmlDataGroup::tr("insert: index out of range"))
<< 4;
QTest::newRow("create < 0")
<< testFileUrl("listmodelproperties.qml")
<< QString("items.create(-2, {\"number\": \"eight\"})")
- << ("<Unknown File>: QML VisualDataGroup: " + QQuickVisualDataGroup::tr("create: index out of range"))
+ << ("<Unknown File>: QML VisualDataGroup: " + QQmlDataGroup::tr("create: index out of range"))
<< 4;
QTest::newRow("create > length")
<< testFileUrl("listmodelproperties.qml")
<< QString("items.create(8, {\"number\": \"eight\"})")
- << ("<Unknown File>: QML VisualDataGroup: " + QQuickVisualDataGroup::tr("create: index out of range"))
+ << ("<Unknown File>: QML VisualDataGroup: " + QQmlDataGroup::tr("create: index out of range"))
<< 4;
QTest::newRow("resolve from < 0")
<< testFileUrl("listmodelproperties.qml")
<< QString("items.resolve(-2, 3)")
- << ("<Unknown File>: QML VisualDataGroup: " + QQuickVisualDataGroup::tr("resolve: from index out of range"))
+ << ("<Unknown File>: QML VisualDataGroup: " + QQmlDataGroup::tr("resolve: from index out of range"))
<< 4;
QTest::newRow("resolve from > length")
<< testFileUrl("listmodelproperties.qml")
<< QString("items.resolve(8, 3)")
- << ("<Unknown File>: QML VisualDataGroup: " + QQuickVisualDataGroup::tr("resolve: from index out of range"))
+ << ("<Unknown File>: QML VisualDataGroup: " + QQmlDataGroup::tr("resolve: from index out of range"))
<< 4;
QTest::newRow("resolve to < 0")
<< testFileUrl("listmodelproperties.qml")
<< QString("items.resolve(3, -2)")
- << ("<Unknown File>: QML VisualDataGroup: " + QQuickVisualDataGroup::tr("resolve: to index out of range"))
+ << ("<Unknown File>: QML VisualDataGroup: " + QQmlDataGroup::tr("resolve: to index out of range"))
<< 4;
QTest::newRow("resolve to > length")
<< testFileUrl("listmodelproperties.qml")
<< QString("items.resolve(3, 8)")
- << ("<Unknown File>: QML VisualDataGroup: " + QQuickVisualDataGroup::tr("resolve: to index out of range"))
+ << ("<Unknown File>: QML VisualDataGroup: " + QQmlDataGroup::tr("resolve: to index out of range"))
<< 4;
QTest::newRow("resolve from invalid index")
<< testFileUrl("listmodelproperties.qml")
<< QString("items.resolve(\"two\", 3)")
- << ("<Unknown File>: QML VisualDataGroup: " + QQuickVisualDataGroup::tr("resolve: from index invalid"))
+ << ("<Unknown File>: QML VisualDataGroup: " + QQmlDataGroup::tr("resolve: from index invalid"))
<< 4;
QTest::newRow("resolve to invalid index")
<< testFileUrl("listmodelproperties.qml")
<< QString("items.resolve(3, \"two\")")
- << ("<Unknown File>: QML VisualDataGroup: " + QQuickVisualDataGroup::tr("resolve: to index invalid"))
+ << ("<Unknown File>: QML VisualDataGroup: " + QQmlDataGroup::tr("resolve: to index invalid"))
<< 4;
QTest::newRow("resolve already resolved item")
<< testFileUrl("listmodelproperties.qml")
<< QString("items.resolve(3, 2)")
- << ("<Unknown File>: QML VisualDataGroup: " + QQuickVisualDataGroup::tr("resolve: from is not an unresolved item"))
+ << ("<Unknown File>: QML VisualDataGroup: " + QQmlDataGroup::tr("resolve: from is not an unresolved item"))
<< 4;
QTest::newRow("resolve already resolved item")
@@ -3733,193 +3733,193 @@ void tst_qquickvisualdatamodel::warnings_data()
<< QString("{ items.insert(0, {\"number\": \"eight\"});"
"items.insert(1, {\"number\": \"seven\"});"
"items.resolve(0, 1)}")
- << ("<Unknown File>: QML VisualDataGroup: " + QQuickVisualDataGroup::tr("resolve: to is not a model item"))
+ << ("<Unknown File>: QML VisualDataGroup: " + QQmlDataGroup::tr("resolve: to is not a model item"))
<< 6;
QTest::newRow("remove index < 0")
<< testFileUrl("listmodelproperties.qml")
<< QString("items.remove(-2, 1)")
- << ("<Unknown File>: QML VisualDataGroup: " + QQuickVisualDataGroup::tr("remove: index out of range"))
+ << ("<Unknown File>: QML VisualDataGroup: " + QQmlDataGroup::tr("remove: index out of range"))
<< 4;
QTest::newRow("remove index == length")
<< testFileUrl("listmodelproperties.qml")
<< QString("items.remove(4, 1)")
- << ("<Unknown File>: QML VisualDataGroup: " + QQuickVisualDataGroup::tr("remove: index out of range"))
+ << ("<Unknown File>: QML VisualDataGroup: " + QQmlDataGroup::tr("remove: index out of range"))
<< 4;
QTest::newRow("remove index > length")
<< testFileUrl("listmodelproperties.qml")
<< QString("items.remove(9, 1)")
- << ("<Unknown File>: QML VisualDataGroup: " + QQuickVisualDataGroup::tr("remove: index out of range"))
+ << ("<Unknown File>: QML VisualDataGroup: " + QQmlDataGroup::tr("remove: index out of range"))
<< 4;
QTest::newRow("remove invalid index")
<< testFileUrl("listmodelproperties.qml")
<< QString("items.remove(\"nine\", 1)")
- << ("<Unknown File>: QML VisualDataGroup: " + QQuickVisualDataGroup::tr("remove: invalid index"))
+ << ("<Unknown File>: QML VisualDataGroup: " + QQmlDataGroup::tr("remove: invalid index"))
<< 4;
QTest::newRow("remove count < 0")
<< testFileUrl("listmodelproperties.qml")
<< QString("items.remove(1, -2)")
- << ("<Unknown File>: QML VisualDataGroup: " + QQuickVisualDataGroup::tr("remove: invalid count"))
+ << ("<Unknown File>: QML VisualDataGroup: " + QQmlDataGroup::tr("remove: invalid count"))
<< 4;
QTest::newRow("remove index + count > length")
<< testFileUrl("listmodelproperties.qml")
<< QString("items.remove(2, 4, \"selected\")")
- << ("<Unknown File>: QML VisualDataGroup: " + QQuickVisualDataGroup::tr("remove: invalid count"))
+ << ("<Unknown File>: QML VisualDataGroup: " + QQmlDataGroup::tr("remove: invalid count"))
<< 4;
QTest::newRow("addGroups index < 0")
<< testFileUrl("listmodelproperties.qml")
<< QString("items.addGroups(-2, 1, \"selected\")")
- << ("<Unknown File>: QML VisualDataGroup: " + QQuickVisualDataGroup::tr("addGroups: index out of range"))
+ << ("<Unknown File>: QML VisualDataGroup: " + QQmlDataGroup::tr("addGroups: index out of range"))
<< 4;
QTest::newRow("addGroups index == length")
<< testFileUrl("listmodelproperties.qml")
<< QString("items.addGroups(4, 1, \"selected\")")
- << ("<Unknown File>: QML VisualDataGroup: " + QQuickVisualDataGroup::tr("addGroups: index out of range"))
+ << ("<Unknown File>: QML VisualDataGroup: " + QQmlDataGroup::tr("addGroups: index out of range"))
<< 4;
QTest::newRow("addGroups index > length")
<< testFileUrl("listmodelproperties.qml")
<< QString("items.addGroups(9, 1, \"selected\")")
- << ("<Unknown File>: QML VisualDataGroup: " + QQuickVisualDataGroup::tr("addGroups: index out of range"))
+ << ("<Unknown File>: QML VisualDataGroup: " + QQmlDataGroup::tr("addGroups: index out of range"))
<< 4;
QTest::newRow("addGroups count < 0")
<< testFileUrl("listmodelproperties.qml")
<< QString("items.addGroups(1, -2, \"selected\")")
- << ("<Unknown File>: QML VisualDataGroup: " + QQuickVisualDataGroup::tr("addGroups: invalid count"))
+ << ("<Unknown File>: QML VisualDataGroup: " + QQmlDataGroup::tr("addGroups: invalid count"))
<< 4;
QTest::newRow("addGroups index + count > length")
<< testFileUrl("listmodelproperties.qml")
<< QString("items.addGroups(2, 4, \"selected\")")
- << ("<Unknown File>: QML VisualDataGroup: " + QQuickVisualDataGroup::tr("addGroups: invalid count"))
+ << ("<Unknown File>: QML VisualDataGroup: " + QQmlDataGroup::tr("addGroups: invalid count"))
<< 4;
QTest::newRow("removeGroups index < 0")
<< testFileUrl("listmodelproperties.qml")
<< QString("items.removeGroups(-2, 1, \"selected\")")
- << ("<Unknown File>: QML VisualDataGroup: " + QQuickVisualDataGroup::tr("removeGroups: index out of range"))
+ << ("<Unknown File>: QML VisualDataGroup: " + QQmlDataGroup::tr("removeGroups: index out of range"))
<< 4;
QTest::newRow("removeGroups index == length")
<< testFileUrl("listmodelproperties.qml")
<< QString("items.removeGroups(4, 1, \"selected\")")
- << ("<Unknown File>: QML VisualDataGroup: " + QQuickVisualDataGroup::tr("removeGroups: index out of range"))
+ << ("<Unknown File>: QML VisualDataGroup: " + QQmlDataGroup::tr("removeGroups: index out of range"))
<< 4;
QTest::newRow("removeGroups index > length")
<< testFileUrl("listmodelproperties.qml")
<< QString("items.removeGroups(9, 1, \"selected\")")
- << ("<Unknown File>: QML VisualDataGroup: " + QQuickVisualDataGroup::tr("removeGroups: index out of range"))
+ << ("<Unknown File>: QML VisualDataGroup: " + QQmlDataGroup::tr("removeGroups: index out of range"))
<< 4;
QTest::newRow("removeGroups count < 0")
<< testFileUrl("listmodelproperties.qml")
<< QString("items.removeGroups(1, -2, \"selected\")")
- << ("<Unknown File>: QML VisualDataGroup: " + QQuickVisualDataGroup::tr("removeGroups: invalid count"))
+ << ("<Unknown File>: QML VisualDataGroup: " + QQmlDataGroup::tr("removeGroups: invalid count"))
<< 4;
QTest::newRow("removeGroups index + count > length")
<< testFileUrl("listmodelproperties.qml")
<< QString("items.removeGroups(2, 4, \"selected\")")
- << ("<Unknown File>: QML VisualDataGroup: " + QQuickVisualDataGroup::tr("removeGroups: invalid count"))
+ << ("<Unknown File>: QML VisualDataGroup: " + QQmlDataGroup::tr("removeGroups: invalid count"))
<< 4;
QTest::newRow("setGroups index < 0")
<< testFileUrl("listmodelproperties.qml")
<< QString("items.setGroups(-2, 1, \"selected\")")
- << ("<Unknown File>: QML VisualDataGroup: " + QQuickVisualDataGroup::tr("setGroups: index out of range"))
+ << ("<Unknown File>: QML VisualDataGroup: " + QQmlDataGroup::tr("setGroups: index out of range"))
<< 4;
QTest::newRow("setGroups index == length")
<< testFileUrl("listmodelproperties.qml")
<< QString("items.setGroups(4, 1, \"selected\")")
- << ("<Unknown File>: QML VisualDataGroup: " + QQuickVisualDataGroup::tr("setGroups: index out of range"))
+ << ("<Unknown File>: QML VisualDataGroup: " + QQmlDataGroup::tr("setGroups: index out of range"))
<< 4;
QTest::newRow("setGroups index > length")
<< testFileUrl("listmodelproperties.qml")
<< QString("items.setGroups(9, 1, \"selected\")")
- << ("<Unknown File>: QML VisualDataGroup: " + QQuickVisualDataGroup::tr("setGroups: index out of range"))
+ << ("<Unknown File>: QML VisualDataGroup: " + QQmlDataGroup::tr("setGroups: index out of range"))
<< 4;
QTest::newRow("setGroups count < 0")
<< testFileUrl("listmodelproperties.qml")
<< QString("items.setGroups(1, -2, \"selected\")")
- << ("<Unknown File>: QML VisualDataGroup: " + QQuickVisualDataGroup::tr("setGroups: invalid count"))
+ << ("<Unknown File>: QML VisualDataGroup: " + QQmlDataGroup::tr("setGroups: invalid count"))
<< 4;
QTest::newRow("setGroups index + count > length")
<< testFileUrl("listmodelproperties.qml")
<< QString("items.setGroups(2, 4, \"selected\")")
- << ("<Unknown File>: QML VisualDataGroup: " + QQuickVisualDataGroup::tr("setGroups: invalid count"))
+ << ("<Unknown File>: QML VisualDataGroup: " + QQmlDataGroup::tr("setGroups: invalid count"))
<< 4;
QTest::newRow("move from < 0")
<< testFileUrl("listmodelproperties.qml")
<< QString("items.move(-2, 1, 1)")
- << ("<Unknown File>: QML VisualDataGroup: " + QQuickVisualDataGroup::tr("move: from index out of range"))
+ << ("<Unknown File>: QML VisualDataGroup: " + QQmlDataGroup::tr("move: from index out of range"))
<< 4;
QTest::newRow("move from == length")
<< testFileUrl("listmodelproperties.qml")
<< QString("items.move(4, 1, 1)")
- << ("<Unknown File>: QML VisualDataGroup: " + QQuickVisualDataGroup::tr("move: from index out of range"))
+ << ("<Unknown File>: QML VisualDataGroup: " + QQmlDataGroup::tr("move: from index out of range"))
<< 4;
QTest::newRow("move from > length")
<< testFileUrl("listmodelproperties.qml")
<< QString("items.move(9, 1, 1)")
- << ("<Unknown File>: QML VisualDataGroup: " + QQuickVisualDataGroup::tr("move: from index out of range"))
+ << ("<Unknown File>: QML VisualDataGroup: " + QQmlDataGroup::tr("move: from index out of range"))
<< 4;
QTest::newRow("move invalid from")
<< testFileUrl("listmodelproperties.qml")
<< QString("items.move(\"nine\", 1, 1)")
- << ("<Unknown File>: QML VisualDataGroup: " + QQuickVisualDataGroup::tr("move: invalid from index"))
+ << ("<Unknown File>: QML VisualDataGroup: " + QQmlDataGroup::tr("move: invalid from index"))
<< 4;
QTest::newRow("move to < 0")
<< testFileUrl("listmodelproperties.qml")
<< QString("items.move(1, -2, 1)")
- << ("<Unknown File>: QML VisualDataGroup: " + QQuickVisualDataGroup::tr("move: to index out of range"))
+ << ("<Unknown File>: QML VisualDataGroup: " + QQmlDataGroup::tr("move: to index out of range"))
<< 4;
QTest::newRow("move to == length")
<< testFileUrl("listmodelproperties.qml")
<< QString("items.move(1, 4, 1)")
- << ("<Unknown File>: QML VisualDataGroup: " + QQuickVisualDataGroup::tr("move: to index out of range"))
+ << ("<Unknown File>: QML VisualDataGroup: " + QQmlDataGroup::tr("move: to index out of range"))
<< 4;
QTest::newRow("move to > length")
<< testFileUrl("listmodelproperties.qml")
<< QString("items.move(1, 9, 1)")
- << ("<Unknown File>: QML VisualDataGroup: " + QQuickVisualDataGroup::tr("move: to index out of range"))
+ << ("<Unknown File>: QML VisualDataGroup: " + QQmlDataGroup::tr("move: to index out of range"))
<< 4;
QTest::newRow("move invalid to")
<< testFileUrl("listmodelproperties.qml")
<< QString("items.move(1, \"nine\", 1)")
- << ("<Unknown File>: QML VisualDataGroup: " + QQuickVisualDataGroup::tr("move: invalid to index"))
+ << ("<Unknown File>: QML VisualDataGroup: " + QQmlDataGroup::tr("move: invalid to index"))
<< 4;
QTest::newRow("move count < 0")
<< testFileUrl("listmodelproperties.qml")
<< QString("items.move(1, 1, -2)")
- << ("<Unknown File>: QML VisualDataGroup: " + QQuickVisualDataGroup::tr("move: invalid count"))
+ << ("<Unknown File>: QML VisualDataGroup: " + QQmlDataGroup::tr("move: invalid count"))
<< 4;
QTest::newRow("move from + count > length")
<< testFileUrl("listmodelproperties.qml")
<< QString("items.move(2, 1, 4)")
- << ("<Unknown File>: QML VisualDataGroup: " + QQuickVisualDataGroup::tr("move: from index out of range"))
+ << ("<Unknown File>: QML VisualDataGroup: " + QQmlDataGroup::tr("move: from index out of range"))
<< 4;
}
@@ -3961,19 +3961,19 @@ void tst_qquickvisualdatamodel::invalidAttachment()
QCOMPARE(component.errors().count(), 0);
QVariant property = object->property("invalidVdm");
- QCOMPARE(property.userType(), qMetaTypeId<QQuickVisualDataModel *>());
- QVERIFY(!property.value<QQuickVisualDataModel *>());
+ QCOMPARE(property.userType(), qMetaTypeId<QQmlDelegateModel *>());
+ QVERIFY(!property.value<QQmlDelegateModel *>());
QQuickItem *item = findItem<QQuickItem>(static_cast<QQuickItem *>(object.data()), "delegate");
QVERIFY(item);
property = item->property("validVdm");
- QCOMPARE(property.userType(), qMetaTypeId<QQuickVisualDataModel *>());
- QVERIFY(property.value<QQuickVisualDataModel *>());
+ QCOMPARE(property.userType(), qMetaTypeId<QQmlDelegateModel *>());
+ QVERIFY(property.value<QQmlDelegateModel *>());
property = item->property("invalidVdm");
- QCOMPARE(property.userType(), qMetaTypeId<QQuickVisualDataModel *>());
- QVERIFY(!property.value<QQuickVisualDataModel *>());
+ QCOMPARE(property.userType(), qMetaTypeId<QQmlDelegateModel *>());
+ QVERIFY(!property.value<QQmlDelegateModel *>());
}
void tst_qquickvisualdatamodel::asynchronousInsert_data()
@@ -4005,15 +4005,15 @@ void tst_qquickvisualdatamodel::asynchronousInsert()
engine.rootContext()->setContextProperty("myModel", &model);
- QQuickVisualDataModel *visualModel = qobject_cast<QQuickVisualDataModel*>(c.create());
+ QQmlDelegateModel *visualModel = qobject_cast<QQmlDelegateModel*>(c.create());
QVERIFY(visualModel);
ItemRequester requester;
- connect(visualModel, SIGNAL(initItem(int,QQuickItem*)), &requester, SLOT(initItem(int,QQuickItem*)));
- connect(visualModel, SIGNAL(createdItem(int,QQuickItem*)), &requester, SLOT(createdItem(int,QQuickItem*)));
- connect(visualModel, SIGNAL(destroyingItem(QQuickItem*)), &requester, SLOT(destroyingItem(QQuickItem*)));
+ connect(visualModel, SIGNAL(initItem(int,QObject*)), &requester, SLOT(initItem(int,QObject*)));
+ connect(visualModel, SIGNAL(createdItem(int,QObject*)), &requester, SLOT(createdItem(int,QObject*)));
+ connect(visualModel, SIGNAL(destroyingItem(QObject*)), &requester, SLOT(destroyingItem(QObject*)));
- QQuickItem *item = visualModel->item(requestIndex, true);
+ QQuickItem *item = qobject_cast<QQuickItem*>(visualModel->object(requestIndex, true));
QVERIFY(!item);
QVERIFY(!requester.itemInitialized);
@@ -4025,7 +4025,7 @@ void tst_qquickvisualdatamodel::asynchronousInsert()
newItems.append(qMakePair(QLatin1String("New item") + QString::number(i), QString(QLatin1String(""))));
model.insertItems(insertIndex, newItems);
- item = visualModel->item(completeIndex, false);
+ item = qobject_cast<QQuickItem*>(visualModel->object(completeIndex, false));
QVERIFY(item);
QCOMPARE(requester.itemInitialized, item);
@@ -4070,15 +4070,15 @@ void tst_qquickvisualdatamodel::asynchronousRemove()
engine.rootContext()->setContextProperty("myModel", &model);
- QQuickVisualDataModel *visualModel = qobject_cast<QQuickVisualDataModel*>(c.create());
+ QQmlDelegateModel *visualModel = qobject_cast<QQmlDelegateModel*>(c.create());
QVERIFY(visualModel);
ItemRequester requester;
- connect(visualModel, SIGNAL(initItem(int,QQuickItem*)), &requester, SLOT(initItem(int,QQuickItem*)));
- connect(visualModel, SIGNAL(createdItem(int,QQuickItem*)), &requester, SLOT(createdItem(int,QQuickItem*)));
- connect(visualModel, SIGNAL(destroyingItem(QQuickItem*)), &requester, SLOT(destroyingItem(QQuickItem*)));
+ connect(visualModel, SIGNAL(initItem(int,QObject*)), &requester, SLOT(initItem(int,QObject*)));
+ connect(visualModel, SIGNAL(createdItem(int,QObject*)), &requester, SLOT(createdItem(int,QObject*)));
+ connect(visualModel, SIGNAL(destroyingItem(QObject*)), &requester, SLOT(destroyingItem(QObject*)));
- QQuickItem *item = visualModel->item(requestIndex, true);
+ QQuickItem *item = qobject_cast<QQuickItem*>(visualModel->object(requestIndex, true));
QVERIFY(!item);
QVERIFY(!requester.itemInitialized);
@@ -4098,7 +4098,7 @@ void tst_qquickvisualdatamodel::asynchronousRemove()
QCOMPARE(requester.itemCreated, requester.itemInitialized);
QCOMPARE(requester.itemDestroyed, requester.itemInitialized);
} else {
- item = visualModel->item(completeIndex, false);
+ item = qobject_cast<QQuickItem*>(visualModel->object(completeIndex, false));
QVERIFY(item);
QCOMPARE(requester.itemInitialized, item);
@@ -4148,15 +4148,15 @@ void tst_qquickvisualdatamodel::asynchronousMove()
engine.rootContext()->setContextProperty("myModel", &model);
- QQuickVisualDataModel *visualModel = qobject_cast<QQuickVisualDataModel*>(c.create());
+ QQmlDelegateModel *visualModel = qobject_cast<QQmlDelegateModel*>(c.create());
QVERIFY(visualModel);
ItemRequester requester;
- connect(visualModel, SIGNAL(initItem(int,QQuickItem*)), &requester, SLOT(initItem(int,QQuickItem*)));
- connect(visualModel, SIGNAL(createdItem(int,QQuickItem*)), &requester, SLOT(createdItem(int,QQuickItem*)));
- connect(visualModel, SIGNAL(destroyingItem(QQuickItem*)), &requester, SLOT(destroyingItem(QQuickItem*)));
+ connect(visualModel, SIGNAL(initItem(int,QObject*)), &requester, SLOT(initItem(int,QObject*)));
+ connect(visualModel, SIGNAL(createdItem(int,QObject*)), &requester, SLOT(createdItem(int,QObject*)));
+ connect(visualModel, SIGNAL(destroyingItem(QObject*)), &requester, SLOT(destroyingItem(QObject*)));
- QQuickItem *item = visualModel->item(requestIndex, true);
+ QQuickItem *item = qobject_cast<QQuickItem*>(visualModel->object(requestIndex, true));
QVERIFY(!item);
QVERIFY(!requester.itemInitialized);
@@ -4165,7 +4165,7 @@ void tst_qquickvisualdatamodel::asynchronousMove()
model.moveItems(from, to, count);
- item = visualModel->item(completeIndex, false);
+ item = qobject_cast<QQuickItem*>(visualModel->object(completeIndex, false));
QVERIFY(item);
@@ -4196,10 +4196,10 @@ void tst_qquickvisualdatamodel::asynchronousCancel()
engine.rootContext()->setContextProperty("myModel", &model);
- QQuickVisualDataModel *visualModel = qobject_cast<QQuickVisualDataModel*>(c.create());
+ QQmlDelegateModel *visualModel = qobject_cast<QQmlDelegateModel*>(c.create());
QVERIFY(visualModel);
- QQuickItem *item = visualModel->item(requestIndex, true);
+ QQuickItem *item = qobject_cast<QQuickItem*>(visualModel->object(requestIndex, true));
QVERIFY(!item);
QCOMPARE(controller.incubatingObjectCount(), 1);
@@ -4221,10 +4221,10 @@ void tst_qquickvisualdatamodel::invalidContext()
QQmlComponent c(&engine, testFileUrl("visualdatamodel.qml"));
- QQuickVisualDataModel *visualModel = qobject_cast<QQuickVisualDataModel*>(c.create(context.data()));
+ QQmlDelegateModel *visualModel = qobject_cast<QQmlDelegateModel*>(c.create(context.data()));
QVERIFY(visualModel);
- QQuickItem *item = visualModel->item(4, false);
+ QQuickItem *item = qobject_cast<QQuickItem*>(visualModel->object(4, false));
QVERIFY(item);
visualModel->release(item);
@@ -4232,7 +4232,7 @@ void tst_qquickvisualdatamodel::invalidContext()
model.insertItem(4, "new item", "");
- item = visualModel->item(4, false);
+ item = qobject_cast<QQuickItem*>(visualModel->object(4, false));
QVERIFY(!item);
}
diff --git a/tests/auto/quick/qquickwindow/data/focus.qml b/tests/auto/quick/qquickwindow/data/focus.qml
index 901f2fcf2e..899b999cdc 100644
--- a/tests/auto/quick/qquickwindow/data/focus.qml
+++ b/tests/auto/quick/qquickwindow/data/focus.qml
@@ -2,6 +2,10 @@ import QtQuick 2.0
import QtQuick.Window 2.0 as Window
Window.Window {
+
+ width: 400
+ height: 300
+
Item {
objectName: "item1"
}
diff --git a/tests/auto/quick/qquickwindow/data/ownershipRootItem.qml b/tests/auto/quick/qquickwindow/data/ownershipRootItem.qml
index 955304e317..03400ba673 100644
--- a/tests/auto/quick/qquickwindow/data/ownershipRootItem.qml
+++ b/tests/auto/quick/qquickwindow/data/ownershipRootItem.qml
@@ -10,6 +10,6 @@ Window.Window {
RootItemAccessor {
id:accessor
objectName:"accessor"
- Component.onCompleted:accessor.rootItem();
+ Component.onCompleted:accessor.contentItem();
}
}
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 3e3a35f8d1..b2e07e4c13 100644
--- a/tests/auto/quick/qquickwindow/tst_qquickwindow.cpp
+++ b/tests/auto/quick/qquickwindow/tst_qquickwindow.cpp
@@ -284,8 +284,11 @@ private slots:
void constantUpdates();
+ void constantUpdatesOnWindow_data();
+ void constantUpdatesOnWindow();
void mouseFiltering();
void headless();
+ void noUpdateWhenNothingChanges();
void touchEvent_basic();
void touchEvent_propagation();
@@ -312,6 +315,13 @@ private slots:
void ownershipRootItem();
+ void hideThenDelete_data();
+ void hideThenDelete();
+
+ void showHideAnimate();
+
+ void testExpose();
+
#ifndef QT_NO_CURSOR
void cursor();
#endif
@@ -331,6 +341,55 @@ void tst_qquickwindow::constantUpdates()
QTRY_VERIFY(item.iterations > 60);
}
+void tst_qquickwindow::constantUpdatesOnWindow_data()
+{
+ QTest::addColumn<bool>("blockedGui");
+ QTest::addColumn<QByteArray>("signal");
+
+ QQuickWindow window;
+ window.setGeometry(100, 100, 300, 200);
+ window.show();
+ QTest::qWaitForWindowExposed(&window);
+ bool threaded = window.openglContext()->thread() != QGuiApplication::instance()->thread();
+
+ if (threaded) {
+ QTest::newRow("blocked, beforeSync") << true << QByteArray(SIGNAL(beforeSynchronizing()));
+ QTest::newRow("blocked, beforeRender") << true << QByteArray(SIGNAL(beforeRendering()));
+ QTest::newRow("blocked, afterRender") << true << QByteArray(SIGNAL(afterRendering()));
+ QTest::newRow("blocked, swapped") << true << QByteArray(SIGNAL(frameSwapped()));
+ }
+ QTest::newRow("unblocked, beforeSync") << false << QByteArray(SIGNAL(beforeSynchronizing()));
+ QTest::newRow("unblocked, beforeRender") << false << QByteArray(SIGNAL(beforeRendering()));
+ QTest::newRow("unblocked, afterRender") << false << QByteArray(SIGNAL(afterRendering()));
+ QTest::newRow("unblocked, swapped") << false << QByteArray(SIGNAL(frameSwapped()));
+}
+
+void tst_qquickwindow::constantUpdatesOnWindow()
+{
+ QFETCH(bool, blockedGui);
+ QFETCH(QByteArray, signal);
+
+ QQuickWindow window;
+ window.setGeometry(100, 100, 300, 200);
+
+ connect(&window, signal.constData(), &window, SLOT(update()), Qt::DirectConnection);
+ window.show();
+ QTRY_VERIFY(window.isExposed());
+
+ QSignalSpy catcher(&window, SIGNAL(frameSwapped()));
+ if (blockedGui)
+ QTest::qSleep(1000);
+ else {
+ window.update();
+ QTest::qWait(1000);
+ }
+ window.hide();
+
+ // We should expect 60, but under loaded conditions we could be skipping
+ // frames, so don't expect too much.
+ QVERIFY(catcher.size() > 10);
+}
+
void tst_qquickwindow::touchEvent_basic()
{
TestTouchItem::clearMousePressCounter();
@@ -945,6 +1004,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();
@@ -984,6 +1045,28 @@ void tst_qquickwindow::headless()
QCOMPARE(originalContent, newContent);
}
+void tst_qquickwindow::noUpdateWhenNothingChanges()
+{
+ QQuickWindow window;
+ window.setGeometry(100, 100, 300, 200);
+
+ QQuickRectangle rect(window.contentItem());
+
+ window.show();
+ QTRY_VERIFY(window.isExposed());
+
+ if (window.openglContext()->thread() == QGuiApplication::instance()->thread()) {
+ QSKIP("Only threaded renderloop implements this feature");
+ return;
+ }
+
+ QSignalSpy spy(&window, SIGNAL(frameSwapped()));
+ rect.update();
+ QTest::qWait(500);
+
+ QCOMPARE(spy.size(), 0);
+}
+
void tst_qquickwindow::focusObject()
{
QQmlEngine engine;
@@ -997,6 +1080,11 @@ void tst_qquickwindow::focusObject()
QQuickWindow *window = qobject_cast<QQuickWindow*>(created);
QVERIFY(window);
+ window->show();
+ QVERIFY(QTest::qWaitForWindowExposed(window));
+ window->requestActivate();
+ QVERIFY(QTest::qWaitForWindowActive(window));
+
QQuickItem *item1 = window->findChild<QQuickItem*>("item1");
QVERIFY(item1);
item1->setFocus(true);
@@ -1207,6 +1295,110 @@ 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);
+}
+
+void tst_qquickwindow::testExpose()
+{
+ QQuickWindow window;
+ window.setGeometry(100, 100, 300, 200);
+
+ window.show();
+ QTRY_VERIFY(window.isExposed());
+
+ QSignalSpy swapSpy(&window, SIGNAL(frameSwapped()));
+
+ // exhaust pending exposes, as some platforms send us plenty
+ // while showing the first time
+ QTest::qWait(1000);
+ while (swapSpy.size() != 0) {
+ swapSpy.clear();
+ QTest::qWait(100);
+ }
+
+ QWindowSystemInterface::handleExposeEvent(&window, QRegion(10, 10, 20, 20));
+ QTRY_COMPARE(swapSpy.size(), 1);
+}
+
QTEST_MAIN(tst_qquickwindow)
#include "tst_qquickwindow.moc"
diff --git a/tests/auto/quick/quick.pro b/tests/auto/quick/quick.pro
index c4a4173e0f..aa1e1ec701 100644
--- a/tests/auto/quick/quick.pro
+++ b/tests/auto/quick/quick.pro
@@ -61,6 +61,7 @@ QUICKTESTS = \
qquickshadereffect \
qquickspritesequence \
qquicktext \
+ qquicktextdocument \
qquicktextedit \
qquicktextinput \
qquickvisualdatamodel \