diff options
author | Bjørn Erik Nilsen <bjorn.nilsen@nokia.com> | 2009-06-10 14:58:17 (GMT) |
---|---|---|
committer | Bjørn Erik Nilsen <bjorn.nilsen@nokia.com> | 2009-06-10 14:58:17 (GMT) |
commit | c3d2c4a7d103ec1289c27425f49f8565a7f4413c (patch) | |
tree | ab77725bf74da5632bc5e9f7492a12759c1dfeaa /tests/auto/qgraphicsview/tst_qgraphicsview.cpp | |
parent | 0141b9b410278e064f3455d20cb21a50c926a2c8 (diff) | |
parent | 32f32ee3e752a6cc03505ddaa48d2849eaedc2a6 (diff) | |
download | Qt-c3d2c4a7d103ec1289c27425f49f8565a7f4413c.zip Qt-c3d2c4a7d103ec1289c27425f49f8565a7f4413c.tar.gz Qt-c3d2c4a7d103ec1289c27425f49f8565a7f4413c.tar.bz2 |
Merge commit 'qt/master' into kinetic-declarativeui
Conflicts:
src/corelib/kernel/qabstractitemmodel.cpp
src/corelib/kernel/qobject.cpp
tools/qdoc3/htmlgenerator.cpp
Diffstat (limited to 'tests/auto/qgraphicsview/tst_qgraphicsview.cpp')
-rw-r--r-- | tests/auto/qgraphicsview/tst_qgraphicsview.cpp | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/tests/auto/qgraphicsview/tst_qgraphicsview.cpp b/tests/auto/qgraphicsview/tst_qgraphicsview.cpp index 8e490ad..5167682 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; |