This is the mail archive of the
mauve-patches@sourceware.org
mailing list for the Mauve project.
FYI: 6 more DefaultStyledDocument/ElementBuffer tests
- From: Anthony Balkissoon <abalkiss at redhat dot com>
- To: mauve-patches at sources dot redhat dot com
- Date: Thu, 12 Jan 2006 10:58:46 -0500
- Subject: FYI: 6 more DefaultStyledDocument/ElementBuffer tests
6 more tests used in the rewrite of
DefaultStyledDocument.ElementBuffer.
2006-01-12 Anthony Balkissoon <abalkiss@redhat.com>
*
gnu/testlet/javax/swing/text/DefaultStyledDocument/ElementBuffer/StyledDocument1.java: New test.
*
gnu/testlet/javax/swing/text/DefaultStyledDocument/ElementBuffer/StyledDocument2.java: New test.
*
gnu/testlet/javax/swing/text/DefaultStyledDocument/ElementBuffer/StyledDocument3.java: New test.
*
gnu/testlet/javax/swing/text/DefaultStyledDocument/ElementBuffer/StyledDocument4.java: New test.
*
gnu/testlet/javax/swing/text/DefaultStyledDocument/ElementBuffer/StyledDocument5.java: New test.
*
gnu/testlet/javax/swing/text/DefaultStyledDocument/ElementBuffer/StyledDocument6.java: New test.
--Tony
Index: gnu/testlet/javax/swing/text/DefaultStyledDocument/ElementBuffer/StyledDocument1.java
===================================================================
RCS file: gnu/testlet/javax/swing/text/DefaultStyledDocument/ElementBuffer/StyledDocument1.java
diff -N gnu/testlet/javax/swing/text/DefaultStyledDocument/ElementBuffer/StyledDocument1.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ gnu/testlet/javax/swing/text/DefaultStyledDocument/ElementBuffer/StyledDocument1.java 12 Jan 2006 15:55:04 -0000
@@ -0,0 +1,114 @@
+// 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.text.DefaultStyledDocument.ElementBuffer;
+
+import javax.swing.*;
+import javax.swing.event.*;
+import javax.swing.text.*;
+
+import gnu.testlet.TestHarness;
+import gnu.testlet.Testlet;
+
+public class StyledDocument1 extends DefaultStyledDocument implements Testlet
+{
+ // A variable to keep track of the number of times text has been inserted
+ static int numInserts = 0;
+
+ static TestHarness h2;
+
+ // Creates a new StyledDocument1 using an ElementBuffer2 as the buffer
+ public StyledDocument1()
+ {
+ super();
+ buffer = new ElementBuffer2(createDefaultRoot());
+ }
+
+ // A class to be the buffer of the styled document that also prints out some
+ // debugging info and checks that internal structure is correct
+ public class ElementBuffer2 extends ElementBuffer
+ {
+ public ElementBuffer2(Element root)
+ {
+ super(root);
+ }
+
+ protected void insertUpdate(ElementSpec[] data)
+ {
+ numInserts ++;
+ if (numInserts == 1)
+ {
+ h2.check (data[0].getType() == ElementSpec.ContentType);
+ h2.check (data[0].getDirection() == ElementSpec.JoinPreviousDirection);
+ h2.check (data[0].getOffset() == 0);
+ h2.check (data[0].getLength() == 10);
+
+ h2.check (data[1].getType() == ElementSpec.EndTagType);
+ h2.check (data[1].getDirection() == ElementSpec.OriginateDirection);
+ h2.check (data[1].getOffset() == 0);
+ h2.check (data[1].getLength() == 0);
+
+ h2.check (data[2].getType() == ElementSpec.StartTagType);
+ h2.check (data[2].getDirection() == ElementSpec.JoinFractureDirection);
+ h2.check (data[2].getOffset() == 0);
+ h2.check (data[2].getLength() == 0);
+
+ h2.check (data[3].getType() == ElementSpec.ContentType);
+ h2.check (data[3].getDirection() == ElementSpec.JoinNextDirection);
+ h2.check (data[3].getOffset() == 0);
+ h2.check (data[3].getLength() == 9);
+ }
+ else if (numInserts == 2)
+ {
+ h2.check (data[0].getType() == ElementSpec.EndTagType);
+ h2.check (data[0].getDirection() == ElementSpec.OriginateDirection);
+ h2.check (data[0].getOffset() == 0);
+ h2.check (data[0].getLength() == 0);
+
+ h2.check (data[1].getType() == ElementSpec.StartTagType);
+ h2.check (data[1].getDirection() == ElementSpec.JoinNextDirection);
+ h2.check (data[1].getOffset() == 0);
+ h2.check (data[1].getLength() == 0);
+
+ h2.check (data[2].getType() == ElementSpec.ContentType);
+ h2.check (data[2].getDirection() == ElementSpec.JoinNextDirection);
+ h2.check (data[2].getOffset() == 0);
+ h2.check (data[2].getLength() == 1);
+ }
+ super.insertUpdate(data);
+ }
+ }
+
+ public void test(TestHarness harness)
+ {
+ h2 = harness;
+ StyledDocument doc = new StyledDocument1();
+ try
+ {
+ doc.insertString(0, "aaaaaaaaa\nbbbbbbbbb", null);
+ doc.insertString(10, "N", null);
+ }
+ catch (BadLocationException ex)
+ {
+ harness.debug(ex);
+ }
+ }
+}
Index: gnu/testlet/javax/swing/text/DefaultStyledDocument/ElementBuffer/StyledDocument2.java
===================================================================
RCS file: gnu/testlet/javax/swing/text/DefaultStyledDocument/ElementBuffer/StyledDocument2.java
diff -N gnu/testlet/javax/swing/text/DefaultStyledDocument/ElementBuffer/StyledDocument2.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ gnu/testlet/javax/swing/text/DefaultStyledDocument/ElementBuffer/StyledDocument2.java 12 Jan 2006 15:55:04 -0000
@@ -0,0 +1,98 @@
+// 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.text.DefaultStyledDocument.ElementBuffer;
+
+import javax.swing.*;
+import javax.swing.event.*;
+import javax.swing.text.*;
+
+import gnu.testlet.TestHarness;
+import gnu.testlet.Testlet;
+
+public class StyledDocument2 extends DefaultStyledDocument implements Testlet
+{
+ // A variable to keep track of the number of times text has been inserted
+ static int numInserts = 0;
+
+ static TestHarness h2;
+
+ // Creates a new StyledDocument2 using an ElementBuffer2 as the buffer
+ public StyledDocument2()
+ {
+ super();
+ buffer = new ElementBuffer2(createDefaultRoot());
+ }
+
+ protected void insertUpdate(DefaultDocumentEvent ev, AttributeSet attr)
+ {
+ super.insertUpdate(ev, attr);
+ h2.check (getDefaultRootElement().getElement(0).getElementCount() == (numInserts + 1));
+ }
+
+ // A class to be the buffer of the styled document that also prints out some
+ // debugging info and checks that internal structure is correct
+ public class ElementBuffer2 extends ElementBuffer
+ {
+ public ElementBuffer2(Element root)
+ {
+ super(root);
+ }
+
+ protected void insertUpdate(ElementSpec[] data)
+ {
+ numInserts ++;
+ if (numInserts == 1)
+ {
+ h2.check (data[0].getType() == ElementSpec.ContentType);
+ h2.check (data[0].getDirection() == ElementSpec.OriginateDirection);
+ h2.check (data[0].getOffset() == 0);
+ h2.check (data[0].getLength() == 5);
+ }
+ else if (numInserts == 2)
+ {
+ h2.check (data[0].getType() == ElementSpec.ContentType);
+ h2.check (data[0].getDirection() == ElementSpec.OriginateDirection);
+ h2.check (data[0].getOffset() == 0);
+ h2.check (data[0].getLength() == 5);
+ }
+
+ super.insertUpdate(data);
+ }
+ }
+
+ public void test(TestHarness harness)
+ {
+ h2 = harness;
+ StyledDocument doc = new StyledDocument2();
+ SimpleAttributeSet atts = new SimpleAttributeSet();
+ try
+ {
+ atts.addAttribute(StyleConstants.StrikeThrough, Boolean.TRUE);
+ doc.insertString(0, "bbbbb", atts);
+ doc.insertString(5, "aaaaa", null);
+ }
+ catch (BadLocationException ex)
+ {
+ ex.printStackTrace();
+ }
+ }
+}
Index: gnu/testlet/javax/swing/text/DefaultStyledDocument/ElementBuffer/StyledDocument3.java
===================================================================
RCS file: gnu/testlet/javax/swing/text/DefaultStyledDocument/ElementBuffer/StyledDocument3.java
diff -N gnu/testlet/javax/swing/text/DefaultStyledDocument/ElementBuffer/StyledDocument3.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ gnu/testlet/javax/swing/text/DefaultStyledDocument/ElementBuffer/StyledDocument3.java 12 Jan 2006 15:55:04 -0000
@@ -0,0 +1,110 @@
+// 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.text.DefaultStyledDocument.ElementBuffer;
+
+import javax.swing.*;
+import javax.swing.event.*;
+import javax.swing.text.*;
+
+import gnu.testlet.TestHarness;
+import gnu.testlet.Testlet;
+
+public class StyledDocument3 extends DefaultStyledDocument implements Testlet
+{
+ // A variable to keep track of the number of times text has been inserted
+ static int numInserts = 0;
+
+ static TestHarness h2;
+
+ // Creates a new StyledDocument3 using an ElementBuffer2 as the buffer
+ public StyledDocument3()
+ {
+ super();
+ buffer = new ElementBuffer2(createDefaultRoot());
+ }
+
+ // A class to be the buffer of the styled document that also prints out some
+ // debugging info and checks that internal structure is correct
+ public class ElementBuffer2 extends ElementBuffer
+ {
+ public ElementBuffer2(Element root)
+ {
+ super(root);
+ }
+
+ protected void insertUpdate(ElementSpec[] data)
+ {
+ numInserts ++;
+ if (numInserts == 1)
+ {
+ h2.check (data[0].getType() == ElementSpec.ContentType);
+ h2.check (data[0].getDirection() == ElementSpec.OriginateDirection);
+ h2.check (data[0].getOffset() == 0);
+ h2.check (data[0].getLength() == 5);
+ }
+ else if (numInserts == 2)
+ {
+ h2.check (data[0].getType() == ElementSpec.ContentType);
+ h2.check (data[0].getDirection() == ElementSpec.OriginateDirection);
+ h2.check (data[0].getOffset() == 0);
+ h2.check (data[0].getLength() == 5);
+ }
+ else if (numInserts == 3)
+ {
+ h2.check (data[0].getType() == ElementSpec.ContentType);
+ h2.check (data[0].getDirection() == ElementSpec.JoinPreviousDirection);
+ h2.check (data[0].getOffset() == 0);
+ h2.check (data[0].getLength() == 1);
+ }
+ else if (numInserts == 4)
+ {
+ h2.check (data[0].getType() == ElementSpec.ContentType);
+ h2.check (data[0].getDirection() == ElementSpec.OriginateDirection);
+ h2.check (data[0].getOffset() == 0);
+ h2.check (data[0].getLength() == 1);
+ }
+
+ super.insertUpdate(data);
+ }
+ }
+
+ public void test(TestHarness harness)
+ {
+ h2 = harness;
+ StyledDocument doc = new StyledDocument3();
+ SimpleAttributeSet atts = new SimpleAttributeSet();
+ try
+ {
+ atts.addAttribute(StyleConstants.StrikeThrough, Boolean.TRUE);
+ doc.insertString(0, "bbbbb", atts);
+ doc.insertString(5, "aaaaa", null);
+ doc.insertString(5, "N", atts);
+ atts.addAttribute(StyleConstants.Bold, Boolean.TRUE);
+ doc.insertString(6, "M", atts);
+ }
+ catch (BadLocationException ex)
+ {
+ ex.printStackTrace();
+ }
+
+ }
+}
Index: gnu/testlet/javax/swing/text/DefaultStyledDocument/ElementBuffer/StyledDocument4.java
===================================================================
RCS file: gnu/testlet/javax/swing/text/DefaultStyledDocument/ElementBuffer/StyledDocument4.java
diff -N gnu/testlet/javax/swing/text/DefaultStyledDocument/ElementBuffer/StyledDocument4.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ gnu/testlet/javax/swing/text/DefaultStyledDocument/ElementBuffer/StyledDocument4.java 12 Jan 2006 15:55:04 -0000
@@ -0,0 +1,119 @@
+// 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.text.DefaultStyledDocument.ElementBuffer;
+
+import javax.swing.*;
+import javax.swing.event.*;
+import javax.swing.text.*;
+
+import gnu.testlet.TestHarness;
+import gnu.testlet.Testlet;
+
+public class StyledDocument4 extends DefaultStyledDocument implements Testlet
+{
+ // A variable to keep track of the number of times text has been inserted
+ static int numInserts = 0;
+
+ static TestHarness h2;
+
+ // Creates a new StyledDocument4 using an ElementBuffer2 as the buffer
+ public StyledDocument4()
+ {
+ super();
+ buffer = new ElementBuffer2(createDefaultRoot());
+ }
+
+ // A class to be the buffer of the styled document that also prints out some
+ // debugging info and checks that internal structure is correct
+ public class ElementBuffer2 extends ElementBuffer
+ {
+ public ElementBuffer2(Element root)
+ {
+ super(root);
+ }
+
+ protected void insertUpdate(ElementSpec[] data)
+ {
+ numInserts ++;
+ if (numInserts == 1)
+ {
+ h2.check (data[0].getType() == ElementSpec.ContentType);
+ h2.check (data[0].getDirection() == ElementSpec.JoinPreviousDirection);
+ h2.check (data[0].getOffset() == 0);
+ h2.check (data[0].getLength() == 10);
+
+ h2.check (data[1].getType() == ElementSpec.EndTagType);
+ h2.check (data[1].getDirection() == ElementSpec.OriginateDirection);
+ h2.check (data[1].getOffset() == 0);
+ h2.check (data[1].getLength() == 0);
+
+ h2.check (data[2].getType() == ElementSpec.StartTagType);
+ h2.check (data[2].getDirection() == ElementSpec.JoinFractureDirection);
+ h2.check (data[2].getOffset() == 0);
+ h2.check (data[2].getLength() == 0);
+
+ h2.check (data[3].getType() == ElementSpec.ContentType);
+ h2.check (data[3].getDirection() == ElementSpec.JoinNextDirection);
+ h2.check (data[3].getOffset() == 0);
+ h2.check (data[3].getLength() == 9);
+ }
+ else if (numInserts == 2)
+ {
+ h2.check (data[0].getType() == ElementSpec.ContentType);
+ h2.check (data[0].getDirection() == ElementSpec.JoinPreviousDirection);
+ h2.check (data[0].getOffset() == 0);
+ h2.check (data[0].getLength() == 1);
+
+ h2.check (data[1].getType() == ElementSpec.EndTagType);
+ h2.check (data[1].getDirection() == ElementSpec.OriginateDirection);
+ h2.check (data[1].getOffset() == 0);
+ h2.check (data[1].getLength() == 0);
+
+ h2.check (data[2].getType() == ElementSpec.StartTagType);
+ h2.check (data[2].getDirection() == ElementSpec.JoinFractureDirection);
+ h2.check (data[2].getOffset() == 0);
+ h2.check (data[2].getLength() == 0);
+
+ h2.check (data[3].getType() == ElementSpec.ContentType);
+ h2.check (data[3].getDirection() == ElementSpec.JoinNextDirection);
+ h2.check (data[3].getOffset() == 0);
+ h2.check (data[3].getLength() == 1);
+ }
+ super.insertUpdate(data);
+ }
+ }
+
+ public void test(TestHarness harness)
+ {
+ h2 = harness;
+ StyledDocument doc = new StyledDocument4();
+ try
+ {
+ doc.insertString(0, "aaaaaaaaa\nbbbbbbbbb", null);
+ doc.insertString(5, "\nN", null);
+ }
+ catch (BadLocationException ex)
+ {
+ ex.printStackTrace();
+ }
+ }
+}
Index: gnu/testlet/javax/swing/text/DefaultStyledDocument/ElementBuffer/StyledDocument5.java
===================================================================
RCS file: gnu/testlet/javax/swing/text/DefaultStyledDocument/ElementBuffer/StyledDocument5.java
diff -N gnu/testlet/javax/swing/text/DefaultStyledDocument/ElementBuffer/StyledDocument5.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ gnu/testlet/javax/swing/text/DefaultStyledDocument/ElementBuffer/StyledDocument5.java 12 Jan 2006 15:55:04 -0000
@@ -0,0 +1,138 @@
+// 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.text.DefaultStyledDocument.ElementBuffer;
+
+import javax.swing.*;
+import javax.swing.event.*;
+import javax.swing.text.*;
+
+import gnu.testlet.TestHarness;
+import gnu.testlet.Testlet;
+
+public class StyledDocument5 extends DefaultStyledDocument implements Testlet
+{
+ // A variable to keep track of the number of times text has been inserted
+ static int numInserts = 0;
+
+ static TestHarness h2;
+
+ // Creates a new StyledDocument5 using an ElementBuffer2 as the buffer
+ public StyledDocument5()
+ {
+ super();
+ buffer = new ElementBuffer2(createDefaultRoot());
+ }
+
+ // A class to be the buffer of the styled document that also prints out some
+ // debugging info and checks that internal structure is correct
+ public class ElementBuffer2 extends ElementBuffer
+ {
+ public ElementBuffer2(Element root)
+ {
+ super(root);
+ }
+
+ protected void insertUpdate(ElementSpec[] data)
+ {
+ numInserts ++;
+ if (numInserts == 1)
+ {
+ h2.check (data[0].getType() == ElementSpec.ContentType);
+ h2.check (data[0].getDirection() == ElementSpec.JoinPreviousDirection);
+ h2.check (data[0].getOffset() == 0);
+ h2.check (data[0].getLength() == 10);
+
+ h2.check (data[1].getType() == ElementSpec.EndTagType);
+ h2.check (data[1].getDirection() == ElementSpec.OriginateDirection);
+ h2.check (data[1].getOffset() == 0);
+ h2.check (data[1].getLength() == 0);
+
+ h2.check (data[2].getType() == ElementSpec.StartTagType);
+ h2.check (data[2].getDirection() == ElementSpec.JoinFractureDirection);
+ h2.check (data[2].getOffset() == 0);
+ h2.check (data[2].getLength() == 0);
+
+ h2.check (data[3].getType() == ElementSpec.ContentType);
+ h2.check (data[3].getDirection() == ElementSpec.JoinNextDirection);
+ h2.check (data[3].getOffset() == 0);
+ h2.check (data[3].getLength() == 9);
+ }
+ else if (numInserts == 2)
+ {
+ h2.check (data[0].getType() == ElementSpec.EndTagType);
+ h2.check (data[0].getDirection() == ElementSpec.OriginateDirection);
+ h2.check (data[0].getOffset() == 0);
+ h2.check (data[0].getLength() == 0);
+
+ h2.check (data[1].getType() == ElementSpec.StartTagType);
+ h2.check (data[1].getDirection() == ElementSpec.JoinNextDirection);
+ h2.check (data[1].getOffset() == 0);
+ h2.check (data[1].getLength() == 0);
+
+ h2.check (data[2].getType() == ElementSpec.ContentType);
+ h2.check (data[2].getDirection() == ElementSpec.JoinNextDirection);
+ h2.check (data[2].getOffset() == 0);
+ h2.check (data[2].getLength() == 1);
+ }
+ else if (numInserts == 3)
+ {
+ h2.check (data[0].getType() == ElementSpec.ContentType);
+ h2.check (data[0].getDirection() == ElementSpec.JoinPreviousDirection);
+ h2.check (data[0].getOffset() == 0);
+ h2.check (data[0].getLength() == 1);
+
+ h2.check (data[1].getType() == ElementSpec.EndTagType);
+ h2.check (data[1].getDirection() == ElementSpec.OriginateDirection);
+ h2.check (data[1].getOffset() == 0);
+ h2.check (data[1].getLength() == 0);
+
+ h2.check (data[2].getType() == ElementSpec.StartTagType);
+ h2.check (data[2].getDirection() == ElementSpec.JoinFractureDirection);
+ h2.check (data[2].getOffset() == 0);
+ h2.check (data[2].getLength() == 0);
+
+ h2.check (data[3].getType() == ElementSpec.ContentType);
+ h2.check (data[3].getDirection() == ElementSpec.JoinNextDirection);
+ h2.check (data[3].getOffset() == 0);
+ h2.check (data[3].getLength() == 9);
+ }
+
+ super.insertUpdate(data);
+ }
+ }
+
+ public void test(TestHarness harness)
+ {
+ h2 = harness;
+ StyledDocument doc = new StyledDocument5();
+ try
+ {
+ doc.insertString(0, "aaaaaaaaa\nbbbbbbbbb", null);
+ doc.insertString(10, "N", null);
+ doc.insertString(5, "\nhellooooo", null);
+ }
+ catch (BadLocationException ex)
+ {
+ harness.debug(ex);
+ }
+ }
+}
Index: gnu/testlet/javax/swing/text/DefaultStyledDocument/ElementBuffer/StyledDocument6.java
===================================================================
RCS file: gnu/testlet/javax/swing/text/DefaultStyledDocument/ElementBuffer/StyledDocument6.java
diff -N gnu/testlet/javax/swing/text/DefaultStyledDocument/ElementBuffer/StyledDocument6.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ gnu/testlet/javax/swing/text/DefaultStyledDocument/ElementBuffer/StyledDocument6.java 12 Jan 2006 15:55:04 -0000
@@ -0,0 +1,126 @@
+// 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.text.DefaultStyledDocument.ElementBuffer;
+
+import javax.swing.*;
+import javax.swing.event.*;
+import javax.swing.text.*;
+
+import gnu.testlet.TestHarness;
+import gnu.testlet.Testlet;
+
+public class StyledDocument6 extends DefaultStyledDocument implements Testlet
+{
+ // A variable to keep track of the number of times text has been inserted
+ static int numInserts = 0;
+
+ static TestHarness h2;
+
+ // Creates a new StyledDocument6 using an ElementBuffer2 as the buffer
+ public StyledDocument6()
+ {
+ super();
+ buffer = new ElementBuffer2(createDefaultRoot());
+ }
+
+ // A class to be the buffer of the styled document that also prints out some
+ // debugging info and checks that internal structure is correct
+ public class ElementBuffer2 extends ElementBuffer
+ {
+ public ElementBuffer2(Element root)
+ {
+ super(root);
+ }
+
+ protected void insertUpdate(ElementSpec[] data)
+ {
+ numInserts ++;
+ if (numInserts == 1)
+ {
+ h2.check (data[0].getType() == ElementSpec.ContentType);
+ h2.check (data[0].getDirection() == ElementSpec.JoinPreviousDirection);
+ h2.check (data[0].getOffset() == 0);
+ h2.check (data[0].getLength() == 3);
+ }
+ else if (numInserts == 2)
+ {
+ h2.check (data[0].getType() == ElementSpec.ContentType);
+ h2.check (data[0].getDirection() == ElementSpec.OriginateDirection);
+ h2.check (data[0].getOffset() == 0);
+ h2.check (data[0].getLength() == 3);
+ }
+ else if (numInserts == 3)
+ {
+ h2.check (data[0].getType() == ElementSpec.ContentType);
+ h2.check (data[0].getDirection() == ElementSpec.OriginateDirection);
+ h2.check (data[0].getOffset() == 0);
+ h2.check (data[0].getLength() == 3);
+ }
+ else if (numInserts == 4)
+ {
+ h2.check (data[0].getType() == ElementSpec.ContentType);
+ h2.check (data[0].getDirection() == ElementSpec.JoinPreviousDirection);
+ h2.check (data[0].getOffset() == 0);
+ h2.check (data[0].getLength() == 1);
+
+ h2.check (data[1].getType() == ElementSpec.EndTagType);
+ h2.check (data[1].getDirection() == ElementSpec.OriginateDirection);
+ h2.check (data[1].getOffset() == 0);
+ h2.check (data[1].getLength() == 0);
+
+ h2.check (data[2].getType() == ElementSpec.StartTagType);
+ h2.check (data[2].getDirection() == ElementSpec.JoinFractureDirection);
+ h2.check (data[2].getOffset() == 0);
+ h2.check (data[2].getLength() == 0);
+
+ h2.check (data[3].getType() == ElementSpec.ContentType);
+ h2.check (data[3].getDirection() == ElementSpec.JoinNextDirection);
+ h2.check (data[3].getOffset() == 0);
+ h2.check (data[3].getLength() == 1);
+ }
+ super.insertUpdate(data);
+ }
+ }
+
+ public void test(TestHarness harness)
+ {
+ h2 = harness;
+ StyledDocument doc = new StyledDocument6();
+ SimpleAttributeSet atts = new SimpleAttributeSet();
+ try
+ {
+ doc.insertString(0, "aaa", null);
+ atts.addAttribute(StyleConstants.Underline, Boolean.TRUE);
+ doc.insertString(3, "bbb", atts);
+ atts.removeAttributes(atts);
+ atts.addAttribute(StyleConstants.StrikeThrough, Boolean.TRUE);
+ doc.insertString(6, "ccc", atts);
+ atts.removeAttributes(atts);
+ atts.addAttribute(StyleConstants.Underline, Boolean.TRUE);
+ doc.insertString(5, "\nB", atts);
+ }
+ catch (BadLocationException ex)
+ {
+ ex.printStackTrace();
+ }
+ }
+}