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:
2026-07-17 17:38:15 +08:00
parent bbf3b2ca38
commit 9ca2b0e716
+17
View File
@@ -1,6 +1,8 @@
#include <gtest/gtest.h>
#include <QProgressBar>
#include <QOffscreenSurface>
#include <QOpenGLContext>
#include <QSignalSpy>
#include <QTest>
#include <QXmlStreamReader>
@@ -248,6 +250,21 @@ TEST(MainWindowStatusBar, DoubleClickEmitsSignal)
// MainWindow directly.
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
// Project whose ColorManager dereferences the default OCIO config
ColorManager::SetUpDefaultConfig();