From: Tania Bento <tbento@redhat.com>
To: mauve-patches@sources.redhat.com
Subject: FYI: New JTextField test
Date: Tue, 31 Oct 2006 19:27:00 -0000 [thread overview]
Message-ID: <1162322842.17015.74.camel@toothpaste.toronto.redhat.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 216 bytes --]
Hey,
This adds one new test for javax.swing.JTextField.fireActionPerformed().
2006-10-31 Tania Bento <tbento@redhat.com>
* gnu/testlet/javax/swing/JTextField/fireActionPerfomed: New
test.
Cheers,
Tania
[-- Attachment #2: patch.diff --]
[-- Type: text/x-patch, Size: 3583 bytes --]
Index: gnu/testlet/javax/swing/JTextField/fireActionPerformed.java
===================================================================
RCS file: gnu/testlet/javax/swing/JTextField/fireActionPerformed.java
diff -N gnu/testlet/javax/swing/JTextField/fireActionPerformed.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ gnu/testlet/javax/swing/JTextField/fireActionPerformed.java 31 Oct 2006 19:26:57 -0000
@@ -0,0 +1,128 @@
+/* fireActionPerfomed.java
+ Copyright (C) 2006
+This file is part of Mauve.
+
+Mauve is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+Mauve is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with Mauve; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+*/
+
+// Tags: 1.4
+
+package gnu.testlet.javax.swing.JTextField;
+
+import java.awt.Point;
+import java.awt.Robot;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.awt.event.InputEvent;
+import java.awt.event.KeyEvent;
+
+import javax.swing.JFrame;
+import javax.swing.JTextField;
+import javax.swing.SwingUtilities;
+
+import gnu.testlet.TestHarness;
+import gnu.testlet.Testlet;
+
+public class fireActionPerformed implements Testlet
+{
+
+ JFrame frame;
+ JTextField text;
+ Robot robot;
+
+ protected void setUp(final TestHarness harness) throws Exception
+ {
+ text = new JTextField();
+ text.addActionListener(new ActionListener() {
+ public void actionPerformed(ActionEvent event)
+ {
+ harness.check(event.getActionCommand() != null);
+ harness.check(event.getActionCommand(), text.getText());
+ }
+ });
+
+ 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();
+ }
+
+ public void click(JTextField text, int x, int y)
+ {
+ Point p = new Point();
+ p.x = x;
+ p.y = y;
+
+ SwingUtilities.convertPointToScreen(p, text);
+ robot.mouseMove(p.x, p.y);
+ robot.mousePress(InputEvent.BUTTON1_MASK);
+ robot.mouseRelease(InputEvent.BUTTON1_MASK);
+ }
+
+ public void type(int key)
+ {
+ robot.keyPress(key);
+ robot.keyRelease(key);
+ }
+
+ public void enterInput(TestHarness harness)
+ {
+ type(KeyEvent.VK_U);
+ type(KeyEvent.VK_S);
+ type(KeyEvent.VK_E);
+ type(KeyEvent.VK_R);
+ type(KeyEvent.VK_SPACE);
+ type(KeyEvent.VK_I);
+ type(KeyEvent.VK_N);
+ type(KeyEvent.VK_P);
+ type(KeyEvent.VK_U);
+ type(KeyEvent.VK_T);
+ type(KeyEvent.VK_ENTER);
+ }
+
+ public void test(TestHarness harness)
+ {
+ try
+ {
+ setUp(harness);
+ try
+ {
+ click(text, text.getWidth() / 2, text.getHeight() / 2);
+ enterInput(harness);
+ }
+ finally
+ {
+ tearDown();
+ }
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ harness.fail("Exception: " + e);
+ }
+ }
+
+}
reply other threads:[~2006-10-31 19:27 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1162322842.17015.74.camel@toothpaste.toronto.redhat.com \
--to=tbento@redhat.com \
--cc=mauve-patches@sources.redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).