This is the mail archive of the mauve-patches@sourceware.org mailing list for the Mauve project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

FYI: Added a new test for JTextField


Hey,

This adds one other test for
javax.swing.JTextField.fireActionPerformed().

2006-10-31  Tania Bento  <tbento@redhat.com>

        * gnu/testlet/javax/swing/JTextField/fireActionPerfomed: Added a
new test.

Cheers,
Tania

Index: gnu/testlet/javax/swing/JTextField/fireActionPerformed.java
===================================================================
RCS file: /cvs/mauve/mauve/gnu/testlet/javax/swing/JTextField/fireActionPerformed.java,v
retrieving revision 1.2
diff -u -r1.2 fireActionPerformed.java
--- gnu/testlet/javax/swing/JTextField/fireActionPerformed.java	31 Oct 2006 19:53:17 -0000	1.2
+++ gnu/testlet/javax/swing/JTextField/fireActionPerformed.java	1 Nov 2006 14:32:05 -0000
@@ -44,7 +44,7 @@
   JTextField text;
   Robot robot;
   
-  protected void setUp(final TestHarness harness) throws Exception
+  protected void setUp1(final TestHarness harness) throws Exception
   {    
     text = new JTextField();
     text.setActionCommand(null);
@@ -66,6 +66,29 @@
     robot.delay(500);
   }
   
+  protected void setUp2(final TestHarness harness) throws Exception
+  {    
+    text = new JTextField();
+    text.setActionCommand("Action Command");
+    text.addActionListener(new ActionListener() {
+      public void actionPerformed(ActionEvent event)
+      {
+        harness.check(event.getActionCommand() != null);
+        harness.check(event.getActionCommand() != text.getText());
+        harness.check(event.getActionCommand() == "Action Command");
+      }
+    });
+    
+    frame = new JFrame();
+    frame.setSize(200, 200);
+    frame.getContentPane().add(text);
+    frame.show();
+    
+    robot = new Robot();
+    robot.setAutoDelay(50);
+    robot.delay(500);
+  }
+  
   protected void tearDown() throws Exception
   {
     frame.dispose();
@@ -106,9 +129,11 @@
   
   public void test(TestHarness harness) 
   {
+    // This test ensures that if actionCommand == null,
+    // then the user's input is used as the actionCommand.
     try
       {
-        setUp(harness);
+        setUp1(harness);
         try 
           {
             click(text, text.getWidth() / 2, text.getHeight() / 2);
@@ -124,6 +149,27 @@
         e.printStackTrace();
         harness.fail("Exception: " + e);
       }
+    
+    // This test ensures that if actionCommand != null,
+    // then the actionCommand is used.
+    try
+    {
+      setUp2(harness);
+      try 
+        {
+          click(text, text.getWidth() / 2, text.getHeight() / 2);
+          enterInput(harness);
+        }
+      finally
+        {
+          tearDown();
+        }
+    }
+  catch (Exception e)
+    {
+      e.printStackTrace();
+      harness.fail("Exception: " + e);
+    }
   }
  
 }

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]