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: (Still) More tests for DefaultStyledDocument


2005-12-20  Anthony Balkissoon  <abalkiss@redhat.com>

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

--Tony
Index: gnu/testlet/javax/swing/text/DefaultStyledDocument/ElementBuffer/ElementStructure3.java
===================================================================
RCS file: gnu/testlet/javax/swing/text/DefaultStyledDocument/ElementBuffer/ElementStructure3.java
diff -N gnu/testlet/javax/swing/text/DefaultStyledDocument/ElementBuffer/ElementStructure3.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ gnu/testlet/javax/swing/text/DefaultStyledDocument/ElementBuffer/ElementStructure3.java	21 Dec 2005 18:50:44 -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.text.DefaultStyledDocument;
+import javax.swing.text.Element;
+import javax.swing.JTextPane;
+
+import gnu.testlet.TestHarness;
+import gnu.testlet.Testlet;
+
+public class ElementStructure3 extends DefaultStyledDocument implements Testlet
+{
+
+  static TestHarness h2;
+
+  // Creates a new ElementStructure3 using an ElementBuffer2 as the buffer
+  public ElementStructure3()
+  {
+    super();
+    buffer = new ElementBuffer2(createDefaultRoot());
+  }
+
+  
+ public class ElementBuffer2 extends ElementBuffer
+  {
+    public ElementBuffer2(Element root)
+    {
+      super(root);
+    }
+    
+    protected void insertUpdate(ElementSpec[] data)
+    {
+      // Check that ElementSpecs were created with the proper direction, offset
+      // and length, and that the right number of Specs were created.
+      h2.check (data.length == 4);
+      for (int i = 0; i < data.length; i ++)
+        {
+          short s = data[i].getDirection();
+          if (s == ElementSpec.JoinPreviousDirection)
+            {
+              h2.check (data[i].getOffset() == 0);
+              h2.check (data[i].getLength() == 70);
+            }
+          else if (s == ElementSpec.JoinNextDirection)
+            {
+              h2.check (data[i].getOffset() == 0);
+              h2.check (data[i].getLength() == 64);
+            }
+          else if (s == ElementSpec.JoinFractureDirection)
+            {
+              h2.check (data[i].getOffset() == 0);
+              h2.check (data[i].getLength() == 0);
+            }
+          else if (s == ElementSpec.OriginateDirection)
+            {
+              h2.check (data[i].getOffset() == 0);
+              h2.check (data[i].getLength() == 0);
+            }
+        }
+      super.insertUpdate(data);
+    }
+  }
+  /**
+   * Starts the test run.
+   *
+   * @param harness the test harness to use
+   */
+  public void test(TestHarness harness)
+  {
+    h2 = harness;
+    JTextPane tp = new JTextPane();
+    tp.setDocument(new ElementStructure3());
+    tp.setText("Questions are <font size=\"+1\" color=\"blue\">a " + 
+               "burden</font> to others,\n" +
+               "answers <font size=\"+2\" color=\"red\">a " + 
+               "prison</font> for oneself.");
+  }
+}

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