This is the mail archive of the
mauve-patches@sourceware.org
mailing list for the Mauve project.
FYI: TextArea and TextField constructors - new tests
- From: David Gilbert <david dot gilbert at object-refinery dot com>
- To: mauve-patches <mauve-patches at sources dot redhat dot com>
- Date: Fri, 30 Jun 2006 10:18:38 +0100
- Subject: FYI: TextArea and TextField constructors - new tests
This patch (committed) adds some checks for the constructors in the TextArea and
TextField classes, which I wrote while looking over a proposed patch from Tania Bento:
2006-06-30 David Gilbert <david.gilbert@object-refinery.com>
* gnu/testlet/java/awt/TextArea/constructors.java: New test,
* gnu/testlet/java/awt/TextField/constructors.java: New test.
Regards,
Dave
Index: gnu/testlet/java/awt/TextArea/constructors.java
===================================================================
RCS file: gnu/testlet/java/awt/TextArea/constructors.java
diff -N gnu/testlet/java/awt/TextArea/constructors.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ gnu/testlet/java/awt/TextArea/constructors.java 30 Jun 2006 09:05:07 -0000
@@ -0,0 +1,178 @@
+/* constructors.java -- some checks for the constructors in the TextField
+ class.
+ Copyright (C) 2006 David Gilbert <david.gilbert@object-refinery.com>
+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: JDK1.1
+
+package gnu.testlet.java.awt.TextArea;
+
+import gnu.testlet.TestHarness;
+import gnu.testlet.Testlet;
+
+import java.awt.TextArea;
+
+public class constructors implements Testlet
+{
+ public void test(TestHarness harness)
+ {
+ testConstructor1(harness);
+ testConstructor2(harness);
+ testConstructor3(harness);
+ testConstructor4(harness);
+ }
+
+ public void testConstructor1(TestHarness harness)
+ {
+ harness.checkPoint("()");
+ TextArea ta = new TextArea();
+ harness.check(ta.getText(), "");
+ harness.check(ta.isEditable());
+ harness.check(ta.getColumns(), 0);
+ harness.check(ta.getScrollbarVisibility(), TextArea.SCROLLBARS_BOTH);
+ }
+
+ public void testConstructor2(TestHarness harness)
+ {
+ harness.checkPoint("(int, int)");
+ TextArea ta = new TextArea(3, 7);
+ harness.check(ta.getText(), "");
+ harness.check(ta.isEditable());
+ harness.check(ta.getColumns(), 7);
+ harness.check(ta.getRows(), 3);
+ harness.check(ta.getScrollbarVisibility(), TextArea.SCROLLBARS_BOTH);
+
+ // try negative rows
+ ta = new TextArea(-1, 7);
+ harness.check(ta.getText(), "");
+ harness.check(ta.isEditable());
+ harness.check(ta.getRows(), 0);
+ harness.check(ta.getColumns(), 7);
+ harness.check(ta.getScrollbarVisibility(), TextArea.SCROLLBARS_BOTH);
+
+ // try negative columns
+ ta = new TextArea(3, -7);
+ harness.check(ta.getText(), "");
+ harness.check(ta.isEditable());
+ harness.check(ta.getRows(), 3);
+ harness.check(ta.getColumns(), 0);
+ harness.check(ta.getScrollbarVisibility(), TextArea.SCROLLBARS_BOTH);
+ }
+
+ public void testConstructor3(TestHarness harness)
+ {
+ harness.checkPoint("(String)");
+ TextArea ta = new TextArea("ABC");
+ harness.check(ta.getText(), "ABC");
+ harness.check(ta.isEditable());
+ harness.check(ta.getRows(), 0);
+ harness.check(ta.getColumns(), 0);
+ harness.check(ta.getScrollbarVisibility(), TextArea.SCROLLBARS_BOTH);
+
+ // try null
+ ta = new TextArea(null);
+ harness.check(ta.getText(), "");
+ harness.check(ta.isEditable());
+ harness.check(ta.getRows(), 0);
+ harness.check(ta.getColumns(), 0);
+ harness.check(ta.getScrollbarVisibility(), TextArea.SCROLLBARS_BOTH);
+ }
+
+ public void testConstructor4(TestHarness harness)
+ {
+ harness.checkPoint("(String, int, int)");
+ TextArea ta = new TextArea("ABC", 3, 7);
+ harness.check(ta.getText(), "ABC");
+ harness.check(ta.isEditable());
+ harness.check(ta.getRows(), 3);
+ harness.check(ta.getColumns(), 7);
+ harness.check(ta.getScrollbarVisibility(), TextArea.SCROLLBARS_BOTH);
+
+ // try null
+ ta = new TextArea(null, 3, 7);
+ harness.check(ta.getText(), "");
+ harness.check(ta.isEditable());
+ harness.check(ta.getRows(), 3);
+ harness.check(ta.getColumns(), 7);
+ harness.check(ta.getScrollbarVisibility(), TextArea.SCROLLBARS_BOTH);
+
+ // try negative rows
+ ta = new TextArea("ABC", -3, 7);
+ harness.check(ta.getText(), "ABC");
+ harness.check(ta.isEditable());
+ harness.check(ta.getRows(), 0);
+ harness.check(ta.getColumns(), 7);
+ harness.check(ta.getScrollbarVisibility(), TextArea.SCROLLBARS_BOTH);
+
+ // try negative columns
+ ta = new TextArea("ABC", 3, -7);
+ harness.check(ta.getText(), "ABC");
+ harness.check(ta.isEditable());
+ harness.check(ta.getRows(), 3);
+ harness.check(ta.getColumns(), 0);
+ harness.check(ta.getScrollbarVisibility(), TextArea.SCROLLBARS_BOTH);
+ }
+
+ public void testConstructor5(TestHarness harness)
+ {
+ harness.checkPoint("(String, int, int, int)");
+ TextArea ta = new TextArea("ABC", 3, 7, TextArea.SCROLLBARS_VERTICAL_ONLY);
+ harness.check(ta.getText(), "ABC");
+ harness.check(ta.isEditable());
+ harness.check(ta.getRows(), 3);
+ harness.check(ta.getColumns(), 7);
+ harness.check(ta.getScrollbarVisibility(), TextArea.SCROLLBARS_VERTICAL_ONLY);
+
+ // try null
+ ta = new TextArea(null, 3, 7, TextArea.SCROLLBARS_VERTICAL_ONLY);
+ harness.check(ta.getText(), "");
+ harness.check(ta.isEditable());
+ harness.check(ta.getRows(), 3);
+ harness.check(ta.getColumns(), 7);
+ harness.check(ta.getScrollbarVisibility(), TextArea.SCROLLBARS_VERTICAL_ONLY);
+
+ // try negative rows
+ ta = new TextArea("ABC", -3, 7, TextArea.SCROLLBARS_VERTICAL_ONLY);
+ harness.check(ta.getText(), "ABC");
+ harness.check(ta.isEditable());
+ harness.check(ta.getRows(), 0);
+ harness.check(ta.getColumns(), 7);
+ harness.check(ta.getScrollbarVisibility(), TextArea.SCROLLBARS_VERTICAL_ONLY);
+
+ // try negative columns
+ ta = new TextArea("ABC", 3, -7, TextArea.SCROLLBARS_VERTICAL_ONLY);
+ harness.check(ta.getText(), "ABC");
+ harness.check(ta.isEditable());
+ harness.check(ta.getRows(), 3);
+ harness.check(ta.getColumns(), 0);
+ harness.check(ta.getScrollbarVisibility(), TextArea.SCROLLBARS_VERTICAL_ONLY);
+
+ // try bad scroll bar visibility
+ ta = new TextArea("ABC", 3, -7, 999);
+ harness.check(ta.getText(), "ABC");
+ harness.check(ta.isEditable());
+ harness.check(ta.getRows(), 3);
+ harness.check(ta.getColumns(), 0);
+ harness.check(ta.getScrollbarVisibility(), TextArea.SCROLLBARS_BOTH);
+
+
+ }
+
+}
Index: gnu/testlet/java/awt/TextField/constructors.java
===================================================================
RCS file: gnu/testlet/java/awt/TextField/constructors.java
diff -N gnu/testlet/java/awt/TextField/constructors.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ gnu/testlet/java/awt/TextField/constructors.java 30 Jun 2006 09:05:07 -0000
@@ -0,0 +1,109 @@
+/* constructors.java -- some checks for the constructors in the TextField
+ class.
+ Copyright (C) 2006 David Gilbert <david.gilbert@object-refinery.com>
+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: JDK1.0
+
+package gnu.testlet.java.awt.TextField;
+
+import gnu.testlet.TestHarness;
+import gnu.testlet.Testlet;
+
+import java.awt.TextField;
+
+public class constructors implements Testlet
+{
+ public void test(TestHarness harness)
+ {
+ testConstructor1(harness);
+ testConstructor2(harness);
+ testConstructor3(harness);
+ testConstructor4(harness);
+ }
+
+ public void testConstructor1(TestHarness harness)
+ {
+ harness.checkPoint("()");
+ TextField tf = new TextField();
+ harness.check(tf.getText(), "");
+ harness.check(tf.isEditable());
+ harness.check(tf.getColumns(), 0);
+ harness.check(tf.getEchoChar(), 0);
+ }
+
+ public void testConstructor2(TestHarness harness)
+ {
+ harness.checkPoint("(int)");
+ TextField tf = new TextField(3);
+ harness.check(tf.getText(), "");
+ harness.check(tf.isEditable());
+ harness.check(tf.getColumns(), 3);
+ harness.check(tf.getEchoChar(), 0);
+
+ // try negative columns
+ tf = new TextField(-1);
+ harness.check(tf.getText(), "");
+ harness.check(tf.isEditable());
+ harness.check(tf.getColumns(), 0);
+ harness.check(tf.getEchoChar(), 0);
+ }
+
+ public void testConstructor3(TestHarness harness)
+ {
+ harness.checkPoint("(String)");
+ TextField tf = new TextField("ABC");
+ harness.check(tf.getText(), "ABC");
+ harness.check(tf.isEditable());
+ harness.check(tf.getColumns(), 3);
+ harness.check(tf.getEchoChar(), 0);
+
+ // try null
+ tf = new TextField(null);
+ harness.check(tf.getText(), "");
+ harness.check(tf.isEditable());
+ harness.check(tf.getColumns(), 0);
+ harness.check(tf.getEchoChar(), 0);
+ }
+
+ public void testConstructor4(TestHarness harness)
+ {
+ harness.checkPoint("(String, int)");
+ TextField tf = new TextField("ABC", 3);
+ harness.check(tf.getText(), "ABC");
+ harness.check(tf.isEditable());
+ harness.check(tf.getColumns(), 3);
+ harness.check(tf.getEchoChar(), 0);
+
+ // try null
+ tf = new TextField(null, 3);
+ harness.check(tf.getText(), "");
+ harness.check(tf.isEditable());
+ harness.check(tf.getColumns(), 3);
+ harness.check(tf.getEchoChar(), 0);
+
+ // try negative columns
+ tf = new TextField("ABC", -3);
+ harness.check(tf.getText(), "ABC");
+ harness.check(tf.isEditable());
+ harness.check(tf.getColumns(), 0);
+ harness.check(tf.getEchoChar(), 0);
+ }
+}