diff options
author | Tom Cooksey <thomas.cooksey@nokia.com> | 2009-08-25 09:29:24 (GMT) |
---|---|---|
committer | Tom Cooksey <thomas.cooksey@nokia.com> | 2009-08-27 15:15:53 (GMT) |
commit | 5daf4391bcf40416c7ea99f8dbbfe28efe1cb19f (patch) | |
tree | 148f06d3a4519969e91ffe24bf3c9133ae70e5b5 /tests | |
parent | 4a2529399dc8c6a30677bd7c3ded6b93a6715b51 (diff) | |
download | Qt-5daf4391bcf40416c7ea99f8dbbfe28efe1cb19f.zip Qt-5daf4391bcf40416c7ea99f8dbbfe28efe1cb19f.tar.gz Qt-5daf4391bcf40416c7ea99f8dbbfe28efe1cb19f.tar.bz2 |
Add an autotest to check reparenting a QGLWidget works
If this is broken it will usually seg-fault, but there's a few checks in
there just to make sure.
Reviewed-by: Samuel
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/qgl/tst_qgl.cpp | 68 |
1 files changed, 68 insertions, 0 deletions
diff --git a/tests/auto/qgl/tst_qgl.cpp b/tests/auto/qgl/tst_qgl.cpp index 5ed8406..8958530 100644 --- a/tests/auto/qgl/tst_qgl.cpp +++ b/tests/auto/qgl/tst_qgl.cpp @@ -50,6 +50,7 @@ #include <QGraphicsView> #include <QGraphicsProxyWidget> +#include <QVBoxLayout> //TESTED_CLASS= //TESTED_FILES= @@ -69,6 +70,7 @@ private slots: void partialGLWidgetUpdates_data(); void partialGLWidgetUpdates(); void glWidgetRendering(); + void glWidgetReparent(); void colormap(); }; @@ -671,6 +673,72 @@ void tst_QGL::glWidgetRendering() 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: |