summaryrefslogtreecommitdiffstats
path: root/tests/auto/corelib/itemmodels
diff options
context:
space:
mode:
authorJason McDonald <jason.mcdonald@nokia.com>2011-12-22 17:16:48 +1000
committerQt by Nokia <qt-info@nokia.com>2011-12-28 04:48:11 +0100
commitea415e20607016651f3cef02dff109235d84eb4d (patch)
tree8c954afe7d078b0ca742a1f2249ccc5a9ddf1b82 /tests/auto/corelib/itemmodels
parent1e7296f3f2e7346f52e8f70d4e531405a248aa8b (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/itemmodels')
-rw-r--r--tests/auto/corelib/itemmodels/qabstractitemmodel/tst_qabstractitemmodel.cpp44
-rw-r--r--tests/auto/corelib/itemmodels/qidentityproxymodel/tst_qidentityproxymodel.cpp20
-rw-r--r--tests/auto/corelib/itemmodels/qitemselectionmodel/tst_qitemselectionmodel.cpp10
-rw-r--r--tests/auto/corelib/itemmodels/qsortfilterproxymodel/tst_qsortfilterproxymodel.cpp51
4 files changed, 125 insertions, 0 deletions
diff --git a/tests/auto/corelib/itemmodels/qabstractitemmodel/tst_qabstractitemmodel.cpp b/tests/auto/corelib/itemmodels/qabstractitemmodel/tst_qabstractitemmodel.cpp
index 199d96c0d1..5028728fd6 100644
--- a/tests/auto/corelib/itemmodels/qabstractitemmodel/tst_qabstractitemmodel.cpp
+++ b/tests/auto/corelib/itemmodels/qabstractitemmodel/tst_qabstractitemmodel.cpp
@@ -720,6 +720,9 @@ void tst_QAbstractItemModel::removeRows()
QSignalSpy rowsAboutToBeRemovedSpy(&model, SIGNAL(rowsAboutToBeRemoved( const QModelIndex &, int , int )));
QSignalSpy rowsRemovedSpy(&model, SIGNAL(rowsRemoved( const QModelIndex &, int, int )));
+ QVERIFY(rowsAboutToBeRemovedSpy.isValid());
+ QVERIFY(rowsRemovedSpy.isValid());
+
QCOMPARE(model.removeRows(6, 4), true);
QCOMPARE(rowsAboutToBeRemovedSpy.count(), 1);
QCOMPARE(rowsRemovedSpy.count(), 1);
@@ -732,6 +735,9 @@ void tst_QAbstractItemModel::removeColumns()
QSignalSpy columnsAboutToBeRemovedSpy(&model, SIGNAL(columnsAboutToBeRemoved( const QModelIndex &, int , int )));
QSignalSpy columnsRemovedSpy(&model, SIGNAL(columnsRemoved( const QModelIndex &, int, int )));
+ QVERIFY(columnsAboutToBeRemovedSpy.isValid());
+ QVERIFY(columnsRemovedSpy.isValid());
+
QCOMPARE(model.removeColumns(6, 4), true);
QCOMPARE(columnsAboutToBeRemovedSpy.count(), 1);
QCOMPARE(columnsRemovedSpy.count(), 1);
@@ -744,6 +750,9 @@ void tst_QAbstractItemModel::insertRows()
QSignalSpy rowsAboutToBeInsertedSpy(&model, SIGNAL(rowsAboutToBeInserted( const QModelIndex &, int , int )));
QSignalSpy rowsInsertedSpy(&model, SIGNAL(rowsInserted( const QModelIndex &, int, int )));
+ QVERIFY(rowsAboutToBeInsertedSpy.isValid());
+ QVERIFY(rowsInsertedSpy.isValid());
+
QCOMPARE(model.insertRows(6, 4), true);
QCOMPARE(rowsAboutToBeInsertedSpy.count(), 1);
QCOMPARE(rowsInsertedSpy.count(), 1);
@@ -756,6 +765,9 @@ void tst_QAbstractItemModel::insertColumns()
QSignalSpy columnsAboutToBeInsertedSpy(&model, SIGNAL(columnsAboutToBeInserted( const QModelIndex &, int , int )));
QSignalSpy columnsInsertedSpy(&model, SIGNAL(columnsInserted( const QModelIndex &, int, int )));
+ QVERIFY(columnsAboutToBeInsertedSpy.isValid());
+ QVERIFY(columnsInsertedSpy.isValid());
+
QCOMPARE(model.insertColumns(6, 4), true);
QCOMPARE(columnsAboutToBeInsertedSpy.count(), 1);
QCOMPARE(columnsInsertedSpy.count(), 1);
@@ -766,6 +778,7 @@ void tst_QAbstractItemModel::reset()
QtTestModel model(10, 10);
QSignalSpy resetSpy(&model, SIGNAL(modelReset()));
+ QVERIFY(resetSpy.isValid());
model.reset();
QCOMPARE(resetSpy.count(), 1);
}
@@ -894,6 +907,9 @@ void tst_QAbstractItemModel::testMoveSameParentDown()
QSignalSpy beforeSpy(m_model, SIGNAL(rowsAboutToBeMoved(const QModelIndex &, int, int, const QModelIndex &, int)));
QSignalSpy afterSpy(m_model, SIGNAL(rowsMoved(const QModelIndex &, int, int, const QModelIndex &, int)));
+ QVERIFY(beforeSpy.isValid());
+ QVERIFY(afterSpy.isValid());
+
ModelMoveCommand *moveCommand = new ModelMoveCommand(m_model, this);
moveCommand->setNumCols(4);
if (!topLevel)
@@ -1019,6 +1035,8 @@ void tst_QAbstractItemModel::testMoveSameParentUp()
QSignalSpy beforeSpy(m_model, SIGNAL(rowsAboutToBeMoved(const QModelIndex &, int, int, const QModelIndex &, int)));
QSignalSpy afterSpy(m_model, SIGNAL(rowsMoved(const QModelIndex &, int, int, const QModelIndex &, int)));
+ QVERIFY(beforeSpy.isValid());
+ QVERIFY(afterSpy.isValid());
ModelMoveCommand *moveCommand = new ModelMoveCommand(m_model, this);
moveCommand->setNumCols(4);
@@ -1180,6 +1198,9 @@ void tst_QAbstractItemModel::testMoveToGrandParent()
QSignalSpy beforeSpy(m_model, SIGNAL(rowsAboutToBeMoved(const QModelIndex &, int, int, const QModelIndex &, int)));
QSignalSpy afterSpy(m_model, SIGNAL(rowsMoved(const QModelIndex &, int, int, const QModelIndex &, int)));
+ QVERIFY(beforeSpy.isValid());
+ QVERIFY(afterSpy.isValid());
+
QPersistentModelIndex persistentSource = sourceIndex;
ModelMoveCommand *moveCommand = new ModelMoveCommand(m_model, this);
@@ -1329,6 +1350,9 @@ void tst_QAbstractItemModel::testMoveToSibling()
QSignalSpy beforeSpy(m_model, SIGNAL(rowsAboutToBeMoved(const QModelIndex &, int, int, const QModelIndex &, int)));
QSignalSpy afterSpy(m_model, SIGNAL(rowsMoved(const QModelIndex &, int, int, const QModelIndex &, int)));
+ QVERIFY(beforeSpy.isValid());
+ QVERIFY(afterSpy.isValid());
+
QPersistentModelIndex persistentDest = destIndex;
ModelMoveCommand *moveCommand = new ModelMoveCommand(m_model, this);
@@ -1489,6 +1513,9 @@ void tst_QAbstractItemModel::testMoveToUncle()
QSignalSpy beforeSpy(m_model, SIGNAL(rowsAboutToBeMoved(const QModelIndex &, int, int, const QModelIndex &, int)));
QSignalSpy afterSpy(m_model, SIGNAL(rowsMoved(const QModelIndex &, int, int, const QModelIndex &, int)));
+ QVERIFY(beforeSpy.isValid());
+ QVERIFY(afterSpy.isValid());
+
ModelMoveCommand *moveCommand = new ModelMoveCommand(m_model, this);
moveCommand->setAncestorRowNumbers(QList<int>() << 9);
moveCommand->setNumCols(4);
@@ -1604,6 +1631,9 @@ void tst_QAbstractItemModel::testMoveToDescendants()
QSignalSpy beforeSpy(m_model, SIGNAL(rowsAboutToBeMoved(const QModelIndex &, int, int, const QModelIndex &, int)));
QSignalSpy afterSpy(m_model, SIGNAL(rowsMoved(const QModelIndex &, int, int, const QModelIndex &, int)));
+ QVERIFY(beforeSpy.isValid());
+ QVERIFY(afterSpy.isValid());
+
ModelMoveCommand *moveCommand;
QList<int> ancestors;
while (ancestors.size() < depth)
@@ -1670,6 +1700,9 @@ void tst_QAbstractItemModel::testMoveWithinOwnRange()
QSignalSpy beforeSpy(m_model, SIGNAL(rowsAboutToBeMoved(const QModelIndex &, int, int, const QModelIndex &, int)));
QSignalSpy afterSpy(m_model, SIGNAL(rowsMoved(const QModelIndex &, int, int, const QModelIndex &, int)));
+ QVERIFY(beforeSpy.isValid());
+ QVERIFY(afterSpy.isValid());
+
ModelMoveCommand *moveCommand = new ModelMoveCommand(m_model, this);
moveCommand->setNumCols(4);
moveCommand->setStartRow(startRow);
@@ -1755,6 +1788,8 @@ void tst_QAbstractItemModel::testReset()
QSignalSpy beforeResetSpy(m_model, SIGNAL(modelAboutToBeReset()));
QSignalSpy afterResetSpy(m_model, SIGNAL(modelReset()));
+ QVERIFY(beforeResetSpy.isValid());
+ QVERIFY(afterResetSpy.isValid());
QSortFilterProxyModel *nullProxy = new QSortFilterProxyModel(this);
nullProxy->setSourceModel(m_model);
@@ -1821,6 +1856,9 @@ void tst_QAbstractItemModel::testDataChanged()
QSignalSpy withRoles(&model, SIGNAL(dataChanged(QModelIndex,QModelIndex,QSet<int>)));
QSignalSpy withoutRoles(&model, SIGNAL(dataChanged(QModelIndex,QModelIndex)));
+ QVERIFY(withRoles.isValid());
+ QVERIFY(withoutRoles.isValid());
+
model.emitSignals();
QCOMPARE(withRoles.size(), withoutRoles.size());
@@ -1920,6 +1958,9 @@ void tst_QAbstractItemModel::testChildrenLayoutsChanged()
QSignalSpy beforeSpy(&model, SIGNAL(layoutAboutToBeChanged(QList<QPersistentModelIndex>)));
QSignalSpy afterSpy(&model, SIGNAL(layoutChanged(QList<QPersistentModelIndex>)));
+ QVERIFY(beforeSpy.isValid());
+ QVERIFY(afterSpy.isValid());
+
ModelChangeChildrenLayoutsCommand *changeCommand = new ModelChangeChildrenLayoutsCommand(&model, this);
changeCommand->setAncestorRowNumbers(QList<int>() << 2);
changeCommand->setSecondAncestorRowNumbers(QList<int>() << 5);
@@ -1984,6 +2025,9 @@ void tst_QAbstractItemModel::testChildrenLayoutsChanged()
QSignalSpy beforeSpy(&model, SIGNAL(layoutAboutToBeChanged(QList<QPersistentModelIndex>)));
QSignalSpy afterSpy(&model, SIGNAL(layoutChanged(QList<QPersistentModelIndex>)));
+ QVERIFY(beforeSpy.isValid());
+ QVERIFY(afterSpy.isValid());
+
// Because the arguments in the signal are persistent, we need to check them for the aboutToBe
// case at emission time - before they get updated.
SignalArgumentChecker checker(p1, p2);
diff --git a/tests/auto/corelib/itemmodels/qidentityproxymodel/tst_qidentityproxymodel.cpp b/tests/auto/corelib/itemmodels/qidentityproxymodel/tst_qidentityproxymodel.cpp
index 86ff00f9d4..2eb17c0305 100644
--- a/tests/auto/corelib/itemmodels/qidentityproxymodel/tst_qidentityproxymodel.cpp
+++ b/tests/auto/corelib/itemmodels/qidentityproxymodel/tst_qidentityproxymodel.cpp
@@ -169,6 +169,11 @@ void tst_QIdentityProxyModel::insertRows()
QSignalSpy proxyBeforeSpy(m_proxy, SIGNAL(rowsAboutToBeInserted(QModelIndex,int,int)));
QSignalSpy proxyAfterSpy(m_proxy, SIGNAL(rowsInserted(QModelIndex,int,int)));
+ QVERIFY(modelBeforeSpy.isValid());
+ QVERIFY(modelAfterSpy.isValid());
+ QVERIFY(proxyBeforeSpy.isValid());
+ QVERIFY(proxyAfterSpy.isValid());
+
QStandardItem *item = new QStandardItem(QString("new item"));
parentItem->appendRow(item);
@@ -205,6 +210,11 @@ void tst_QIdentityProxyModel::removeRows()
QSignalSpy proxyBeforeSpy(m_proxy, SIGNAL(rowsAboutToBeRemoved(QModelIndex,int,int)));
QSignalSpy proxyAfterSpy(m_proxy, SIGNAL(rowsRemoved(QModelIndex,int,int)));
+ QVERIFY(modelBeforeSpy.isValid());
+ QVERIFY(modelAfterSpy.isValid());
+ QVERIFY(proxyBeforeSpy.isValid());
+ QVERIFY(proxyAfterSpy.isValid());
+
const QModelIndex topLevel = m_model->index(0, 0, QModelIndex());
const QModelIndex secondLevel = m_model->index(0, 0, topLevel);
const QModelIndex thirdLevel = m_model->index(0, 0, secondLevel);
@@ -254,6 +264,11 @@ void tst_QIdentityProxyModel::moveRows()
QSignalSpy proxyBeforeSpy(m_proxy, SIGNAL(rowsAboutToBeMoved(QModelIndex,int,int,QModelIndex,int)));
QSignalSpy proxyAfterSpy(m_proxy, SIGNAL(rowsMoved(QModelIndex,int,int,QModelIndex,int)));
+ QVERIFY(modelBeforeSpy.isValid());
+ QVERIFY(modelAfterSpy.isValid());
+ QVERIFY(proxyBeforeSpy.isValid());
+ QVERIFY(proxyAfterSpy.isValid());
+
{
ModelMoveCommand moveCommand(&model, 0);
moveCommand.setAncestorRowNumbers(QList<int>() << 5);
@@ -310,6 +325,11 @@ void tst_QIdentityProxyModel::reset()
QSignalSpy proxyBeforeSpy(m_proxy, SIGNAL(modelAboutToBeReset()));
QSignalSpy proxyAfterSpy(m_proxy, SIGNAL(modelReset()));
+ QVERIFY(modelBeforeSpy.isValid());
+ QVERIFY(modelAfterSpy.isValid());
+ QVERIFY(proxyBeforeSpy.isValid());
+ QVERIFY(proxyAfterSpy.isValid());
+
{
ModelResetCommandFixed resetCommand(&model, 0);
resetCommand.setAncestorRowNumbers(QList<int>() << 5);
diff --git a/tests/auto/corelib/itemmodels/qitemselectionmodel/tst_qitemselectionmodel.cpp b/tests/auto/corelib/itemmodels/qitemselectionmodel/tst_qitemselectionmodel.cpp
index 2097cb31ee..dedcd0f4b1 100644
--- a/tests/auto/corelib/itemmodels/qitemselectionmodel/tst_qitemselectionmodel.cpp
+++ b/tests/auto/corelib/itemmodels/qitemselectionmodel/tst_qitemselectionmodel.cpp
@@ -1550,6 +1550,7 @@ void tst_QItemSelectionModel::resetModel()
view.setModel(&model);
QSignalSpy spy(view.selectionModel(), SIGNAL(selectionChanged(QItemSelection,QItemSelection)));
+ QVERIFY(spy.isValid());
view.selectionModel()->select(QItemSelection(model.index(0, 0), model.index(5, 5)), QItemSelectionModel::Select);
@@ -1612,6 +1613,7 @@ void tst_QItemSelectionModel::removeRows()
MyStandardItemModel model(rowCount, columnCount);
QItemSelectionModel selections(&model);
QSignalSpy spy(&selections, SIGNAL(selectionChanged(QItemSelection,QItemSelection)));
+ QVERIFY(spy.isValid());
QModelIndex tl = model.index(selectTop, selectLeft);
QModelIndex br = model.index(selectBottom, selectRight);
@@ -1674,6 +1676,7 @@ void tst_QItemSelectionModel::removeColumns()
MyStandardItemModel model(rowCount, columnCount);
QItemSelectionModel selections(&model);
QSignalSpy spy(&selections, SIGNAL(selectionChanged(QItemSelection,QItemSelection)));
+ QVERIFY(spy.isValid());
QModelIndex tl = model.index(selectTop, selectLeft);
QModelIndex br = model.index(selectBottom, selectRight);
@@ -1943,6 +1946,10 @@ void tst_QItemSelectionModel::setCurrentIndex()
QSignalSpy columnSpy(selectionModel,
SIGNAL(currentColumnChanged(QModelIndex,QModelIndex)));
+ QVERIFY(currentSpy.isValid());
+ QVERIFY(rowSpy.isValid());
+ QVERIFY(columnSpy.isValid());
+
// Select the same row and column indexes, but with a different parent
selectionModel->setCurrentIndex(
treemodel->index(0, 0, treemodel->index(1, 0)),
@@ -2217,6 +2224,7 @@ void tst_QItemSelectionModel::task232634_childrenDeselectionSignal()
selectionModel.select(sel, QItemSelectionModel::SelectCurrent);
QSignalSpy deselectSpy(&selectionModel, SIGNAL(selectionChanged(const QItemSelection& , const QItemSelection&)));
+ QVERIFY(deselectSpy.isValid());
model.removeRows(0, 1, root);
QVERIFY(deselectSpy.count() == 1);
@@ -2401,6 +2409,7 @@ void tst_QItemSelectionModel::deselectRemovedMiddleRange()
RemovalObserver ro(&selModel);
QSignalSpy spy(&selModel, SIGNAL(selectionChanged(QItemSelection, QItemSelection)));
+ QVERIFY(spy.isValid());
bool ok = model.removeRows(4, 2);
QVERIFY(ok);
@@ -2735,6 +2744,7 @@ void tst_QItemSelectionModel::testClearCurrentIndex()
QItemSelectionModel selectionModel(&model, 0);
QSignalSpy currentIndexSpy(&selectionModel, SIGNAL(currentChanged(QModelIndex,QModelIndex)));
+ QVERIFY(currentIndexSpy.isValid());
QModelIndex firstIndex = model.index(0, 0);
QVERIFY(firstIndex.isValid());
diff --git a/tests/auto/corelib/itemmodels/qsortfilterproxymodel/tst_qsortfilterproxymodel.cpp b/tests/auto/corelib/itemmodels/qsortfilterproxymodel/tst_qsortfilterproxymodel.cpp
index cc8299e28f..6d3e8906c9 100644
--- a/tests/auto/corelib/itemmodels/qsortfilterproxymodel/tst_qsortfilterproxymodel.cpp
+++ b/tests/auto/corelib/itemmodels/qsortfilterproxymodel/tst_qsortfilterproxymodel.cpp
@@ -1504,6 +1504,7 @@ void tst_QSortFilterProxyModel::filterCurrent()
view.show();
view.setModel(&proxy);
QSignalSpy spy(view.selectionModel(), SIGNAL(currentChanged(QModelIndex, QModelIndex)));
+ QVERIFY(spy.isValid());
view.setCurrentIndex(proxy.index(0, 0));
QCOMPARE(spy.count(), 1);
@@ -1628,6 +1629,11 @@ void tst_QSortFilterProxyModel::removeSourceRows()
QSignalSpy aboutToRemoveSpy(&proxy, SIGNAL(rowsAboutToBeRemoved(QModelIndex, int, int)));
QSignalSpy aboutToInsertSpy(&proxy, SIGNAL(rowsAboutToBeInserted(QModelIndex, int, int)));
+ QVERIFY(removeSpy.isValid());
+ QVERIFY(insertSpy.isValid());
+ QVERIFY(aboutToRemoveSpy.isValid());
+ QVERIFY(aboutToInsertSpy.isValid());
+
model.removeRows(start, count, QModelIndex());
QCOMPARE(aboutToRemoveSpy.count(), expectedRemovedProxyIntervals.count());
@@ -1802,6 +1808,9 @@ void tst_QSortFilterProxyModel::changeFilter()
QSignalSpy initialRemoveSpy(&proxy, SIGNAL(rowsRemoved(QModelIndex, int, int)));
QSignalSpy initialInsertSpy(&proxy, SIGNAL(rowsInserted(QModelIndex, int, int)));
+ QVERIFY(initialRemoveSpy.isValid());
+ QVERIFY(initialInsertSpy.isValid());
+
proxy.setFilterRegExp(initialFilter);
QCOMPARE(initialRemoveSpy.count(), initialRemoveIntervals.count());
@@ -1823,6 +1832,9 @@ void tst_QSortFilterProxyModel::changeFilter()
QSignalSpy finalRemoveSpy(&proxy, SIGNAL(rowsRemoved(QModelIndex, int, int)));
QSignalSpy finalInsertSpy(&proxy, SIGNAL(rowsInserted(QModelIndex, int, int)));
+ QVERIFY(finalRemoveSpy.isValid());
+ QVERIFY(finalInsertSpy.isValid());
+
proxy.setFilterRegExp(finalFilter);
QCOMPARE(finalRemoveSpy.count(), finalRemoveIntervals.count());
@@ -1971,6 +1983,9 @@ void tst_QSortFilterProxyModel::changeSourceData()
QSignalSpy removeSpy(&proxy, SIGNAL(rowsRemoved(QModelIndex, int, int)));
QSignalSpy insertSpy(&proxy, SIGNAL(rowsInserted(QModelIndex, int, int)));
+ QVERIFY(removeSpy.isValid());
+ QVERIFY(insertSpy.isValid());
+
{
QModelIndex index = model.index(row, 0, QModelIndex());
model.setData(index, newValue, Qt::DisplayRole);
@@ -2065,6 +2080,7 @@ void tst_QSortFilterProxyModel::selectionFilteredOut()
view.show();
view.setModel(&proxy);
QSignalSpy spy(view.selectionModel(), SIGNAL(currentChanged(QModelIndex, QModelIndex)));
+ QVERIFY(spy.isValid());
view.setCurrentIndex(proxy.index(0, 0));
QCOMPARE(spy.count(), 1);
@@ -2181,6 +2197,9 @@ void tst_QSortFilterProxyModel::insertIntoChildrenlessItem()
QSignalSpy colsInsertedSpy(&proxy, SIGNAL(columnsInserted(const QModelIndex&, int, int)));
QSignalSpy rowsInsertedSpy(&proxy, SIGNAL(rowsInserted(const QModelIndex&, int, int)));
+ QVERIFY(colsInsertedSpy.isValid());
+ QVERIFY(rowsInsertedSpy.isValid());
+
(void)proxy.rowCount(QModelIndex()); // force mapping of "a", "b", "c"
QCOMPARE(colsInsertedSpy.count(), 0);
QCOMPARE(rowsInsertedSpy.count(), 0);
@@ -2256,6 +2275,7 @@ void tst_QSortFilterProxyModel::insertRowIntoFilteredParent()
proxy.setSourceModel(&model);
QSignalSpy spy(&proxy, SIGNAL(rowsInserted(const QModelIndex&, int, int)));
+ QVERIFY(spy.isValid());
QStandardItem *itemA = new QStandardItem();
model.appendRow(itemA); // A will be filtered
@@ -2286,6 +2306,9 @@ void tst_QSortFilterProxyModel::filterOutParentAndFilterInChild()
QSignalSpy removedSpy(&proxy, SIGNAL(rowsRemoved(const QModelIndex&, int, int)));
QSignalSpy insertedSpy(&proxy, SIGNAL(rowsInserted(const QModelIndex&, int, int)));
+ QVERIFY(removedSpy.isValid());
+ QVERIFY(insertedSpy.isValid());
+
proxy.setFilterRegExp("C"); // A and B will be filtered out, C filtered in
// we should now have been notified that the subtree represented by itemA has been removed
@@ -2882,6 +2905,9 @@ void tst_QSortFilterProxyModel::taskQTBUG_7537_appearsAndSort()
QSignalSpy spyAbout1(&proxyModel, SIGNAL(layoutAboutToBeChanged()));
QSignalSpy spyChanged1(&proxyModel, SIGNAL(layoutChanged()));
+ QVERIFY(spyAbout1.isValid());
+ QVERIFY(spyChanged1.isValid());
+
//introducing secondProxyModel to test the layoutChange when many items appears at once
QSortFilterProxyModel secondProxyModel;
secondProxyModel.setSourceModel(&proxyModel);
@@ -2891,6 +2917,9 @@ void tst_QSortFilterProxyModel::taskQTBUG_7537_appearsAndSort()
QSignalSpy spyAbout2(&secondProxyModel, SIGNAL(layoutAboutToBeChanged()));
QSignalSpy spyChanged2(&secondProxyModel, SIGNAL(layoutChanged()));
+ QVERIFY(spyAbout2.isValid());
+ QVERIFY(spyChanged2.isValid());
+
proxyModel.updateXX();
QApplication::processEvents();
//now rows should be visible, and sorted
@@ -3248,16 +3277,27 @@ void tst_QSortFilterProxyModel::testParentLayoutChanged()
QSignalSpy dataChangedSpy(&model, SIGNAL(dataChanged(QModelIndex,QModelIndex)));
+ QVERIFY(dataChangedSpy.isValid());
+
// Verify that the no-arg signal is still emitted.
QSignalSpy layoutAboutToBeChangedSpy(&proxy, SIGNAL(layoutAboutToBeChanged()));
QSignalSpy layoutChangedSpy(&proxy, SIGNAL(layoutChanged()));
+ QVERIFY(layoutAboutToBeChangedSpy.isValid());
+ QVERIFY(layoutChangedSpy.isValid());
+
QSignalSpy parentsAboutToBeChangedSpy(&proxy, SIGNAL(layoutAboutToBeChanged(QList<QPersistentModelIndex>)));
QSignalSpy parentsChangedSpy(&proxy, SIGNAL(layoutChanged(QList<QPersistentModelIndex>)));
+ QVERIFY(parentsAboutToBeChangedSpy.isValid());
+ QVERIFY(parentsChangedSpy.isValid());
+
QSignalSpy proxy2ParentsAboutToBeChangedSpy(&proxy2, SIGNAL(layoutAboutToBeChanged(QList<QPersistentModelIndex>)));
QSignalSpy proxy2ParentsChangedSpy(&proxy2, SIGNAL(layoutChanged(QList<QPersistentModelIndex>)));
+ QVERIFY(proxy2ParentsAboutToBeChangedSpy.isValid());
+ QVERIFY(proxy2ParentsChangedSpy.isValid());
+
QStandardItem *item = model.invisibleRootItem()->child(1)->child(1);
// Ensure mapped:
@@ -3426,6 +3466,17 @@ void tst_QSortFilterProxyModel::moveSourceRows()
QSignalSpy filterBothBeforeParentLayoutSpy(&filterBothProxy, SIGNAL(layoutAboutToBeChanged(QList<QPersistentModelIndex>)));
QSignalSpy filterBothAfterParentLayoutSpy(&filterBothProxy, SIGNAL(layoutChanged(QList<QPersistentModelIndex>)));
+ QVERIFY(modelBeforeSpy.isValid());
+ QVERIFY(modelAfterSpy.isValid());
+ QVERIFY(proxyBeforeMoveSpy.isValid());
+ QVERIFY(proxyAfterMoveSpy.isValid());
+ QVERIFY(proxyBeforeParentLayoutSpy.isValid());
+ QVERIFY(proxyAfterParentLayoutSpy.isValid());
+ QVERIFY(filterBeforeParentLayoutSpy.isValid());
+ QVERIFY(filterAfterParentLayoutSpy.isValid());
+ QVERIFY(filterBothBeforeParentLayoutSpy.isValid());
+ QVERIFY(filterBothAfterParentLayoutSpy.isValid());
+
{
ModelMoveCommand moveCommand(&model, 0);
moveCommand.setAncestorRowNumbers(QList<int>() << 2);