aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@theqtcompany.com>2015-01-26 09:25:15 +0100
committerFriedemann Kleint <Friedemann.Kleint@theqtcompany.com>2015-01-29 11:10:49 +0000
commitc1c7a952bc11d3bd9edcd3739c57df15b60a9e79 (patch)
treeecd1ad0087f973e0eba66e5392db48d00e478036
parentcf6e97119df5bf17b4a952b257d05d43b7d6ca26 (diff)
Verify context creation in Quick tests.
Verify initialization steps and initialize pointers to avoid crashes. Change-Id: I2d3a53c6719727aed56e673d0d8cf5a02ae0f0f6 Reviewed-by: Laszlo Agocs <laszlo.agocs@theqtcompany.com>
-rw-r--r--tests/auto/quick/nodes/tst_nodestest.cpp17
-rw-r--r--tests/auto/quick/qquickitemlayer/tst_qquickitemlayer.cpp13
-rw-r--r--tests/auto/quick/scenegraph/tst_scenegraph.cpp4
3 files changed, 24 insertions, 10 deletions
diff --git a/tests/auto/quick/nodes/tst_nodestest.cpp b/tests/auto/quick/nodes/tst_nodestest.cpp
index e017cae422..37a73cca6f 100644
--- a/tests/auto/quick/nodes/tst_nodestest.cpp
+++ b/tests/auto/quick/nodes/tst_nodestest.cpp
@@ -82,19 +82,24 @@ void NodesTest::initTestCase()
surface = new QOffscreenSurface;
surface->create();
+ QVERIFY(surface->isValid());
context = new QOpenGLContext();
- context->create();
- context->makeCurrent(surface);
+ QVERIFY(context->create());
+ QVERIFY(context->makeCurrent(surface));
renderContext = renderLoop->createRenderContext(renderLoop->sceneGraphContext());
+ QVERIFY(renderContext);
renderContext->initialize(context);
+ QVERIFY(renderContext->isValid());
}
void NodesTest::cleanupTestCase()
{
- renderContext->invalidate();
- context->doneCurrent();
+ if (renderContext)
+ renderContext->invalidate();
+ if (context)
+ context->doneCurrent();
delete context;
delete surface;
}
@@ -133,10 +138,12 @@ public:
int DummyRenderer::globalRendereringOrder;
NodesTest::NodesTest()
+ : surface(Q_NULLPTR)
+ , context(Q_NULLPTR)
+ , renderContext(Q_NULLPTR)
{
}
-
void NodesTest::propegate()
{
QSGRootNode root;
diff --git a/tests/auto/quick/qquickitemlayer/tst_qquickitemlayer.cpp b/tests/auto/quick/qquickitemlayer/tst_qquickitemlayer.cpp
index eb720e5109..d46258889f 100644
--- a/tests/auto/quick/qquickitemlayer/tst_qquickitemlayer.cpp
+++ b/tests/auto/quick/qquickitemlayer/tst_qquickitemlayer.cpp
@@ -62,6 +62,7 @@ public:
}
private slots:
+ void initTestCase() Q_DECL_OVERRIDE;
void layerEnabled();
void layerSmooth();
void layerMipmap();
@@ -92,14 +93,20 @@ private:
};
tst_QQuickItemLayer::tst_QQuickItemLayer()
- : m_mesaVersion(0)
+ : m_isMesaSoftwareRasterizer(false)
+ , m_mesaVersion(0)
{
+}
+
+void tst_QQuickItemLayer::initTestCase()
+{
+ QQmlDataTest::initTestCase();
QWindow window;
QOpenGLContext context;
window.setSurfaceType(QWindow::OpenGLSurface);
window.create();
- context.create();
- context.makeCurrent(&window);
+ QVERIFY(context.create());
+ QVERIFY(context.makeCurrent(&window));
const char *vendor = (const char *)context.functions()->glGetString(GL_VENDOR);
const char *renderer = (const char *)context.functions()->glGetString(GL_RENDERER);
m_isMesaSoftwareRasterizer = strcmp(vendor, "Mesa Project") == 0
diff --git a/tests/auto/quick/scenegraph/tst_scenegraph.cpp b/tests/auto/quick/scenegraph/tst_scenegraph.cpp
index 4f24acc48c..7189fda8b7 100644
--- a/tests/auto/quick/scenegraph/tst_scenegraph.cpp
+++ b/tests/auto/quick/scenegraph/tst_scenegraph.cpp
@@ -222,7 +222,7 @@ void tst_SceneGraph::manyWindows()
QOpenGLContext sharedGLContext;
ShareContextResetter cleanup; // To avoid dangling pointer in case of test-failure.
if (shared) {
- sharedGLContext.create();
+ QVERIFY(sharedGLContext.create());
QOpenGLContextPrivate::setGlobalShareContext(&sharedGLContext);
}
@@ -459,7 +459,7 @@ void tst_SceneGraph::hideWithOtherContext()
window.resize(100, 100);
window.create();
QOpenGLContext context;
- context.create();
+ QVERIFY(context.create());
bool renderingOnMainThread = false;
{