summaryrefslogtreecommitdiffstats
path: root/tests/auto
diff options
context:
space:
mode:
authorGabriel de Dietrich <gabriel.dietrich-de@nokia.com>2009-08-10 18:46:16 (GMT)
committerGabriel de Dietrich <gabriel.dietrich-de@nokia.com>2009-08-10 18:52:11 (GMT)
commit36c93eca351218ce43a0c6346209d364737b6b84 (patch)
treee07eaca509e13e6128036dc38af6c82029f61754 /tests/auto
parentdd9d869300d34725bc480d827f91b3103c84f045 (diff)
downloadQt-36c93eca351218ce43a0c6346209d364737b6b84.zip
Qt-36c93eca351218ce43a0c6346209d364737b6b84.tar.gz
Qt-36c93eca351218ce43a0c6346209d364737b6b84.tar.bz2
Better implementation for commit d13418effc5f00474541ae513a30c9a42c2a1cb3. The
previous version could run in an endless loop with infinite models. Reviewed-by: olivier
Diffstat (limited to 'tests/auto')
-rw-r--r--tests/auto/qitemselectionmodel/tst_qitemselectionmodel.cpp30
1 files changed, 30 insertions, 0 deletions
diff --git a/tests/auto/qitemselectionmodel/tst_qitemselectionmodel.cpp b/tests/auto/qitemselectionmodel/tst_qitemselectionmodel.cpp
index 05e23f1..ec21f79 100644
--- a/tests/auto/qitemselectionmodel/tst_qitemselectionmodel.cpp
+++ b/tests/auto/qitemselectionmodel/tst_qitemselectionmodel.cpp
@@ -2209,6 +2209,36 @@ void tst_QItemSelectionModel::task232634_childrenDeselectionSignal()
QSignalSpy deselectSpy(&selectionModel, SIGNAL(selectionChanged(const QItemSelection& , const QItemSelection&)));
model.removeRows(0, 1, root);
QVERIFY(deselectSpy.count() == 1);
+
+ // More testing stress for the patch.
+ model.clear();
+ selectionModel.clear();
+
+ parentItem = model.invisibleRootItem();
+ for (int i = 0; i < 2; ++i) {
+ QStandardItem *item = new QStandardItem(QString("item %0").arg(i));
+ parentItem->appendRow(item);
+ }
+ for (int i = 0; i < 2; ++i) {
+ parentItem = model.invisibleRootItem()->child(i, 0);
+ for (int j = 0; j < 2; ++j) {
+ QStandardItem *item = new QStandardItem(QString("item %0.%1").arg(i).arg(j));
+ parentItem->appendRow(item);
+ }
+ }
+
+ sel = model.index(0, 0).child(0, 0);
+ selectionModel.select(sel, QItemSelectionModel::Select);
+ QModelIndex sel2 = model.index(1, 0).child(0, 0);
+ selectionModel.select(sel2, QItemSelectionModel::Select);
+
+ QVERIFY(selectionModel.selection().contains(sel));
+ QVERIFY(selectionModel.selection().contains(sel2));
+ deselectSpy.clear();
+ model.removeRow(0, model.index(0, 0));
+ QVERIFY(deselectSpy.count() == 1);
+ QVERIFY(!selectionModel.selection().contains(sel));
+ QVERIFY(selectionModel.selection().contains(sel2));
}
QTEST_MAIN(tst_QItemSelectionModel)