summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThiago Macieira <thiago.macieira@nokia.com>2009-08-27 15:17:30 (GMT)
committerThiago Macieira <thiago.macieira@nokia.com>2009-08-27 15:17:30 (GMT)
commit26b8b6783afe2c1c9f27c935eb46c05229757af1 (patch)
tree6e906223eefee16488dc3a12b4e8704b94dca1ef
parent8c755acd7549a1de53acb9d93e9a44e333be2b5b (diff)
parent5daf4391bcf40416c7ea99f8dbbfe28efe1cb19f (diff)
downloadQt-26b8b6783afe2c1c9f27c935eb46c05229757af1.zip
Qt-26b8b6783afe2c1c9f27c935eb46c05229757af1.tar.gz
Qt-26b8b6783afe2c1c9f27c935eb46c05229757af1.tar.bz2
Merge branch '4.6' of git:qt/qt into 4.6
-rw-r--r--tests/auto/qgl/tst_qgl.cpp114
1 files changed, 114 insertions, 0 deletions
diff --git a/tests/auto/qgl/tst_qgl.cpp b/tests/auto/qgl/tst_qgl.cpp
index f92670d..8958530 100644
--- a/tests/auto/qgl/tst_qgl.cpp
+++ b/tests/auto/qgl/tst_qgl.cpp
@@ -46,9 +46,11 @@
#include <qdebug.h>
#include <qgl.h>
#include <qglcolormap.h>
+#include <qpaintengine.h>
#include <QGraphicsView>
#include <QGraphicsProxyWidget>
+#include <QVBoxLayout>
//TESTED_CLASS=
//TESTED_FILES=
@@ -67,6 +69,8 @@ private slots:
void graphicsViewClipping();
void partialGLWidgetUpdates_data();
void partialGLWidgetUpdates();
+ void glWidgetRendering();
+ void glWidgetReparent();
void colormap();
};
@@ -625,6 +629,116 @@ 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);
+}
+
+void tst_QGL::glWidgetReparent()
+{
+ // Try it as a top-level first:
+ GLWidget *widget = new GLWidget;
+ widget->setGeometry(0, 0, 200, 30);
+ widget->show();
+
+ QWidget grandParentWidget;
+ grandParentWidget.setPalette(Qt::blue);
+ QVBoxLayout grandParentLayout(&grandParentWidget);
+
+ QWidget parentWidget(&grandParentWidget);
+ grandParentLayout.addWidget(&parentWidget);
+ parentWidget.setPalette(Qt::green);
+ parentWidget.setAutoFillBackground(true);
+ QVBoxLayout parentLayout(&parentWidget);
+
+ grandParentWidget.setGeometry(0, 100, 200, 200);
+ grandParentWidget.show();
+
+#ifdef Q_WS_X11
+ qt_x11_wait_for_window_manager(widget);
+ qt_x11_wait_for_window_manager(&parentWidget);
+#endif
+ QTest::qWait(2000);
+
+ QVERIFY(parentWidget.children().count() == 1); // The layout
+
+ // Now both widgets should be created & shown, time to re-parent:
+ parentLayout.addWidget(widget);
+
+#ifdef Q_WS_X11
+ qt_x11_wait_for_window_manager(&parentWidget);
+#endif
+ QTest::qWait(2000);
+
+ QVERIFY(parentWidget.children().count() == 2); // Layout & glwidget
+ QVERIFY(parentWidget.children().contains(widget));
+ QVERIFY(widget->height() > 30);
+
+ delete widget;
+
+#ifdef Q_WS_X11
+ qt_x11_wait_for_window_manager(&parentWidget);
+#endif
+ QTest::qWait(2000);
+
+ QVERIFY(parentWidget.children().count() == 1); // The layout
+
+ // Now do pretty much the same thing, but don't show the
+ // widget first:
+ widget = new GLWidget;
+ parentLayout.addWidget(widget);
+
+#ifdef Q_WS_X11
+ qt_x11_wait_for_window_manager(&parentWidget);
+#endif
+ QTest::qWait(2000);
+
+ QVERIFY(parentWidget.children().count() == 2); // Layout & glwidget
+ QVERIFY(parentWidget.children().contains(widget));
+ QVERIFY(widget->height() > 30);
+
+ delete widget;
+}
+
class ColormapExtended : public QGLColormap
{
public: