diff options
author | Thierry Bastian <thierry.bastian@nokia.com> | 2009-10-27 14:18:59 (GMT) |
---|---|---|
committer | Thierry Bastian <thierry.bastian@nokia.com> | 2009-10-27 14:20:05 (GMT) |
commit | c79d83b6d661ea49d893b4590480a434d75b19bd (patch) | |
tree | ce3a7ca4528080f7ff6d7ffdb9f4c86083a90d99 /tests/auto | |
parent | 8f040ea4da93f1b9cae1db560e5e9f9b3140b3ff (diff) | |
download | Qt-c79d83b6d661ea49d893b4590480a434d75b19bd.zip Qt-c79d83b6d661ea49d893b4590480a434d75b19bd.tar.gz Qt-c79d83b6d661ea49d893b4590480a434d75b19bd.tar.bz2 |
QComboBox did not emit currentItemChanged when the model was reset
Task-number: QTBUG-569
Reviewed-by: ogoffart
Diffstat (limited to 'tests/auto')
-rw-r--r-- | tests/auto/qcombobox/tst_qcombobox.cpp | 33 |
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" |