You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by nd...@apache.org on 2006/11/30 06:13:43 UTC

svn commit: r480838 - in /harmony/enhanced/classlib/trunk/modules/swing: make/ src/test/api/java/common/javax/swing/text/

Author: ndbeyer
Date: Wed Nov 29 21:13:39 2006
New Revision: 480838

URL: http://svn.apache.org/viewvc?view=rev&rev=480838
Log:
Apply patch from HARMONY-2304: [classlib][swing] j.s.text.CompositeView.getNextVisualPositionFrom should use another algorithm

Added:
    harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/text/CompositeView_VisualPositionTest.java   (with props)
    harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/text/View_VisualPositionTest.java   (with props)
    harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/text/View_VisualPosition_PartTest.java   (with props)
    harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/text/VisualPositionHelper.java   (with props)
Modified:
    harmony/enhanced/classlib/trunk/modules/swing/make/exclude.linux.x86.drl
    harmony/enhanced/classlib/trunk/modules/swing/make/exclude.linux.x86.ibm
    harmony/enhanced/classlib/trunk/modules/swing/make/exclude.linux.x86_64.drl
    harmony/enhanced/classlib/trunk/modules/swing/make/exclude.linux.x86_64.ibm
    harmony/enhanced/classlib/trunk/modules/swing/make/exclude.windows.x86.drl
    harmony/enhanced/classlib/trunk/modules/swing/make/exclude.windows.x86.ibm
    harmony/enhanced/classlib/trunk/modules/swing/make/exclude.windows.x86_64.drl
    harmony/enhanced/classlib/trunk/modules/swing/make/exclude.windows.x86_64.ibm

Modified: harmony/enhanced/classlib/trunk/modules/swing/make/exclude.linux.x86.drl
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/swing/make/exclude.linux.x86.drl?view=diff&rev=480838&r1=480837&r2=480838
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/swing/make/exclude.linux.x86.drl (original)
+++ harmony/enhanced/classlib/trunk/modules/swing/make/exclude.linux.x86.drl Wed Nov 29 21:13:39 2006
@@ -134,4 +134,7 @@
 javax/swing/colorchooser/ColorChooserComponentFactoryTest.java
 javax/swing/plaf/basic/BasicColorChooserUITest.java
 
+javax/swing/text/View_VisualPositionTest.java
+javax/swing/text/View_VisualPosition_PartTest.java
+javax/swing/text/CompositeView_VisualPositionTest.java
 org/apache/harmony/swing/tests/javax/swing/text/parser/ContentModelCompatilityTest.java

Modified: harmony/enhanced/classlib/trunk/modules/swing/make/exclude.linux.x86.ibm
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/swing/make/exclude.linux.x86.ibm?view=diff&rev=480838&r1=480837&r2=480838
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/swing/make/exclude.linux.x86.ibm (original)
+++ harmony/enhanced/classlib/trunk/modules/swing/make/exclude.linux.x86.ibm Wed Nov 29 21:13:39 2006
@@ -134,4 +134,7 @@
 javax/swing/colorchooser/ColorChooserComponentFactoryTest.java
 javax/swing/plaf/basic/BasicColorChooserUITest.java
 
+javax/swing/text/View_VisualPositionTest.java
+javax/swing/text/View_VisualPosition_PartTest.java
+javax/swing/text/CompositeView_VisualPositionTest.java
 org/apache/harmony/swing/tests/javax/swing/text/parser/ContentModelCompatilityTest.java

Modified: harmony/enhanced/classlib/trunk/modules/swing/make/exclude.linux.x86_64.drl
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/swing/make/exclude.linux.x86_64.drl?view=diff&rev=480838&r1=480837&r2=480838
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/swing/make/exclude.linux.x86_64.drl (original)
+++ harmony/enhanced/classlib/trunk/modules/swing/make/exclude.linux.x86_64.drl Wed Nov 29 21:13:39 2006
@@ -134,4 +134,7 @@
 javax/swing/colorchooser/ColorChooserComponentFactoryTest.java
 javax/swing/plaf/basic/BasicColorChooserUITest.java
 
+javax/swing/text/View_VisualPositionTest.java
+javax/swing/text/View_VisualPosition_PartTest.java
+javax/swing/text/CompositeView_VisualPositionTest.java
 org/apache/harmony/swing/tests/javax/swing/text/parser/ContentModelCompatilityTest.java

Modified: harmony/enhanced/classlib/trunk/modules/swing/make/exclude.linux.x86_64.ibm
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/swing/make/exclude.linux.x86_64.ibm?view=diff&rev=480838&r1=480837&r2=480838
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/swing/make/exclude.linux.x86_64.ibm (original)
+++ harmony/enhanced/classlib/trunk/modules/swing/make/exclude.linux.x86_64.ibm Wed Nov 29 21:13:39 2006
@@ -134,4 +134,7 @@
 javax/swing/colorchooser/ColorChooserComponentFactoryTest.java
 javax/swing/plaf/basic/BasicColorChooserUITest.java
 
+javax/swing/text/View_VisualPositionTest.java
+javax/swing/text/View_VisualPosition_PartTest.java
+javax/swing/text/CompositeView_VisualPositionTest.java
 org/apache/harmony/swing/tests/javax/swing/text/parser/ContentModelCompatilityTest.java

Modified: harmony/enhanced/classlib/trunk/modules/swing/make/exclude.windows.x86.drl
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/swing/make/exclude.windows.x86.drl?view=diff&rev=480838&r1=480837&r2=480838
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/swing/make/exclude.windows.x86.drl (original)
+++ harmony/enhanced/classlib/trunk/modules/swing/make/exclude.windows.x86.drl Wed Nov 29 21:13:39 2006
@@ -134,4 +134,7 @@
 javax/swing/colorchooser/ColorChooserComponentFactoryTest.java
 javax/swing/plaf/basic/BasicColorChooserUITest.java
 
+javax/swing/text/View_VisualPositionTest.java
+javax/swing/text/View_VisualPosition_PartTest.java
+javax/swing/text/CompositeView_VisualPositionTest.java
 org/apache/harmony/swing/tests/javax/swing/text/parser/ContentModelCompatilityTest.java

