From 70f6652ebd7153b4a381c30756e3e76fc3cab562 Mon Sep 17 00:00:00 2001 From: Albert Astals Cid Date: Tue, 19 Feb 2013 23:51:31 +0100 Subject: Forward the 3rd parameter of dataChanged Change-Id: I94f893bf65cd150c3cb1099c91cb13882bcca79a Reviewed-by: Stephen Kelly --- .../tst_qidentityproxymodel.cpp | 38 ++++++++++++++++++++++ 1 file changed, 38 insertions(+) (limited to 'tests/auto/corelib/itemmodels/qidentityproxymodel/tst_qidentityproxymodel.cpp') diff --git a/tests/auto/corelib/itemmodels/qidentityproxymodel/tst_qidentityproxymodel.cpp b/tests/auto/corelib/itemmodels/qidentityproxymodel/tst_qidentityproxymodel.cpp index c7e4664007..f750b7a9d4 100644 --- a/tests/auto/corelib/itemmodels/qidentityproxymodel/tst_qidentityproxymodel.cpp +++ b/tests/auto/corelib/itemmodels/qidentityproxymodel/tst_qidentityproxymodel.cpp @@ -46,6 +46,20 @@ #include "dynamictreemodel.h" #include "qidentityproxymodel.h" +class DataChangedModel : public QAbstractListModel +{ +public: + int rowCount(const QModelIndex &parent) const { return parent.isValid() ? 0 : 1; } + QVariant data(const QModelIndex&, int) const { return QVariant(); } + QModelIndex index(int row, int column, const QModelIndex &) const { return createIndex(row, column); } + + void changeData() + { + const QModelIndex idx = index(0, 0, QModelIndex()); + Q_EMIT dataChanged(idx, idx, QVector() << 1); + } +}; + class tst_QIdentityProxyModel : public QObject { Q_OBJECT @@ -63,6 +77,7 @@ private slots: void removeRows(); void moveRows(); void reset(); + void dataChanged(); protected: void verifyIdentity(QAbstractItemModel *model, const QModelIndex &parent = QModelIndex()); @@ -79,6 +94,7 @@ tst_QIdentityProxyModel::tst_QIdentityProxyModel() void tst_QIdentityProxyModel::initTestCase() { + qRegisterMetaType >(); m_model = new QStandardItemModel(0, 1); m_proxy = new QIdentityProxyModel(); } @@ -326,5 +342,27 @@ void tst_QIdentityProxyModel::reset() m_proxy->setSourceModel(0); } +void tst_QIdentityProxyModel::dataChanged() +{ + DataChangedModel model; + m_proxy->setSourceModel(&model); + + verifyIdentity(&model); + + QSignalSpy modelSpy(&model, SIGNAL(dataChanged(QModelIndex,QModelIndex,QVector))); + QSignalSpy proxySpy(m_proxy, SIGNAL(dataChanged(QModelIndex,QModelIndex,QVector))); + + QVERIFY(modelSpy.isValid()); + QVERIFY(proxySpy.isValid()); + + model.changeData(); + + QCOMPARE(modelSpy.first().at(2).value >(), QVector() << 1); + QVERIFY(modelSpy.first().at(2) == proxySpy.first().at(2)); + + verifyIdentity(&model); + m_proxy->setSourceModel(0); +} + QTEST_MAIN(tst_QIdentityProxyModel) #include "tst_qidentityproxymodel.moc" -- cgit v1.2.3