summaryrefslogtreecommitdiffstats
path: root/tests/auto/qpainter/tst_qpainter.cpp
diff options
context:
space:
mode:
authorMichael Brasser <michael.brasser@nokia.com>2009-12-07 04:40:54 (GMT)
committerMichael Brasser <michael.brasser@nokia.com>2009-12-07 04:40:54 (GMT)
commit93a2b57c7e3c2be5b1c64d3408d27acb4aa2c8fc (patch)
tree5efe4f6c6386e25dc7d3235c7f261d3fdf5a19c3 /tests/auto/qpainter/tst_qpainter.cpp
parent55a3fda3baf545cc7fbfa6b2c00705be40a7319b (diff)
parent47008b211fe3b972077466e593a2a9016446bab2 (diff)
downloadQt-93a2b57c7e3c2be5b1c64d3408d27acb4aa2c8fc.zip
Qt-93a2b57c7e3c2be5b1c64d3408d27acb4aa2c8fc.tar.gz
Qt-93a2b57c7e3c2be5b1c64d3408d27acb4aa2c8fc.tar.bz2
Merge branch '4.6' of scm.dev.nokia.troll.no:qt/qt into kinetic-declarativeui
Conflicts: src/tools/moc/generator.cpp
Diffstat (limited to 'tests/auto/qpainter/tst_qpainter.cpp')
-rw-r--r--tests/auto/qpainter/tst_qpainter.cpp58
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"