diff options
author | Benjamin Poulain <benjamin.poulain@nokia.com> | 2009-08-25 12:16:31 (GMT) |
---|---|---|
committer | Benjamin Poulain <benjamin.poulain@nokia.com> | 2009-08-25 12:16:31 (GMT) |
commit | caa024e76818ae543897c2f2890cd70212bae23a (patch) | |
tree | 7afcd223b8a49f27d03d7739f85ef4fc25a224e4 /tests/auto | |
parent | c9d2f14b2a814fd29c858d9519e82fc5cbc2afdf (diff) | |
download | Qt-caa024e76818ae543897c2f2890cd70212bae23a.zip Qt-caa024e76818ae543897c2f2890cd70212bae23a.tar.gz Qt-caa024e76818ae543897c2f2890cd70212bae23a.tar.bz2 |
Fix subControlRect of the Mac style for the QComboBox
The subControlRect of the arrow and the listBoxPopup where assuming
the widget rect is at the origin.
Reviewed-by: Richard Moe Gustavsen
Reviewed-by: Pierre Rossi
Diffstat (limited to 'tests/auto')
-rw-r--r-- | tests/auto/qcombobox/tst_qcombobox.cpp | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/tests/auto/qcombobox/tst_qcombobox.cpp b/tests/auto/qcombobox/tst_qcombobox.cpp index 204a2fa..52c6c02 100644 --- a/tests/auto/qcombobox/tst_qcombobox.cpp +++ b/tests/auto/qcombobox/tst_qcombobox.cpp @@ -145,6 +145,8 @@ private slots: void setItemDelegate(); void task253944_itemDelegateIsReset(); void paintingWithOffset(); + void subControlRectsWithOffset_data(); + void subControlRectsWithOffset(); protected slots: void onEditTextChanged( const QString &newString ); @@ -2276,5 +2278,53 @@ void tst_QComboBox::paintingWithOffset() QCOMPARE(noOffsetImage, translatedOffsetImage); } +void tst_QComboBox::subControlRectsWithOffset_data() +{ + QTest::addColumn<bool>("editable"); + + QTest::newRow("editable = true") << true; + QTest::newRow("editable = false") << false; +} + +void tst_QComboBox::subControlRectsWithOffset() +{ + // The sub control rect relative position should not depends + // on the position of the combobox + + class FriendlyCombo : public QComboBox { + public: + void styleOption(QStyleOptionComboBox *optCombo) { + initStyleOption(optCombo); + } + } combo; + QStyleOptionComboBox optCombo; + combo.styleOption(&optCombo); + + + const QRect rectAtOrigin(0, 0, 80, 30); + const QPoint offset(25, 50); + const QRect rectWithOffset = rectAtOrigin.translated(offset); + + QStyle *style = combo.style(); + + QFETCH(bool, editable); + optCombo.editable = editable; + + optCombo.rect = rectAtOrigin; + QRect editFieldRect = style->subControlRect(QStyle::CC_ComboBox, &optCombo, QStyle::SC_ComboBoxEditField, 0); + QRect arrowRect = style->subControlRect(QStyle::CC_ComboBox, &optCombo, QStyle::SC_ComboBoxArrow, 0); + QRect listboxRect = style->subControlRect(QStyle::CC_ComboBox, &optCombo, QStyle::SC_ComboBoxListBoxPopup, 0); + + optCombo.rect = rectWithOffset; + QRect editFieldRectWithOffset = style->subControlRect(QStyle::CC_ComboBox, &optCombo, QStyle::SC_ComboBoxEditField, 0); + QRect arrowRectWithOffset = style->subControlRect(QStyle::CC_ComboBox, &optCombo, QStyle::SC_ComboBoxArrow, 0); + QRect listboxRectWithOffset = style->subControlRect(QStyle::CC_ComboBox, &optCombo, QStyle::SC_ComboBoxListBoxPopup, 0); + + QCOMPARE(editFieldRect, editFieldRectWithOffset.translated(-offset)); + QCOMPARE(arrowRect, arrowRectWithOffset.translated(-offset)); + QCOMPARE(listboxRect, listboxRectWithOffset.translated(-offset)); + +} + QTEST_MAIN(tst_QComboBox) #include "tst_qcombobox.moc" |