Modified: harmony/enhanced/classlib/trunk/modules/swing/make/exclude.windows.x86.ibm
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/swing/make/exclude.windows.x86.ibm?view=diff&rev=480838&r1=480837&r2=480838
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/swing/make/exclude.windows.x86.ibm (original)
+++ harmony/enhanced/classlib/trunk/modules/swing/make/exclude.windows.x86.ibm Wed Nov 29 21:13:39 2006
@@ -134,4 +134,7 @@
 javax/swing/colorchooser/ColorChooserComponentFactoryTest.java
 javax/swing/plaf/basic/BasicColorChooserUITest.java
 
+javax/swing/text/View_VisualPositionTest.java
+javax/swing/text/View_VisualPosition_PartTest.java
+javax/swing/text/CompositeView_VisualPositionTest.java
 org/apache/harmony/swing/tests/javax/swing/text/parser/ContentModelCompatilityTest.java

Modified: harmony/enhanced/classlib/trunk/modules/swing/make/exclude.windows.x86_64.drl
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/swing/make/exclude.windows.x86_64.drl?view=diff&rev=480838&r1=480837&r2=480838
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/swing/make/exclude.windows.x86_64.drl (original)
+++ harmony/enhanced/classlib/trunk/modules/swing/make/exclude.windows.x86_64.drl Wed Nov 29 21:13:39 2006
@@ -134,5 +134,8 @@
 javax/swing/colorchooser/ColorChooserComponentFactoryTest.java
 javax/swing/plaf/basic/BasicColorChooserUITest.java
 
+javax/swing/text/View_VisualPositionTest.java
+javax/swing/text/View_VisualPosition_PartTest.java
+javax/swing/text/CompositeView_VisualPositionTest.java
 org/apache/harmony/swing/tests/javax/swing/text/parser/ContentModelCompatilityTestorg/apache/harmony/swing/tests/javax/swing/text/parser/ContentModelCompatilityTest.java
 

Modified: harmony/enhanced/classlib/trunk/modules/swing/make/exclude.windows.x86_64.ibm
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/swing/make/exclude.windows.x86_64.ibm?view=diff&rev=480838&r1=480837&r2=480838
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/swing/make/exclude.windows.x86_64.ibm (original)
+++ harmony/enhanced/classlib/trunk/modules/swing/make/exclude.windows.x86_64.ibm Wed Nov 29 21:13:39 2006
@@ -134,4 +134,7 @@
 javax/swing/colorchooser/ColorChooserComponentFactoryTest.java
 javax/swing/plaf/basic/BasicColorChooserUITest.java
 
+javax/swing/text/View_VisualPositionTest.java
+javax/swing/text/View_VisualPosition_PartTest.java
+javax/swing/text/CompositeView_VisualPositionTest.java
 org/apache/harmony/swing/tests/javax/swing/text/parser/ContentModelCompatilityTest.java

