MCPcopy Create free account
hub / github.com/comaps/comaps / RunTestInOpenGLOffscreenEnvironment

Function RunTestInOpenGLOffscreenEnvironment

libs/qt_tstfrm/test_main_loop.cpp:47–86  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

45}
46
47void RunTestInOpenGLOffscreenEnvironment(char const * testName, testing::TestFunction const & fn)
48{
49 std::vector<char> buf(strlen(testName) + 1);
50 strcpy(buf.data(), testName);
51 char * raw = buf.data();
52
53 int argc = 1;
54 QApplication app(argc, &raw);
55
56 QSurfaceFormat fmt;
57 fmt.setAlphaBufferSize(8);
58 fmt.setBlueBufferSize(8);
59 fmt.setGreenBufferSize(8);
60 fmt.setRedBufferSize(8);
61 fmt.setStencilBufferSize(0);
62 fmt.setSamples(0);
63 fmt.setSwapBehavior(QSurfaceFormat::DoubleBuffer);
64 fmt.setSwapInterval(1);
65 fmt.setDepthBufferSize(16);
66 fmt.setProfile(QSurfaceFormat::CoreProfile);
67 fmt.setVersion(3, 2);
68
69 auto surface = std::make_unique<QOffscreenSurface>();
70 surface->setFormat(fmt);
71 surface->create();
72
73 auto context = std::make_unique<QOpenGLContext>();
74 context->setFormat(fmt);
75 context->create();
76 context->makeCurrent(surface.get());
77
78 if (fn)
79 fn();
80
81 context->doneCurrent();
82 surface->destroy();
83
84 QTimer::singleShot(0, &app, SLOT(quit()));
85 app.exec();
86}

Callers 2

UNIT_TESTFunction · 0.85
UNIT_TESTFunction · 0.85

Calls 5

makeCurrentMethod · 0.80
getMethod · 0.65
dataMethod · 0.45
createMethod · 0.45
destroyMethod · 0.45

Tested by

no test coverage detected