将测试运行程序与被测应用程序同步

发布于 2024-12-23 17:17:02 字数 439 浏览 1 评论 0原文

我正在修复使用 java.awt.Robot 来操作测试下的应用程序的自定义测试运行程序。
在每个最简单的操作(鼠标移动到某个组件,单击鼠标)之后,我需要测试运行程序等待被测应用程序处理事件。仅在此之后继续检查值,单击其他一些按钮等。
有 Robot.waitForIdle() 函数可以等待事件队列变空。
但由于早期检查值,我仍然遇到同步问题(假设值不是在某些后台线程中计算的,而是在 EDT 线程中计算的)。
我猜测这是因为 Robot 没有直接将事件放入事件队列,但这有利于底层操作系统将 Robot 生成的新事件放入 JVM 事件队列。而且这个本机调用是异步的,这意味着将新事件放入事件队列不会由任何 JVM 线程执行,这与 SwingUtilities.invokeLater() 不同。

是否可以实现一些钩子来确定或等待底层操作系统将新事件放入事件队列?
我错过了什么吗?

谢谢。

I'm fixing custom test runner that use java.awt.Robot to manipulate applicaition under test.
After each simplest operation (mouse mote to some component, mouse click) I need test runner TO WAIT for application under test process the event. And ONLY AFTER this continue to check values, clicking some other buttons etc.
There is Robot.waitForIdle() function that could wait for event queue to become empty.
But I still have problems with synchronisation due to early checking values (let suppose values that is not calculated in some background threads but very EDT thread).
My guess this is due to Robot is not putting event to event queue directly but this is favour of underlying OS to put new event generated by Robot to JVM event queue. And this native calls is asynchronous, means putting new event to event queue is not performed by any of JVM threads not like SwingUtilities.invokeLater() does.

Is it posible to implement some hook to determine or to wait for underlying OS put new event to event queue?
Am I missing anything?

Thanks.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

洋洋洒洒 2024-12-30 17:17:02

SunToolkit#realSync()

SunToolkit#realSync()

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文