Java 对于Sikulix,Mac上的App.close()关闭应用程序,但返回false。这是正确的吗?
我正在用Java构建一个自动化脚本,对Java 对于Sikulix,Mac上的App.close()关闭应用程序,但返回false。这是正确的吗?,java,testing,sikuli,sikuli-x,Java,Testing,Sikuli,Sikuli X,我正在用Java构建一个自动化脚本,对.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 c
.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;
}
对我来说,问题的部分是回报。我的理解是,因为它返回一个布尔值,所以如果关闭成功则为真,如果关闭失败则为假。但是,此代码的作用正好相反。
基于我对这个逻辑有缺陷的(?)理解,我最初是这样写代码的
if (myApp.close()) {
System.out.println("closed.");
isAppClosed = true;
} else {
System.out.println("NOT closed!");
isAppClosed = false;
}
这与我想要的结果相反,因为应用程序正在成功关闭,但测试失败,因为正在打印“未关闭”
我是否发现了一个bug,或者我遗漏了什么
谢谢。原来是个bug。该项目的维护人员已在最新版本1.1.4中修补了该问题。