📄 testsleepcommand.java
字号:
import junit.framework.*;
import junit.swingui.TestRunner;
public class TestSleepCommand extends TestCase
{
public static void main(String[] args)
{
TestRunner.main(new String[]{"TestSleepCommand"});
}
public TestSleepCommand(String name)
{
super(name);
}
private boolean commandExecuted = false;
public void testSleep() throws Exception
{
Command wakeup = new Command()
{
public void execute() {commandExecuted = true;}
};
ActiveObjectEngine e = new ActiveObjectEngine();
SleepCommand c = new SleepCommand(1000,e,wakeup);
e.addCommand(c);
long start = System.currentTimeMillis();
e.run();
long stop = System.currentTimeMillis();
long sleepTime = (stop-start);
assert("SleepTime " + sleepTime + " expected > 1000", sleepTime > 1000);
assert("SleepTime " + sleepTime + " expected < 1100", sleepTime < 1100);
assert("Command Executed", commandExecuted);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -