summaryrefslogtreecommitdiffstats
path: root/tests/auto/qcombobox
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/qcombobox')
-rw-r--r--tests/auto/qcombobox/tst_qcombobox.cpp33
1 files changed, 33 insertions, 0 deletions
diff --git a/tests/auto/qcombobox/tst_qcombobox.cpp b/tests/auto/qcombobox/tst_qcombobox.cpp
index 0d3469d..8acae7a 100644
--- a/tests/auto/qcombobox/tst_qcombobox.cpp
+++ b/tests/auto/qcombobox/tst_qcombobox.cpp
@@ -152,6 +152,7 @@ private slots:
void subControlRectsWithOffset();
void task260974_menuItemRectangleForComboBoxPopup();
void removeItem();
+ void resetModel();
protected slots:
void onEditTextChanged( const QString &newString );
@@ -2416,5 +2417,37 @@ void tst_QComboBox::removeItem()
QCOMPARE(cb.count(), 0);
}
+void tst_QComboBox::resetModel()
+{
+ class StringListModel : public QStringListModel
+ {
+ public:
+ StringListModel(const QStringList &list) : QStringListModel(list)
+ {
+ }
+
+ void reset()
+ {
+ QStringListModel::reset();
+ }
+ };
+ QComboBox cb;
+ StringListModel model( QStringList() << "1" << "2");
+ QSignalSpy spy(&cb, SIGNAL(currentIndexChanged(int)));
+ QCOMPARE(spy.count(), 0);
+ QCOMPARE(cb.currentIndex(), -1); //no selection
+
+ cb.setModel(&model);
+
+ QCOMPARE(spy.count(), 1);
+ QCOMPARE(cb.currentIndex(), 0); //first item selected
+
+ model.reset();
+ QCOMPARE(spy.count(), 2);
+ QCOMPARE(cb.currentIndex(), -1); //no selection
+
+}
+
+
QTEST_MAIN(tst_QComboBox)
#include "tst_qcombobox.moc"