summaryrefslogtreecommitdiffstats
path: root/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp')
-rw-r--r--tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp23
1 files changed, 23 insertions, 0 deletions
diff --git a/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp b/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp
index 556602b523..5007983aa6 100644
--- a/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp
+++ b/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp
@@ -1577,11 +1577,34 @@ void tst_QComboBox::setModel()
QCOMPARE(box.currentIndex(), 0);
QVERIFY(box.model() != oldModel);
+ // set a new root index
+ QModelIndex rootModelIndex;
+ rootModelIndex = box.model()->index(0, 0);
+ QVERIFY(rootModelIndex.isValid());
+ box.setRootModelIndex(rootModelIndex);
+ QCOMPARE(box.rootModelIndex(), rootModelIndex);
+
+ // change the model, ensure that the root index gets reset
+ oldModel = box.model();
+ box.setModel(new QStandardItemModel(2, 1, &box));
+ QCOMPARE(box.currentIndex(), 0);
+ QVERIFY(box.model() != oldModel);
+ QVERIFY(box.rootModelIndex() != rootModelIndex);
+ QVERIFY(box.rootModelIndex() == QModelIndex());
+
// check that setting the very same model doesn't move the current item
box.setCurrentIndex(1);
QCOMPARE(box.currentIndex(), 1);
box.setModel(box.model());
QCOMPARE(box.currentIndex(), 1);
+
+ // check that setting the very same model doesn't move the root index
+ rootModelIndex = box.model()->index(0, 0);
+ QVERIFY(rootModelIndex.isValid());
+ box.setRootModelIndex(rootModelIndex);
+ QCOMPARE(box.rootModelIndex(), rootModelIndex);
+ box.setModel(box.model());
+ QCOMPARE(box.rootModelIndex(), rootModelIndex);
}
void tst_QComboBox::setCustomModelAndView()