summaryrefslogtreecommitdiffstats
path: root/tests/auto/declarative/qmlgraphicslistview
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/declarative/qmlgraphicslistview')
-rw-r--r--tests/auto/declarative/qmlgraphicslistview/data/listview-initCurrent.qml2
-rw-r--r--tests/auto/declarative/qmlgraphicslistview/data/listview.qml34
-rw-r--r--tests/auto/declarative/qmlgraphicslistview/tst_qmlgraphicslistview.cpp78
3 files changed, 105 insertions, 9 deletions
diff --git a/tests/auto/declarative/qmlgraphicslistview/data/listview-initCurrent.qml b/tests/auto/declarative/qmlgraphicslistview/data/listview-initCurrent.qml
index 65a9d8a..74f5ef4 100644
--- a/tests/auto/declarative/qmlgraphicslistview/data/listview-initCurrent.qml
+++ b/tests/auto/declarative/qmlgraphicslistview/data/listview-initCurrent.qml
@@ -43,8 +43,8 @@ Rectangle {
width: 240
height: 320
keyNavigationWraps: testWrap
- model: testModel
delegate: myDelegate
highlightMoveSpeed: 1000
+ model: testModel
}
}
diff --git a/tests/auto/declarative/qmlgraphicslistview/data/listview.qml b/tests/auto/declarative/qmlgraphicslistview/data/listview.qml
index ccefeba..ec8bb68 100644
--- a/tests/auto/declarative/qmlgraphicslistview/data/listview.qml
+++ b/tests/auto/declarative/qmlgraphicslistview/data/listview.qml
@@ -4,6 +4,29 @@ Rectangle {
width: 240
height: 320
color: "#ffffff"
+ function checkProperties() {
+ testObject.error = false;
+ if (list.model != testModel) {
+ print("model property incorrect");
+ testObject.error = true;
+ }
+ if (!testObject.animate && list.delegate != myDelegate) {
+ print("delegate property incorrect - expected myDelegate");
+ testObject.error = true;
+ }
+ if (testObject.animate && list.delegate != animatedDelegate) {
+ print("delegate property incorrect - expected animatedDelegate");
+ testObject.error = true;
+ }
+ if (testObject.invalidHighlight && list.highlight != invalidHl) {
+ print("highlight property incorrect - expected invalidHl");
+ testObject.error = true;
+ }
+ if (!testObject.invalidHighlight && list.highlight != myHighlight) {
+ print("highlight property incorrect - expected myHighlight");
+ testObject.error = true;
+ }
+ }
resources: [
Component {
id: myDelegate
@@ -70,6 +93,14 @@ Rectangle {
*/
}
}
+ },
+ Component {
+ id: myHighlight
+ Rectangle { color: "green" }
+ },
+ Component {
+ id: invalidHl
+ EaseFollow {}
}
]
ListView {
@@ -79,7 +110,8 @@ Rectangle {
width: 240
height: 320
model: testModel
- delegate: testAnimate ? myDelegate : animatedDelegate
+ delegate: testObject.animate ? animatedDelegate : myDelegate
+ highlight: testObject.invalidHighlight ? invalidHl : myHighlight
highlightMoveSpeed: 1000
highlightResizeSpeed: 1000
}
diff --git a/tests/auto/declarative/qmlgraphicslistview/tst_qmlgraphicslistview.cpp b/tests/auto/declarative/qmlgraphicslistview/tst_qmlgraphicslistview.cpp
index d416603..7e6dc0d 100644
--- a/tests/auto/declarative/qmlgraphicslistview/tst_qmlgraphicslistview.cpp
+++ b/tests/auto/declarative/qmlgraphicslistview/tst_qmlgraphicslistview.cpp
@@ -90,6 +90,38 @@ private:
QList<T*> findItems(QmlGraphicsItem *parent, const QString &objectName);
};
+class TestObject : public QObject
+{
+ Q_OBJECT
+
+ Q_PROPERTY(bool error READ error WRITE setError NOTIFY changedError)
+ Q_PROPERTY(bool animate READ animate NOTIFY changedAnim)
+ Q_PROPERTY(bool invalidHighlight READ invalidHighlight NOTIFY changedHl)
+
+public:
+ TestObject(QObject *parent = 0)
+ : QObject(parent), mError(true), mAnimate(false), mInvalidHighlight(false) {}
+
+ bool error() const { return mError; }
+ void setError(bool err) { mError = err; emit changedError(); }
+
+ bool animate() const { return mAnimate; }
+ void setAnimate(bool anim) { mAnimate = anim; emit changedAnim(); }
+
+ bool invalidHighlight() const { return mInvalidHighlight; }
+ void setInvalidHighlight(bool invalid) { mInvalidHighlight = invalid; emit changedHl(); }
+
+signals:
+ void changedError();
+ void changedAnim();
+ void changedHl();
+
+public:
+ bool mError;
+ bool mAnimate;
+ bool mInvalidHighlight;
+};
+
class TestModel : public QListModelInterface
{
Q_OBJECT
@@ -243,7 +275,9 @@ void tst_QmlGraphicsListView::items()
QmlContext *ctxt = canvas->rootContext();
ctxt->setContextProperty("testModel", &model);
- ctxt->setContextProperty("testAnimate", QVariant(false));
+
+ TestObject *testObject = new TestObject;
+ ctxt->setContextProperty("testObject", testObject);
canvas->execute();
qApp->processEvents();
@@ -254,6 +288,9 @@ void tst_QmlGraphicsListView::items()
QmlGraphicsItem *viewport = listview->viewport();
QVERIFY(viewport != 0);
+ QMetaObject::invokeMethod(canvas->root(), "checkProperties");
+ QVERIFY(testObject->error() == false);
+
QCOMPARE(listview->count(), model.count());
QCOMPARE(viewport->childItems().count(), model.count()+1); // assumes all are visible, +1 for the (default) highlight item
@@ -269,6 +306,16 @@ void tst_QmlGraphicsListView::items()
QCOMPARE(number->text(), model.number(i));
}
+ // switch to other delegate
+ testObject->setAnimate(true);
+ QMetaObject::invokeMethod(canvas->root(), "checkProperties");
+ QVERIFY(testObject->error() == false);
+
+ // set invalid highlight
+ testObject->setInvalidHighlight(true);
+ QMetaObject::invokeMethod(canvas->root(), "checkProperties");
+ QVERIFY(testObject->error() == false);
+
// set an empty model and confirm that items are destroyed
T model2;
ctxt->setContextProperty("testModel", &model2);
@@ -294,7 +341,9 @@ void tst_QmlGraphicsListView::changed()
QmlContext *ctxt = canvas->rootContext();
ctxt->setContextProperty("testModel", &model);
- ctxt->setContextProperty("testAnimate", QVariant(false));
+
+ TestObject *testObject = new TestObject;
+ ctxt->setContextProperty("testObject", testObject);
canvas->execute();
qApp->processEvents();
@@ -328,7 +377,9 @@ void tst_QmlGraphicsListView::inserted()
QmlContext *ctxt = canvas->rootContext();
ctxt->setContextProperty("testModel", &model);
- ctxt->setContextProperty("testAnimate", QVariant(false));
+
+ TestObject *testObject = new TestObject;
+ ctxt->setContextProperty("testObject", testObject);
canvas->execute();
qApp->processEvents();
@@ -415,7 +466,10 @@ void tst_QmlGraphicsListView::removed(bool animated)
QmlContext *ctxt = canvas->rootContext();
ctxt->setContextProperty("testModel", &model);
- ctxt->setContextProperty("testAnimate", QVariant(animated));
+
+ TestObject *testObject = new TestObject;
+ testObject->setAnimate(animated);
+ ctxt->setContextProperty("testObject", testObject);
canvas->execute();
qApp->processEvents();
@@ -526,7 +580,9 @@ void tst_QmlGraphicsListView::moved()
QmlContext *ctxt = canvas->rootContext();
ctxt->setContextProperty("testModel", &model);
- ctxt->setContextProperty("testAnimate", QVariant(false));
+
+ TestObject *testObject = new TestObject;
+ ctxt->setContextProperty("testObject", testObject);
canvas->execute();
qApp->processEvents();
@@ -665,7 +721,9 @@ void tst_QmlGraphicsListView::spacing()
QmlContext *ctxt = canvas->rootContext();
ctxt->setContextProperty("testModel", &model);
- ctxt->setContextProperty("testAnimate", QVariant(false));
+
+ TestObject *testObject = new TestObject;
+ ctxt->setContextProperty("testObject", testObject);
canvas->execute();
qApp->processEvents();
@@ -934,7 +992,9 @@ void tst_QmlGraphicsListView::cacheBuffer()
QmlContext *ctxt = canvas->rootContext();
ctxt->setContextProperty("testModel", &model);
- ctxt->setContextProperty("testAnimate", QVariant(false));
+
+ TestObject *testObject = new TestObject;
+ ctxt->setContextProperty("testObject", testObject);
canvas->execute();
qApp->processEvents();
@@ -944,6 +1004,9 @@ void tst_QmlGraphicsListView::cacheBuffer()
QmlGraphicsItem *viewport = listview->viewport();
QVERIFY(viewport != 0);
+ QVERIFY(listview->delegate() != 0);
+ QVERIFY(listview->model() != 0);
+ QVERIFY(listview->highlight() == 0);
// Confirm items positioned correctly
int itemCount = findItems<QmlGraphicsItem>(viewport, "wrapper").count();
@@ -955,6 +1018,7 @@ void tst_QmlGraphicsListView::cacheBuffer()
}
listview->setCacheBuffer(400);
+ QVERIFY(listview->cacheBuffer() == 400);
int newItemCount = findItems<QmlGraphicsItem>(viewport, "wrapper").count();
QVERIFY(newItemCount > itemCount);