This is the mail archive of the mauve-patches@sourceware.org mailing list for the Mauve project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

FYI: More DefaultStyledDocument tests


Here are more tests that we currently fail.  I'm still trying to figure
out the internals of DefaultStyledDocument and its interaction with the
text Views and events.  

2006-01-04  Anthony Balkissoon  <abalkiss@redhat.com>

	*
gnu/testlet/javax/swing/text/DefaultStyledDocument/ElementBuffer/ElementStructure4.java: New test.
	*
gnu/testlet/javax/swing/text/DefaultStyledDocument/ElementBuffer/ElementStructure5.java: New test.

--Tony
Index: gnu/testlet/javax/swing/text/DefaultStyledDocument/ElementBuffer/ElementStructure4.java
===================================================================
RCS file: gnu/testlet/javax/swing/text/DefaultStyledDocument/ElementBuffer/ElementStructure4.java
diff -N gnu/testlet/javax/swing/text/DefaultStyledDocument/ElementBuffer/ElementStructure4.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ gnu/testlet/javax/swing/text/DefaultStyledDocument/ElementBuffer/ElementStructure4.java	4 Jan 2006 16:31:14 -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.text.DefaultStyledDocument.ElementBuffer;
+
+import javax.swing.text.DefaultStyledDocument;
+import javax.swing.text.BadLocationException;
+import javax.swing.text.Element;
+import javax.swing.text.SimpleAttributeSet;
+import javax.swing.text.StyleConstants;
+
+import gnu.testlet.TestHarness;
+import gnu.testlet.Testlet;
+
+public class ElementStructure4 implements Testlet
+{
+  /**
+   * Starts the test run.
+   *
+   * @param harness the test harness to use
+   */
+  public void test(TestHarness harness)
+  {
+    try
+      {
+        DefaultStyledDocument doc = new DefaultStyledDocument();
+        SimpleAttributeSet atts = new SimpleAttributeSet();
+        Element root = doc.getDefaultRootElement();
+
+        // Add strike trough text.
+        atts.addAttribute(StyleConstants.StrikeThrough, Boolean.TRUE);
+        doc.insertString(0, "Strike through text.\n", atts);
+        atts.removeAttributes(atts);
+        harness.check(root.getElementCount() == 2);
+        harness.check(root.getElement(0).getStartOffset() == 0);
+        harness.check(root.getElement(0).getEndOffset() == 21);
+        harness.check(root.getElement(1).getStartOffset() == 21);
+        harness.check(root.getElement(1).getEndOffset() == 22);
+
+
+        // Add plain text in front.
+        doc.insertString(0, "a", null);
+        harness.check(root.getElement(0).getElementCount() == 2);
+        harness.check(root.getElement(1).getElementCount() == 1);
+        doc.insertString(1, "b", null);
+        harness.check(root.getElement(0).getElementCount() == 2);
+        harness.check(root.getElement(1).getElementCount() == 1);
+
+
+        Element first = root.getElement(0).getElement(0);
+        harness.check(first.getStartOffset() == 0);
+        harness.check(first.getEndOffset() == 2);
+
+        Element second = root.getElement(0).getElement(1);
+        harness.check(second.getStartOffset() == 2);
+        harness.check(second.getEndOffset() == 23);
+      }
+    catch (Throwable t)
+      {
+        harness.debug(t);
+      }
+  }
+}
Index: gnu/testlet/javax/swing/text/DefaultStyledDocument/ElementBuffer/ElementStructure5.java
===================================================================
RCS file: gnu/testlet/javax/swing/text/DefaultStyledDocument/ElementBuffer/ElementStructure5.java
diff -N gnu/testlet/javax/swing/text/DefaultStyledDocument/ElementBuffer/ElementStructure5.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ gnu/testlet/javax/swing/text/DefaultStyledDocument/ElementBuffer/ElementStructure5.java	4 Jan 2006 16:31:14 -0000
@@ -0,0 +1,79 @@
+// 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.text.DefaultStyledDocument;
+import javax.swing.text.BadLocationException;
+import javax.swing.text.Element;
+
+import gnu.testlet.TestHarness;
+import gnu.testlet.Testlet;
+
+public class ElementStructure5 implements Testlet
+{
+  /**
+   * Starts the test run.
+   *
+   * @param harness the test harness to use
+   */
+  public void test(TestHarness harness)
+  {
+    try
+      {
+        DefaultStyledDocument doc = new DefaultStyledDocument();
+        Element root = doc.getDefaultRootElement();
+
+        // Add a first line of text.
+        doc.insertString(0, "first line of text. \n", null);
+        harness.check(root.getElementCount() == 2);
+        harness.check(root.getElement(0).getStartOffset() == 0);
+        harness.check(root.getElement(0).getEndOffset() == 21);
+        harness.check(root.getElement(1).getStartOffset() == 21);
+        harness.check(root.getElement(1).getEndOffset() == 22);
+
+
+        // Add another line of text.
+        doc.insertString(21, "second line of text. \n", null);
+        harness.check(root.getElementCount() == 3);
+        harness.check(root.getElement(0).getElementCount() == 1);
+        harness.check(root.getElement(1).getElementCount() == 1);
+        harness.check(root.getElement(2).getElementCount() == 1);
+
+
+        Element first = root.getElement(0).getElement(0);
+        harness.check(first.getStartOffset() == 0);
+        harness.check(first.getEndOffset() == 21);
+
+        Element second = root.getElement(1).getElement(0);
+        harness.check(second.getStartOffset() == 21);
+        harness.check(second.getEndOffset() == 43);
+
+        Element third = root.getElement(2).getElement(0);
+        harness.check(third.getStartOffset() == 43);
+        harness.check(third.getEndOffset() == 44);
+      }
+    catch (Throwable t)
+      {
+        harness.debug(t);
+      }
+  }
+}

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]