Added: harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/text/CompositeView_VisualPositionTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/text/CompositeView_VisualPositionTest.java?view=auto&rev=480838
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/text/CompositeView_VisualPositionTest.java (added)
+++ harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/text/CompositeView_VisualPositionTest.java Wed Nov 29 21:13:39 2006
@@ -0,0 +1,822 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+package javax.swing.text;
+
+import java.awt.Shape;
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.swing.text.Position.Bias;
+
+import junit.framework.TestCase;
+
+/**
+ * Tests how <code>CompositeView</code> traverses view hierarchy to calculate
+ * next visual position.
+ *
+ * <p>The behaviour is tested using <code>BoxView</code>
+ * (instead of <code>CompositeView</code>),
+ * and <code>GlyphView</code> instances are used as child views.
+ *
+ * <p>Only <code>View.EAST</code> (right) and <code>View.WEST</code> (left)
+ * directions are tested here.
+ */
+public class CompositeView_VisualPositionTest extends TestCase {
+    private static class FlipCallResult {
+        private final View view;
+        private final int offset;
+        private final Bias bias;
+        private final boolean result;
+
+        FlipCallResult(final View view,
+                       final int offset, final Bias bias,
+                       final boolean result) {
+            this.view = view;
+            this.offset = offset;
+            this.bias = bias;
+            this.result = result;
+        }
+
+        void assertValues(final View view,
+                          final int offset, final Bias bias,
+                          final boolean result) {
+            assertSame("Flip.view", view, this.view);
+            assertEquals("Flip.offset", offset, this.offset);
+            assertSame("Flip.bias", bias, this.bias);
+            assertEquals("Flip.result", result, this.result);
+        }
+    }
+
+    private static class VisPosCallResult {
+        private final View view;
+        private final int offset;
+        private final Bias bias;
+        private final int result;
+        private final Bias resultBias;
+
+        VisPosCallResult(final View view,
+                         final int offset, final Bias bias,
+                         final int result, final Bias resultBias) {
+            this.view = view;
+            this.offset = offset;
+            this.bias = bias;
+            this.result = result;
+            this.resultBias = resultBias;
+        }
+
+        void assertValues(final View view,
+                          final int offset, final Bias bias,
+                          final int result, final Bias resultBias) {
+            assertSame("VisPos.view", view, this.view);
+            assertEquals("VisPos.offset", offset, this.offset);
+            assertSame("VisPos.bias", bias, this.bias);
+            assertEquals("VisPos.result", result, this.result);
+            assertSame("VisPos.resultBias", resultBias, this.resultBias);
+        }
+    }
+
+    private static final Bias Forward = Bias.Forward;
+    private static final Bias Backward = Bias.Backward;
+
+    private Document doc;
+    private View view;
+    private Element root;
+    private int length;
+    private Bias[] biasRet;
+    private ViewFactory factory;
+
+    private List<VisPosCallResult> visPosCalled;
+    private List<FlipCallResult> flipCalled;
+
+    private boolean boxViewFlip;
+
+    @Override
+    protected void setUp() throws Exception {
+        super.setUp();
+        doc = new PlainDocument();
+        doc.insertString(0, "line 1\nthe second line is rather long\n"
+                            + "the third line", null);
+        root = doc.getDefaultRootElement();
+        length = doc.getLength();
+
+        factory = new ViewFactory() {
+            public View create(Element element) {
+                return new GlyphView(element) {
+                    {
+                        checkPainter();
+                    }
+
+                    @Override
+                    public int viewToModel(float fx, float fy,
+                                           Shape a, Bias[] bias) {
+                        fail(toString() + ".viewToModel is called");
+                        return super.viewToModel(fx, fy, a, bias);
+                    }
+
+                    @Override
+                    public Shape modelToView(int pos, Shape a, Bias b)
+                        throws BadLocationException {
+
+                        fail(toString() + ".modelToView is called");
+                        return super.modelToView(pos, a, b);
+                    }
+
+                    @Override
+                    public boolean isVisible() {
+                        fail(toString() + ".isVisible() is called");
+                        return super.isVisible();
+                    }
+
+                    @Override
+                    public int getNextVisualPositionFrom(int pos, Bias b, Shape a, int direction, Bias[] biasRet) throws BadLocationException {
+                        final int result =
+                            super.getNextVisualPositionFrom(pos, b, a,
+                                                            direction, biasRet);
+                        visPosCalled.add(new VisPosCallResult(this, pos, b, result, biasRet[0]));
+                        return result;
+                    }
+
+                    @Override
+                    public String toString() {
+                        return "GV[" + getStartOffset() + ", "
+                                     + getEndOffset() + "]";
+                    }
+                };
+            }
+        };
+        view = new BoxView(root, View.Y_AXIS) {
+            {
+                loadChildren(factory);
+            }
+
+            @Override
+            public int viewToModel(float fx, float fy, Shape a, Bias[] bias) {
+                fail("BV.viewToModel is called");
+                return super.viewToModel(fx, fy, a, bias);
+            }
+
+            @Override
+            public Shape modelToView(int pos, Shape a, Bias b)
+                throws BadLocationException {
+
+                fail("BV.modelToView is called");
+                return super.modelToView(pos, a, b);
+            }
+
+            @Override
+            protected boolean flipEastAndWestAtEnds(int position, Bias bias) {
+                final boolean result =
+                    position == 2 || position == 6 || position == 38
+                    ? boxViewFlip
+                    : super.flipEastAndWestAtEnds(position, bias);
+                flipCalled.add(new FlipCallResult(this, position, bias, result));
+                return result;
+            }
+        };
+        assertEquals(root.getElementCount(), view.getViewCount());
+
+        biasRet = new Bias[1];
+
+        visPosCalled = new ArrayList<VisPosCallResult>();
+        flipCalled = new ArrayList<FlipCallResult>();
+    }
+
+    public void testGetNextVisualPositionFrom_Right_01Edge_NonFlipped()
+        throws BadLocationException {
+
+        boxViewFlip = false;
+
+        // Forward
+        assertNextPosition(7, Forward, 6, Forward, View.EAST);
+        assertEquals(2, visPosCalled.size());
+        visPosCalled.get(0).assertValues(view.getView(0),
+                                         6, Forward, -1, null);
+        visPosCalled.get(1).assertValues(view.getView(1), -1, Forward, 7, Forward);
+
+        assertEquals(1, flipCalled.size());
+        flipCalled.get(0).assertValues(view, 6, Forward, false);
+
+        visPosCalled.clear();
+        flipCalled.clear();
+
+
+        // Backward
+        assertNextPosition(7, Forward, 6, Backward, View.EAST);
+        assertEquals(2, visPosCalled.size());
+        visPosCalled.get(0).assertValues(view.getView(0),
+                                         6, Backward, -1, null);
+        visPosCalled.get(1).assertValues(view.getView(1), -1, Backward, 7, Forward);
+
+        assertEquals(1, flipCalled.size());
+        flipCalled.get(0).assertValues(view, 6, Backward, false);
+
+        visPosCalled.clear();
+        flipCalled.clear();
+    }
+
+    public void testGetNextVisualPositionFrom_Right_01Edge_Flipped()
+        throws BadLocationException {
+
+        boxViewFlip = true;
+
+        // Forward
+        assertNextPosition(-1, null, 6, Forward, View.EAST);
+        assertEquals(1, visPosCalled.size());
+        visPosCalled.get(0).assertValues(view.getView(0),
+                                         6, Forward, -1, null);
+
+        assertEquals(1, flipCalled.size());
+        flipCalled.get(0).assertValues(view, 6, Forward, true);
+
+        visPosCalled.clear();
+        flipCalled.clear();
+
+
+        // Backward
+        assertNextPosition(-1, null, 6, Backward, View.EAST);
+        assertEquals(1, visPosCalled.size());
+        visPosCalled.get(0).assertValues(view.getView(0),
+                                         6, Backward, -1, null);
+
+        assertEquals(1, flipCalled.size());
+        flipCalled.get(0).assertValues(view, 6, Backward, true);
+
+        visPosCalled.clear();
+        flipCalled.clear();
+    }
+
+    public void testGetNextVisualPositionFrom_Right_12Edge_NonFlipped()
+        throws BadLocationException {
+
+        boxViewFlip = false;
+
+        // Forward
+        assertNextPosition(39, Forward, 38, Forward, View.EAST);
+        assertEquals(1, visPosCalled.size());
+        visPosCalled.get(0).assertValues(view.getView(2),
+                                         38, Forward, 39, Forward);
+
+        assertEquals(1, flipCalled.size());
+        flipCalled.get(0).assertValues(view, 38, Forward, false);
+
+        visPosCalled.clear();
+        flipCalled.clear();
+
+
+        // Backward
+        assertNextPosition(39, Forward, 38, Backward, View.EAST);
+        assertEquals(3, visPosCalled.size());
+        visPosCalled.get(0).assertValues(view.getView(1),
+                                         38, Backward, -1, null);
+        visPosCalled.get(1).assertValues(view.getView(2),
+                                         -1, Backward, 38, Forward);
+        visPosCalled.get(2).assertValues(view.getView(2),
+                                         38, Forward, 39, Forward);
+
+        assertEquals(2, flipCalled.size());
+        flipCalled.get(0).assertValues(view, 38, Backward, false);
+        flipCalled.get(0).assertValues(view, 38, Backward, false);
+
+        visPosCalled.clear();
+        flipCalled.clear();
+    }
+
+    public void testGetNextVisualPositionFrom_Right_12Edge_Flipped()
+        throws BadLocationException {
+
+        boxViewFlip = true;
+
+        // Forward
+        assertNextPosition(39, Forward, 38, Forward, View.EAST);
+        assertEquals(1, visPosCalled.size());
+        visPosCalled.get(0).assertValues(view.getView(2),
+                                         38, Forward, 39, Forward);
+
+        assertEquals(1, flipCalled.size());
+        flipCalled.get(0).assertValues(view, 38, Forward, true);
+
+        visPosCalled.clear();
+        flipCalled.clear();
+
+
+        // Backward
+        assertNextPosition(0, Forward, 38, Backward, View.EAST);
+        assertEquals(2, visPosCalled.size());
+        visPosCalled.get(0).assertValues(view.getView(1),
+                                         38, Backward, -1, null);
+        visPosCalled.get(1).assertValues(view.getView(0),
+                                         -1, Backward, 0, Forward);
+
+        assertEquals(1, flipCalled.size());
+        flipCalled.get(0).assertValues(view, 38, Backward, true);
+
+        visPosCalled.clear();
+        flipCalled.clear();
+    }
+
+    public void testGetNextVisualPositionFrom_Right_0Middle_NonFlipped()
+        throws BadLocationException {
+
+        boxViewFlip = false;
+
+        // Forward
+        assertNextPosition(3, Forward, 2, Forward, View.EAST);
+        assertEquals(1, visPosCalled.size());
+        visPosCalled.get(0).assertValues(view.getView(0),
+                                         2, Forward, 3, Forward);
+
+        assertEquals(1, flipCalled.size());
+        flipCalled.get(0).assertValues(view, 2, Forward, false);
+
+        visPosCalled.clear();
+        flipCalled.clear();
+
+
+        // Backward
+        assertNextPosition(3, Forward, 2, Backward, View.EAST);
+        assertEquals(1, visPosCalled.size());
+        visPosCalled.get(0).assertValues(view.getView(0),
+                                         2, Backward, 3, Forward);
+
+        assertEquals(1, flipCalled.size());
+        flipCalled.get(0).assertValues(view, 2, Backward, false);
+
+        visPosCalled.clear();
+        flipCalled.clear();
+    }
+
+    public void testGetNextVisualPositionFrom_Right_0Middle_Flipped()
+        throws BadLocationException {
+
+        boxViewFlip = true;
+
+        // Forward
+        assertNextPosition(3, Forward, 2, Forward, View.EAST);
+        assertEquals(1, visPosCalled.size());
+        visPosCalled.get(0).assertValues(view.getView(0),
+                                         2, Forward, 3, Forward);
+
+        assertEquals(1, flipCalled.size());
+        flipCalled.get(0).assertValues(view, 2, Forward, true);
+
+        visPosCalled.clear();
+        flipCalled.clear();
+
+
+        // Backward
+        assertNextPosition(3, Forward, 2, Backward, View.EAST);
+        assertEquals(1, visPosCalled.size());
+        visPosCalled.get(0).assertValues(view.getView(0),
+                                         2, Backward, 3, Forward);
+
+        assertEquals(1, flipCalled.size());
+        flipCalled.get(0).assertValues(view, 2, Backward, true);
+
+        visPosCalled.clear();
+        flipCalled.clear();
+    }
+
+    public void testGetNextVisualPositionFrom_Right_AtBeginning0()
+        throws BadLocationException {
+
+        // Forward
+        assertNextPosition(1, Forward, 0, Forward, View.EAST);
+        assertEquals(1, visPosCalled.size());
+        visPosCalled.get(0).assertValues(view.getView(0),
+                                         0, Forward, 1, Forward);
+
+        assertEquals(1, flipCalled.size());
+        flipCalled.get(0).assertValues(view, 0, Forward, false);
+
+        visPosCalled.clear();
+        flipCalled.clear();
+
+
+        // Backward
+        assertNextPosition(1, Forward, 0, Backward, View.EAST);
+        assertEquals(1, visPosCalled.size());
+        visPosCalled.get(0).assertValues(view.getView(0),
+                                         0, Backward, 1, Forward);
+
+        assertEquals(1, flipCalled.size());
+        flipCalled.get(0).assertValues(view, 0, Backward, false);
+
+        visPosCalled.clear();
+        flipCalled.clear();
+    }
+
+    public void testGetNextVisualPositionFrom_Right_AtBeginningMinus1()
+        throws BadLocationException {
+
+        assertEquals(-1, view.getViewIndex(-1, Forward));
+
+        // Forward
+        assertNextPosition(0, Forward, -1, Forward, View.EAST);
+        assertEquals(1, visPosCalled.size());
+        visPosCalled.get(0).assertValues(view.getView(0),
+                                         -1, Forward, 0, Forward);
+
+        assertEquals(0, flipCalled.size());
+
+        visPosCalled.clear();
+        flipCalled.clear();
+
+
+        // Backward
+        assertNextPosition(0, Forward, -1, Backward, View.EAST);
+        assertEquals(1, visPosCalled.size());
+        visPosCalled.get(0).assertValues(view.getView(0),
+                                         -1, Backward, 0, Forward);
+
+        assertEquals(0, flipCalled.size());
+
+        visPosCalled.clear();
+        flipCalled.clear();
+    }
+
+    public void testGetNextVisualPositionFrom_Right_AtBeginningMinus2()
+        throws BadLocationException {
+
+        assertEquals(-1, view.getViewIndex(-2, Forward));
+        try {
+            assertNextPosition(length, Forward, -2, Forward, View.EAST);
+            fail("ArrayIndexOutOfBoundsException is expected");
+        } catch (ArrayIndexOutOfBoundsException e) {
+            // expected
+        }
+    }
+
+
+    public void testGetNextVisualPositionFrom_Right_AtEndLength()
+        throws BadLocationException {
+
+        assertEquals(2, view.getViewIndex(length, Forward));
+
+        // Forward
+        assertNextPosition(-1, null, length, Forward, View.EAST);
+        assertEquals(1, visPosCalled.size());
+        visPosCalled.get(0).assertValues(view.getView(2),
+                                         length, Forward, -1, null);
+
+        assertEquals(1, flipCalled.size());
+        flipCalled.get(0).assertValues(view, length, Forward, false);
+
+        visPosCalled.clear();
+        flipCalled.clear();
+
+
+        // Backward
+        assertNextPosition(-1, null, length, Backward, View.EAST);
+        assertEquals(1, visPosCalled.size());
+        visPosCalled.get(0).assertValues(view.getView(2),
+                                         length, Backward, -1, null);
+
+        assertEquals(1, flipCalled.size());
+        flipCalled.get(0).assertValues(view, length, Backward, false);
+
+        visPosCalled.clear();
+        flipCalled.clear();
+    }
+
+    public void testGetNextVisualPositionFrom_Right_AtEndLength1()
+        throws BadLocationException {
+
+        assertEquals(-1, view.getViewIndex(length + 1, Forward));
+        try {
+            assertNextPosition(length, Forward, length + 1, Forward, View.EAST);
+            fail("ArrayIndexOutOfBoundsException is expected");
+        } catch (ArrayIndexOutOfBoundsException e) {
+            // expected
+        }
+    }
+
+
+
+    public void testGetNextVisualPositionFrom_Left_01Edge_NonFlipped()
+        throws BadLocationException {
+
+        boxViewFlip = false;
+
+        // Forward
+        assertNextPosition(5, Forward, 6, Forward, View.WEST);
+        assertEquals(1, visPosCalled.size());
+        visPosCalled.get(0).assertValues(view.getView(0),
+                                         6, Forward, 5, Forward);
+
+        assertEquals(1, flipCalled.size());
+        flipCalled.get(0).assertValues(view, 6, Forward, false);
+
+        visPosCalled.clear();
+        flipCalled.clear();
+
+
+        // Backward
+        assertNextPosition(5, Forward, 6, Backward, View.WEST);
+        assertEquals(1, visPosCalled.size());
+        visPosCalled.get(0).assertValues(view.getView(0),
+                                         6, Backward, 5, Forward);
+
+        assertEquals(1, flipCalled.size());
+        flipCalled.get(0).assertValues(view, 6, Backward, false);
+
+        visPosCalled.clear();
+        flipCalled.clear();
+    }
+
+    public void testGetNextVisualPositionFrom_Left_01Edge_Flipped()
+        throws BadLocationException {
+
+        boxViewFlip = true;
+
+        // Forward
+        assertNextPosition(5, Forward, 6, Forward, View.WEST);
+        assertEquals(1, visPosCalled.size());
+        visPosCalled.get(0).assertValues(view.getView(0),
+                                         6, Forward, 5, Forward);
+
+        assertEquals(1, flipCalled.size());
+        flipCalled.get(0).assertValues(view, 6, Forward, true);
+
+        visPosCalled.clear();
+        flipCalled.clear();
+
+
+        // Backward
+        assertNextPosition(5, Forward, 6, Backward, View.WEST);
+        assertEquals(1, visPosCalled.size());
+        visPosCalled.get(0).assertValues(view.getView(0),
+                                         6, Backward, 5, Forward);
+
+        assertEquals(1, flipCalled.size());
+        flipCalled.get(0).assertValues(view, 6, Backward, true);
+
+        visPosCalled.clear();
+        flipCalled.clear();
+    }
+
+    public void testGetNextVisualPositionFrom_Left_12Edge_NonFlipped()
+        throws BadLocationException {
+
+        boxViewFlip = false;
+
+        // Forward
+        assertNextPosition(37, Forward, 38, Forward, View.WEST);
+        assertEquals(2, visPosCalled.size());
+        visPosCalled.get(0).assertValues(view.getView(2),
+                                         38, Forward, -1, null);
+        visPosCalled.get(1).assertValues(view.getView(1),
+                                         -1, Forward, 37, Forward);
+
+        assertEquals(1, flipCalled.size());
+        flipCalled.get(0).assertValues(view, 38, Forward, false);
+
+        visPosCalled.clear();
+        flipCalled.clear();
+
+
+        // Backward
+        assertNextPosition(37, Forward, 38, Backward, View.WEST);
+        assertEquals(1, visPosCalled.size());
+        visPosCalled.get(0).assertValues(view.getView(1),
+                                         38, Backward, 37, Forward);
+
+        assertEquals(1, flipCalled.size());
+        flipCalled.get(0).assertValues(view, 38, Backward, false);
+
+        visPosCalled.clear();
+        flipCalled.clear();
+    }
+
+    public void testGetNextVisualPositionFrom_Left_12Edge_Flipped()
+        throws BadLocationException {
+
+        boxViewFlip = true;
+
+        // Forward
+        assertNextPosition(-1, null, 38, Forward, View.WEST);
+        assertEquals(1, visPosCalled.size());
+        visPosCalled.get(0).assertValues(view.getView(2),
+                                         38, Forward, -1, null);
+
+        assertEquals(1, flipCalled.size());
+        flipCalled.get(0).assertValues(view, 38, Forward, true);
+
+        visPosCalled.clear();
+        flipCalled.clear();
+
+
+        // Backward
+        assertNextPosition(37, Forward, 38, Backward, View.WEST);
+        assertEquals(1, visPosCalled.size());
+        visPosCalled.get(0).assertValues(view.getView(1),
+                                         38, Backward, 37, Forward);
+
+        assertEquals(1, flipCalled.size());
+        flipCalled.get(0).assertValues(view, 38, Backward, true);
+
+        visPosCalled.clear();
+        flipCalled.clear();
+    }
+
+    public void testGetNextVisualPositionFrom_Left_0Middle_NonFlipped()
+        throws BadLocationException {
+
+        boxViewFlip = false;
+
+        // Forward
+        assertNextPosition(1, Forward, 2, Forward, View.WEST);
+        assertEquals(1, visPosCalled.size());
+        visPosCalled.get(0).assertValues(view.getView(0),
+                                         2, Forward, 1, Forward);
+
+        assertEquals(1, flipCalled.size());
+        flipCalled.get(0).assertValues(view, 2, Forward, false);
+
+        visPosCalled.clear();
+        flipCalled.clear();
+
+
+        // Backward
+        assertNextPosition(1, Forward, 2, Backward, View.WEST);
+        assertEquals(1, visPosCalled.size());
+        visPosCalled.get(0).assertValues(view.getView(0),
+                                         2, Backward, 1, Forward);
+
+        assertEquals(1, flipCalled.size());
+        flipCalled.get(0).assertValues(view, 2, Backward, false);
+
+        visPosCalled.clear();
+        flipCalled.clear();
+    }
+
+    public void testGetNextVisualPositionFrom_Left_0Middle_Flipped()
+        throws BadLocationException {
+
+        boxViewFlip = true;
+
+        // Forward
+        assertNextPosition(1, Forward, 2, Forward, View.WEST);
+        assertEquals(1, visPosCalled.size());
+        visPosCalled.get(0).assertValues(view.getView(0),
+                                         2, Forward, 1, Forward);
+
+        assertEquals(1, flipCalled.size());
+        flipCalled.get(0).assertValues(view, 2, Forward, true);
+
+        visPosCalled.clear();
+        flipCalled.clear();
+
+
+        // Backward
+        assertNextPosition(1, Forward, 2, Backward, View.WEST);
+        assertEquals(1, visPosCalled.size());
+        visPosCalled.get(0).assertValues(view.getView(0),
+                                         2, Backward, 1, Forward);
+
+        assertEquals(1, flipCalled.size());
+        flipCalled.get(0).assertValues(view, 2, Backward, true);
+
+        visPosCalled.clear();
+        flipCalled.clear();
+    }
+
+    public void testGetNextVisualPositionFrom_Left_AtBeginning0()
+        throws BadLocationException {
+
+        // Forward
+        assertNextPosition(-1, null, 0, Forward, View.WEST);
+        assertEquals(1, visPosCalled.size());
+        visPosCalled.get(0).assertValues(view.getView(0),
+                                         0, Forward, -1, null);
+
+        assertEquals(1, flipCalled.size());
+        flipCalled.get(0).assertValues(view, 0, Forward, false);
+
+        visPosCalled.clear();
+        flipCalled.clear();
+
+
+        // Backward
+        assertNextPosition(-1, null, 0, Backward, View.WEST);
+        assertEquals(1, visPosCalled.size());
+        visPosCalled.get(0).assertValues(view.getView(0),
+                                         0, Backward, -1, null);
+
+        assertEquals(1, flipCalled.size());
+        flipCalled.get(0).assertValues(view, 0, Backward, false);
+
+        visPosCalled.clear();
+        flipCalled.clear();
+    }
+
+    public void testGetNextVisualPositionFrom_Left_AtBeginningMinus1()
+        throws BadLocationException {
+
+        // Forward
+        assertNextPosition(length, Forward, -1, Forward, View.WEST);
+        assertEquals(1, visPosCalled.size());
+        visPosCalled.get(0).assertValues(view.getView(2),
+                                         -1, Forward, length, Forward);
+
+        assertEquals(0, flipCalled.size());
+
+        visPosCalled.clear();
+        flipCalled.clear();
+
+
+        // Backward
+        assertNextPosition(length, Forward, -1, Backward, View.WEST);
+        assertEquals(1, visPosCalled.size());
+        visPosCalled.get(0).assertValues(view.getView(2),
+                                         -1, Backward, length, Forward);
+
+        assertEquals(0, flipCalled.size());
+//        flipCalled.get(0).assertValues(view, 0, Backward, false);
+
+        visPosCalled.clear();
+        flipCalled.clear();
+    }
+
+    public void testGetNextVisualPositionFrom_Left_AtBeginningMinus2()
+    throws BadLocationException {
+
+        try {
+            assertNextPosition(length, Forward, -2, Forward, View.WEST);
+            fail("ArrayIndexOutOfBoundsException is expected");
+        } catch (ArrayIndexOutOfBoundsException e) {
+            // expected
+        }
+    }
+
+
+    public void testGetNextVisualPositionFrom_Left_AtEndLength()
+        throws BadLocationException {
+
+        // Forward
+        assertNextPosition(length - 1, Forward, length, Forward, View.WEST);
+        assertEquals(1, visPosCalled.size());
+        visPosCalled.get(0).assertValues(view.getView(2),
+                                         length, Forward, length - 1, Forward);
+
+        assertEquals(1, flipCalled.size());
+        flipCalled.get(0).assertValues(view, length, Forward, false);
+
+        visPosCalled.clear();
+        flipCalled.clear();
+
+
+        // Backward
+        assertNextPosition(length - 1, Forward, length, Backward, View.WEST);
+        assertEquals(1, visPosCalled.size());
+        visPosCalled.get(0).assertValues(view.getView(2),
+                                         length, Backward, length - 1, Forward);
+
+        assertEquals(1, flipCalled.size());
+        flipCalled.get(0).assertValues(view, length, Backward, false);
+
+        visPosCalled.clear();
+        flipCalled.clear();
+    }
+
+    public void testGetNextVisualPositionFrom_Left_AtEndLength1()
+        throws BadLocationException {
+
+        try {
+            assertNextPosition(length, Forward, length + 1, Forward, View.WEST);
+            fail("ArrayIndexOutOfBoundsException is expected");
+        } catch (ArrayIndexOutOfBoundsException e) {
+            // expected
+        }
+    }
+
+
+    private void assertNextPosition(final int expectedPosition,
+                                    final Bias expectedBias,
+                                    final int position,
+                                    final Bias bias,
+                                    final int direction)
+        throws BadLocationException {
+
+        biasRet[0] = null;
+        assertEquals(bias + " at " + position,
+                     expectedPosition,
+                     view.getNextVisualPositionFrom(position, bias,
+                                                    null, direction,
+                                                    biasRet));
+        assertSame(expectedBias, biasRet[0]);
+    }
+}

