summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorOlivier Goffart <ogoffart@trolltech.com>2009-07-13 19:43:12 (GMT)
committerOlivier Goffart <ogoffart@trolltech.com>2009-07-15 09:28:30 (GMT)
commita72c30020bdadbe0d82e583e17acd25715604f7b (patch)
treece82e9ace289d9cb22a09d847497b01222ad1a1c /tests
parente9ded3b600256686e4a735e365988f317a51db03 (diff)
downloadQt-a72c30020bdadbe0d82e583e17acd25715604f7b.zip
Qt-a72c30020bdadbe0d82e583e17acd25715604f7b.tar.gz
Qt-a72c30020bdadbe0d82e583e17acd25715604f7b.tar.bz2
Bad drawing of styled viewports within QAbstractScrollArea
This patch includes lots of refactoring, but the real problem was that in QWidgetPrivate::paintBackground we call drawPrimitive(PE_Widget) with a potentialy translated painter, but the opt.rect is not translated. When having a scroll area the calling function used to translated the painter and then pass the offset around to rectify. but drawPrimitive cannot rectify it. The solution is not to translate the painter but use other way to rectify the brush Task-number: 257517 Reviewed-by: bnilsen
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/qabstractscrollarea/tst_qabstractscrollarea.cpp35
1 files changed, 35 insertions, 0 deletions
diff --git a/tests/auto/qabstractscrollarea/tst_qabstractscrollarea.cpp b/tests/auto/qabstractscrollarea/tst_qabstractscrollarea.cpp
index e976c1b..556e850 100644
--- a/tests/auto/qabstractscrollarea/tst_qabstractscrollarea.cpp
+++ b/tests/auto/qabstractscrollarea/tst_qabstractscrollarea.cpp
@@ -66,6 +66,7 @@ private slots:
void setScrollBars();
void setScrollBars2();
void objectNaming();
+ void patternBackground();
void viewportCrash();
void task214488_layoutDirection_data();
@@ -350,5 +351,39 @@ void tst_QAbstractScrollArea::task214488_layoutDirection()
QVERIFY(lessThan ? (hbar->value() < refValue) : (hbar->value() > refValue));
}
+void tst_QAbstractScrollArea::patternBackground()
+{
+ QScrollArea scrollArea;
+ scrollArea.resize(200, 200);
+ QWidget widget;
+ widget.resize(600, 600);
+ scrollArea.setWidget(&widget);
+ scrollArea.show();
+
+ QLinearGradient linearGrad(QPointF(250, 250), QPointF(300, 300));
+ linearGrad.setColorAt(0, Qt::yellow);
+ linearGrad.setColorAt(1, Qt::red);
+ QBrush bg(linearGrad);
+ scrollArea.viewport()->setPalette(QPalette(Qt::black, bg, bg, bg, bg, bg, bg, bg, bg));
+ widget.setPalette(Qt::transparent);
+
+ QTest::qWait(50);
+
+ QImage image(200, 200, QImage::Format_ARGB32);
+ scrollArea.render(&image);
+
+ QCOMPARE(image.pixel(QPoint(20,20)) , QColor(Qt::yellow).rgb());
+
+ QScrollBar *hbar = scrollArea.horizontalScrollBar();
+ hbar->setValue(hbar->maximum());
+ QScrollBar *vbar = scrollArea.verticalScrollBar();
+ vbar->setValue(vbar->maximum());
+
+ QTest::qWait(50);
+
+ scrollArea.render(&image);
+ QCOMPARE(image.pixel(QPoint(20,20)) , QColor(Qt::red).rgb());
+}
+
QTEST_MAIN(tst_QAbstractScrollArea)
#include "tst_qabstractscrollarea.moc"