diff options
author | Alexis Menard <alexis.menard@nokia.com> | 2009-05-12 12:45:32 (GMT) |
---|---|---|
committer | Alexis Menard <alexis.menard@nokia.com> | 2009-05-12 12:45:32 (GMT) |
commit | 1898c46452beae9e28cf9be7851099b4b4d2779e (patch) | |
tree | 00477e689bf1bd867fb3428476029b47817a9db8 /tests/auto/qgl/tst_qgl.cpp | |
parent | f15b8a83e2e51955776a3f07cb85ebfc342dd8ef (diff) | |
parent | 4d5a5149b716c67f031a3a40e23370f90542c92f (diff) | |
download | Qt-1898c46452beae9e28cf9be7851099b4b4d2779e.zip Qt-1898c46452beae9e28cf9be7851099b4b4d2779e.tar.gz Qt-1898c46452beae9e28cf9be7851099b4b4d2779e.tar.bz2 |
Merge branch '4.5' of git@scm.dev.nokia.troll.no:qt/qt into kinetic-statemachine
Conflicts:
src/gui/graphicsview/qgraphicsitem.cpp
Diffstat (limited to 'tests/auto/qgl/tst_qgl.cpp')
-rw-r--r-- | tests/auto/qgl/tst_qgl.cpp | 65 |
1 files changed, 65 insertions, 0 deletions
diff --git a/tests/auto/qgl/tst_qgl.cpp b/tests/auto/qgl/tst_qgl.cpp index a64dfc4..69141f3 100644 --- a/tests/auto/qgl/tst_qgl.cpp +++ b/tests/auto/qgl/tst_qgl.cpp @@ -66,6 +66,8 @@ private slots: void getSetCheck(); void openGLVersionCheck(); void graphicsViewClipping(); + void partialGLWidgetUpdates_data(); + void partialGLWidgetUpdates(); }; tst_QGL::tst_QGL() @@ -404,5 +406,68 @@ void tst_QGL::graphicsViewClipping() #endif } +void tst_QGL::partialGLWidgetUpdates_data() +{ + QTest::addColumn<bool>("doubleBufferedContext"); + QTest::addColumn<bool>("autoFillBackground"); + QTest::addColumn<bool>("supportsPartialUpdates"); + + QTest::newRow("Double buffered context") << true << true << false; + QTest::newRow("Double buffered context without auto-fill background") << true << false << false; + QTest::newRow("Single buffered context") << false << true << false; + QTest::newRow("Single buffered context without auto-fill background") << false << false << true; +} + +void tst_QGL::partialGLWidgetUpdates() +{ +#ifdef QT_NO_OPENGL + QSKIP("QGL not yet supported", SkipAll); +#else + if (!QGLFormat::hasOpenGL()) + QSKIP("QGL not supported on this platform", SkipAll); + + QFETCH(bool, doubleBufferedContext); + QFETCH(bool, autoFillBackground); + QFETCH(bool, supportsPartialUpdates); + + class MyGLWidget : public QGLWidget + { + public: + QRegion paintEventRegion; + void paintEvent(QPaintEvent *e) + { + paintEventRegion = e->region(); + } + }; + + QGLFormat format = QGLFormat::defaultFormat(); + format.setDoubleBuffer(doubleBufferedContext); + QGLFormat::setDefaultFormat(format); + + MyGLWidget widget; + widget.setFixedSize(150, 150); + widget.setAutoFillBackground(autoFillBackground); + widget.show(); +#ifdef Q_WS_X11 + qt_x11_wait_for_window_manager(&widget); +#endif + QTest::qWait(200); + + if (widget.format().doubleBuffer() != doubleBufferedContext) + QSKIP("Platform does not support requested format", SkipAll); + + widget.paintEventRegion = QRegion(); + widget.repaint(50, 50, 50, 50); +#ifdef Q_WS_MAC + // repaint() is not immediate on the Mac; it has to go through the event loop. + QTest::qWait(200); +#endif + if (supportsPartialUpdates) + QCOMPARE(widget.paintEventRegion, QRegion(50, 50, 50, 50)); + else + QCOMPARE(widget.paintEventRegion, QRegion(widget.rect())); +#endif +} + QTEST_MAIN(tst_QGL) #include "tst_qgl.moc" |