aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorAndrew den Exter <andrew.den-exter@nokia.com>2011-09-01 15:24:34 +1000
committerQt by Nokia <qt-info@nokia.com>2011-09-21 08:23:52 +0200
commit51102228258ed107a255b79606ef855bfa0e460d (patch)
treef34134b772ba45e229cd264a11dba81c0ed77155 /tests
parentce7b66871ce342b4cc62969ec0a3a9d90cee49e9 (diff)
Use QDeclarativeChangeSet to communicate changes to views.
Allows QSGVisualDataModel to send multiple changes at a time. Changes sets with multiple changes will be generated by VisualDataModels with items that have been re-ordered or filtered. Task-number: QTBUG-20107 Change-Id: I28f2620431cc89c61e1061635ffb68dc5801675c Reviewed-on: http://codereview.qt-project.org/4034 Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com> Reviewed-by: Bea Lam <bea.lam@nokia.com> Reviewed-by: Alan Alpert <alan.alpert@nokia.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/declarative/qsgvisualdatamodel/tst_qsgvisualdatamodel.cpp33
1 files changed, 26 insertions, 7 deletions
diff --git a/tests/auto/declarative/qsgvisualdatamodel/tst_qsgvisualdatamodel.cpp b/tests/auto/declarative/qsgvisualdatamodel/tst_qsgvisualdatamodel.cpp
index a2e6d95a41..bd17deb777 100644
--- a/tests/auto/declarative/qsgvisualdatamodel/tst_qsgvisualdatamodel.cpp
+++ b/tests/auto/declarative/qsgvisualdatamodel/tst_qsgvisualdatamodel.cpp
@@ -51,6 +51,7 @@
#include <private/qsgtext_p.h>
#include <private/qsgvisualdatamodel_p.h>
#include <private/qdeclarativevaluetype_p.h>
+#include <private/qdeclarativechangeset_p.h>
#include <math.h>
#include <QtOpenGL/QGLShaderProgram>
@@ -138,8 +139,12 @@ private:
template<typename T>
T *findItem(QSGItem *parent, const QString &objectName, int index);
};
+
+Q_DECLARE_METATYPE(QDeclarativeChangeSet)
+
void tst_qsgvisualdatamodel::initTestCase()
{
+ qRegisterMetaType<QDeclarativeChangeSet>();
}
void tst_qsgvisualdatamodel::cleanupTestCase()
@@ -566,14 +571,28 @@ void tst_qsgvisualdatamodel::qaimRowsMoved()
QSGVisualDataModel *obj = qobject_cast<QSGVisualDataModel*>(c.create());
QVERIFY(obj != 0);
- QSignalSpy spy(obj, SIGNAL(itemsMoved(int,int,int)));
+ QSignalSpy spy(obj, SIGNAL(modelUpdated(QDeclarativeChangeSet,bool)));
model.emitMove(sourceFirst, sourceLast, destinationChild);
- QTRY_COMPARE(spy.count(), 1);
-
- QCOMPARE(spy[0].count(), 3);
- QCOMPARE(spy[0][0].toInt(), expectFrom);
- QCOMPARE(spy[0][1].toInt(), expectTo);
- QCOMPARE(spy[0][2].toInt(), expectCount);
+ // QAbstractItemModel also emits the changed signal when items are moved.
+ QCOMPARE(spy.count(), 2);
+
+ bool move = false;
+ for (int i = 0; i < 2; ++i) {
+ QCOMPARE(spy[1].count(), 2);
+ QDeclarativeChangeSet changeSet = spy[i][0].value<QDeclarativeChangeSet>();
+ if (!changeSet.changes().isEmpty())
+ continue;
+ move = true;
+ QCOMPARE(changeSet.removes().count(), 1);
+ QCOMPARE(changeSet.removes().at(0).index, expectFrom);
+ QCOMPARE(changeSet.removes().at(0).count, expectCount);
+ QCOMPARE(changeSet.inserts().count(), 1);
+ QCOMPARE(changeSet.inserts().at(0).index, expectTo);
+ QCOMPARE(changeSet.inserts().at(0).count, expectCount);
+ QCOMPARE(changeSet.removes().at(0).moveId, changeSet.inserts().at(0).moveId);
+ QCOMPARE(spy[i][1].toBool(), false);
+ }
+ QVERIFY(move);
delete obj;
}