summaryrefslogtreecommitdiffstats
path: root/tests/auto/qitemmodel
diff options
context:
space:
mode:
authorJason McDonald <jason.mcdonald@nokia.com>2011-05-03 10:52:52 +1000
committerJason McDonald <jason.mcdonald@nokia.com>2011-05-04 13:21:06 +1000
commit0d773d839e39f4f4bfd0bf9d652e4f2650adfcb0 (patch)
treedf464378e0c607f98dff45e3b42d9c72c3a054f9 /tests/auto/qitemmodel
parenta388e104febb131cd35438bbb1397eeab41d3ab8 (diff)
Remove Q_ASSERT from qitemmodel autotest
Allow createModel() to return a null model on failure (which it already did in release mode builds), but fail the test gracefully instead of crashing when a null model is returned. Change-Id: Iaa0ec31183e0c90fcea512223d01e07ed188a380 Task-number: QTBUG-17582 Reviewed-by: Rohan McGovern
Diffstat (limited to 'tests/auto/qitemmodel')
-rw-r--r--tests/auto/qitemmodel/modelstotest.cpp1
-rw-r--r--tests/auto/qitemmodel/tst_qitemmodel.cpp12
2 files changed, 12 insertions, 1 deletions
diff --git a/tests/auto/qitemmodel/modelstotest.cpp b/tests/auto/qitemmodel/modelstotest.cpp
index c4c2cbb521..cec170334f 100644
--- a/tests/auto/qitemmodel/modelstotest.cpp
+++ b/tests/auto/qitemmodel/modelstotest.cpp
@@ -227,7 +227,6 @@ QAbstractItemModel *ModelsToTest::createModel(const QString &modelType)
return widget->model();
}
- Q_ASSERT(false);
return 0;
}
diff --git a/tests/auto/qitemmodel/tst_qitemmodel.cpp b/tests/auto/qitemmodel/tst_qitemmodel.cpp
index 7e177bae9b..948285386f 100644
--- a/tests/auto/qitemmodel/tst_qitemmodel.cpp
+++ b/tests/auto/qitemmodel/tst_qitemmodel.cpp
@@ -199,6 +199,7 @@ void tst_QItemModel::nonDestructiveBasicTest()
{
QFETCH(QString, modelType);
currentModel = testModels->createModel(modelType);
+ QVERIFY(currentModel);
QCOMPARE(currentModel->buddy(QModelIndex()), QModelIndex());
currentModel->canFetchMore(QModelIndex());
@@ -244,6 +245,7 @@ void tst_QItemModel::rowCount()
{
QFETCH(QString, modelType);
currentModel = testModels->createModel(modelType);
+ QVERIFY(currentModel);
QFETCH(bool, isEmpty);
if (isEmpty) {
@@ -291,6 +293,7 @@ void tst_QItemModel::columnCount()
{
QFETCH(QString, modelType);
currentModel = testModels->createModel(modelType);
+ QVERIFY(currentModel);
QFETCH(bool, isEmpty);
if (isEmpty) {
@@ -325,6 +328,7 @@ void tst_QItemModel::hasIndex()
{
QFETCH(QString, modelType);
currentModel = testModels->createModel(modelType);
+ QVERIFY(currentModel);
// Make sure that invalid values returns an invalid index
QCOMPARE(currentModel->hasIndex(-2, -2), false);
@@ -359,6 +363,7 @@ void tst_QItemModel::index()
{
QFETCH(QString, modelType);
currentModel = testModels->createModel(modelType);
+ QVERIFY(currentModel);
// Make sure that invalid values returns an invalid index
QCOMPARE(currentModel->index(-2, -2), QModelIndex());
@@ -489,6 +494,7 @@ void tst_QItemModel::parent()
{
QFETCH(QString, modelType);
currentModel = testModels->createModel(modelType);
+ QVERIFY(currentModel);
// Make sure the model wont crash and will return an invalid QModelIndex
// when asked for the parent of an invalid index.
@@ -538,6 +544,7 @@ void tst_QItemModel::data()
{
QFETCH(QString, modelType);
currentModel = testModels->createModel(modelType);
+ QVERIFY(currentModel);
// Invalid index should return an invalid qvariant
QVERIFY(!currentModel->data(QModelIndex()).isValid());
@@ -618,6 +625,7 @@ void tst_QItemModel::setData()
{
QFETCH(QString, modelType);
currentModel = testModels->createModel(modelType);
+ QVERIFY(currentModel);
qRegisterMetaType<QModelIndex>("QModelIndex");
QSignalSpy spy(currentModel, SIGNAL(dataChanged(const QModelIndex &, const QModelIndex &)));
QCOMPARE(currentModel->setData(QModelIndex(), QVariant()), false);
@@ -660,6 +668,7 @@ void tst_QItemModel::setHeaderData()
{
QFETCH(QString, modelType);
currentModel = testModels->createModel(modelType);
+ QVERIFY(currentModel);
QCOMPARE(currentModel->setHeaderData(-1, Qt::Horizontal, QVariant()), false);
QCOMPARE(currentModel->setHeaderData(-1, Qt::Vertical, QVariant()), false);
@@ -708,6 +717,7 @@ void tst_QItemModel::sort()
{
QFETCH(QString, modelType);
currentModel = testModels->createModel(modelType);
+ QVERIFY(currentModel);
QFETCH(bool, isEmpty);
if (isEmpty)
@@ -819,6 +829,7 @@ void tst_QItemModel::remove()
QFETCH(QString, modelType);
currentModel = testModels->createModel(modelType);
+ QVERIFY(currentModel);
QFETCH(bool, readOnly);
if (readOnly)
@@ -1160,6 +1171,7 @@ void tst_QItemModel::insert()
{
QFETCH(QString, modelType);
currentModel = testModels->createModel(modelType);
+ QVERIFY(currentModel);
QFETCH(bool, readOnly);
if (readOnly)