diff options
author | Tom Cooksey <thomas.cooksey@nokia.com> | 2009-08-25 09:27:38 (GMT) |
---|---|---|
committer | Tom Cooksey <thomas.cooksey@nokia.com> | 2009-08-27 15:15:42 (GMT) |
commit | 4a2529399dc8c6a30677bd7c3ded6b93a6715b51 (patch) | |
tree | 8b50bf54ceb2b944299e7b1a3f0971a7172f3316 /tests/auto/qgl/tst_qgl.cpp | |
parent | d0cdddb61c46a5d27fe0e4fae176964c2009e971 (diff) | |
download | Qt-4a2529399dc8c6a30677bd7c3ded6b93a6715b51.zip Qt-4a2529399dc8c6a30677bd7c3ded6b93a6715b51.tar.gz Qt-4a2529399dc8c6a30677bd7c3ded6b93a6715b51.tar.bz2 |
Add an autotest to check rendering to a QGLWidget works
Reviewed-by: Samuel
Diffstat (limited to 'tests/auto/qgl/tst_qgl.cpp')
-rw-r--r-- | tests/auto/qgl/tst_qgl.cpp | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/tests/auto/qgl/tst_qgl.cpp b/tests/auto/qgl/tst_qgl.cpp index f92670d..5ed8406 100644 --- a/tests/auto/qgl/tst_qgl.cpp +++ b/tests/auto/qgl/tst_qgl.cpp @@ -46,6 +46,7 @@ #include <qdebug.h> #include <qgl.h> #include <qglcolormap.h> +#include <qpaintengine.h> #include <QGraphicsView> #include <QGraphicsProxyWidget> @@ -67,6 +68,7 @@ private slots: void graphicsViewClipping(); void partialGLWidgetUpdates_data(); void partialGLWidgetUpdates(); + void glWidgetRendering(); void colormap(); }; @@ -625,6 +627,50 @@ void tst_QGL::partialGLWidgetUpdates() QCOMPARE(widget.paintEventRegion, QRegion(widget.rect())); } + +class GLWidget : public QGLWidget +{ +public: + GLWidget(QWidget* p = 0) + : QGLWidget(p), beginOk(false), engineType(QPaintEngine::MaxUser) {} + bool beginOk; + QPaintEngine::Type engineType; + void paintGL() + { + QPainter p; + beginOk = p.begin(this); + QPaintEngine* pe = p.paintEngine(); + engineType = pe->type(); + + // This test only ensures it's possible to paint onto a QGLWidget. Full + // paint engine feature testing is way out of scope! + + p.fillRect(0, 0, width(), height(), Qt::red); + // No p.end() or swap buffers, should be done automatically + } + +}; + +void tst_QGL::glWidgetRendering() +{ + GLWidget w; + w.show(); + +#ifdef Q_WS_X11 + qt_x11_wait_for_window_manager(&w); +#endif + QTest::qWait(200); + + QVERIFY(w.beginOk); + QVERIFY(w.engineType == QPaintEngine::OpenGL); + + QImage fb = w.grabFrameBuffer(false).convertToFormat(QImage::Format_RGB32); + QImage reference(fb.size(), QImage::Format_RGB32); + reference.fill(0xffff0000); + + QCOMPARE(fb, reference); +} + class ColormapExtended : public QGLColormap { public: |