将测试运行程序与被测应用程序同步
我正在修复使用 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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
SunToolkit#realSync()
SunToolkit#realSync()