From 2f96fb1beec5251e27381c09d0ad810c6e829c37 Mon Sep 17 00:00:00 2001 From: Laszlo Agocs Date: Tue, 9 Sep 2014 10:06:45 +0200 Subject: Add an option to share between TLWs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Task-number: QTBUG-41191 Change-Id: I510d1631926ed0d9e371703d22229aed92432aa6 Reviewed-by: Jørgen Lind --- .../kernel/qguiapplication/tst_qguiapplication.cpp | 27 ++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'tests') diff --git a/tests/auto/gui/kernel/qguiapplication/tst_qguiapplication.cpp b/tests/auto/gui/kernel/qguiapplication/tst_qguiapplication.cpp index 2ce9dca153..1d6df973ed 100644 --- a/tests/auto/gui/kernel/qguiapplication/tst_qguiapplication.cpp +++ b/tests/auto/gui/kernel/qguiapplication/tst_qguiapplication.cpp @@ -53,6 +53,8 @@ #include #endif +#include + #include #include "tst_qcoreapplication.h" @@ -79,6 +81,7 @@ private slots: void quitOnLastWindowClosed(); void genericPluginsAndWindowSystemEvents(); void layoutDirection(); + void globalShareContext(); }; void tst_QGuiApplication::cleanup() @@ -915,4 +918,28 @@ void tst_QGuiApplication::layoutDirection() QCOMPARE(signalSpy.count(), 1); } +void tst_QGuiApplication::globalShareContext() +{ +#ifndef QT_NO_OPENGL + // Test that there is a global share context when requested. + QCoreApplication::setAttribute(Qt::AA_ShareOpenGLContexts); + int argc = 1; + char *argv[] = { const_cast("tst_qguiapplication") }; + QScopedPointer app(new QGuiApplication(argc, argv)); + QOpenGLContext *ctx = qt_gl_global_share_context(); + QVERIFY(ctx); + app.reset(); + ctx = qt_gl_global_share_context(); + QVERIFY(!ctx); + + // Test that there is no global share context by default. + QCoreApplication::setAttribute(Qt::AA_ShareOpenGLContexts, false); + app.reset(new QGuiApplication(argc, argv)); + ctx = qt_gl_global_share_context(); + QVERIFY(!ctx); +#else + QSKIP("No OpenGL support"); +#endif +} + QTEST_APPLESS_MAIN(tst_QGuiApplication) -- cgit v1.2.3