diff options
author | Jason McDonald <jason.mcdonald@nokia.com> | 2011-12-22 17:16:48 +1000 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2011-12-28 04:48:11 +0100 |
commit | ea415e20607016651f3cef02dff109235d84eb4d (patch) | |
tree | 8c954afe7d078b0ca742a1f2249ccc5a9ddf1b82 /tests/auto/corelib/kernel/qitemmodel/tst_qitemmodel.cpp | |
parent | 1e7296f3f2e7346f52e8f70d4e531405a248aa8b (diff) |
Cleanup corelib autotests.
When using QSignalSpy, always verify that the signal spy is valid. This
will cause the test to give a meaningful failure when spying on a
non-existant signal. Without this change, tests that spy on a signal to
ensure that it is not emitted (i.e. by comparing the spy count to zero)
could pass erroneously if something went wrong when creating the signal
spy, as an invalid QSignalSpy will always return a count of zero.
Change-Id: I41f4a63d9f0de9190a86de237662dc96be802446
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Rohan McGovern <rohan.mcgovern@nokia.com>
Diffstat (limited to 'tests/auto/corelib/kernel/qitemmodel/tst_qitemmodel.cpp')
-rw-r--r-- | tests/auto/corelib/kernel/qitemmodel/tst_qitemmodel.cpp | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/tests/auto/corelib/kernel/qitemmodel/tst_qitemmodel.cpp b/tests/auto/corelib/kernel/qitemmodel/tst_qitemmodel.cpp index a4b1044cab..3f68379542 100644 --- a/tests/auto/corelib/kernel/qitemmodel/tst_qitemmodel.cpp +++ b/tests/auto/corelib/kernel/qitemmodel/tst_qitemmodel.cpp @@ -601,6 +601,7 @@ void tst_QItemModel::setData() QVERIFY(currentModel); qRegisterMetaType<QModelIndex>("QModelIndex"); QSignalSpy spy(currentModel, SIGNAL(dataChanged(const QModelIndex &, const QModelIndex &))); + QVERIFY(spy.isValid()); QCOMPARE(currentModel->setData(QModelIndex(), QVariant()), false); QCOMPARE(spy.count(), 0); @@ -662,6 +663,7 @@ void tst_QItemModel::setHeaderData() qRegisterMetaType<Qt::Orientation>("Qt::Orientation"); QSignalSpy spy(currentModel, SIGNAL(headerDataChanged( Qt::Orientation, int , int ))); + QVERIFY(spy.isValid()); QString text = "Index private pointers should always be the same"; int signalCount = 0; @@ -702,6 +704,7 @@ void tst_QItemModel::sort() QModelIndex index = currentModel->index(0, 0, topIndex); QVERIFY(index.isValid()); QSignalSpy spy(currentModel, SIGNAL(layoutChanged())); + QVERIFY(spy.isValid()); for (int i=-1; i < 10; ++i){ currentModel->sort(i); if (index != currentModel->index(0, 0, topIndex)){ @@ -846,6 +849,13 @@ void tst_QItemModel::remove() QSignalSpy modelResetSpy(currentModel, SIGNAL(modelReset())); QSignalSpy modelLayoutChangedSpy(currentModel, SIGNAL(layoutChanged())); + QVERIFY(columnsAboutToBeRemovedSpy.isValid()); + QVERIFY(rowsAboutToBeRemovedSpy.isValid()); + QVERIFY(columnsRemovedSpy.isValid()); + QVERIFY(rowsRemovedSpy.isValid()); + QVERIFY(modelResetSpy.isValid()); + QVERIFY(modelLayoutChangedSpy.isValid()); + QFETCH(int, numberOfRowsAboutToBeRemovedSignals); QFETCH(int, numberOfColumnsAboutToBeRemovedSignals); QFETCH(int, numberOfRowsRemovedSignals); @@ -1182,6 +1192,13 @@ void tst_QItemModel::insert() QSignalSpy modelResetSpy(currentModel, SIGNAL(modelReset())); QSignalSpy modelLayoutChangedSpy(currentModel, SIGNAL(layoutChanged())); + QVERIFY(columnsAboutToBeInsertedSpy.isValid()); + QVERIFY(rowsAboutToBeInsertedSpy.isValid()); + QVERIFY(columnsInsertedSpy.isValid()); + QVERIFY(rowsInsertedSpy.isValid()); + QVERIFY(modelResetSpy.isValid()); + QVERIFY(modelLayoutChangedSpy.isValid()); + QFETCH(int, numberOfRowsAboutToBeInsertedSignals); QFETCH(int, numberOfColumnsAboutToBeInsertedSignals); QFETCH(int, numberOfRowsInsertedSignals); |