tests: skip MainWindow construction test where OpenGL is unavailable
The test forces GraphicsBackend=opengl and builds a full MainWindow with QOpenGLWidget-based viewer panels. On headless platforms whose QPA cannot provide a GL context (Ubuntu/Windows CI on offscreen), the app's GL calls crash on a non-current context (SEGFAULT in CI on both). Probe with QOpenGLContext+QOffscreenSurface and GTEST_SKIP when GL is unusable; the test still runs on platforms with real GL.
This commit is contained in:
@@ -1,6 +1,8 @@
|
|||||||
#include <gtest/gtest.h>
|
#include <gtest/gtest.h>
|
||||||
|
|
||||||
#include <QProgressBar>
|
#include <QProgressBar>
|
||||||
|
#include <QOffscreenSurface>
|
||||||
|
#include <QOpenGLContext>
|
||||||
#include <QSignalSpy>
|
#include <QSignalSpy>
|
||||||
#include <QTest>
|
#include <QTest>
|
||||||
#include <QXmlStreamReader>
|
#include <QXmlStreamReader>
|
||||||
@@ -248,6 +250,21 @@ TEST(MainWindowStatusBar, DoubleClickEmitsSignal)
|
|||||||
// MainWindow directly.
|
// MainWindow directly.
|
||||||
TEST(MainWindow, ConstructsOffscreenWithPanelsAndMenus)
|
TEST(MainWindow, ConstructsOffscreenWithPanelsAndMenus)
|
||||||
{
|
{
|
||||||
|
// MainWindow instantiates viewer panels containing QOpenGLWidget. On
|
||||||
|
// platforms without a usable OpenGL implementation (e.g. headless CI
|
||||||
|
// runners on the offscreen QPA), constructing it crashes in GL code
|
||||||
|
// ("QOpenGLFunctions created with non-current context"). Probe first and
|
||||||
|
// skip where GL is unavailable.
|
||||||
|
QOffscreenSurface probe_surface;
|
||||||
|
probe_surface.create();
|
||||||
|
QOpenGLContext probe_context;
|
||||||
|
const bool gl_available =
|
||||||
|
probe_context.create() && probe_context.makeCurrent(&probe_surface);
|
||||||
|
probe_context.doneCurrent();
|
||||||
|
if (!gl_available) {
|
||||||
|
GTEST_SKIP() << "OpenGL is not usable on this platform";
|
||||||
|
}
|
||||||
|
|
||||||
// Must precede RenderManager creation: PreviewAutoCacher constructs a
|
// Must precede RenderManager creation: PreviewAutoCacher constructs a
|
||||||
// Project whose ColorManager dereferences the default OCIO config
|
// Project whose ColorManager dereferences the default OCIO config
|
||||||
ColorManager::SetUpDefaultConfig();
|
ColorManager::SetUpDefaultConfig();
|
||||||
|
|||||||
Reference in New Issue
Block a user