summaryrefslogtreecommitdiffstats
path: root/tests/auto
diff options
context:
space:
mode:
authorOlivier Goffart <ogoffart@trolltech.com>2009-11-23 16:04:49 (GMT)
committerOlivier Goffart <ogoffart@trolltech.com>2009-11-30 11:44:17 (GMT)
commit5c488b7e15dbd5ee08a909e4dcc997a58ba63a2d (patch)
tree1575ff2260a04a6a5d6c16e19ceae33bfab86505 /tests/auto
parent14fcc4890cf41c17e69853ca7cafd14c947ba7b1 (diff)
downloadQt-5c488b7e15dbd5ee08a909e4dcc997a58ba63a2d.zip
Qt-5c488b7e15dbd5ee08a909e4dcc997a58ba63a2d.tar.gz
Qt-5c488b7e15dbd5ee08a909e4dcc997a58ba63a2d.tar.bz2
Adjust documentation on QCombobox::maxVisibleItems to mention that this does not work with gtk.
Also fixed the fact that it would show one item to many. Task-number: QTBUG-760 Reviewed-by: jbache
Diffstat (limited to 'tests/auto')
-rw-r--r--tests/auto/qcombobox/tst_qcombobox.cpp30
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"