对于Sikulix,Mac上的App.close()会关闭应用程序,但返回false.这是正确的吗



我正在用Java构建SikuliX自动化脚本,对.close()方法的行为感到困惑。在Sikuli的App类中,关闭方法如下:

/**
* tries to close the app defined by this App instance, waits max given seconds for the app to no longer be running
*
* @return this or null on failure
*/
public boolean close(int waitTime) {
if (!isRunning()) {
log("App.close: not running: %s", this);
return false;
}
if (_osUtil.close(this)) {
int timeTowait = maxWait;
if (waitTime > 0) {
timeTowait = waitTime;
}
while (isRunning(0) && timeTowait > 0) {
timeTowait--;
}
}
if (!isValid()) {
log("App.close: %s", this);
} else {
log("App.close: did not work: %s", this);
return true;
}
return false;
}

对我来说,有问题的部分是回报。我的理解是,由于它返回一个布尔值,所以如果关闭成功,它将为true,如果关闭失败,它将是false。但是,此代码的作用正好相反。基于我对这个逻辑有缺陷的理解,我最初写的代码是这样的,

if (myApp.close()) {
System.out.println("closed.");
isAppClosed = true;
} else {
System.out.println("NOT closed!");
isAppClosed = false;
}

这与我想要的结果相反,因为应用程序正在成功关闭,但测试失败了,因为";未关闭";正在打印。

我发现虫子了吗?还是我遗漏了什么?

谢谢。

原来这是一个错误。该项目的维护人员在1.1.4的最新版本中修补了这个问题。https://bugs.launchpad.net/sikuli/+bug/1811938

最新更新