This is the mail archive of the
mauve-patches@sourceware.org
mailing list for the Mauve project.
FYI: New ZoneView tests
- From: Roman Kennke <kennke at aicas dot com>
- To: mauve-patches at sources dot redhat dot com
- Date: Wed, 30 Aug 2006 17:24:42 +0200
- Subject: FYI: New ZoneView tests
This is a bunch of tests for the javax.swing.text.ZoneView class, which
tests all of the original ZoneView methods (not yet those that override
methods from superclasses).
2006-08-29 Roman Kennke <kennke@aicas.com>
* gnu/testlet/javax/swing/text/ZoneView/TestView.java,
* gnu/testlet/javax/swing/text/ZoneView/TestZoneView.java:
New helper classes.
* gnu/testlet/javax/swing/text/ZoneView/constructor.java,
* gnu/testlet/javax/swing/text/ZoneView/createZone.java,
* gnu/testlet/javax/swing/text/ZoneView/getMaxZonesLoaded.java,
* gnu/testlet/javax/swing/text/ZoneView/getMaximumZoneSize.java,
* gnu/testlet/javax/swing/text/ZoneView/isZoneLoaded.java,
* gnu/testlet/javax/swing/text/ZoneView/setMaxZonesLoaded.java,
* gnu/testlet/javax/swing/text/ZoneView/setMaximumZoneSize.java,
* gnu/testlet/javax/swing/text/ZoneView/unloadZone.java,
* gnu/testlet/javax/swing/text/ZoneView/zoneWasLoaded.java:
New tests.
/Roman
Index: gnu/testlet/javax/swing/text/ZoneView/TestView.java
===================================================================
RCS file: gnu/testlet/javax/swing/text/ZoneView/TestView.java
diff -N gnu/testlet/javax/swing/text/ZoneView/TestView.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ gnu/testlet/javax/swing/text/ZoneView/TestView.java 30 Aug 2006 15:21:31 -0000
@@ -0,0 +1,63 @@
+/* TestView.java -- A view for testing zones
+ Copyright (C) 2006 Roman Kennke (kennke@aicas.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: not-a-test
+
+package gnu.testlet.javax.swing.text.ZoneView;
+
+import javax.swing.text.BoxView;
+import javax.swing.text.Element;
+import javax.swing.text.PlainDocument;
+
+public class TestView extends BoxView
+{
+
+ private static final Element DEFAULT_ELEMENT;
+ static
+ {
+ PlainDocument doc = new PlainDocument();
+ Element el = doc.getDefaultRootElement();
+ DEFAULT_ELEMENT = el;
+ }
+
+ boolean removeAllCalled;
+
+ TestView()
+ {
+ this(X_AXIS);
+ }
+
+ TestView(int axis)
+ {
+ this(DEFAULT_ELEMENT, axis);
+ }
+
+ TestView(Element el, int axis)
+ {
+ super(el, axis);
+ }
+
+ public void removeAll()
+ {
+ super.removeAll();
+ removeAllCalled = true;
+ }
+}
Index: gnu/testlet/javax/swing/text/ZoneView/TestZoneView.java
===================================================================
RCS file: gnu/testlet/javax/swing/text/ZoneView/TestZoneView.java
diff -N gnu/testlet/javax/swing/text/ZoneView/TestZoneView.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ gnu/testlet/javax/swing/text/ZoneView/TestZoneView.java 30 Aug 2006 15:21:31 -0000
@@ -0,0 +1,85 @@
+/* TestZoneView.java -- A ZoneView subclass for testing
+ Copyright (C) 2006 Roman Kennke (kennke@aicas.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: not-a-test
+
+package gnu.testlet.javax.swing.text.ZoneView;
+
+import java.util.ArrayList;
+
+import javax.swing.text.Element;
+import javax.swing.text.PlainDocument;
+import javax.swing.text.View;
+import javax.swing.text.ZoneView;
+
+public class TestZoneView extends ZoneView
+{
+
+ private static final Element DEFAULT_ELEMENT;
+ static
+ {
+ PlainDocument doc = new PlainDocument();
+ Element el = doc.getDefaultRootElement();
+ DEFAULT_ELEMENT = el;
+ }
+
+ ArrayList lastUnloadedZones;
+
+ TestZoneView()
+ {
+ this(X_AXIS);
+ }
+
+ TestZoneView(int axis)
+ {
+ this(DEFAULT_ELEMENT, axis);
+ }
+
+ TestZoneView(Element el, int axis)
+ {
+ super(el, axis);
+ lastUnloadedZones = new ArrayList();
+ }
+
+ /**
+ * Overridden to make method publicly accessible.
+ */
+ public void zoneWasLoaded(View zone)
+ {
+ super.zoneWasLoaded(zone);
+ }
+
+ public void unloadZone(View zone)
+ {
+ super.unloadZone(zone);
+ lastUnloadedZones.add(zone);
+ }
+
+ public boolean isZoneLoaded(View z)
+ {
+ return super.isZoneLoaded(z);
+ }
+
+ public View createZone(int p0, int p1)
+ {
+ return super.createZone(p0, p1);
+ }
+}
Index: gnu/testlet/javax/swing/text/ZoneView/constructor.java
===================================================================
RCS file: gnu/testlet/javax/swing/text/ZoneView/constructor.java
diff -N gnu/testlet/javax/swing/text/ZoneView/constructor.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ gnu/testlet/javax/swing/text/ZoneView/constructor.java 30 Aug 2006 15:21:31 -0000
@@ -0,0 +1,68 @@
+/* constructor.java -- Tests the constructor of ZoneView
+ Copyright (C) 2006 Roman Kennke (kennke@aicas.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.3
+
+package gnu.testlet.javax.swing.text.ZoneView;
+
+import javax.swing.text.Element;
+import javax.swing.text.PlainDocument;
+import javax.swing.text.View;
+import javax.swing.text.ZoneView;
+
+import gnu.testlet.TestHarness;
+import gnu.testlet.Testlet;
+
+public class constructor implements Testlet
+{
+
+ public void test(TestHarness harness)
+ {
+ testSimple(harness);
+ testDefaultValues(harness);
+ }
+
+ /**
+ * Some very simple tests.
+ *
+ * @param h the test harness
+ */
+ private void testSimple(TestHarness h)
+ {
+ PlainDocument doc = new PlainDocument();
+ Element el = doc.getDefaultRootElement();
+ ZoneView zv = new ZoneView(el, View.X_AXIS);
+ h.check(zv.getAxis(), View.X_AXIS);
+ h.check(zv.getElement(), el);
+ zv = new ZoneView(el, View.Y_AXIS);
+ h.check(zv.getAxis(), View.Y_AXIS);
+ h.check(zv.getElement(), el);
+ }
+
+ private void testDefaultValues(TestHarness h)
+ {
+ PlainDocument doc = new PlainDocument();
+ Element el = doc.getDefaultRootElement();
+ ZoneView zv = new ZoneView(el, View.X_AXIS);
+ h.check(zv.getMaximumZoneSize(), 8192);
+ h.check(zv.getMaxZonesLoaded(), 3);
+ }
+}
Index: gnu/testlet/javax/swing/text/ZoneView/createZone.java
===================================================================
RCS file: gnu/testlet/javax/swing/text/ZoneView/createZone.java
diff -N gnu/testlet/javax/swing/text/ZoneView/createZone.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ gnu/testlet/javax/swing/text/ZoneView/createZone.java 30 Aug 2006 15:21:31 -0000
@@ -0,0 +1,80 @@
+/* createZone.java -- Tests ZoneView.createZone()
+ Copyright (C) 2006 Roman Kennke (kennke@aicas.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.3
+
+package gnu.testlet.javax.swing.text.ZoneView;
+
+import javax.swing.text.AsyncBoxView;
+import javax.swing.text.BadLocationException;
+import javax.swing.text.Element;
+import javax.swing.text.PlainDocument;
+import javax.swing.text.View;
+
+import gnu.testlet.TestHarness;
+import gnu.testlet.Testlet;
+
+public class createZone implements Testlet
+{
+
+ public void test(TestHarness h)
+ {
+ PlainDocument doc = new PlainDocument();
+ try
+ {
+ doc.insertString(0, "123456789", null);
+ }
+ catch (BadLocationException ex)
+ {
+ RuntimeException rte = new RuntimeException();
+ rte.initCause(ex);
+ throw rte;
+ }
+ Element el = doc.getDefaultRootElement();
+ TestZoneView zv = new TestZoneView(el, View.X_AXIS);
+
+ // Try valid zone.
+ View zone = zv.createZone(0, 9);
+ h.check(zone instanceof AsyncBoxView);
+ h.check(zone.getStartOffset(), 0);
+ h.check(zone.getEndOffset(), 9);
+ // Check if the zone follows document insertions (via Positions).
+ try
+ {
+ doc.insertString(5, "abcde", null);
+ }
+ catch (BadLocationException ex)
+ {
+ RuntimeException rte = new RuntimeException();
+ rte.initCause(ex);
+ throw rte;
+ }
+ h.check(zone.getStartOffset(), 0);
+ h.check(zone.getEndOffset(), 14);
+
+ // Try invalid zone. No error is thrown and the zone tracks some more
+ // or less random positions. This is probably due to a bug in the Content
+ // implementation of Sun, but anyway. We don't check the exact positions
+ // here as it doesn't really matter anyway. This is unspecified!
+ zone = zv.createZone(-10, 23);
+ }
+
+}
Index: gnu/testlet/javax/swing/text/ZoneView/getMaxZonesLoaded.java
===================================================================
RCS file: gnu/testlet/javax/swing/text/ZoneView/getMaxZonesLoaded.java
diff -N gnu/testlet/javax/swing/text/ZoneView/getMaxZonesLoaded.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ gnu/testlet/javax/swing/text/ZoneView/getMaxZonesLoaded.java 30 Aug 2006 15:21:31 -0000
@@ -0,0 +1,62 @@
+/* getMaxZonesLoaded.java -- Checks ZoneView.getMaxZonesLoaded()
+ Copyright (C) 2006 Roman Kennke (kennke@aicas.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.3
+
+package gnu.testlet.javax.swing.text.ZoneView;
+
+import gnu.testlet.TestHarness;
+
+import javax.swing.text.ZoneView;
+
+public class getMaxZonesLoaded
+{
+ public void test(TestHarness h)
+ {
+ ZoneView zv = new TestZoneView();
+ // Test legal values.
+ zv.setMaxZonesLoaded(1);
+ h.check(zv.getMaxZonesLoaded(), 1);
+ zv.setMaxZonesLoaded(Integer.MAX_VALUE);
+ h.check(zv.getMaxZonesLoaded(), Integer.MAX_VALUE);
+ // Test illegal values.
+ try
+ {
+ zv.setMaxZonesLoaded(0);
+ h.fail("Should have thrown IllegalArgumentException");
+ }
+ catch (IllegalArgumentException ex)
+ {
+ h.check(true);
+ }
+ h.check(zv.getMaxZonesLoaded(), Integer.MAX_VALUE);
+ try
+ {
+ zv.setMaxZonesLoaded(Integer.MIN_VALUE);
+ h.fail("Should have thrown IllegalArgumentException");
+ }
+ catch (IllegalArgumentException ex)
+ {
+ h.check(true);
+ }
+ h.check(zv.getMaxZonesLoaded(), Integer.MAX_VALUE);
+ }
+}
Index: gnu/testlet/javax/swing/text/ZoneView/getMaximumZoneSize.java
===================================================================
RCS file: gnu/testlet/javax/swing/text/ZoneView/getMaximumZoneSize.java
diff -N gnu/testlet/javax/swing/text/ZoneView/getMaximumZoneSize.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ gnu/testlet/javax/swing/text/ZoneView/getMaximumZoneSize.java 30 Aug 2006 15:21:31 -0000
@@ -0,0 +1,48 @@
+/* getMaximumZoneSize.java -- Tests ZoneView.getMaximumZoneSize()
+ Copyright (C) 2006 Roman Kennke (kennke@aicas.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.3
+
+package gnu.testlet.javax.swing.text.ZoneView;
+
+import javax.swing.text.ZoneView;
+
+import gnu.testlet.TestHarness;
+import gnu.testlet.Testlet;
+
+public class getMaximumZoneSize implements Testlet
+{
+
+ public void test(TestHarness h)
+ {
+ ZoneView zv = new TestZoneView();
+ h.check(zv.getMaximumZoneSize(), 8192);
+ zv.setMaximumZoneSize(0);
+ h.check(zv.getMaximumZoneSize(), 0);
+ zv.setMaximumZoneSize(1);
+ h.check(zv.getMaximumZoneSize(), 1);
+ zv.setMaximumZoneSize(Integer.MAX_VALUE);
+ h.check(zv.getMaximumZoneSize(), Integer.MAX_VALUE);
+ zv.setMaximumZoneSize(Integer.MIN_VALUE);
+ h.check(zv.getMaximumZoneSize(), Integer.MIN_VALUE);
+ }
+
+}
Index: gnu/testlet/javax/swing/text/ZoneView/isZoneLoaded.java
===================================================================
RCS file: gnu/testlet/javax/swing/text/ZoneView/isZoneLoaded.java
diff -N gnu/testlet/javax/swing/text/ZoneView/isZoneLoaded.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ gnu/testlet/javax/swing/text/ZoneView/isZoneLoaded.java 30 Aug 2006 15:21:31 -0000
@@ -0,0 +1,45 @@
+/* isZoneLoaded.java -- Checks ZoneView.isZoneLoaded()
+ Copyright (C) 2006 Roman Kennke (kennke@aicas.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.3
+
+package gnu.testlet.javax.swing.text.ZoneView;
+
+import gnu.testlet.TestHarness;
+import gnu.testlet.Testlet;
+
+public class isZoneLoaded implements Testlet
+{
+
+ public void test(TestHarness h)
+ {
+ // Note that we don't add the view to the ZoneView. The ZoneView
+ // only checks if the view has children.
+ TestZoneView zv = new TestZoneView();
+ // Create a view without children.
+ TestView v = new TestView();
+ h.check(zv.isZoneLoaded(v), false);
+ TestView child = new TestView();
+ v.append(child);
+ h.check(zv.isZoneLoaded(v), true);
+ }
+
+}
Index: gnu/testlet/javax/swing/text/ZoneView/setMaxZonesLoaded.java
===================================================================
RCS file: gnu/testlet/javax/swing/text/ZoneView/setMaxZonesLoaded.java
diff -N gnu/testlet/javax/swing/text/ZoneView/setMaxZonesLoaded.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ gnu/testlet/javax/swing/text/ZoneView/setMaxZonesLoaded.java 30 Aug 2006 15:21:31 -0000
@@ -0,0 +1,97 @@
+/* setMaxZonesLoaded.java -- Tests ZoneView.setMaxZonesLoaded()
+ Copyright (C) 2006 Roman Kennke (kennke@aicas.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.3
+
+package gnu.testlet.javax.swing.text.ZoneView;
+
+import javax.swing.text.ZoneView;
+
+import gnu.testlet.TestHarness;
+import gnu.testlet.Testlet;
+
+public class setMaxZonesLoaded implements Testlet
+{
+
+ public void test(TestHarness h)
+ {
+ testSimple(h);
+ testUnloading(h);
+ }
+
+ private void testSimple(TestHarness h)
+ {
+ ZoneView zv = new TestZoneView();
+ // Test legal values.
+ zv.setMaxZonesLoaded(1);
+ h.check(zv.getMaxZonesLoaded(), 1);
+ zv.setMaxZonesLoaded(Integer.MAX_VALUE);
+ h.check(zv.getMaxZonesLoaded(), Integer.MAX_VALUE);
+ // Test illegal values.
+ try
+ {
+ zv.setMaxZonesLoaded(0);
+ h.fail("Should have thrown IllegalArgumentException");
+ }
+ catch (IllegalArgumentException ex)
+ {
+ h.check(true);
+ }
+ try
+ {
+ zv.setMaxZonesLoaded(Integer.MIN_VALUE);
+ h.fail("Should have thrown IllegalArgumentException");
+ }
+ catch (IllegalArgumentException ex)
+ {
+ h.check(true);
+ }
+ }
+
+ private void testUnloading(TestHarness h)
+ {
+ TestZoneView zv = new TestZoneView();
+ // Add 4 zones, which are the number of allowed zones.
+ zv.setMaxZonesLoaded(4);
+ TestView v1 = new TestView();
+ zv.zoneWasLoaded(v1);
+ TestView v2 = new TestView();
+ zv.zoneWasLoaded(v2);
+ TestView v3 = new TestView();
+ zv.zoneWasLoaded(v3);
+ TestView v4 = new TestView();
+ zv.zoneWasLoaded(v4);
+ // Zero zones unloaded so far.
+ h.check(zv.lastUnloadedZones.size(), 0);
+ zv.setMaxZonesLoaded(2);
+ // The first two zones are unloaded.
+ h.check(zv.lastUnloadedZones.size(), 2);
+ h.check(zv.lastUnloadedZones.remove(0), v1);
+ h.check(zv.lastUnloadedZones.remove(0), v2);
+ // No zones get unloaded when growing the allowed range.
+ zv.setMaxZonesLoaded(4);
+ h.check(zv.lastUnloadedZones.size(), 0);
+ // The v3 gets unloaded when shrinking to 1.
+ zv.setMaxZonesLoaded(1);
+ h.check(zv.lastUnloadedZones.size(), 1);
+ h.check(zv.lastUnloadedZones.remove(0), v3);
+ }
+}
Index: gnu/testlet/javax/swing/text/ZoneView/setMaximumZoneSize.java
===================================================================
RCS file: gnu/testlet/javax/swing/text/ZoneView/setMaximumZoneSize.java
diff -N gnu/testlet/javax/swing/text/ZoneView/setMaximumZoneSize.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ gnu/testlet/javax/swing/text/ZoneView/setMaximumZoneSize.java 30 Aug 2006 15:21:31 -0000
@@ -0,0 +1,47 @@
+/* setMaximumZoneSize.java -- Tests ZoneView.setMaximumZoneSize()
+ Copyright (C) 2006 Roman Kennke (kennke@aicas.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.3
+
+package gnu.testlet.javax.swing.text.ZoneView;
+
+import javax.swing.text.ZoneView;
+
+import gnu.testlet.TestHarness;
+import gnu.testlet.Testlet;
+
+public class setMaximumZoneSize implements Testlet
+{
+
+ public void test(TestHarness h)
+ {
+ ZoneView zv = new TestZoneView();
+ zv.setMaximumZoneSize(0);
+ h.check(zv.getMaximumZoneSize(), 0);
+ zv.setMaximumZoneSize(1);
+ h.check(zv.getMaximumZoneSize(), 1);
+ zv.setMaximumZoneSize(Integer.MAX_VALUE);
+ h.check(zv.getMaximumZoneSize(), Integer.MAX_VALUE);
+ zv.setMaximumZoneSize(Integer.MIN_VALUE);
+ h.check(zv.getMaximumZoneSize(), Integer.MIN_VALUE);
+ }
+
+}
Index: gnu/testlet/javax/swing/text/ZoneView/unloadZone.java
===================================================================
RCS file: gnu/testlet/javax/swing/text/ZoneView/unloadZone.java
diff -N gnu/testlet/javax/swing/text/ZoneView/unloadZone.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ gnu/testlet/javax/swing/text/ZoneView/unloadZone.java 30 Aug 2006 15:21:31 -0000
@@ -0,0 +1,53 @@
+/* unloadZone.java -- Tests ZoneView.unloadZone()
+ Copyright (C) 2006 Roman Kennke (kennke@aicas.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.3
+
+package gnu.testlet.javax.swing.text.ZoneView;
+
+import gnu.testlet.TestHarness;
+import gnu.testlet.Testlet;
+
+public class unloadZone implements Testlet
+{
+
+ public void test(TestHarness h)
+ {
+ // This method should simply call removeAll() on the zone view.
+ // So we test this.
+ TestZoneView zv = new TestZoneView();
+ TestView v = new TestView();
+ v.removeAllCalled = false;
+ zv.unloadZone(v);
+ h.check(v.removeAllCalled, true);
+ // Also check for null argument.
+ try
+ {
+ zv.unloadZone(null);
+ h.fail("NullPointerException should be thrown");
+ }
+ catch (NullPointerException ex)
+ {
+ h.check(true);
+ }
+ }
+
+}
Index: gnu/testlet/javax/swing/text/ZoneView/zoneWasLoaded.java
===================================================================
RCS file: gnu/testlet/javax/swing/text/ZoneView/zoneWasLoaded.java
diff -N gnu/testlet/javax/swing/text/ZoneView/zoneWasLoaded.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ gnu/testlet/javax/swing/text/ZoneView/zoneWasLoaded.java 30 Aug 2006 15:21:31 -0000
@@ -0,0 +1,90 @@
+/* zoneWasLoaded.java -- Checks ZoneView.zoneWasLoaded()
+ Copyright (C) 2006 Roman Kennke (kennke@aicas.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.3
+
+package gnu.testlet.javax.swing.text.ZoneView;
+
+import gnu.testlet.TestHarness;
+import gnu.testlet.Testlet;
+
+public class zoneWasLoaded implements Testlet
+{
+
+ public void test(TestHarness h)
+ {
+ TestZoneView zv = new TestZoneView();
+ zv.setMaxZonesLoaded(3);
+ TestView v1 = new TestView();
+ zv.lastUnloadedZones.clear();
+ // 3 Zones are allowed to be loaded. So load them and check that none
+ // is unloaded.
+ zv.zoneWasLoaded(v1);
+ h.check(zv.lastUnloadedZones.size(), 0);
+ TestView v2 = new TestView();
+ zv.zoneWasLoaded(v2);
+ h.check(zv.lastUnloadedZones.size(), 0);
+ TestView v3 = new TestView();
+ zv.zoneWasLoaded(v3);
+ h.check(zv.lastUnloadedZones.size(), 0);
+ // After loading this zone, the first one must get unloaded.
+ TestView v4 = new TestView();
+ zv.zoneWasLoaded(v4);
+ h.check(zv.lastUnloadedZones.size(), 1);
+ h.check(zv.lastUnloadedZones.remove(0), v1);
+ // Then the second.
+ TestView v5 = new TestView();
+ zv.zoneWasLoaded(v5);
+ h.check(zv.lastUnloadedZones.size(), 1);
+ h.check(zv.lastUnloadedZones.remove(0), v2);
+ // And then the third.
+ TestView v6 = new TestView();
+ zv.zoneWasLoaded(v6);
+ h.check(zv.lastUnloadedZones.size(), 1);
+ h.check(zv.lastUnloadedZones.remove(0), v3);
+
+ // Also check for null argument.
+ try
+ {
+ // Push out v4, v5 and v6 and see if we get to unload(null) after this.
+ zv.zoneWasLoaded(null);
+ zv.zoneWasLoaded(null);
+ zv.zoneWasLoaded(null);
+ h.check(true);
+ }
+ catch (NullPointerException ex)
+ {
+ h.fail("No NullPointerException should be thrown");
+ }
+ try
+ {
+ // The above statements pushed 3 nulls in there, which get pulled now
+ // and trigger an NPE.
+ zv.zoneWasLoaded(v1);
+ h.fail("NullPointerException should be thrown");
+ }
+ catch (NullPointerException ex)
+ {
+ h.check(true);
+ }
+ }
+
+}