public inbox for mauve-patches@sourceware.org
 help / color / mirror / Atom feed
* Patch: New DefaultStyledDocument.ElementBuffer test
@ 2006-01-12 15:37 Lillian Angel
  2006-01-12 16:49 ` FYI: " Lillian Angel
  0 siblings, 1 reply; 2+ messages in thread
From: Lillian Angel @ 2006-01-12 15:37 UTC (permalink / raw)
  To: mauve-patches

[-- Attachment #1: Type: text/plain, Size: 158 bytes --]

2006-01-12  Lillian Angel  <langel@redhat.com>

        *
gnu/testlet/javax/swing/text/DefaultStyledDocument/ElementBuffer/ElementStructure7.java: New Test.


[-- Attachment #2: patch.diff --]
[-- Type: text/x-patch, Size: 3893 bytes --]

Index: gnu/testlet/javax/swing/text/DefaultStyledDocument/ElementBuffer/ElementStructure7.java
===================================================================
RCS file: gnu/testlet/javax/swing/text/DefaultStyledDocument/ElementBuffer/ElementStructure7.java
diff -N gnu/testlet/javax/swing/text/DefaultStyledDocument/ElementBuffer/ElementStructure7.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ gnu/testlet/javax/swing/text/DefaultStyledDocument/ElementBuffer/ElementStructure7.java	12 Jan 2006 15:34:06 -0000
@@ -0,0 +1,117 @@
+/* ElementStructure7.java --
+   Copyright (C) 2006 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.JTextPane;
+import javax.swing.text.*;
+import javax.swing.event.*;
+
+import java.util.Vector;
+
+import gnu.testlet.TestHarness;
+import gnu.testlet.Testlet;
+
+public class ElementStructure7 implements Testlet
+{
+
+  static TestHarness h2;
+
+  /**
+   * Starts the test run.
+   * 
+   * @param harness
+   *          the test harness to use
+   */
+  public void test(TestHarness harness)
+  {
+    try
+      {
+        JTextPane tp = new JTextPane();
+        StyledDocument doc = new StyledDocument2();
+        GapContent gc = new GapContent();
+        tp.setStyledDocument(doc);
+
+        h2 = harness;
+        doc.insertString(0, "aaaaaaaaa\nbbbbbbbbb", null);
+        doc.insertString(5, "\nN", null);
+      }
+    catch (BadLocationException ex)
+      {
+        h2.debug(ex);
+      }
+  }
+
+  static class StyledDocument2 extends DefaultStyledDocument
+  {
+    DefaultDocumentEvent2 docEvent = null;
+
+    public StyledDocument2()
+    {
+      super();
+      buffer = new ElementBuffer2(createDefaultRoot());
+    }
+
+    public class ElementBuffer2 extends ElementBuffer
+    {
+
+      public ElementBuffer2(Element root)
+      {
+        super(root);
+      }
+
+      public void insert(int offset, int length, ElementSpec[] data,
+                         DefaultDocumentEvent ev)
+      {
+        docEvent = new DefaultDocumentEvent2(ev.getOffset(), ev.getLength(),
+                                             ev.getType());
+        super.insert(offset, length, data, docEvent);
+        Vector edits = docEvent.getEdits();
+        
+        h2.check(edits.size(), 3);
+        Object zero = edits.get(0);
+        h2.check(zero instanceof AbstractDocument.ElementEdit);
+        h2.check(((AbstractDocument.ElementEdit) zero).canUndo());
+        Object one = edits.get(1);
+        h2.check(one instanceof AbstractDocument.ElementEdit);
+        h2.check(((AbstractDocument.ElementEdit) one).canUndo());
+        Object two = edits.get(2);
+        h2.check(two instanceof AbstractDocument.ElementEdit);
+        h2.check(((AbstractDocument.ElementEdit) two).canUndo());
+      }
+    }
+
+    public class DefaultDocumentEvent2 extends DefaultDocumentEvent
+    {
+
+      public DefaultDocumentEvent2(int offset, int length,
+                                   DocumentEvent.EventType type)
+      {
+        super(offset, length, type);
+      }
+
+      public Vector getEdits()
+      {
+        return edits;
+      }
+    }
+  }
+}

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: FYI: New DefaultStyledDocument.ElementBuffer test
  2006-01-12 15:37 Patch: New DefaultStyledDocument.ElementBuffer test Lillian Angel
@ 2006-01-12 16:49 ` Lillian Angel
  0 siblings, 0 replies; 2+ messages in thread
From: Lillian Angel @ 2006-01-12 16:49 UTC (permalink / raw)
  To: mauve-patches

[-- Attachment #1: Type: text/plain, Size: 413 bytes --]

2006-01-12  Lillian Angel  <langel@redhat.com>

        *
gnu/testlet/javax/swing/text/DefaultStyledDocument/ElementBuffer/ElementStructure7.java: Added new checks for ElementSpec data.



On Thu, 2006-01-12 at 10:36 -0500, Lillian Angel wrote:
> 2006-01-12  Lillian Angel  <langel@redhat.com>
> 
>         *
> gnu/testlet/javax/swing/text/DefaultStyledDocument/ElementBuffer/ElementStructure7.java: New Test.
> 

[-- Attachment #2: patch.diff --]
[-- Type: text/x-patch, Size: 1521 bytes --]

Index: gnu/testlet/javax/swing/text/DefaultStyledDocument/ElementBuffer/ElementStructure7.java
===================================================================
RCS file: /cvs/mauve/mauve/gnu/testlet/javax/swing/text/DefaultStyledDocument/ElementBuffer/ElementStructure7.java,v
retrieving revision 1.2
diff -u -r1.2 ElementStructure7.java
--- gnu/testlet/javax/swing/text/DefaultStyledDocument/ElementBuffer/ElementStructure7.java	12 Jan 2006 15:38:48 -0000	1.2
+++ gnu/testlet/javax/swing/text/DefaultStyledDocument/ElementBuffer/ElementStructure7.java	12 Jan 2006 16:48:17 -0000
@@ -84,7 +84,15 @@
                                              ev.getType());
         super.insert(offset, length, data, docEvent);
         Vector edits = docEvent.getEdits();
-        
+        h2.check(data.length == 4);
+        h2.check(data[0].getType() == ElementSpec.ContentType);
+        h2.check(data[0].getDirection() == ElementSpec.JoinPreviousDirection);
+        h2.check(data[1].getType() == ElementSpec.EndTagType);
+        h2.check(data[1].getDirection() == ElementSpec.OriginateDirection);
+        h2.check(data[2].getType() == ElementSpec.StartTagType);
+        h2.check(data[2].getDirection() == ElementSpec.JoinFractureDirection);
+        h2.check(data[3].getType() == ElementSpec.ContentType);
+        h2.check(data[3].getDirection() == ElementSpec.JoinNextDirection);
         h2.check(edits.size(), 3);
         Object zero = edits.get(0);
         h2.check(zero instanceof AbstractDocument.ElementEdit);

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2006-01-12 16:49 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-01-12 15:37 Patch: New DefaultStyledDocument.ElementBuffer test Lillian Angel
2006-01-12 16:49 ` FYI: " Lillian Angel

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).