summaryrefslogtreecommitdiffstats
path: root/tests/auto/modeltest/tst_modeltest.cpp
diff options
context:
space:
mode:
authorJyri Tahtela <jyri.tahtela@nokia.com>2011-05-18 10:41:09 +0300
committerJyri Tahtela <jyri.tahtela@nokia.com>2011-05-18 10:41:09 +0300
commit9cacde74f7de702689725882633073e60c0a2baa (patch)
tree330d22dadbd28b14a7d8896823d1c33597e9993e /tests/auto/modeltest/tst_modeltest.cpp
parent006c8e22075112eff6230d8168d716e44a9e29d5 (diff)
parent2c07b5d2cba8d8e499bd0861eefef12d4e00d99a (diff)
Merge remote-tracking branch 'qt/4.8'
Conflicts: doc/src/examples/wheel.qdoc src/gui/util/qflickgesture.cpp src/gui/util/qflickgesture_p.h src/gui/util/qscroller.cpp src/gui/util/qscroller.h src/gui/util/qscroller_p.h src/gui/util/qscrollerproperties.cpp src/gui/util/qscrollerproperties.h tests/auto/qscroller/tst_qscroller.cpp
Diffstat (limited to 'tests/auto/modeltest/tst_modeltest.cpp')
-rw-r--r--tests/auto/modeltest/tst_modeltest.cpp52
1 files changed, 42 insertions, 10 deletions
diff --git a/tests/auto/modeltest/tst_modeltest.cpp b/tests/auto/modeltest/tst_modeltest.cpp
index cfaf210523..aba0894c30 100644
--- a/tests/auto/modeltest/tst_modeltest.cpp
+++ b/tests/auto/modeltest/tst_modeltest.cpp
@@ -201,8 +201,10 @@ class ObservingObject : public QObject
Q_OBJECT
public:
ObservingObject(AccessibleProxyModel *proxy, QObject *parent = 0)
- : QObject(parent),
- m_proxy(proxy)
+ : QObject(parent)
+ , m_proxy(proxy)
+ , storePersistentFailureCount(0)
+ , checkPersistentFailureCount(0)
{
connect(m_proxy, SIGNAL(layoutAboutToBeChanged()), SLOT(storePersistent()));
connect(m_proxy, SIGNAL(layoutChanged()), SLOT(checkPersistent()));
@@ -215,8 +217,14 @@ public slots:
for (int row = 0; row < m_proxy->rowCount(parent); ++row) {
QModelIndex proxyIndex = m_proxy->index(row, 0, parent);
QModelIndex sourceIndex = m_proxy->mapToSource(proxyIndex);
- Q_ASSERT(proxyIndex.isValid());
- Q_ASSERT(sourceIndex.isValid());
+ if (!proxyIndex.isValid()) {
+ qWarning("%s: Invalid proxy index", Q_FUNC_INFO);
+ ++storePersistentFailureCount;
+ }
+ if (!sourceIndex.isValid()) {
+ qWarning("%s: invalid source index", Q_FUNC_INFO);
+ ++storePersistentFailureCount;
+ }
m_persistentSourceIndexes.append(sourceIndex);
m_persistentProxyIndexes.append(proxyIndex);
if (m_proxy->hasChildren(proxyIndex))
@@ -226,12 +234,24 @@ public slots:
void storePersistent()
{
- foreach(const QModelIndex &idx, m_persistentProxyIndexes)
- Q_ASSERT(idx.isValid()); // This is called from layoutAboutToBeChanged. Persistent indexes should be valid
-
- Q_ASSERT(m_proxy->persistent().isEmpty());
+ // This method is called from layoutAboutToBeChanged. Persistent indexes should be valid
+ foreach(const QModelIndex &idx, m_persistentProxyIndexes)
+ if (!idx.isValid()) {
+ qWarning("%s: persistentProxyIndexes contains invalid index", Q_FUNC_INFO);
+ ++storePersistentFailureCount;
+ }
+
+ if (!m_proxy->persistent().isEmpty()) {
+ qWarning("%s: proxy should have no persistent indexes when storePersistent called",
+ Q_FUNC_INFO);
+ ++storePersistentFailureCount;
+ }
storePersistent(QModelIndex());
- Q_ASSERT(!m_proxy->persistent().isEmpty());
+ if (m_proxy->persistent().isEmpty()) {
+ qWarning("%s: proxy should have persistent index after storePersistent called",
+ Q_FUNC_INFO);
+ ++storePersistentFailureCount;
+ }
}
void checkPersistent()
@@ -243,7 +263,10 @@ public slots:
for (int row = 0; row < m_persistentProxyIndexes.size(); ++row) {
QModelIndex updatedProxy = m_persistentProxyIndexes.at(row);
QModelIndex updatedSource = m_persistentSourceIndexes.at(row);
- QCOMPARE(m_proxy->mapToSource(updatedProxy), updatedSource);
+ if (m_proxy->mapToSource(updatedProxy) != updatedSource) {
+ qWarning("%s: check failed at row %d", Q_FUNC_INFO, row);
+ ++checkPersistentFailureCount;
+ }
}
m_persistentSourceIndexes.clear();
m_persistentProxyIndexes.clear();
@@ -253,6 +276,9 @@ private:
AccessibleProxyModel *m_proxy;
QList<QPersistentModelIndex> m_persistentSourceIndexes;
QList<QPersistentModelIndex> m_persistentProxyIndexes;
+public:
+ int storePersistentFailureCount;
+ int checkPersistentFailureCount;
};
void tst_ModelTest::moveSourceItems()
@@ -280,6 +306,9 @@ void tst_ModelTest::moveSourceItems()
moveCommand->setDestAncestors(QList<int>() << 1);
moveCommand->setDestRow(0);
moveCommand->doCommand();
+
+ QCOMPARE(observer.storePersistentFailureCount, 0);
+ QCOMPARE(observer.checkPersistentFailureCount, 0);
}
void tst_ModelTest::testResetThroughProxy()
@@ -302,6 +331,9 @@ void tst_ModelTest::testResetThroughProxy()
ModelResetCommand *resetCommand = new ModelResetCommand(model, this);
resetCommand->setNumCols(0);
resetCommand->doCommand();
+
+ QCOMPARE(observer.storePersistentFailureCount, 0);
+ QCOMPARE(observer.checkPersistentFailureCount, 0);
}