OpenGL 应用程序的自动化测试 [英] Automated testing for OpenGL application

查看:28
本文介绍了OpenGL 应用程序的自动化测试的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个使用 JOGL 提供大部分 GUI 的 Java 应用程序.

I have a Java Application that uses JOGL to provide a large part of the GUI.

是否有任何您知道或使用过的工具可以自动测试 OpenGL 应用程序(或者更具体地说是使用 JOGL 的应用程序)

Is there any tool which you know of, or have used which can automate the testing of OpenGL applications (or more specificly those using JOGL)

只是为了更新:该工具可以在 linux 或 windows 上运行.

Just to update: The tool can run on either linux or windows.

推荐答案

我已经为 C++ (Qt on Linux) &之前的OpenGL.我不知道它也不应该适用于 Java 的任何原因.

I have written unit-tests for C++ (Qt on Linux) & OpenGL before. I don't know any reason it shouldn't work for Java too.

对我有用的是:

  • 抽象您的 OpenGL 上下文提供程序,以便您的其余代码独立于它.在我的例子中,主应用程序使用了 Qt 的 QGLWidget,但是单元测试使用了一个基于 pbuffer 的应用程序,我可以在没有窗口基础设施的情况下创建它(除了指定的 X11 DISPLAY).后来我添加了一个屏幕外 Mesa"(纯软件 OpenGL 实现),因此他们甚至可以在完全没有 GPU 的无头构建机器上工作.

  • Abstract your OpenGL context provider so the rest of your code is independent of it. In my case the main app used Qt's QGLWidget, but the unittests used a pbuffer-based one which I could create with no windowing infrastructure at all (other than a designated X11 DISPLAY). Later I added an "offscreen Mesa" (pure software OpenGL implementation) so they'd even work on a headless build machine with no GPU at all.

让您的 OpenGL 代码独立于您的 GUI 代码.在我的情况下,OpenGL渲染引擎"对 Qt 类(例如鼠标事件)一无所知.定义您自己的可测试 API,它不依赖于任何特定的 GUI 概念,并为其编写测试.

Keep your OpenGL code independent of your GUI code. In my case the OpenGL "rendering engine" didn't know anything about Qt classes (e.g mouse events). Define your own testable API which isn't tied to any specific GUI concepts, and write tests for it.

在单元测试中,使用 glReadPixels 从帧缓冲区中读回内容,然后用一些关于哪些像素应该是特定值的断言来命中它们,或者沿着回归测试路线并将帧缓冲区捕获与存储的数据进行比较您知道是好的图像(来自手动验证,或者因为它是从其他参考模型生成的).

In the unittests, read the contents back from the framebuffer using glReadPixels and either hit them with some assertions about which pixels should be particular values, or go down the regression-testing route and compare the framebuffer capture with a stored image you know is good (either from manual verification, or because it's produced from some other reference model).

在任何图像回归测试中允许一些模糊性;大多数 OpenGL 实现产生的输出略有不同.

Allow a bit of fuzziness in any image regression testing; most OpenGL implementations produce slightly different output.

(我没有这样做,但是...)理想情况下,您希望能够通过断言它对您的渲染引擎进行预期的调用序列以响应 GUI 活动来测试 GUI 层.如果它这样做了,并且由于上述测试,您对渲染层充满信心......好吧,不需要实际进行渲染.因此,为您的渲染层创建一个合适的模拟对象以在 GUI 测试时使用(我想像鼠标从这里拖动到那里导致调用渲染层以设置特定的变换矩阵"之类的测试......像这样的东西).

(I didn't do this, but...) Ideally you want to be able to test the GUI layer by asserting that it makes the expected sequence of calls to your rendering engine in response to GUI activity. If it does that, and you're confident of your render layer because of the above tests... well, no need to actually do the rendering. So create a suitable mock object of your rendering layer for use when GUI testing (I'd imagine tests like "mouse drag from here to there results in a call to the rendering layer to set a particular transform matrix"... stuff like that).

这篇关于OpenGL 应用程序的自动化测试的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