Propchange: harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/text/CompositeView_VisualPositionTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/text/View_VisualPositionTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/text/View_VisualPositionTest.java?view=auto&rev=480838
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/text/View_VisualPositionTest.java (added)
+++ harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/text/View_VisualPositionTest.java Wed Nov 29 21:13:39 2006
@@ -0,0 +1,112 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+package javax.swing.text;
+
+import static javax.swing.text.VisualPositionHelper.assertNextPosition;
+import junit.framework.TestCase;
+
+/**
+ * Tests <code>View.getNextVisualPositionFrom</code> method on
+ * <code>PlainView</code> which doesn't overrides this method.
+ *
+ * <p>The view is constructed on the <em>root</em> element of
+ * document (<code>PlainDocument</code>).
+ *
+ * <p>Only <code>View.EAST</code> (right) and <code>View.WEST</code> (left)
+ * directions are tested here.
+ */
+public class View_VisualPositionTest extends TestCase {
+    private Document doc;
+    private View view;
+    private Element root;
+    private int length;
+
+    @Override
+    protected void setUp() throws Exception {
+        super.setUp();
+        doc = new PlainDocument();
+        doc.insertString(0, "line 1\nthe second line is rather long\n"
+                            + "the third line", null);
+        length = doc.getLength();
+
+        root = doc.getDefaultRootElement();
+        view = new PlainView(root);
+    }
+
+    public void testGetNextVisualPositionFrom_Right() throws BadLocationException {
+        for (int i = 0; i < length; i++) {
+            assertNextPosition(i + 1, i, View.EAST, view, null);
+        };
+    }
+
+    public void testGetNextVisualPositionFrom_RightAtBeginning()
+        throws BadLocationException {
+
+        assertNextPosition(0, -1, View.EAST, view, null);
+
+        assertNextPosition(-1, -2, View.EAST, view, null);
+        assertNextPosition(-2, -3, View.EAST, view, null);
+        assertNextPosition(-3, -4, View.EAST, view, null);
+
+        assertNextPosition(-9, -10, View.EAST, view, null);
+    }
+
+    public void testGetNextVisualPositionFrom_RightAtEnd()
+        throws BadLocationException {
+
+        assertNextPosition(length, length - 1, View.EAST, view, null);
+        assertNextPosition(length, length, View.EAST, view, null);
+
+        assertNextPosition(length, length + 1, View.EAST, view, null);
+        assertNextPosition(length, length + 2, View.EAST, view, null);
+        assertNextPosition(length, length + 3, View.EAST, view, null);
+
+        assertNextPosition(length, length + 10, View.EAST, view, null);
+    }
+
+    public void testGetNextVisualPositionFrom_Left() throws BadLocationException {
+        for (int i = 1; i <= length; i++) {
+            assertNextPosition(i - 1, i, View.WEST, view, null);
+        };
+    }
+
+    public void testGetNextVisualPositionFrom_LeftAtBeginning()
+        throws BadLocationException {
+
+        assertNextPosition(0, 1, View.WEST, view, null);
+        assertNextPosition(0, 0, View.WEST, view, null);
+
+        assertNextPosition(length, -1, View.WEST, view, null);
+
+        assertNextPosition(0, -2, View.WEST, view, null);
+        assertNextPosition(0, -3, View.WEST, view, null);
+
+        assertNextPosition(0, -10, View.WEST, view, null);
+    }
+
+    public void testGetNextVisualPositionFrom_LeftAtEnd()
+        throws BadLocationException {
+
+        assertNextPosition(length - 1, length, View.WEST, view, null);
+        assertNextPosition(length, length + 1, View.WEST, view, null);
+
+        assertNextPosition(length + 1, length + 2, View.WEST, view, null);
+        assertNextPosition(length + 2, length + 3, View.WEST, view, null);
+
+        assertNextPosition(length + 9, length + 10, View.WEST, view, null);
+    }
+}

