如何在无头环境中测试 JavaFX 2? [英] How to test JavaFX 2 in a headless environment?

查看:29
本文介绍了如何在无头环境中测试 JavaFX 2?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用集成的 JavaFX 2.2 自动测试在 Java 7u6 上运行的 JavaFX 2 应用程序.为此,我构建并集成了 Jemmy3JemmyFX 进入我的构建环境.在所有相关操作系统上运行一个简单的冒烟测试.

I am trying to automate testing for a JavaFX 2 application running on Java 7u6 with the integrated JavaFX 2.2. To that end, I have built and integrated Jemmy3 and JemmyFX into my build environment. A simple smoke test runs on all relevant OSs.

下一步,我想在持续部署过程中运行测试.由于当前的 CI 服务器运行在 OpenSUSE 上,JavaFX 并未正式支持,我已经在虚拟机中安装了 Ubuntu Server 并安装了 gtk2.
为了弥补缺乏完全成熟的窗口系统的问题,我尝试在 XvncXvfb 上运行测试,但无济于事.

As a next step, I want to run the tests as part of the continuous deployment process. Since the current CI server runs on OpenSUSE, which is not officially supported by JavaFX, I have set up an Ubuntu Server installation in a virtual machine and installed gtk2.
To remedy the lack of a fully fledged windowing system, I have tried running the tests on both Xvnc and Xvfb, but to no avail.

Xvnc 上,测试失败并显示

On Xvnc, the tests fail with

Prism ES2 Error - nInitialize: glXChooseFBConfig failed

而在 Xvfb 上,他们给了我

whereas on Xvfb, they give me

Xlib:  extension "RANDR" missing on display ":10".

建议博文安装 gtk-engines-pixbuf 来缓解第二个问题,但这只是改变了错误消息中显示的数量.

A blog post suggested to install gtk-engines-pixbuf to alleviate the second problem, but this only changed the number of the display in the error message.

现在,我召唤StackOverflow的JavaFX知识问

Now, I summon the JavaFX knowledge of StackOverflow and ask

  • 您知道如何解决上述错误吗?
  • 您是否在(无头)CI 服务器上成功运行 JavaFX 2 测试或机器人交互?
  • 您如何配置该系统以使其正常工作?

推荐答案

JavaFX 的(无头)CI 服务器测试在 JavaFX 8 之前不可用.

Support for (headless) CI server testing of JavaFX is not available until JavaFX 8.

根据这些 JavaFX 问题跟踪记录中的信息回答:

Answer based on information in these JavaFX issue tracking records:

  • JDK-8088651 "Headless Glass 工具包需要连接到 Quantum 和棱镜单元测试"
  • JDK-8091286量子需要无头和有头测试").
  • JDK-8088651 "Headless Glass toolkit needs to be connected to Quantum and Prism unit tests"
  • JDK-8091286 "Quantum needs headless and headful tests").

2015 年 1 月 8 日更新

链接的 JavaFX 问题跟踪记录未针对 Java 8 实现,已重新分配给 Java 9.

The linked JavaFX issue tracking records were not implemented for Java 8 and have been reassigned to Java 9.

Java 8 源代码当前包含一个名为 Monocle 的最小渲染引擎,它为 JavaFX 组件提供无头渲染(以及针对各种其他目标平台的渲染).我从未使用过 Monocle,也无法提供有关如何使用它进行无头渲染的详细说明.我相信要使用 Monocle,您目前需要从源代码执行 JavaFX 的自定义构建(因为我认为 Monocle 通常只提供嵌入式 JavaFX 版本,这不是桌面 Java 运行时和 JDK 环境附带的标准 JavaFX 版本).

Java 8 source code currently includes a minimal rendering engine named Monocle which provides Headless rendering (and rendering for various other target platforms) for JavaFX components. I have never used Monocle and cannot provide detailed instructions on how to use it for headless rendering. I believe to use Monocle, you currently need to perform a custom build of JavaFX from source (as I think Monocle is usually only shipped in embedded JavaFX versions, which is not the standard JavaFX version which ships with the desktop Java runtime and JDK environments).

JavaFX wiki 上提供了有关 Monocle 的信息.

Information on Monocle is available on the JavaFX wiki.

虽然,无头渲染是由 Monocle 提供的,但我不认为 Oracle 官方支持使用 Monocle 进行无头渲染(虽然我不认为官方支持任何形式的 JavaFX 无头渲染,所以我猜如果Monocle 很适合你,一定要使用它).

Although, headless rendering is provided by Monocle, I do not think that using Monocle to perform headless rendering is officially supported by Oracle (though i don't think headless rendering of JavaFX in any form is officially supported, so I guess if Monocle works well for you, by all means use it).

Monocle 中的无头渲染是一种软件渲染实现,因此某些图形基元的执行速度可能比桌面环境中 JavaFX 的标准硬件加速操作慢.

The headless rendering in Monocle is a software rendering implementation so execution of some graphic primitives may be slower than the standard hardware accelerated operation of JavaFX in a desktop environment.

可能还有其他方法可以让 JavaFX 在我不知道的无头环境中运行.

There may be other methods of allowing JavaFX to run in a headless environment that I am not aware of.

如果有疑问,请在 openjfx-dev 邮件列表.

如果您在 Linux 下运行,则按照 Jan Zarnikov 的回答建议使用 Xvfb 可能是一个很好的解决方案,并且可能比使用 Monocle 更可取.

If you are running under Linux, using Xvfb as suggested by Jan Zarnikov's answer is probably a good solution and is likely preferable to using Monocle.

这篇关于如何在无头环境中测试 JavaFX 2?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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