01: package org.uispec4j;
02:
03: import junit.framework.AssertionFailedError;
04: import org.uispec4j.xml.XmlAssert;
05:
06: import javax.swing.JMenuBar;
07: import javax.swing.JTextField;
08: import java.awt.Frame;
09:
10: public class WindowForAwtWindowTest extends WindowTestCase {
11: public void test() throws Exception {
12: Window window = createWindow();
13: assertEquals("", window.getTitle());
14: }
15:
16: public void testWindowManagesMenuBars() throws Exception {
17: // not supported
18: }
19:
20: public void testGetTitle() throws Exception {
21: assertEquals("", createWindow().getTitle());
22: }
23:
24: public void testAssertTitleEquals() throws Exception {
25: final Window window = createWindow();
26: assertTrue(window.titleEquals(""));
27: checkAssertionFails(window.titleEquals("title"),
28: "expected:<title> but was:<>");
29: }
30:
31: public void testGetDescription() throws Exception {
32: Window window = createWindow();
33: window.getAwtComponent().setName("myFrame");
34:
35: JTextField textField = new JTextField();
36: textField.setName("myText");
37: addComponent(window, textField);
38:
39: XmlAssert.assertEquivalent("<window title=''>"
40: + " <textBox name='myText'/>" + "</window>", window
41: .getDescription());
42: }
43:
44: protected Window createWindowWithMenu(JMenuBar jMenuBar) {
45: throw new AssertionFailedError("not supported");
46: }
47:
48: protected Window createWindowWithTitle(String title) {
49: throw new AssertionFailedError("not supported");
50: }
51:
52: protected void close(Window window) {
53: java.awt.Window awtWindow = (java.awt.Window) window
54: .getAwtComponent();
55: awtWindow.setVisible(false);
56: }
57:
58: protected UIComponent createComponent() {
59: return createWindow();
60: }
61:
62: protected Window createWindow() {
63: java.awt.Window awtWindow = new java.awt.Window(new Frame());
64: return new Window(awtWindow);
65: }
66: }
|