Propchange: harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/text/View_VisualPositionTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/text/View_VisualPosition_PartTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/text/View_VisualPosition_PartTest.java?view=auto&rev=480838
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/text/View_VisualPosition_PartTest.java (added)
+++ harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/text/View_VisualPosition_PartTest.java Wed Nov 29 21:13:39 2006
@@ -0,0 +1,140 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+package javax.swing.text;
+
+import static javax.swing.text.VisualPositionHelper.assertNextPosition;
+
+import java.awt.Rectangle;
+import java.awt.Shape;
+
+import junit.framework.TestCase;
+
+/**
+ * Tests <code>View.getNextVisualPositionFrom</code> method on
+ * <code>PlainView</code> which doesn't overrides this method.
+ *
+ * <p>The view is constructed on the <em>element</em> representing
+ * the <em>second paragraph</em>
+ * in document (<code>PlainDocument</code>).
+ *
+ * <p>Only <code>View.EAST</code> (right) and <code>View.WEST</code> (left)
+ * directions are tested here.
+ */
+public class View_VisualPosition_PartTest extends TestCase {
+    private Document doc;
+    private Element root;
+    private Element element;
+    private int startOffset;
+    private int endOffset;
+    private int length;
+
+    private View view;
+    private Shape alloc;
+
+    @Override
+    protected void setUp() throws Exception {
+        super.setUp();
+        doc = new PlainDocument();
+        doc.insertString(0, "line 1\nthe second line is rather long\n"
+                            + "the third line", null);
+        length = doc.getLength();
+
+        root = doc.getDefaultRootElement();
+        element = root.getElement(1);
+        startOffset = element.getStartOffset();
+        endOffset = element.getEndOffset();
+
+        view = new PlainView(element);
+
+        alloc = new Rectangle(10, 15, 100, 18);
+    }
+
+    public void testGetNextVisualPositionFrom_Right()
+        throws BadLocationException {
+
+        for (int i = 0; i < length; i++) {
+            assertNextPosition(i + 1, i, View.EAST, view, alloc);
+        };
+    }
+
+    public void testGetNextVisualPositionFrom_RightAtBeginning()
+        throws BadLocationException {
+
+        assertNextPosition(startOffset, -1, View.EAST, view, alloc);
+
+        assertNextPosition(1, 0, View.EAST, view, alloc);
+        assertNextPosition(-1, -2, View.EAST, view, alloc);
+        assertNextPosition(-2, -3, View.EAST, view, alloc);
+        assertNextPosition(-9, -10, View.EAST, view, alloc);
+
+        for (int i = startOffset - 2; i <= startOffset + 2; i++) {
+            assertNextPosition(i + 1, i, View.EAST, view, alloc);
+        }
+    }
+
+    public void testGetNextVisualPositionFrom_RightAtEnd()
+        throws BadLocationException {
+
+        for (int i = endOffset - 2; i <= endOffset + 2; i++) {
+            assertNextPosition(i + 1, i, View.EAST, view, alloc);
+        }
+
+        assertNextPosition(length, length - 1, View.EAST, view, alloc);
+        assertNextPosition(length, length, View.EAST, view, alloc);
+        assertNextPosition(length, length + 1, View.EAST, view, alloc);
+        assertNextPosition(length, length + 2, View.EAST, view, alloc);
+
+        assertNextPosition(length, length + 10, View.EAST, view, alloc);
+    }
+
+    public void testGetNextVisualPositionFrom_Left()
+        throws BadLocationException {
+
+        for (int i = 1; i <= length; i++) {
+            assertNextPosition(i - 1, i, View.WEST, view, alloc);
+        };
+    }
+
+    public void testGetNextVisualPositionFrom_LeftAtBeginning()
+        throws BadLocationException {
+
+        assertNextPosition(endOffset - 1, -1, View.WEST, view, alloc);
+
+        assertNextPosition(0, 0, View.WEST, view, alloc);
+        assertNextPosition(0, -2, View.WEST, view, alloc);
+        assertNextPosition(0, -3, View.WEST, view, alloc);
+        assertNextPosition(0, -10, View.WEST, view, alloc);
+
+        for (int i = startOffset - 2; i <= startOffset + 2; i++) {
+            assertNextPosition(i - 1, i, View.WEST, view, alloc);
+        }
+    }
+
+    public void testGetNextVisualPositionFrom_LeftAtEnd()
+        throws BadLocationException {
+
+        for (int i = endOffset - 2; i <= endOffset + 2; i++) {
+            assertNextPosition(i - 1, i, View.WEST, view, alloc);
+        }
+
+        assertNextPosition(length - 2, length - 1, View.WEST, view, alloc);
+        assertNextPosition(length - 1, length, View.WEST, view, alloc);
+        assertNextPosition(length, length + 1, View.WEST, view, alloc);
+        assertNextPosition(length + 1, length + 2, View.WEST, view, alloc);
+        assertNextPosition(length + 9, length + 10, View.WEST, view, alloc);
+    }
+}

