summaryrefslogtreecommitdiffstats
path: root/tests/auto/qgraphicsview
diff options
context:
space:
mode:
authorAlexis Menard <alexis.menard@nokia.com>2009-06-11 09:33:54 (GMT)
committerAlexis Menard <alexis.menard@nokia.com>2009-06-11 09:34:05 (GMT)
commitc6f2229bcecbbea2d1f3df149d1a397cd26b43c7 (patch)
treebb14b976cddccdb196a68bed6f9b94d10273f857 /tests/auto/qgraphicsview
parentbc3abd32ed1c5a872d7a7817c1af0a13f442d536 (diff)
parent0989cbe2b164560eef14334a540fcbcb2e2ec8cb (diff)
downloadQt-c6f2229bcecbbea2d1f3df149d1a397cd26b43c7.zip
Qt-c6f2229bcecbbea2d1f3df149d1a397cd26b43c7.tar.gz
Qt-c6f2229bcecbbea2d1f3df149d1a397cd26b43c7.tar.bz2
Merge branch 'master' of git@scm.dev.nokia.troll.no:qt/qt into qt-main/qgraphicssceneindex
Painfull merge due to recent changes in QGV framework. Conflicts: src/gui/graphicsview/qgraphicsitem.cpp src/gui/graphicsview/qgraphicsscene.cpp src/gui/graphicsview/qgraphicsscene.h src/gui/graphicsview/qgraphicsscene_p.h src/gui/graphicsview/qgraphicsview.cpp
Diffstat (limited to 'tests/auto/qgraphicsview')
-rw-r--r--tests/auto/qgraphicsview/tst_qgraphicsview.cpp59
1 files changed, 59 insertions, 0 deletions
diff --git a/tests/auto/qgraphicsview/tst_qgraphicsview.cpp b/tests/auto/qgraphicsview/tst_qgraphicsview.cpp
index 696a42d..6b0d8b7 100644
--- a/tests/auto/qgraphicsview/tst_qgraphicsview.cpp
+++ b/tests/auto/qgraphicsview/tst_qgraphicsview.cpp
@@ -191,6 +191,7 @@ private slots:
void centerOnDirtyItem();
void mouseTracking();
void mouseTracking2();
+ void render();
// task specific tests below me
void task172231_untransformableItems();
@@ -2525,6 +2526,8 @@ void tst_QGraphicsView::acceptMousePressEvent()
scene.addRect(0, 0, 2000, 2000)->setFlag(QGraphicsItem::ItemIsMovable);
+ qApp->processEvents(); // ensure scene rect is updated
+
QApplication::sendEvent(view.viewport(), &event);
QVERIFY(view.accepted);
}
@@ -3201,6 +3204,62 @@ void tst_QGraphicsView::mouseTracking2()
QCOMPARE(spy.count(), 1);
}
+class RenderTester : public QGraphicsRectItem
+{
+public:
+ RenderTester(const QRectF &rect)
+ : QGraphicsRectItem(rect), paints(0)
+ { }
+
+ void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
+ QWidget *widget)
+ {
+ QGraphicsRectItem::paint(painter, option, widget);
+ ++paints;
+ }
+
+ int paints;
+};
+
+void tst_QGraphicsView::render()
+{
+ // ### This test can be much more thorough - see QGraphicsScene::render.
+ QGraphicsScene scene;
+ RenderTester *r1 = new RenderTester(QRectF(0, 0, 50, 50));
+ RenderTester *r2 = new RenderTester(QRectF(50, 50, 50, 50));
+ RenderTester *r3 = new RenderTester(QRectF(0, 50, 50, 50));
+ RenderTester *r4 = new RenderTester(QRectF(50, 0, 50, 50));
+ scene.addItem(r1);
+ scene.addItem(r2);
+ scene.addItem(r3);
+ scene.addItem(r4);
+
+ QGraphicsView view(&scene);
+ view.setFrameStyle(0);
+ view.resize(200, 200);
+ view.show();
+#ifdef Q_WS_X11
+ qt_x11_wait_for_window_manager(&view);
+#endif
+ QTest::qWait(200);
+
+ QCOMPARE(r1->paints, 1);
+ QCOMPARE(r2->paints, 1);
+ QCOMPARE(r3->paints, 1);
+ QCOMPARE(r4->paints, 1);
+
+ QPixmap pix(200, 200);
+ pix.fill(Qt::transparent);
+ QPainter painter(&pix);
+ view.render(&painter);
+ painter.end();
+
+ QCOMPARE(r1->paints, 2);
+ QCOMPARE(r2->paints, 2);
+ QCOMPARE(r3->paints, 2);
+ QCOMPARE(r4->paints, 2);
+}
+
void tst_QGraphicsView::task253415_reconnectUpdateSceneOnSceneChanged()
{
QGraphicsView view;