diff options
Diffstat (limited to 'tests/auto/qcombobox')
-rw-r--r-- | tests/auto/qcombobox/qcombobox.pro | 2 | ||||
-rw-r--r-- | tests/auto/qcombobox/tst_qcombobox.cpp | 111 |
2 files changed, 62 insertions, 51 deletions
diff --git a/tests/auto/qcombobox/qcombobox.pro b/tests/auto/qcombobox/qcombobox.pro index 60bf1c8..f36a6fe 100644 --- a/tests/auto/qcombobox/qcombobox.pro +++ b/tests/auto/qcombobox/qcombobox.pro @@ -2,5 +2,3 @@ load(qttest_p4) SOURCES += tst_qcombobox.cpp contains(QT_CONFIG, qt3support): QT += qt3support - - diff --git a/tests/auto/qcombobox/tst_qcombobox.cpp b/tests/auto/qcombobox/tst_qcombobox.cpp index 52c6c02..dac32bb 100644 --- a/tests/auto/qcombobox/tst_qcombobox.cpp +++ b/tests/auto/qcombobox/tst_qcombobox.cpp @@ -139,12 +139,12 @@ private slots: void task190205_setModelAdjustToContents(); void task248169_popupWithMinimalSize(); void task247863_keyBoardSelection(); + void task220195_keyBoardSelection2(); void setModelColumn(); void noScrollbar_data(); void noScrollbar(); void setItemDelegate(); void task253944_itemDelegateIsReset(); - void paintingWithOffset(); void subControlRectsWithOffset_data(); void subControlRectsWithOffset(); @@ -1236,7 +1236,6 @@ void tst_QComboBox::insertItem() testWidget->setEditable(true); if (editable) testWidget->setEditText("FOO"); - #if defined (QT3_SUPPORT) if (testQt3Support) testWidget->insertItem(itemLabel, insertIndex); @@ -1897,10 +1896,10 @@ void tst_QComboBox::itemListPosition() //tests that the list is not out of the screen boundaries //put the QApplication layout back - qApp->setLayoutDirection(Qt::LeftToRight); + QApplication::setLayoutDirection(Qt::LeftToRight); //we test QFontComboBox because it has the specific behaviour to set a fixed size - //the the list view + //to the list view QFontComboBox combo; //the code to get the avaialbe screen space is copied from QComboBox code @@ -1917,13 +1916,17 @@ void tst_QComboBox::itemListPosition() screen = QApplication::desktop()->availableGeometry(scrNumber); #endif - combo.move(screen.width()-combo.sizeHint().width(), 0); //puts the combo the the top-right corner + combo.move(screen.width()-combo.sizeHint().width(), 0); //puts the combo to the top-right corner combo.show(); QTest::qWait(100); //wait because the window manager can move the window if there is a right panel combo.showPopup(); QTest::qWait(100); +#if defined(Q_WS_S60) + // Assuming that QtS60 style is used, here. But other ones would certainly also fail + QEXPECT_FAIL("", "QtS60Style does not yet position the combobox popup correctly", Continue); +#endif QVERIFY( combo.view()->window()->x() + combo.view()->window()->width() <= screen.x() + screen.width() ); } @@ -1976,6 +1979,7 @@ void tst_QComboBox::task190351_layout() listCombo.showPopup(); QTest::qWait(100); +#ifdef QT_BUILD_INTERNAL QFrame *container = qFindChild<QComboBoxPrivateContainer *>(&listCombo); QVERIFY(container); QCOMPARE(static_cast<QAbstractItemView *>(list), qFindChild<QAbstractItemView *>(container)); @@ -1983,6 +1987,7 @@ void tst_QComboBox::task190351_layout() QVERIFY(top); QVERIFY(top->isVisible()); QCOMPARE(top->mapToGlobal(QPoint(0, top->height())).y(), list->mapToGlobal(QPoint()).y()); +#endif QApplication::setStyle(oldStyle); #else @@ -2048,6 +2053,7 @@ void tst_QComboBox::task191329_size() tableCombo.showPopup(); QTest::qWait(100); +#ifdef QT_BUILD_INTERNAL QFrame *container = qFindChild<QComboBoxPrivateContainer *>(&tableCombo); QVERIFY(container); QCOMPARE(static_cast<QAbstractItemView *>(table), qFindChild<QAbstractItemView *>(container)); @@ -2055,6 +2061,7 @@ void tst_QComboBox::task191329_size() //the popup should be large enough to contains everithing so the top and left button are hidden QVERIFY(!button->isVisible()); } +#endif QApplication::setStyle(oldStyle); #else @@ -2091,7 +2098,7 @@ void tst_QComboBox::task190205_setModelAdjustToContents() #endif // box should be resized to the same size as correctBox - QCOMPARE(box.size(), correctBox.size()); + QTRY_COMPARE(box.size(), correctBox.size()); } void tst_QComboBox::task248169_popupWithMinimalSize() @@ -2110,9 +2117,11 @@ void tst_QComboBox::task248169_popupWithMinimalSize() comboBox.showPopup(); QTest::qWait(100); +#ifdef QT_BUILD_INTERNAL QFrame *container = qFindChild<QComboBoxPrivateContainer *>(&comboBox); QVERIFY(container); QVERIFY(desktop.screenGeometry(container).contains(container->geometry())); +#endif } void tst_QComboBox::task247863_keyBoardSelection() @@ -2135,6 +2144,40 @@ void tst_QComboBox::task247863_keyBoardSelection() QCOMPARE(spy.count(), 1); } +void tst_QComboBox::task220195_keyBoardSelection2() +{ + QComboBox combo; + combo.setEditable(false); + combo.addItem( QLatin1String("foo1")); + combo.addItem( QLatin1String("foo2")); + combo.addItem( QLatin1String("foo3")); + combo.show(); + QApplication::setActiveWindow(&combo); + QTest::qWait(100); + + combo.setCurrentIndex(-1); + QVERIFY(combo.currentText().isNull()); + + QTest::keyClick(&combo, 'f'); + QCOMPARE(combo.currentText(), QLatin1String("foo1")); + QTest::qWait(QApplication::keyboardInputInterval() + 30); + QTest::keyClick(&combo, 'f'); + QCOMPARE(combo.currentText(), QLatin1String("foo2")); + QTest::qWait(QApplication::keyboardInputInterval() + 30); + QTest::keyClick(&combo, 'f'); + QCOMPARE(combo.currentText(), QLatin1String("foo3")); + QTest::qWait(QApplication::keyboardInputInterval() + 30); + QTest::keyClick(&combo, 'f'); + QCOMPARE(combo.currentText(), QLatin1String("foo1")); + QTest::qWait(QApplication::keyboardInputInterval() + 30); + + combo.setCurrentIndex(1); + QCOMPARE(combo.currentText(), QLatin1String("foo2")); + QTest::keyClick(&combo, 'f'); + QCOMPARE(combo.currentText(), QLatin1String("foo3")); +} + + void tst_QComboBox::setModelColumn() { QStandardItemModel model(5,3); @@ -2196,7 +2239,7 @@ void tst_QComboBox::noScrollbar() QVERIFY(!comboBox.view()->horizontalScrollBar()->isVisible()); QVERIFY(!comboBox.view()->verticalScrollBar()->isVisible()); } - + { QTableWidget *table = new QTableWidget(2,2); QComboBox comboBox; @@ -2219,7 +2262,11 @@ void tst_QComboBox::setItemDelegate() QComboBox comboBox; QStyledItemDelegate *itemDelegate = new QStyledItemDelegate; comboBox.setItemDelegate(itemDelegate); +#ifdef Q_CC_MWERKS + QCOMPARE(static_cast<QStyledItemDelegate *>(comboBox.itemDelegate()), itemDelegate); +#else QCOMPARE(comboBox.itemDelegate(), itemDelegate); +#endif } void tst_QComboBox::task253944_itemDelegateIsReset() @@ -2229,54 +2276,20 @@ void tst_QComboBox::task253944_itemDelegateIsReset() comboBox.setItemDelegate(itemDelegate); comboBox.setEditable(true); +#ifdef Q_CC_MWERKS + QCOMPARE(static_cast<QStyledItemDelegate *>(comboBox.itemDelegate()), itemDelegate); +#else QCOMPARE(comboBox.itemDelegate(), itemDelegate); +#endif comboBox.setStyleSheet("QComboBox { border: 1px solid gray; }"); +#ifdef Q_CC_MWERKS + QCOMPARE(static_cast<QStyledItemDelegate *>(comboBox.itemDelegate()), itemDelegate); +#else QCOMPARE(comboBox.itemDelegate(), itemDelegate); +#endif } -static void paintCombo(QImage *image, const QRect &rect) -{ - class FriendlyCombo : public QComboBox { - public: - void styleOption(QStyleOptionComboBox *optCombo) { - initStyleOption(optCombo); - } - } combo; - combo.setEditable(true); - - QStyleOptionComboBox optCombo; - combo.styleOption(&optCombo); - optCombo.rect = rect; - optCombo.palette.setCurrentColorGroup(QPalette::Active); - optCombo.state = QStyle::State_None; - - QPainter painter(image); - painter.fillRect(image->rect(), Qt::white); - QApplication::style()->drawComplexControl(QStyle::CC_ComboBox, &optCombo, &painter, 0); -} - -void tst_QComboBox::paintingWithOffset() -{ - // The painting of the combobox should not depend on its position in - // the widget. Some style are making the assumuption that the combobox - // start at 0,0 - const QSize comboSize(80, 30); - QImage noOffsetImage(comboSize, QImage::Format_ARGB32); - const QRect noOffsetRect(QPoint(0, 0), comboSize); - paintCombo(&noOffsetImage, noOffsetRect); - - QImage offsetImage(105, 80, QImage::Format_ARGB32); - const QRect offsetRect(QPoint(25, 50), comboSize); - paintCombo(&offsetImage, offsetRect); - - QImage translatedOffsetImage(comboSize, QImage::Format_ARGB32); - { - QPainter painter(&translatedOffsetImage); - painter.drawImage(noOffsetRect, offsetImage, offsetRect); - } - QCOMPARE(noOffsetImage, translatedOffsetImage); -} void tst_QComboBox::subControlRectsWithOffset_data() { |