diff options
Diffstat (limited to 'tests/auto/qcombobox')
-rw-r--r-- | tests/auto/qcombobox/tst_qcombobox.cpp | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/tests/auto/qcombobox/tst_qcombobox.cpp b/tests/auto/qcombobox/tst_qcombobox.cpp index af71961..941494f 100644 --- a/tests/auto/qcombobox/tst_qcombobox.cpp +++ b/tests/auto/qcombobox/tst_qcombobox.cpp @@ -156,6 +156,7 @@ private slots: void resetModel(); void keyBoardNavigationWithMouse(); void task_QTBUG_1071_changingFocusEmitsActivated(); + void maxVisibleItems(); protected slots: void onEditTextChanged( const QString &newString ); @@ -2527,5 +2528,34 @@ void tst_QComboBox::task_QTBUG_1071_changingFocusEmitsActivated() QTRY_COMPARE(spy.count(), 1); } +void tst_QComboBox::maxVisibleItems() +{ + QComboBox comboBox; + QCOMPARE(comboBox.maxVisibleItems(), 10); //default value. + + QStringList content; + for(int i = 1; i < 50; i++) + content += QString::number(i); + + comboBox.addItems(content); + comboBox.show(); + comboBox.resize(200, comboBox.height()); + QTRY_VERIFY(comboBox.isVisible()); + + comboBox.setMaxVisibleItems(5); + QCOMPARE(comboBox.maxVisibleItems(), 5); + + comboBox.showPopup(); + QTRY_VERIFY(comboBox.view()); + QTRY_VERIFY(comboBox.view()->isVisible()); + + QAbstractItemView *v = comboBox.view(); + int itemHeight = v->visualRect(v->model()->index(0,0)).height(); + if (v->style()->styleHint(QStyle::SH_ComboBox_Popup)) + QCOMPARE(v->viewport()->height(), itemHeight * comboBox.maxVisibleItems()); + // QCombobox without a popup does not work, see QTBUG-760 +} + + QTEST_MAIN(tst_QComboBox) #include "tst_qcombobox.moc" |