summaryrefslogtreecommitdiffstats
path: root/tests/auto/qcombobox/tst_qcombobox.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/qcombobox/tst_qcombobox.cpp')
-rw-r--r--tests/auto/qcombobox/tst_qcombobox.cpp46
1 files changed, 45 insertions, 1 deletions
diff --git a/tests/auto/qcombobox/tst_qcombobox.cpp b/tests/auto/qcombobox/tst_qcombobox.cpp
index c94ace0fc..204a2fa95 100644
--- a/tests/auto/qcombobox/tst_qcombobox.cpp
+++ b/tests/auto/qcombobox/tst_qcombobox.cpp
@@ -34,7 +34,7 @@
** met: http://www.gnu.org/copyleft/gpl.html.
**
** If you are unsure which license is appropriate for your use, please
-** contact the sales department at http://www.qtsoftware.com/contact.
+** contact the sales department at http://qt.nokia.com/contact.
** $QT_END_LICENSE$
**
****************************************************************************/
@@ -144,6 +144,7 @@ private slots:
void noScrollbar();
void setItemDelegate();
void task253944_itemDelegateIsReset();
+ void paintingWithOffset();
protected slots:
void onEditTextChanged( const QString &newString );
@@ -2232,5 +2233,48 @@ void tst_QComboBox::task253944_itemDelegateIsReset()
QCOMPARE(comboBox.itemDelegate(), itemDelegate);
}
+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);
+}
+
QTEST_MAIN(tst_QComboBox)
#include "tst_qcombobox.moc"