summaryrefslogtreecommitdiffstats
path: root/tests/auto/qcombobox
diff options
context:
space:
mode:
authorThierry Bastian <thierry.bastian@nokia.com>2009-10-27 15:18:59 +0100
committerThierry Bastian <thierry.bastian@nokia.com>2009-10-27 15:20:05 +0100
commitc79d83b6d661ea49d893b4590480a434d75b19bd (patch)
treece3a7ca4528080f7ff6d7ffdb9f4c86083a90d99 /tests/auto/qcombobox
parent8f040ea4da93f1b9cae1db560e5e9f9b3140b3ff (diff)
QComboBox did not emit currentItemChanged when the model was reset
Task-number: QTBUG-569 Reviewed-by: ogoffart
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 0d3469daeb..8acae7af09 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"