summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorDavid Faure <david.faure@kdab.com>2018-06-25 15:50:35 +0200
committerDavid Faure <david.faure@kdab.com>2018-06-27 10:11:35 +0000
commit27ea5a65dd3fdabdad1569f5330f90248cdca4f5 (patch)
tree0f98161577c58f2aea7d983533329b9f4d45008f /tests
parent74be42ca598c4f13486191c0b8c58bee3d1f1090 (diff)
QAbstractItemModelTester: fix out-of-bounds index() calls
When removing rows, the tester is looking at the data of the row "just before" and the row "just after" the removed rows, to see if they are still the same at the end of the removal operation. Guard this with bounds check, in case there is no row just before or just after. This is the opportunity to use modeltester in tst_qidentityproxymodel, which was already a testcase for removing the only row in a given parent. Change-Id: Iec8228c16b9c670b794e2665356d153679178494 Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/corelib/itemmodels/qidentityproxymodel/tst_qidentityproxymodel.cpp12
1 files changed, 9 insertions, 3 deletions
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()