aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/quick/qquickpathview/tst_qquickpathview.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/quick/qquickpathview/tst_qquickpathview.cpp')
-rw-r--r--tests/auto/quick/qquickpathview/tst_qquickpathview.cpp256
1 files changed, 112 insertions, 144 deletions
diff --git a/tests/auto/quick/qquickpathview/tst_qquickpathview.cpp b/tests/auto/quick/qquickpathview/tst_qquickpathview.cpp
index 8821203902..e805a6b074 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()
@@ -312,34 +310,34 @@ void tst_QQuickPathView::insertModel_data()
// We have 8 items, with currentIndex == 4
QTest::newRow("insert after current")
- << int(QQuickPathView::StrictlyEnforceRange) << 6 << 1 << 5. << 4;
+ << int(QQuickPathView::StrictlyEnforceRange) << 6 << 1 << qreal(5.) << 4;
QTest::newRow("insert before current")
- << int(QQuickPathView::StrictlyEnforceRange) << 2 << 1 << 4. << 5;
+ << int(QQuickPathView::StrictlyEnforceRange) << 2 << 1 << qreal(4.)<< 5;
QTest::newRow("insert multiple after current")
- << int(QQuickPathView::StrictlyEnforceRange) << 5 << 2 << 6. << 4;
+ << int(QQuickPathView::StrictlyEnforceRange) << 5 << 2 << qreal(6.) << 4;
QTest::newRow("insert multiple before current")
- << int(QQuickPathView::StrictlyEnforceRange) << 1 << 2 << 4. << 6;
+ << int(QQuickPathView::StrictlyEnforceRange) << 1 << 2 << qreal(4.) << 6;
QTest::newRow("insert at end")
- << int(QQuickPathView::StrictlyEnforceRange) << 8 << 1 << 5. << 4;
+ << int(QQuickPathView::StrictlyEnforceRange) << 8 << 1 << qreal(5.) << 4;
QTest::newRow("insert at beginning")
- << int(QQuickPathView::StrictlyEnforceRange) << 0 << 1 << 4. << 5;
+ << int(QQuickPathView::StrictlyEnforceRange) << 0 << 1 << qreal(4.) << 5;
QTest::newRow("insert at current")
- << int(QQuickPathView::StrictlyEnforceRange) << 4 << 1 << 4. << 5;
+ << int(QQuickPathView::StrictlyEnforceRange) << 4 << 1 << qreal(4.) << 5;
QTest::newRow("no range - insert after current")
- << int(QQuickPathView::NoHighlightRange) << 6 << 1 << 5. << 4;
+ << int(QQuickPathView::NoHighlightRange) << 6 << 1 << qreal(5.) << 4;
QTest::newRow("no range - insert before current")
- << int(QQuickPathView::NoHighlightRange) << 2 << 1 << 4. << 5;
+ << int(QQuickPathView::NoHighlightRange) << 2 << 1 << qreal(4.) << 5;
QTest::newRow("no range - insert multiple after current")
- << int(QQuickPathView::NoHighlightRange) << 5 << 2 << 6. << 4;
+ << int(QQuickPathView::NoHighlightRange) << 5 << 2 << qreal(6.) << 4;
QTest::newRow("no range - insert multiple before current")
- << int(QQuickPathView::NoHighlightRange) << 1 << 2 << 4. << 6;
+ << int(QQuickPathView::NoHighlightRange) << 1 << 2 << qreal(4.) << 6;
QTest::newRow("no range - insert at end")
- << int(QQuickPathView::NoHighlightRange) << 8 << 1 << 5. << 4;
+ << int(QQuickPathView::NoHighlightRange) << 8 << 1 << qreal(5.) << 4;
QTest::newRow("no range - insert at beginning")
- << int(QQuickPathView::NoHighlightRange) << 0 << 1 << 4. << 5;
+ << int(QQuickPathView::NoHighlightRange) << 0 << 1 << qreal(4.) << 5;
QTest::newRow("no range - insert at current")
- << int(QQuickPathView::NoHighlightRange) << 4 << 1 << 4. << 5;
+ << int(QQuickPathView::NoHighlightRange) << 4 << 1 << qreal(4.) << 5;
}
void tst_QQuickPathView::insertModel()
@@ -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()
@@ -402,38 +398,38 @@ void tst_QQuickPathView::removeModel_data()
// We have 8 items, with currentIndex == 4
QTest::newRow("remove after current")
- << int(QQuickPathView::StrictlyEnforceRange) << 6 << 1 << 3. << 4;
+ << int(QQuickPathView::StrictlyEnforceRange) << 6 << 1 << qreal(3.) << 4;
QTest::newRow("remove before current")
- << int(QQuickPathView::StrictlyEnforceRange) << 2 << 1 << 4. << 3;
+ << int(QQuickPathView::StrictlyEnforceRange) << 2 << 1 << qreal(4.) << 3;
QTest::newRow("remove multiple after current")
- << int(QQuickPathView::StrictlyEnforceRange) << 5 << 2 << 2. << 4;
+ << int(QQuickPathView::StrictlyEnforceRange) << 5 << 2 << qreal(2.) << 4;
QTest::newRow("remove multiple before current")
- << int(QQuickPathView::StrictlyEnforceRange) << 1 << 2 << 4. << 2;
+ << int(QQuickPathView::StrictlyEnforceRange) << 1 << 2 << qreal(4.) << 2;
QTest::newRow("remove last")
- << int(QQuickPathView::StrictlyEnforceRange) << 7 << 1 << 3. << 4;
+ << int(QQuickPathView::StrictlyEnforceRange) << 7 << 1 << qreal(3.) << 4;
QTest::newRow("remove first")
- << int(QQuickPathView::StrictlyEnforceRange) << 0 << 1 << 4. << 3;
+ << int(QQuickPathView::StrictlyEnforceRange) << 0 << 1 << qreal(4.) << 3;
QTest::newRow("remove current")
- << int(QQuickPathView::StrictlyEnforceRange) << 4 << 1 << 3. << 4;
+ << int(QQuickPathView::StrictlyEnforceRange) << 4 << 1 << qreal(3.) << 4;
QTest::newRow("remove all")
- << int(QQuickPathView::StrictlyEnforceRange) << 0 << 8 << 0. << 0;
+ << int(QQuickPathView::StrictlyEnforceRange) << 0 << 8 << qreal(0.) << 0;
QTest::newRow("no range - remove after current")
- << int(QQuickPathView::NoHighlightRange) << 6 << 1 << 3. << 4;
+ << int(QQuickPathView::NoHighlightRange) << 6 << 1 << qreal(3.) << 4;
QTest::newRow("no range - remove before current")
- << int(QQuickPathView::NoHighlightRange) << 2 << 1 << 4. << 3;
+ << int(QQuickPathView::NoHighlightRange) << 2 << 1 << qreal(4.) << 3;
QTest::newRow("no range - remove multiple after current")
- << int(QQuickPathView::NoHighlightRange) << 5 << 2 << 2. << 4;
+ << int(QQuickPathView::NoHighlightRange) << 5 << 2 << qreal(2.) << 4;
QTest::newRow("no range - remove multiple before current")
- << int(QQuickPathView::NoHighlightRange) << 1 << 2 << 4. << 2;
+ << int(QQuickPathView::NoHighlightRange) << 1 << 2 << qreal(4.) << 2;
QTest::newRow("no range - remove last")
- << int(QQuickPathView::NoHighlightRange) << 7 << 1 << 3. << 4;
+ << int(QQuickPathView::NoHighlightRange) << 7 << 1 << qreal(3.) << 4;
QTest::newRow("no range - remove first")
- << int(QQuickPathView::NoHighlightRange) << 0 << 1 << 4. << 3;
+ << int(QQuickPathView::NoHighlightRange) << 0 << 1 << qreal(4.) << 3;
QTest::newRow("no range - remove current offset")
- << int(QQuickPathView::NoHighlightRange) << 4 << 1 << 4. << 4;
+ << int(QQuickPathView::NoHighlightRange) << 4 << 1 << qreal(4.) << 4;
QTest::newRow("no range - remove all")
- << int(QQuickPathView::NoHighlightRange) << 0 << 8 << 0. << 0;
+ << int(QQuickPathView::NoHighlightRange) << 0 << 8 << qreal(0.) << 0;
}
void tst_QQuickPathView::removeModel()
@@ -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;
}
@@ -494,40 +489,40 @@ void tst_QQuickPathView::moveModel_data()
// We have 8 items, with currentIndex == 4
QTest::newRow("move after current")
- << int(QQuickPathView::StrictlyEnforceRange) << 5 << 6 << 1 << 4. << 4;
+ << int(QQuickPathView::StrictlyEnforceRange) << 5 << 6 << 1 << qreal(4.) << 4;
QTest::newRow("move before current")
- << int(QQuickPathView::StrictlyEnforceRange) << 2 << 3 << 1 << 4. << 4;
+ << int(QQuickPathView::StrictlyEnforceRange) << 2 << 3 << 1 << qreal(4.) << 4;
QTest::newRow("move before current to after")
- << int(QQuickPathView::StrictlyEnforceRange) << 2 << 6 << 1 << 5. << 3;
+ << int(QQuickPathView::StrictlyEnforceRange) << 2 << 6 << 1 << qreal(5.) << 3;
QTest::newRow("move multiple after current")
- << int(QQuickPathView::StrictlyEnforceRange) << 5 << 6 << 2 << 4. << 4;
+ << int(QQuickPathView::StrictlyEnforceRange) << 5 << 6 << 2 << qreal(4.) << 4;
QTest::newRow("move multiple before current")
- << int(QQuickPathView::StrictlyEnforceRange) << 0 << 1 << 2 << 4. << 4;
+ << int(QQuickPathView::StrictlyEnforceRange) << 0 << 1 << 2 << qreal(4.) << 4;
QTest::newRow("move before current to end")
- << int(QQuickPathView::StrictlyEnforceRange) << 2 << 7 << 1 << 5. << 3;
+ << int(QQuickPathView::StrictlyEnforceRange) << 2 << 7 << 1 << qreal(5.) << 3;
QTest::newRow("move last to beginning")
- << int(QQuickPathView::StrictlyEnforceRange) << 7 << 0 << 1 << 3. << 5;
+ << int(QQuickPathView::StrictlyEnforceRange) << 7 << 0 << 1 << qreal(3.) << 5;
QTest::newRow("move current")
- << int(QQuickPathView::StrictlyEnforceRange) << 4 << 6 << 1 << 2. << 6;
+ << int(QQuickPathView::StrictlyEnforceRange) << 4 << 6 << 1 << qreal(2.) << 6;
QTest::newRow("no range - move after current")
- << int(QQuickPathView::NoHighlightRange) << 5 << 6 << 1 << 4. << 4;
+ << int(QQuickPathView::NoHighlightRange) << 5 << 6 << 1 << qreal(4.) << 4;
QTest::newRow("no range - move before current")
- << int(QQuickPathView::NoHighlightRange) << 2 << 3 << 1 << 4. << 4;
+ << int(QQuickPathView::NoHighlightRange) << 2 << 3 << 1 << qreal(4.) << 4;
QTest::newRow("no range - move before current to after")
- << int(QQuickPathView::NoHighlightRange) << 2 << 6 << 1 << 5. << 3;
+ << int(QQuickPathView::NoHighlightRange) << 2 << 6 << 1 << qreal(5.) << 3;
QTest::newRow("no range - move multiple after current")
- << int(QQuickPathView::NoHighlightRange) << 5 << 6 << 2 << 4. << 4;
+ << int(QQuickPathView::NoHighlightRange) << 5 << 6 << 2 << qreal(4.) << 4;
QTest::newRow("no range - move multiple before current")
- << int(QQuickPathView::NoHighlightRange) << 0 << 1 << 2 << 4. << 4;
+ << int(QQuickPathView::NoHighlightRange) << 0 << 1 << 2 << qreal(4.) << 4;
QTest::newRow("no range - move before current to end")
- << int(QQuickPathView::NoHighlightRange) << 2 << 7 << 1 << 5. << 3;
+ << int(QQuickPathView::NoHighlightRange) << 2 << 7 << 1 << qreal(5.) << 3;
QTest::newRow("no range - move last to beginning")
- << int(QQuickPathView::NoHighlightRange) << 7 << 0 << 1 << 3. << 5;
+ << int(QQuickPathView::NoHighlightRange) << 7 << 0 << 1 << qreal(3.) << 5;
QTest::newRow("no range - move current")
- << int(QQuickPathView::NoHighlightRange) << 4 << 6 << 1 << 4. << 6;
+ << int(QQuickPathView::NoHighlightRange) << 4 << 6 << 1 << qreal(4.) << 6;
QTest::newRow("no range - move multiple incl. current")
- << int(QQuickPathView::NoHighlightRange) << 0 << 1 << 5 << 4. << 5;
+ << int(QQuickPathView::NoHighlightRange) << 0 << 1 << 5 << qreal(4.) << 5;
}
void tst_QQuickPathView::moveModel()
@@ -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()
@@ -2029,16 +1998,16 @@ void tst_QQuickPathView::indexAt_itemAt_data()
QTest::addColumn<qreal>("y");
QTest::addColumn<int>("index");
- QTest::newRow("Item 0 - 585, 95") << 585. << 95. << 0;
- QTest::newRow("Item 0 - 660, 165") << 660. << 165. << 0;
- QTest::newRow("No Item a - 580, 95") << 580. << 95. << -1;
- QTest::newRow("No Item b - 585, 85") << 585. << 85. << -1;
- QTest::newRow("Item 7 - 360, 200") << 360. << 200. << 7;
+ QTest::newRow("Item 0 - 585, 95") << qreal(585.) << qreal(95.) << 0;
+ QTest::newRow("Item 0 - 660, 165") << qreal(660.) << qreal(165.) << 0;
+ QTest::newRow("No Item a - 580, 95") << qreal(580.) << qreal(95.) << -1;
+ QTest::newRow("No Item b - 585, 85") << qreal(585.) << qreal(85.) << -1;
+ QTest::newRow("Item 7 - 360, 200") << qreal(360.) << qreal(200.) << 7;
}
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)