windowinterceptiontest.java
来自「基于Junit的 功能和单元测试的的测试工具。只支持Swing.」· Java 代码 · 共 29 行
JAVA
29 行
package org.uispec4j.interception;
import junit.framework.AssertionFailedError;
import org.uispec4j.utils.AssertionFailureNotDetectedError;
import org.uispec4j.utils.Utils;
import javax.swing.*;
public class WindowInterceptionTest extends InterceptionTestCase {
public void testShowingAnUnexpectedWindow() throws Exception {
JFrame frame = new JFrame();
String frameTitle = "frame(" + getName() + ")";
frame.setTitle(frameTitle);
frame.getContentPane().add(new JButton("OK"));
try {
frame.setVisible(true);
throw new AssertionFailureNotDetectedError();
}
catch (AssertionFailedError e) {
assertEquals("Unexpected window shown - this window should be handled with WindowInterceptor. " +
"Window contents:" +
"<window title=\"" + frameTitle + "\">" +
"<button label=\"OK\"/></window>",
e.getMessage().replaceAll(Utils.LINE_SEPARATOR, ""));
}
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?