Title: [jbehave] [603] trunk/extensions/swing/src/behaviour/jbehave/extensions/threaded/swing/DefaultWindowWrapperBehaviour.java: [EK] Found the problem with the mocking of actions; pending now fixed.
Revision
603
Author
sirenian
Date
2006-12-01 10:23:07 -0600 (Fri, 01 Dec 2006)

Log Message

[EK] Found the problem with the mocking of actions; pending now fixed.

Modified Paths

Diff

Modified: trunk/extensions/swing/src/behaviour/jbehave/extensions/threaded/swing/DefaultWindowWrapperBehaviour.java (602 => 603)

--- trunk/extensions/swing/src/behaviour/jbehave/extensions/threaded/swing/DefaultWindowWrapperBehaviour.java	2006-12-01 16:04:35 UTC (rev 602)
+++ trunk/extensions/swing/src/behaviour/jbehave/extensions/threaded/swing/DefaultWindowWrapperBehaviour.java	2006-12-01 16:23:07 UTC (rev 603)
@@ -14,7 +14,6 @@
 import javax.swing.KeyStroke;
 import javax.swing.text.JTextComponent;
 
-import jbehave.core.exception.PendingException;
 import jbehave.core.minimock.UsingMiniMock;
 import jbehave.core.mock.Constraint;
 import jbehave.core.mock.Mock;
@@ -126,23 +125,17 @@
     
     public void shouldSimulateKeyPressesForInputMap() throws TimeoutException {
         checkForHeadless();
-        if (true) { throw new PendingException(); }
 		DefaultWindowWrapper wrapper = new DefaultWindowWrapper("a.window");
 		
         try {
-            JFrame frame = disposeOnCloseFrame();
-            JPanel panel = new JPanel();
-            panel.getInputMap().put(KeyStroke.getKeyStroke(' '), "an action");
-            frame.setContentPane(panel);
-            frame.setName("a.window");
-            frame.pack();
-            frame.setVisible(true);
+            AFrame frame = new AFrame();            
+
+            Mock action = ""
+            action.stubs("isEnabled").will(returnValue(true));
+            action.expects("actionPerformed").with(anything());
             
+            frame.contentPanel.getActionMap().put("an action", (Action) action);
             
-            Mock action = ""
-            action.expects("actionPerformed");
-            panel.getActionMap().put("an action", (Action) action);
-            
             wrapper.pressKeychar(' ');
             
             verifyMocks();
@@ -189,5 +182,18 @@
         new HeadlessChecker().check();
     }
 
+    public class AFrame extends JFrame {
+        private JPanel contentPanel = new JPanel();
+        public AFrame() {
+            setName("a.window");
+            setContentPane(contentPanel);
 
+            contentPanel.getInputMap().put(KeyStroke.getKeyStroke(' '), "an action");
+            
+            this.pack();
+            this.setVisible(true);
+            
+            this.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
+        }
+    }
 }


To unsubscribe from this list please visit:

http://xircles.codehaus.org/manage_email

Reply via email to