This is the mail archive of the
mauve-patches@sourceware.org
mailing list for the Mauve project.
FYI: New test for JTextField.
- From: Anthony Balkissoon <abalkiss at redhat dot com>
- To: mauve-patches at sources dot redhat dot com
- Date: Thu, 12 Jan 2006 15:00:00 -0500
- Subject: FYI: New test for JTextField.
This test was to fix one of the regressions that Mark pointed out before
we release tomorrow.
2006-01-12 Anthony Balkissoon <abalkiss@redhat.com>
* gnu/testlet/javax/swing/JTextField/setDocument.java: New test.
--Tony
Index: gnu/testlet/javax/swing/JTextField/setDocument.java
===================================================================
RCS file: gnu/testlet/javax/swing/JTextField/setDocument.java
diff -N gnu/testlet/javax/swing/JTextField/setDocument.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ gnu/testlet/javax/swing/JTextField/setDocument.java 12 Jan 2006 19:58:24 -0000
@@ -0,0 +1,81 @@
+// Tags: JDK1.2
+
+// Copyright (C) 2005 Red Hat.
+
+// 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.
+
+package gnu.testlet.javax.swing.JTextField;
+
+import java.beans.PropertyChangeEvent;
+
+import javax.swing.JTextField;
+import javax.swing.text.Document;
+import javax.swing.plaf.basic.BasicTextFieldUI;
+
+import gnu.testlet.TestHarness;
+import gnu.testlet.Testlet;
+
+/**
+ * Checks if the setDocument method sets the "filterNewLines" property and if
+ * it does so through a PropertyChangeEvent.
+ */
+public class setDocument implements Testlet
+{
+ static TestHarness h2;
+
+ class TestUI extends BasicTextFieldUI
+ {
+ protected void propertyChange(PropertyChangeEvent evt)
+ {
+ Document doc = ((JTextField)getComponent()).getDocument();
+ h2.check (doc.getProperty("filterNewlines"), Boolean.TRUE);
+ super.propertyChange(evt);
+ h2.check (doc.getProperty("filterNewlines"), Boolean.TRUE);
+ }
+ }
+
+ static class TestTextField extends JTextField
+ {
+ public void setDocument(Document doc)
+ {
+ h2.check (doc.getProperty("filterNewlines") == null);
+ super.setDocument(doc);
+ h2.check (doc.getProperty("filterNewlines") != null);
+ }
+
+ public Document createDefaultModel()
+ {
+ return super.createDefaultModel();
+ }
+ }
+
+ /**
+ * Starts the testrun.
+ *
+ * @param harness the test harness to use
+ */
+ public void test(TestHarness harness)
+ {
+ h2 = harness;
+ TestTextField tf = new TestTextField();
+ tf.setUI(new TestUI());
+ Document doc = tf.createDefaultModel();
+ tf.setDocument(doc);
+ }
+
+}