diff options
-rw-r--r-- | src/testlib/qabstractitemmodeltester.cpp | 19 | ||||
-rw-r--r-- | tests/auto/corelib/itemmodels/qidentityproxymodel/tst_qidentityproxymodel.cpp | 12 |
2 files changed, 24 insertions, 7 deletions
diff --git a/src/testlib/qabstractitemmodeltester.cpp b/src/testlib/qabstractitemmodeltester.cpp index e970be2c8d..04fa99bc4d 100644 --- a/src/testlib/qabstractitemmodeltester.cpp +++ b/src/testlib/qabstractitemmodeltester.cpp @@ -712,8 +712,17 @@ void QAbstractItemModelTesterPrivate::rowsAboutToBeRemoved(const QModelIndex &pa Changing c; c.parent = parent; c.oldSize = model->rowCount(parent); - c.last = model->data(model->index(start - 1, 0, parent)); - c.next = model->data(model->index(end + 1, 0, parent)); + if (start > 0) { + const QModelIndex startIndex = model->index(start - 1, 0, parent); + MODELTESTER_VERIFY(startIndex.isValid()); + c.last = model->data(startIndex); + } + if (end < c.oldSize - 1) { + const QModelIndex endIndex = model->index(end + 1, 0, parent); + MODELTESTER_VERIFY(endIndex.isValid()); + c.next = model->data(endIndex); + } + remove.push(c); } @@ -732,8 +741,10 @@ void QAbstractItemModelTesterPrivate::rowsRemoved(const QModelIndex &parent, int Changing c = remove.pop(); MODELTESTER_COMPARE(parent, c.parent); MODELTESTER_COMPARE(model->rowCount(parent), c.oldSize - (end - start + 1)); - MODELTESTER_COMPARE(model->data(model->index(start - 1, 0, c.parent)), c.last); - MODELTESTER_COMPARE(model->data(model->index(start, 0, c.parent)), c.next); + if (start > 0) + MODELTESTER_COMPARE(model->data(model->index(start - 1, 0, c.parent)), c.last); + if (end < c.oldSize - 1) + MODELTESTER_COMPARE(model->data(model->index(start, 0, c.parent)), c.next); } void QAbstractItemModelTesterPrivate::dataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight) diff --git a/tests/auto/corelib/itemmodels/qidentityproxymodel/tst_qidentityproxymodel.cpp b/tests/auto/corelib/itemmodels/qidentityproxymodel/tst_qidentityproxymodel.cpp index f8c5c92677..262c6dd9c8 100644 --- a/tests/auto/corelib/itemmodels/qidentityproxymodel/tst_qidentityproxymodel.cpp +++ b/tests/auto/corelib/itemmodels/qidentityproxymodel/tst_qidentityproxymodel.cpp @@ -26,9 +26,12 @@ ** ****************************************************************************/ -#include <QtTest/QtTest> -#include <QtCore/QCoreApplication> -#include <QtGui/QStandardItemModel> +#include <QAbstractItemModelTester> +#include <QCoreApplication> +#include <QSignalSpy> +#include <QStandardItemModel> +#include <QStringListModel> +#include <QTest> #include "dynamictreemodel.h" #include "qidentityproxymodel.h" @@ -76,6 +79,7 @@ protected: private: QStandardItemModel *m_model; QIdentityProxyModel *m_proxy; + QAbstractItemModelTester *m_modelTest; }; tst_QIdentityProxyModel::tst_QIdentityProxyModel() @@ -88,12 +92,14 @@ void tst_QIdentityProxyModel::initTestCase() qRegisterMetaType<QVector<int> >(); m_model = new QStandardItemModel(0, 1); m_proxy = new QIdentityProxyModel(); + m_modelTest = new QAbstractItemModelTester(m_proxy, this); } void tst_QIdentityProxyModel::cleanupTestCase() { delete m_proxy; delete m_model; + delete m_modelTest; } void tst_QIdentityProxyModel::cleanup() |