154 void task260974_menuItemRectangleForComboBoxPopup(); |
154 void task260974_menuItemRectangleForComboBoxPopup(); |
155 void removeItem(); |
155 void removeItem(); |
156 void resetModel(); |
156 void resetModel(); |
157 void keyBoardNavigationWithMouse(); |
157 void keyBoardNavigationWithMouse(); |
158 void task_QTBUG_1071_changingFocusEmitsActivated(); |
158 void task_QTBUG_1071_changingFocusEmitsActivated(); |
|
159 void maxVisibleItems(); |
159 |
160 |
160 protected slots: |
161 protected slots: |
161 void onEditTextChanged( const QString &newString ); |
162 void onEditTextChanged( const QString &newString ); |
162 |
163 |
163 private: |
164 private: |
2527 edit.setFocus(); |
2528 edit.setFocus(); |
2528 QTRY_VERIFY(edit.hasFocus()); |
2529 QTRY_VERIFY(edit.hasFocus()); |
2529 QTRY_COMPARE(spy.count(), 1); |
2530 QTRY_COMPARE(spy.count(), 1); |
2530 } |
2531 } |
2531 |
2532 |
|
2533 void tst_QComboBox::maxVisibleItems() |
|
2534 { |
|
2535 QComboBox comboBox; |
|
2536 QCOMPARE(comboBox.maxVisibleItems(), 10); //default value. |
|
2537 |
|
2538 QStringList content; |
|
2539 for(int i = 1; i < 50; i++) |
|
2540 content += QString::number(i); |
|
2541 |
|
2542 comboBox.addItems(content); |
|
2543 comboBox.show(); |
|
2544 comboBox.resize(200, comboBox.height()); |
|
2545 QTRY_VERIFY(comboBox.isVisible()); |
|
2546 |
|
2547 comboBox.setMaxVisibleItems(5); |
|
2548 QCOMPARE(comboBox.maxVisibleItems(), 5); |
|
2549 |
|
2550 comboBox.showPopup(); |
|
2551 QTRY_VERIFY(comboBox.view()); |
|
2552 QTRY_VERIFY(comboBox.view()->isVisible()); |
|
2553 |
|
2554 QAbstractItemView *v = comboBox.view(); |
|
2555 int itemHeight = v->visualRect(v->model()->index(0,0)).height(); |
|
2556 if (v->style()->styleHint(QStyle::SH_ComboBox_Popup)) |
|
2557 QCOMPARE(v->viewport()->height(), itemHeight * comboBox.maxVisibleItems()); |
|
2558 // QCombobox without a popup does not work, see QTBUG-760 |
|
2559 } |
|
2560 |
|
2561 |
2532 QTEST_MAIN(tst_QComboBox) |
2562 QTEST_MAIN(tst_QComboBox) |
2533 #include "tst_qcombobox.moc" |
2563 #include "tst_qcombobox.moc" |