gWidget:有没有办法在 testthat 中模拟用户操作?

gWidget : is there a way to emulate user actions in testthat?

在我的包中,我使用了 testthatgWidgetRGtk2,我想知道是否有一种方法可以从代码行中模拟用户操作,例如下面的我'正在测试用户按下按钮的动作。到目前为止,我一直无法测试那部分代码,所以我必须手动测试所有这些。

require(gWidgets)
options("guiToolkit"="RGtk2")

win <- gwindow("Hello World", visible=TRUE)
obj <- gbutton("Hello world", container = gwindow(),
 handler = function(h,...) assign("test",1,.GlobalEnv))

require(testthat)
test_that("Test button click",{
     # Something here to emulate pushing button      
      expect_equivalent(test,1)
    })

如何模拟用户的操作?

经过仔细搜索,我认为答案是在测试中调用处理函数。我没有找到从源代码访问 invoke_change_handler 的任何方法。