windowforawtwindowtest.java

来自「基于Junit的 功能和单元测试的的测试工具。只支持Swing.」· Java 代码 · 共 67 行

JAVA
67
字号
package org.uispec4j;

import junit.framework.AssertionFailedError;
import org.uispec4j.xml.XmlAssert;

import javax.swing.JMenuBar;
import javax.swing.JTextField;
import java.awt.Frame;

public class WindowForAwtWindowTest extends WindowTestCase {
  public void test() throws Exception {
    Window window = createWindow();
    assertEquals("", window.getTitle());
  }

  public void testWindowManagesMenuBars() throws Exception {
    // not supported
  }

  public void testGetTitle() throws Exception {
    assertEquals("", createWindow().getTitle());
  }

  public void testAssertTitleEquals() throws Exception {
    final Window window = createWindow();
    assertTrue(window.titleEquals(""));
    checkAssertionFails(window.titleEquals("title"),
                        "expected:<title> but was:<>");
  }

  public void testGetDescription() throws Exception {
    Window window = createWindow();
    window.getAwtComponent().setName("myFrame");

    JTextField textField = new JTextField();
    textField.setName("myText");
    addComponent(window, textField);

    XmlAssert.assertEquivalent("<window title=''>" +
                               "  <textBox name='myText'/>" +
                               "</window>",
                               window.getDescription());
  }

  protected Window createWindowWithMenu(JMenuBar jMenuBar) {
    throw new AssertionFailedError("not supported");
  }

  protected Window createWindowWithTitle(String title) {
    throw new AssertionFailedError("not supported");
  }

  protected void close(Window window) {
    java.awt.Window awtWindow = (java.awt.Window)window.getAwtComponent();
    awtWindow.setVisible(false);
  }

  protected UIComponent createComponent() {
    return createWindow();
  }

  protected Window createWindow() {
    java.awt.Window awtWindow = new java.awt.Window(new Frame());
    return new Window(awtWindow);
  }
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?