Propchange: harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/text/View_VisualPosition_PartTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/text/VisualPositionHelper.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/text/VisualPositionHelper.java?view=auto&rev=480838
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/text/VisualPositionHelper.java (added)
+++ harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/text/VisualPositionHelper.java Wed Nov 29 21:13:39 2006
@@ -0,0 +1,96 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+package javax.swing.text;
+
+import static junit.framework.Assert.assertEquals;
+import static junit.framework.Assert.assertSame;
+
+import java.awt.Shape;
+
+import javax.swing.text.Position.Bias;
+
+/**
+ * Utility class to support testing of
+ * <code>View.getNextVisualPositionFrom</code> method.
+ */
+public final class VisualPositionHelper {
+    private static final Bias[] biasRet = new Bias[1];
+    private static final Bias[] biases = new Bias[] {Bias.Forward,
+                                                     Bias.Backward};
+
+    private VisualPositionHelper() {
+    }
+
+    public static void assertNextPosition(final int expectedPosition,
+                                          final int offset,
+                                          final int direction,
+                                          final View view,
+                                          final Shape allocation)
+        throws BadLocationException {
+
+        for (Bias bias : biases) {
+            biasRet[0] = null;
+            assertEquals(bias + " from " + offset,
+                         expectedPosition,
+                         view.getNextVisualPositionFrom(offset, bias,
+                                                        allocation, direction,
+                                                        biasRet));
+            assertSame(Bias.Forward, biasRet[0]);
+        }
+    }
+
+    public static void assertNextBiasedPosition(final int expectedPosition,
+                                                final int offset,
+                                                final int direction,
+                                                final View view,
+                                                final Shape allocation,
+                                                final Bias bias)
+        throws BadLocationException {
+
+        biasRet[0] = null;
+        assertEquals(bias + " from " + offset,
+                     expectedPosition,
+                     view.getNextVisualPositionFrom(offset, bias,
+                                                    allocation, direction,
+                                                    biasRet));
+        assertSame(Bias.Forward, biasRet[0]);
+    }
+
+    public static void assertNextForwardPosition(final int expectedPosition,
+                                                 final int offset,
+                                                 final int direction,
+                                                 final View view,
+                                                 final Shape allocation)
+        throws BadLocationException {
+
+        assertNextBiasedPosition(expectedPosition,
+                                 offset, direction, view,
+                                 allocation, Bias.Forward);
+    }
+
+    public static void assertNextBackwardPosition(final int expectedPosition,
+                                                  final int offset,
+                                                  final int direction,
+                                                  final View view,
+                                                  final Shape allocation)
+        throws BadLocationException {
+
+        assertNextBiasedPosition(expectedPosition,
+                                 offset, direction, view,
+                                 allocation, Bias.Backward);
+    }
+}

Propchange: harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/text/VisualPositionHelper.java
------------------------------------------------------------------------------
    svn:eol-style = native