diff options
Diffstat (limited to 'tests/auto/qpainter/tst_qpainter.cpp')
-rw-r--r-- | tests/auto/qpainter/tst_qpainter.cpp | 58 |
1 files changed, 57 insertions, 1 deletions
diff --git a/tests/auto/qpainter/tst_qpainter.cpp b/tests/auto/qpainter/tst_qpainter.cpp index 8b71349..67d1972 100644 --- a/tests/auto/qpainter/tst_qpainter.cpp +++ b/tests/auto/qpainter/tst_qpainter.cpp @@ -41,7 +41,7 @@ #include <QtTest/QtTest> - +#include "../../shared/util.h" #include <qpainter.h> #include <qapplication.h> @@ -67,6 +67,11 @@ #include <qqueue.h> +#include <qgraphicsview.h> +#include <qgraphicsscene.h> +#include <qgraphicsproxywidget.h> +#include <qlayout.h> + #if defined(Q_OS_SYMBIAN) # define SRCDIR "." #endif @@ -244,6 +249,8 @@ private slots: void setPenColorOnImage(); void setPenColorOnPixmap(); + void QTBUG5939_attachPainterPrivate(); + private: void fillData(); void setPenColor(QPainter& p); @@ -4404,6 +4411,55 @@ void tst_QPainter::setPenColorOnPixmap() setPenColor(p); } +class TestProxy : public QGraphicsProxyWidget +{ +public: + TestProxy() : QGraphicsProxyWidget() {} + void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) + { + QGraphicsProxyWidget::paint(painter, option, widget); + deviceTransform = painter->deviceTransform(); + } + QTransform deviceTransform; +}; + +class TestWidget : public QWidget +{ +Q_OBJECT +public: + TestWidget() : QWidget(), painted(false) {} + void paintEvent(QPaintEvent *) + { + QPainter p(this); + deviceTransform = p.deviceTransform(); + worldTransform = p.worldTransform(); + painted = true; + } + QTransform deviceTransform; + QTransform worldTransform; + bool painted; +}; + +void tst_QPainter::QTBUG5939_attachPainterPrivate() +{ + QWidget *w = new QWidget(); + QGraphicsScene *scene = new QGraphicsScene(); + QGraphicsView *view = new QGraphicsView(scene, w); + view->move(50 ,50); + TestProxy *proxy = new TestProxy(); + TestWidget *widget = new TestWidget(); + proxy->setWidget(widget); + scene->addItem(proxy); + proxy->rotate(45); + w->resize(scene->sceneRect().size().toSize()); + + w->show(); + QTRY_VERIFY(widget->painted); + + QVERIFY(widget->worldTransform.isIdentity()); + QCOMPARE(widget->deviceTransform, proxy->deviceTransform); +} + QTEST_MAIN(tst_QPainter) #include "tst_qpainter.moc" |