harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ndbe...@apache.org
Subject svn commit: r479418 [34/43] - in /harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common: javax/swing/ javax/swing/border/ javax/swing/colorchooser/ javax/swing/event/ javax/swing/filechooser/ javax/swing/plaf/ javax/swing/plaf/basic/ j...
Date Sun, 26 Nov 2006 20:15:55 GMT
Modified: harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/text/PlainViewI18NTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/text/PlainViewI18NTest.java?view=diff&rev=479418&r1=479417&r2=479418
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/text/PlainViewI18NTest.java (original)
+++ harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/text/PlainViewI18NTest.java Sun Nov 26 12:15:43 2006
@@ -14,7 +14,6 @@
  *  See the License for the specific language governing permissions and
  *  limitations under the License.
  */
-
 /**
  * @author Alexey A. Ivanov
  * @version $Revision$
@@ -23,7 +22,6 @@
 
 import java.awt.Container;
 import java.awt.FontMetrics;
-
 import javax.swing.JTextArea;
 import javax.swing.SwingTestCase;
 
@@ -32,54 +30,47 @@
  */
 public class PlainViewI18NTest extends SwingTestCase {
     private JTextArea area;
+
     private Document doc;
 
     private int line2Width;
 
     private int lineCount;
+
     private FontMetrics metrics;
 
-    private Element  root;
+    private Element root;
+
     private PlainViewI18N view;
 
     public void testGetMaximumSpan() throws Exception {
         if (!isHarmony()) {
             return;
         }
-
-        assertEquals(lineCount * metrics.getHeight(),
-                     (int)view.getMaximumSpan(View.Y_AXIS));
-        assertEquals(Integer.MAX_VALUE,
-                     (int)view.getMaximumSpan(View.X_AXIS));
+        assertEquals(lineCount * metrics.getHeight(), (int) view.getMaximumSpan(View.Y_AXIS));
+        assertEquals(Integer.MAX_VALUE, (int) view.getMaximumSpan(View.X_AXIS));
     }
 
     public void testGetMinimumSpan() throws Exception {
         if (!isHarmony()) {
             return;
         }
-
-        assertEquals(lineCount * metrics.getHeight(),
-                     (int)view.getMinimumSpan(View.Y_AXIS));
-        assertEquals(line2Width,
-                     (int)view.getMinimumSpan(View.X_AXIS));
+        assertEquals(lineCount * metrics.getHeight(), (int) view.getMinimumSpan(View.Y_AXIS));
+        assertEquals(line2Width, (int) view.getMinimumSpan(View.X_AXIS));
     }
 
     public void testGetPreferredSpan() throws Exception {
         if (!isHarmony()) {
             return;
         }
-
-        assertEquals(lineCount * metrics.getHeight(),
-                     (int)view.getPreferredSpan(View.Y_AXIS));
-        assertEquals(line2Width,
-                     (int)view.getPreferredSpan(View.X_AXIS));
+        assertEquals(lineCount * metrics.getHeight(), (int) view.getPreferredSpan(View.Y_AXIS));
+        assertEquals(line2Width, (int) view.getPreferredSpan(View.X_AXIS));
     }
 
     public void testGetViewFactory() {
         if (!isHarmony()) {
             return;
         }
-
         assertNull(view.getParent());
         assertNotNull(view.getViewFactory());
     }
@@ -88,55 +79,47 @@
         if (!isHarmony()) {
             return;
         }
-
-        Object tabSizeProperty =
-            doc.getProperty(PlainDocument.tabSizeAttribute);
-        int tabSize = ((Integer)tabSizeProperty).intValue();
+        Object tabSizeProperty = doc.getProperty(PlainDocument.tabSizeAttribute);
+        int tabSize = ((Integer) tabSizeProperty).intValue();
         int tabStop = metrics.charWidth('m') * tabSize;
-
-        assertEquals(tabStop, (int)view.nextTabStop(0, 0));
-        assertEquals(tabStop, (int)view.nextTabStop(tabStop / 2, 0));
-        assertEquals(2 * tabStop, (int)view.nextTabStop(tabStop, 0));
+        assertEquals(tabStop, (int) view.nextTabStop(0, 0));
+        assertEquals(tabStop, (int) view.nextTabStop(tabStop / 2, 0));
+        assertEquals(2 * tabStop, (int) view.nextTabStop(tabStop, 0));
     }
 
     public void testPlainViewI18N() {
         if (!isHarmony()) {
             return;
         }
-
         view = new PlainViewI18N(root);
         assertEquals(View.Y_AXIS, view.getAxis());
-
         assertEquals(0, view.getViewCount());
         view.loadChildren(view.getViewFactory());
         assertEquals(root.getElementCount(), view.getViewCount());
     }
 
+    @Override
     protected void setUp() throws Exception {
         super.setUp();
-
         if (!isHarmony()) {
             return;
         }
-
         doc = new PlainDocument();
         doc.insertString(0, "line1\nline two", null);
         root = doc.getDefaultRootElement();
-
         view = new PlainViewI18N(root) {
+            @Override
             public Container getContainer() {
                 return area;
             }
         };
         view.loadChildren(view.getViewFactory());
-
         area = new JTextArea();
         metrics = area.getFontMetrics(area.getFont());
-
         lineCount = root.getElementCount();
         Element line2 = root.getElement(1);
-        line2Width = metrics.stringWidth(doc.getText(line2.getStartOffset(),
-                                                     line2.getEndOffset()
-                                                     - line2.getStartOffset()));
+        line2Width = metrics.stringWidth(doc.getText(line2.getStartOffset(), line2
+                .getEndOffset()
+                - line2.getStartOffset()));
     }
 }

Modified: harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/text/PlainViewI18N_BidiTextViewTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/text/PlainViewI18N_BidiTextViewTest.java?view=diff&rev=479418&r1=479417&r2=479418
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/text/PlainViewI18N_BidiTextViewTest.java (original)
+++ harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/text/PlainViewI18N_BidiTextViewTest.java Sun Nov 26 12:15:43 2006
@@ -14,7 +14,6 @@
  *  See the License for the specific language governing permissions and
  *  limitations under the License.
  */
-
 /**
  * @author Alexey A. Ivanov
  * @version $Revision$
@@ -24,35 +23,41 @@
 import java.awt.Container;
 import java.awt.FontMetrics;
 import java.awt.Rectangle;
-
 import javax.swing.event.DocumentEvent;
 import javax.swing.event.DocumentListener;
 import javax.swing.text.Position.Bias;
 import javax.swing.text.PlainViewI18N_LineViewTest.PlainViewI18NWithTextArea;
-
 import junit.framework.TestCase;
 
-public class PlainViewI18N_BidiTextViewTest extends TestCase
-    implements DocumentListener {
-
+public class PlainViewI18N_BidiTextViewTest extends TestCase implements DocumentListener {
     private View view;
+
     private PlainViewI18N parent;
+
     private PlainDocument doc;
+
     private Element root;
+
     private int startOffset;
+
     private int endOffset;
+
     private FontMetrics metrics;
+
     private final Rectangle shape = new Rectangle(27, 74, 91, 41);
+
     private DocumentEvent insertEvent;
+
     private DocumentEvent removeEvent;;
 
+    @Override
     protected void setUp() throws Exception {
         super.setUp();
         doc = new PlainDocument();
         doc.insertString(0, PlainViewI18N_LineViewTest.defText, null);
         root = doc.getDefaultRootElement();
         startOffset = root.getElement(1).getStartOffset() + 1;
-        endOffset   = root.getElement(3).getEndOffset() - 1;
+        endOffset = root.getElement(3).getEndOffset() - 1;
         parent = new PlainViewI18NWithTextArea(root, doc);
     }
 
@@ -70,10 +75,8 @@
 
     private void init() throws BadLocationException {
         view.setParent(parent);
-
         Container container = view.getContainer();
         metrics = container.getFontMetrics(container.getFont());
-
         shape.width = getTextWidth(startOffset, endOffset - startOffset);
         shape.height = metrics.getHeight();
         parent.setSize(shape.width, shape.height);
@@ -83,9 +86,7 @@
         return view.getDocument().getText(offset, length);
     }
 
-    private int getTextWidth(int offset, int length)
-        throws BadLocationException {
-
+    private int getTextWidth(int offset, int length) throws BadLocationException {
         return getTextWidth(getText(offset, length));
     }
 
@@ -95,7 +96,7 @@
 
     private void setOffsets(Element element) {
         startOffset = element.getStartOffset();
-        endOffset   = element.getEndOffset();
+        endOffset = element.getEndOffset();
     }
 
     public void testModelToViewLTR() throws BadLocationException {
@@ -103,32 +104,24 @@
         setOffsets(line);
         view = parent.new LTRTextView(line, startOffset, endOffset);
         init();
-
-        assertEquals(new Rectangle(shape.x, shape.y, 1, shape.height),
-                     view.modelToView(startOffset, shape, Bias.Forward));
-
-        assertEquals(new Rectangle(shape.x + getTextWidth(startOffset, 1),
-                                   shape.y, 1, shape.height),
-                     view.modelToView(startOffset + 1, shape, Bias.Forward));
-
-        assertEquals(new Rectangle(shape.x
-                                   + getTextWidth(startOffset,
-                                                  endOffset - startOffset),
-                                   shape.y, 1, shape.height),
-                     view.modelToView(endOffset, shape, Bias.Forward));
-
+        assertEquals(new Rectangle(shape.x, shape.y, 1, shape.height), view.modelToView(
+                startOffset, shape, Bias.Forward));
+        assertEquals(new Rectangle(shape.x + getTextWidth(startOffset, 1), shape.y, 1,
+                shape.height), view.modelToView(startOffset + 1, shape, Bias.Forward));
+        assertEquals(new Rectangle(
+                shape.x + getTextWidth(startOffset, endOffset - startOffset), shape.y, 1,
+                shape.height), view.modelToView(endOffset, shape, Bias.Forward));
         // Invalid values
         try {
             view.modelToView(startOffset - 1, shape, Bias.Forward);
-
             fail("BadLocationException must be thrown");
-        } catch (BadLocationException e) { }
-
+        } catch (BadLocationException e) {
+        }
         try {
             view.modelToView(endOffset + 1, shape, Bias.Forward);
-
             fail("BadLocationException must be thrown");
-        } catch (BadLocationException e) { }
+        } catch (BadLocationException e) {
+        }
     }
 
     public void testModelToViewRTL() throws BadLocationException {
@@ -136,42 +129,35 @@
         setOffsets(line);
         view = parent.new RTLTextView(line, startOffset, endOffset);
         init();
-
         assertEquals(new Rectangle(shape.x
-                                   // all RTLtext (both symbols)
-                                   + getTextWidth(startOffset,
-                                                  endOffset - startOffset - 1),
-                                   shape.y, 1, shape.height),
-                     view.modelToView(startOffset, shape, Bias.Forward));
-
+        // all RTLtext (both symbols)
+                + getTextWidth(startOffset, endOffset - startOffset - 1), shape.y, 1,
+                shape.height), view.modelToView(startOffset, shape, Bias.Forward));
         assertEquals(new Rectangle(shape.x
-                                   // the second symbol in the model
-                                   + getTextWidth(startOffset + 1,
-                                                  endOffset - startOffset - 2),
-                                   shape.y, 1, shape.height),
-                     view.modelToView(startOffset + 1, shape, Bias.Forward));
-
-                                   // no text at all
-        assertEquals(new Rectangle(shape.x, shape.y, 1, shape.height),
-                     view.modelToView(endOffset, shape, Bias.Forward));
-
+        // the second symbol in the model
+                + getTextWidth(startOffset + 1, endOffset - startOffset - 2), shape.y, 1,
+                shape.height), view.modelToView(startOffset + 1, shape, Bias.Forward));
+        // no text at all
+        assertEquals(new Rectangle(shape.x, shape.y, 1, shape.height), view.modelToView(
+                endOffset, shape, Bias.Forward));
         // Invalid values
         try {
             view.modelToView(startOffset - 1, shape, Bias.Forward);
-
             fail("BadLocationException must be thrown");
-        } catch (BadLocationException e) { }
-
+        } catch (BadLocationException e) {
+        }
         try {
             view.modelToView(endOffset + 1, shape, Bias.Forward);
-
             fail("BadLocationException must be thrown");
-        } catch (BadLocationException e) { }
+        } catch (BadLocationException e) {
+        }
     }
 
     public static class PreferenceChange {
-        private final View    child;
+        private final View child;
+
         private final boolean width;
+
         private final boolean height;
 
         public PreferenceChange(View child, boolean width, boolean height) {
@@ -193,15 +179,14 @@
         final Element line = root.getElement(0);
         setOffsets(line);
         view = parent.new LTRTextView(line, startOffset, endOffset) {
+            @Override
             public void preferenceChanged(View child, boolean w, boolean h) {
                 preferenceParams = new PreferenceChange(child, w, h);
             }
         };
         init();
-
         doc.addDocumentListener(this);
         doc.insertString(startOffset + 1, PlainViewI18N_LineViewTest.LTR, null);
-
         view.insertUpdate(insertEvent, shape, null);
         preferenceParams.check(view, true, false);
     }
@@ -210,15 +195,14 @@
         final Element line = root.getElement(1);
         setOffsets(line);
         view = parent.new RTLTextView(line, startOffset, endOffset) {
+            @Override
             public void preferenceChanged(View child, boolean w, boolean h) {
                 preferenceParams = new PreferenceChange(child, w, h);
             }
         };
         init();
-
         doc.addDocumentListener(this);
         doc.insertString(startOffset + 1, PlainViewI18N_LineViewTest.RTL, null);
-
         view.insertUpdate(insertEvent, shape, null);
         preferenceParams.check(view, true, false);
     }
@@ -227,15 +211,14 @@
         final Element line = root.getElement(0);
         setOffsets(line);
         view = parent.new LTRTextView(line, startOffset, endOffset) {
+            @Override
             public void preferenceChanged(View child, boolean w, boolean h) {
                 preferenceParams = new PreferenceChange(child, w, h);
             }
         };
         init();
-
         doc.addDocumentListener(this);
         doc.remove(startOffset + 1, 1);
-
         view.removeUpdate(removeEvent, shape, null);
         preferenceParams.check(view, true, false);
     }
@@ -244,15 +227,14 @@
         final Element line = root.getElement(1);
         setOffsets(line);
         view = parent.new RTLTextView(line, startOffset, endOffset) {
+            @Override
             public void preferenceChanged(View child, boolean w, boolean h) {
                 preferenceParams = new PreferenceChange(child, w, h);
             }
         };
         init();
-
         doc.addDocumentListener(this);
         doc.remove(startOffset + 1, 1);
-
         view.removeUpdate(removeEvent, shape, null);
         preferenceParams.check(view, true, false);
     }
@@ -267,8 +249,6 @@
     public void removeUpdate(DocumentEvent event) {
         removeEvent = event;
     }
-
-//    public void testBidiTextView() {
-//    }
-
+    //    public void testBidiTextView() {
+    //    }
 }

Modified: harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/text/PlainViewI18N_LayoutTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/text/PlainViewI18N_LayoutTest.java?view=diff&rev=479418&r1=479417&r2=479418
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/text/PlainViewI18N_LayoutTest.java (original)
+++ harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/text/PlainViewI18N_LayoutTest.java Sun Nov 26 12:15:43 2006
@@ -14,7 +14,6 @@
  *  See the License for the specific language governing permissions and
  *  limitations under the License.
  */
-
 /**
  * @author Alexey A. Ivanov
  * @version $Revision$
@@ -32,32 +31,30 @@
  */
 public class PlainViewI18N_LayoutTest extends SwingTestCase {
     private JTextArea area;
+
     private Document doc;
+
     private JFrame frame;
+
     private View rootView;
+
     private CompositeView view;
 
     /**
      * Tests values returned by <code>flipEastAndWestAtEnds()</code>.
      */
     public void testFlipEastAndWest() throws Exception {
-        boolean[] forward = new boolean[] {
-            false, false, false, false, false,
-            false, false, false, false, false,
-            false, false
-        };
-        boolean[] backward = new boolean[] {
-            false, false, false, false, false,
-            false, false, false, false, false,
-            false, false
-        };
+        boolean[] forward = new boolean[] { false, false, false, false, false, false, false,
+                false, false, false, false, false };
+        boolean[] backward = new boolean[] { false, false, false, false, false, false, false,
+                false, false, false, false, false };
         getLineView();
         final int length = doc.getLength() + 1;
         for (int i = 0; i <= length; i++) {
-            assertEquals("Bias.Forward[" + i + "]", forward[i],
-                         view.flipEastAndWestAtEnds(i, Bias.Forward));
-            assertEquals("Bias.Backward[" + i + "]", backward[i],
-                         view.flipEastAndWestAtEnds(i, Bias.Backward));
+            assertEquals("Bias.Forward[" + i + "]", forward[i], view.flipEastAndWestAtEnds(i,
+                    Bias.Forward));
+            assertEquals("Bias.Backward[" + i + "]", backward[i], view.flipEastAndWestAtEnds(i,
+                    Bias.Backward));
         }
     }
 
@@ -66,21 +63,14 @@
      * resposible for.
      */
     public void testViewLayout() throws Exception {
-        int[] levels = new int[] {0, 1, 2, 1, 0};
-        Element bidiRoot = ((AbstractDocument)doc).getBidiRootElement();
+        int[] levels = new int[] { 0, 1, 2, 1, 0 };
+        Element bidiRoot = ((AbstractDocument) doc).getBidiRootElement();
         assertEquals(5, bidiRoot.getElementCount());
         for (int i = 0; i < levels.length; i++) {
             Element child = bidiRoot.getElement(i);
-            assertEquals(levels[i],
-                         StyleConstants.getBidiLevel(child.getAttributes()));
+            assertEquals(levels[i], StyleConstants.getBidiLevel(child.getAttributes()));
         }
-        int[] viewPos = new int[] {
-            0, 2,
-            6, 8,
-            4, 6,
-            2, 4,
-            8, 11
-        };
+        int[] viewPos = new int[] { 0, 2, 6, 8, 4, 6, 2, 4, 8, 11 };
         getLineView();
         assertEquals(5, view.getViewCount());
         for (int i = 0, posIndex = 0; i < levels.length; i++, posIndex += 2) {
@@ -90,6 +80,7 @@
         }
     }
 
+    @Override
     protected void setUp() throws Exception {
         super.setUp();
         frame = new JFrame("PlainViewI18N Layout Test");
@@ -98,12 +89,11 @@
         frame.getContentPane().add(area);
         frame.setSize(150, 100);
         frame.pack();
-
         doc = area.getDocument();
-
         rootView = area.getUI().getRootView(area).getView(0);
     }
 
+    @Override
     protected void tearDown() throws Exception {
         super.tearDown();
         frame.dispose();
@@ -111,10 +101,9 @@
 
     private void getLineView() {
         if (isHarmony()) {
-            view = (CompositeView)rootView.getView(0);
+            view = (CompositeView) rootView.getView(0);
         } else {
-            view = (CompositeView)rootView.getView(0).getView(0);
+            view = (CompositeView) rootView.getView(0).getView(0);
         }
     }
-
 }

Modified: harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/text/PlainViewI18N_LineViewTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/text/PlainViewI18N_LineViewTest.java?view=diff&rev=479418&r1=479417&r2=479418
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/text/PlainViewI18N_LineViewTest.java (original)
+++ harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/text/PlainViewI18N_LineViewTest.java Sun Nov 26 12:15:43 2006
@@ -14,7 +14,6 @@
  *  See the License for the specific language governing permissions and
  *  limitations under the License.
  */
-
 /**
  * @author Alexey A. Ivanov
  * @version $Revision$
@@ -24,7 +23,6 @@
 import java.awt.Container;
 import java.awt.FontMetrics;
 import java.awt.Rectangle;
-
 import javax.swing.JTextArea;
 import javax.swing.SwingTestCase;
 
@@ -52,28 +50,34 @@
     }
 
     public static final String LTR = "\u0061\u0062";
+
     public static final String RTL = "\u05DC\u05DD";
+
     public static final String newLine = "\n";
 
-    public static final String defText = LTR + newLine
-                                         + RTL + newLine
-                                         + LTR + RTL + newLine
-                                         + RTL + LTR + RTL;
+    public static final String defText = LTR + newLine + RTL + newLine + LTR + RTL + newLine
+            + RTL + LTR + RTL;
 
     public static final int LTRLength = LTR.length();
+
     public static final int RTLLength = RTL.length();
 
     private static final int HEIGHT = 200;
+
     private static final int WIDTH = 100;
 
     private static final int X_AXIS = View.X_AXIS;
+
     private static final int Y_AXIS = View.Y_AXIS;
 
     private Segment buffer;
+
     private PlainDocument doc;
+
     private PlainViewI18N parent;
 
     private Element root;
+
     private PlainViewI18N.LineView view;
 
     /**
@@ -83,26 +87,20 @@
         if (!isHarmony()) {
             return;
         }
-
         Element line = root.getElement(0);
         view = parent.new LineView(line);
         view.setParent(parent);
         parent.setSize(WIDTH, HEIGHT); // this will initialize metrics
-
         final FontMetrics metrics = getMetrics();
-        assertEquals(metrics.stringWidth(getViewText()),
-                     (int)view.getPreferredSpan(X_AXIS));
-        assertEquals(metrics.getHeight(), (int)view.getPreferredSpan(Y_AXIS));
-
+        assertEquals(metrics.stringWidth(getViewText()), (int) view.getPreferredSpan(X_AXIS));
+        assertEquals(metrics.getHeight(), (int) view.getPreferredSpan(Y_AXIS));
         // Insert tab character and recreate view
         doc.insertString(line.getStartOffset() + 1, "\t", null);
         view = parent.new LineView(line);
         view.setParent(parent);
-
-        assertEquals(Utilities.getTabbedTextWidth(getViewTextSegment(),
-                                                  metrics, 0, parent, 0),
-                     (int)view.getPreferredSpan(X_AXIS));
-        assertEquals(metrics.getHeight(), (int)view.getPreferredSpan(Y_AXIS));
+        assertEquals(Utilities.getTabbedTextWidth(getViewTextSegment(), metrics, 0, parent, 0),
+                (int) view.getPreferredSpan(X_AXIS));
+        assertEquals(metrics.getHeight(), (int) view.getPreferredSpan(Y_AXIS));
     }
 
     /**
@@ -112,39 +110,30 @@
         if (!isHarmony()) {
             return;
         }
-
         Element line = root.getElement(1);
         view = parent.new LineView(line);
         view.setParent(parent);
         parent.setSize(WIDTH, HEIGHT); // this will initialize metrics
-
         final FontMetrics metrics = getMetrics();
-        assertEquals(metrics.stringWidth(getViewText()),
-                     (int)view.getPreferredSpan(X_AXIS));
-        assertEquals(metrics.getHeight(), (int)view.getPreferredSpan(Y_AXIS));
-
+        assertEquals(metrics.stringWidth(getViewText()), (int) view.getPreferredSpan(X_AXIS));
+        assertEquals(metrics.getHeight(), (int) view.getPreferredSpan(Y_AXIS));
         // Insert tab character and recreate view
         doc.insertString(line.getStartOffset() + 1, "\t", null);
         view = parent.new LineView(line);
         view.setParent(parent);
         assertEquals(4, view.getViewCount());
-
-        assertEquals(Utilities.getTabbedTextWidth(getViewTextSegment(),
-                                                  metrics, 0, parent, 0),
-                     (int)view.getPreferredSpan(X_AXIS));
-        assertEquals(metrics.getHeight(), (int)view.getPreferredSpan(Y_AXIS));
+        assertEquals(Utilities.getTabbedTextWidth(getViewTextSegment(), metrics, 0, parent, 0),
+                (int) view.getPreferredSpan(X_AXIS));
+        assertEquals(metrics.getHeight(), (int) view.getPreferredSpan(Y_AXIS));
     }
 
     public void testGetResizeWeight() {
         if (!isHarmony()) {
             return;
         }
-
         parent.getPreferredSpan(X_AXIS); // Update metrics
-
         view = parent.new LineView(root.getElement(3));
         view.loadChildren(null);
-
         assertEquals(0, view.getResizeWeight(X_AXIS));
         assertEquals(0, view.getResizeWeight(Y_AXIS));
     }
@@ -158,11 +147,9 @@
         if (!isHarmony()) {
             return;
         }
-
         view = parent.new LineView(root.getElement(0));
         view.loadChildren(null);
         assertEquals(1, view.getViewCount());
-
         checkChild(view.getView(0), view.getStartOffset(), view.getEndOffset());
     }
 
@@ -173,11 +160,9 @@
         if (!isHarmony()) {
             return;
         }
-
         view = parent.new LineView(root.getElement(1));
         view.loadChildren(null);
         assertEquals(1, view.getViewCount());
-
         checkChild(view.getView(0), view.getStartOffset(), view.getEndOffset());
     }
 
@@ -188,11 +173,9 @@
         if (!isHarmony()) {
             return;
         }
-
         view = parent.new LineView(root.getElement(2));
         view.loadChildren(null);
         assertEquals(3, view.getViewCount());
-
         int offset = view.getStartOffset();
         checkChild(view.getView(0), offset, offset + LTRLength);
         offset += LTRLength;
@@ -208,11 +191,9 @@
         if (!isHarmony()) {
             return;
         }
-
         view = parent.new LineView(root.getElement(3));
         view.loadChildren(null);
         assertEquals(3, view.getViewCount());
-
         int offset = view.getStartOffset();
         checkChild(view.getView(0), offset, offset + RTLLength);
         offset += RTLLength;
@@ -226,22 +207,18 @@
         if (!isHarmony()) {
             return;
         }
-
         view = parent.new LineView(root.getElement(0));
         view.loadChildren(null);
         assertEquals(1, view.getViewCount());
-
         assertFalse(view.isAfter(31, 10, new Rectangle(30, 5, 5, 10)));
     }
 
     @Override
     protected void setUp() throws Exception {
         super.setUp();
-
         if (!isHarmony()) {
             return;
         }
-
         doc = new PlainDocument();
         doc.insertString(0, defText, null);
         root = doc.getDefaultRootElement();
@@ -250,12 +227,10 @@
     }
 
     private void checkChild(View child, int start, int end) {
-        assertSame("Element of a child must equal to one of parent",
-                   view.getElement(), child.getElement());
-        assertEquals("Start offsets are different",
-                     start, child.getStartOffset());
-        assertEquals("End offsets are different",
-                     end, child.getEndOffset());
+        assertSame("Element of a child must equal to one of parent", view.getElement(), child
+                .getElement());
+        assertEquals("Start offsets are different", start, child.getStartOffset());
+        assertEquals("End offsets are different", end, child.getEndOffset());
     }
 
     private FontMetrics getMetrics() {
@@ -269,9 +244,8 @@
 
     private Segment getViewTextSegment() throws BadLocationException {
         final int start = view.getStartOffset();
-        final int end   = view.getEndOffset();
+        final int end = view.getEndOffset();
         doc.getText(start, end - start - 1, buffer);
         return buffer;
     }
-
 }

Modified: harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/text/PlainViewI18N_LineView_UpdateTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/text/PlainViewI18N_LineView_UpdateTest.java?view=diff&rev=479418&r1=479417&r2=479418
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/text/PlainViewI18N_LineView_UpdateTest.java (original)
+++ harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/text/PlainViewI18N_LineView_UpdateTest.java Sun Nov 26 12:15:43 2006
@@ -14,7 +14,6 @@
  *  See the License for the specific language governing permissions and
  *  limitations under the License.
  */
-
 /**
  * @author Alexey A. Ivanov
  * @version $Revision$
@@ -22,7 +21,6 @@
 package javax.swing.text;
 
 import java.awt.Rectangle;
-
 import javax.swing.SwingTestCase;
 import javax.swing.event.DocumentEvent;
 import javax.swing.event.DocumentListener;
@@ -34,33 +32,36 @@
  * Tests PlainViewI18N.LineView class, in particular how it reacts to changes
  * in a document.
  */
-public class PlainViewI18N_LineView_UpdateTest extends SwingTestCase
-    implements DocumentListener {
-
+public class PlainViewI18N_LineView_UpdateTest extends SwingTestCase implements
+        DocumentListener {
     private PlainDocument doc;
+
     private Element root;
+
     private Element bidi;
 
     private PlainViewI18N parent;
+
     private PlainViewI18N.LineView view;
 
     private PreferenceChange preferenceParams;
 
     private DocumentEvent insertEvent;
+
     private DocumentEvent removeEvent;
 
     private Element line;
+
     private int startOffset;
 
     private final Rectangle shape = new Rectangle(27, 74, 91, 41);
 
+    @Override
     protected void setUp() throws Exception {
         super.setUp();
-
         if (!isHarmony()) {
             return;
         }
-
         doc = new PlainDocument();
         doc.insertString(0, PlainViewI18N_LineViewTest.defText, null);
         root = doc.getDefaultRootElement();
@@ -68,14 +69,13 @@
         parent = new PlainViewI18NWithTextArea(root, doc);
         line = root.getElement(3);
         startOffset = line.getStartOffset();
-
         view = parent.new LineView(line) {
+            @Override
             public void preferenceChanged(View child, boolean w, boolean h) {
                 preferenceParams = new PreferenceChange(child, w, h);
             }
         };
         view.setParent(parent);
-
         doc.addDocumentListener(this);
     }
 
@@ -83,10 +83,8 @@
         if (!isHarmony()) {
             return;
         }
-
         doc.insertString(startOffset + PlainViewI18N_LineViewTest.RTLLength + 1,
-                         PlainViewI18N_LineViewTest.LTR, null);
-
+                PlainViewI18N_LineViewTest.LTR, null);
         view.insertUpdate(insertEvent, shape, null);
         assertNull(insertEvent.getChange(bidi));
         preferenceParams.check(view.getView(1), true, false);
@@ -96,9 +94,7 @@
         if (!isHarmony()) {
             return;
         }
-
         doc.insertString(startOffset + 1, PlainViewI18N_LineViewTest.RTL, null);
-
         view.insertUpdate(insertEvent, shape, null);
         assertNull(insertEvent.getChange(bidi));
         preferenceParams.check(view.getView(0), true, false);
@@ -108,17 +104,12 @@
         if (!isHarmony()) {
             return;
         }
-
-        doc.insertString(startOffset + 1,
-                         PlainViewI18N_LineViewTest.LTR, null);
-
+        doc.insertString(startOffset + 1, PlainViewI18N_LineViewTest.LTR, null);
         view.insertUpdate(insertEvent, shape, null);
-
         ElementChange change = insertEvent.getChange(bidi);
         assertNotNull(change);
         assertEquals(3, change.getChildrenRemoved().length);
         assertEquals(6, change.getChildrenAdded().length);
-
         assertEquals(6, view.getViewCount());
     }
 
@@ -126,17 +117,13 @@
         if (!isHarmony()) {
             return;
         }
-
         doc.insertString(startOffset + PlainViewI18N_LineViewTest.RTLLength + 1,
-                         PlainViewI18N_LineViewTest.RTL, null);
-
+                PlainViewI18N_LineViewTest.RTL, null);
         view.insertUpdate(insertEvent, shape, null);
-
         ElementChange change = insertEvent.getChange(bidi);
         assertNotNull(change);
         assertEquals(3, change.getChildrenRemoved().length);
         assertEquals(6, change.getChildrenAdded().length);
-
         assertEquals(6, view.getViewCount());
     }
 
@@ -144,37 +131,32 @@
     // tho' it needn't have been modified. If document is optimized to
     // handle this situation, these tests may become actual.
     /*
-    public void testRemoveUpdateLTRNoChange() throws Exception {
-        doc.remove(startOffset + PlainViewI18N_LineViewTest.RTLLength + 1, 1);
-
-        view.removeUpdate(removeEvent, shape, null);
-        assertNull(removeEvent.getChange(bidi));
-        preferenceParams.check(view.getView(1), true, false);
-    }
-
-    public void testRemoveUpdateRTLNoChange() throws Exception {
-        doc.remove(startOffset + 1, 1);
-
-        view.removeUpdate(removeEvent, shape, null);
-        assertNull(removeEvent.getChange(bidi));
-        preferenceParams.check(view.getView(0), true, false);
-    }
-    */
+     public void testRemoveUpdateLTRNoChange() throws Exception {
+     doc.remove(startOffset + PlainViewI18N_LineViewTest.RTLLength + 1, 1);
 
+     view.removeUpdate(removeEvent, shape, null);
+     assertNull(removeEvent.getChange(bidi));
+     preferenceParams.check(view.getView(1), true, false);
+     }
+
+     public void testRemoveUpdateRTLNoChange() throws Exception {
+     doc.remove(startOffset + 1, 1);
+
+     view.removeUpdate(removeEvent, shape, null);
+     assertNull(removeEvent.getChange(bidi));
+     preferenceParams.check(view.getView(0), true, false);
+     }
+     */
     public void testRemoveUpdateWithChange() throws Exception {
         if (!isHarmony()) {
             return;
         }
-
         doc.remove(startOffset + 1, 2);
-
         view.removeUpdate(removeEvent, shape, null);
-
         ElementChange change = removeEvent.getChange(bidi);
         assertNotNull(change);
         assertEquals(3, change.getChildrenRemoved().length);
         assertEquals(4, change.getChildrenAdded().length);
-
         assertEquals(4, view.getViewCount());
     }
 

Modified: harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/text/PlainViewI18N_ModelViewTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/text/PlainViewI18N_ModelViewTest.java?view=diff&rev=479418&r1=479417&r2=479418
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/text/PlainViewI18N_ModelViewTest.java (original)
+++ harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/text/PlainViewI18N_ModelViewTest.java Sun Nov 26 12:15:43 2006
@@ -14,7 +14,6 @@
  *  See the License for the specific language governing permissions and
  *  limitations under the License.
  */
-
 /**
  * @author Alexey A. Ivanov
  * @version $Revision$
@@ -23,7 +22,6 @@
 
 import java.awt.FontMetrics;
 import java.awt.Rectangle;
-
 import javax.swing.BasicSwingTestCase;
 import javax.swing.JFrame;
 import javax.swing.JTextArea;
@@ -38,15 +36,23 @@
  *
  */
 public class PlainViewI18N_ModelViewTest extends SwingTestCase {
-    private Document    doc;
-    private View        view;
-    private Rectangle   shape;
-    private JFrame      frame;
-    private JTextArea   area;
-    private Bias[]      bias;
+    private Document doc;
+
+    private View view;
+
+    private Rectangle shape;
+
+    private JFrame frame;
+
+    private JTextArea area;
+
+    private Bias[] bias;
+
     private FontMetrics metrics;
-    private int         rtlWidth;
 
+    private int rtlWidth;
+
+    @Override
     protected void setUp() throws Exception {
         super.setUp();
         frame = new JFrame("PlainViewI18N Model/View Test");
@@ -55,16 +61,15 @@
         frame.getContentPane().add(area);
         frame.setSize(150, 100);
         frame.pack();
-
-        doc   = area.getDocument();
-        view  = area.getUI().getRootView(area).getView(0);
+        doc = area.getDocument();
+        view = area.getUI().getRootView(area).getView(0);
         shape = area.getVisibleRect();
-        bias  = new Bias[1];
-
+        bias = new Bias[1];
         metrics = area.getFontMetrics(area.getFont());
         rtlWidth = metrics.stringWidth(doc.getText(0, 2));
     }
 
+    @Override
     protected void tearDown() throws Exception {
         super.tearDown();
         frame.dispose();
@@ -78,16 +83,14 @@
         if (!isHarmony()) {
             return;
         }
-
         assertEquals(2, view.getNextVisualPositionFrom(0, Bias.Forward, shape,
-                                                       SwingConstants.EAST,
-                                                       bias));
-        assertSame(Bias.Forward, bias[0]);             bias[0] = null;
-
+                SwingConstants.EAST, bias));
+        assertSame(Bias.Forward, bias[0]);
+        bias[0] = null;
         assertEquals(2, view.getNextVisualPositionFrom(0, Bias.Backward, shape,
-                                                       SwingConstants.EAST,
-                                                       bias));
-        assertSame(Bias.Backward, bias[0]);            bias[0] = null;
+                SwingConstants.EAST, bias));
+        assertSame(Bias.Backward, bias[0]);
+        bias[0] = null;
     }
 
     /**
@@ -96,14 +99,13 @@
      */
     public void testGetNextVisualPositionEast02() throws BadLocationException {
         assertEquals(0, view.getNextVisualPositionFrom(1, Bias.Forward, shape,
-                                                       SwingConstants.EAST,
-                                                       bias));
-        assertSame(Bias.Forward, bias[0]);             bias[0] = null;
-
+                SwingConstants.EAST, bias));
+        assertSame(Bias.Forward, bias[0]);
+        bias[0] = null;
         assertEquals(0, view.getNextVisualPositionFrom(1, Bias.Backward, shape,
-                                                       SwingConstants.EAST,
-                                                       bias));
-        assertSame(Bias.Forward, bias[0]);             bias[0] = null;
+                SwingConstants.EAST, bias));
+        assertSame(Bias.Forward, bias[0]);
+        bias[0] = null;
     }
 
     /**
@@ -114,16 +116,14 @@
         if (!isHarmony()) {
             return;
         }
-
         assertEquals(3, view.getNextVisualPositionFrom(2, Bias.Forward, shape,
-                                                       SwingConstants.EAST,
-                                                       bias));
-        assertSame(Bias.Backward, bias[0]);            bias[0] = null;
-
+                SwingConstants.EAST, bias));
+        assertSame(Bias.Backward, bias[0]);
+        bias[0] = null;
         assertEquals(1, view.getNextVisualPositionFrom(2, Bias.Backward, shape,
-                                                       SwingConstants.EAST,
-                                                       bias));
-        assertSame(Bias.Forward, bias[0]);             bias[0] = null;
+                SwingConstants.EAST, bias));
+        assertSame(Bias.Forward, bias[0]);
+        bias[0] = null;
     }
 
     /**
@@ -132,14 +132,13 @@
      */
     public void testGetNextVisualPositionEast04() throws BadLocationException {
         assertEquals(6, view.getNextVisualPositionFrom(3, Bias.Forward, shape,
-                                                       SwingConstants.EAST,
-                                                       bias));
-        assertSame(Bias.Forward, bias[0]);             bias[0] = null;
-
+                SwingConstants.EAST, bias));
+        assertSame(Bias.Forward, bias[0]);
+        bias[0] = null;
         assertEquals(6, view.getNextVisualPositionFrom(3, Bias.Backward, shape,
-                                                       SwingConstants.EAST,
-                                                       bias));
-        assertSame(Bias.Backward, bias[0]);            bias[0] = null;
+                SwingConstants.EAST, bias));
+        assertSame(Bias.Backward, bias[0]);
+        bias[0] = null;
     }
 
     /**
@@ -150,16 +149,14 @@
         if (!isHarmony()) {
             return;
         }
-
         assertEquals(1, view.getNextVisualPositionFrom(0, Bias.Forward, shape,
-                                                       SwingConstants.WEST,
-                                                       bias));
-        assertSame(Bias.Forward, bias[0]);             bias[0] = null;
-
+                SwingConstants.WEST, bias));
+        assertSame(Bias.Forward, bias[0]);
+        bias[0] = null;
         assertEquals(-1, view.getNextVisualPositionFrom(0, Bias.Backward, shape,
-                                                       SwingConstants.WEST,
-                                                       bias));
-        assertSame(Bias.Forward, bias[0]);         bias[0] = null;
+                SwingConstants.WEST, bias));
+        assertSame(Bias.Forward, bias[0]);
+        bias[0] = null;
     }
 
     /**
@@ -170,16 +167,14 @@
         if (!isHarmony()) {
             return;
         }
-
         assertEquals(2, view.getNextVisualPositionFrom(1, Bias.Forward, shape,
-                                                       SwingConstants.WEST,
-                                                       bias));
-        assertSame(Bias.Backward, bias[0]);            bias[0] = null;
-
+                SwingConstants.WEST, bias));
+        assertSame(Bias.Backward, bias[0]);
+        bias[0] = null;
         assertEquals(2, view.getNextVisualPositionFrom(1, Bias.Backward, shape,
-                                                       SwingConstants.WEST,
-                                                       bias));
-        assertSame(Bias.Forward, bias[0]);             bias[0] = null;
+                SwingConstants.WEST, bias));
+        assertSame(Bias.Forward, bias[0]);
+        bias[0] = null;
     }
 
     /**
@@ -190,16 +185,14 @@
         if (!isHarmony()) {
             return;
         }
-
         assertEquals(0, view.getNextVisualPositionFrom(2, Bias.Forward, shape,
-                                                       SwingConstants.WEST,
-                                                       bias));
-        assertSame(Bias.Forward, bias[0]);             bias[0] = null;
-
+                SwingConstants.WEST, bias));
+        assertSame(Bias.Forward, bias[0]);
+        bias[0] = null;
         assertEquals(0, view.getNextVisualPositionFrom(2, Bias.Backward, shape,
-                                                       SwingConstants.WEST,
-                                                       bias));
-        assertSame(Bias.Forward, bias[0]);         bias[0] = null;
+                SwingConstants.WEST, bias));
+        assertSame(Bias.Forward, bias[0]);
+        bias[0] = null;
     }
 
     /**
@@ -208,19 +201,16 @@
      */
     public void testGetNextVisualPositionWest04() throws BadLocationException {
         assertEquals(4, view.getNextVisualPositionFrom(3, Bias.Forward, shape,
-                                                       SwingConstants.WEST,
-                                                       bias));
-        assertSame(Bias.Forward, bias[0]);             bias[0] = null;
-
+                SwingConstants.WEST, bias));
+        assertSame(Bias.Forward, bias[0]);
+        bias[0] = null;
         assertEquals(2, view.getNextVisualPositionFrom(3, Bias.Backward, shape,
-                                                       SwingConstants.WEST,
-                                                       bias));
-        assertSame(Bias.Forward, bias[0]);             bias[0] = null;
+                SwingConstants.WEST, bias));
+        assertSame(Bias.Forward, bias[0]);
+        bias[0] = null;
     }
 
-    private static void assertRectEquals(Rectangle rc,
-                                   int x, int y,
-                                   int width, int height) {
+    private static void assertRectEquals(Rectangle rc, int x, int y, int width, int height) {
         assertEquals("Unexpected X", x, rc.x);
         assertEquals("Unexpected Y", y, rc.y);
         assertEquals("Unexpected width", width, rc.width);
@@ -235,44 +225,36 @@
      * <p>The offsets used are 0, 2.
      */
     public void testModelToView01() throws Exception {
-        Rectangle viewAt0F = (Rectangle)view.modelToView(0, shape,
-                                                         Bias.Forward);
-        Rectangle viewAt2B = (Rectangle)view.modelToView(2, shape,
-                                                         Bias.Forward);
+        Rectangle viewAt0F = (Rectangle) view.modelToView(0, shape, Bias.Forward);
+        Rectangle viewAt2B = (Rectangle) view.modelToView(2, shape, Bias.Forward);
         assertEquals(viewAt0F.x, viewAt2B.x);
-
         final int beforeTabWidth = metrics.stringWidth(doc.getText(0, 2));
-        assertRectEquals(viewAt0F,
-                         beforeTabWidth, 0, 1, metrics.getHeight());
-        assertRectEquals((Rectangle)view.modelToView(0, shape, Bias.Backward),
-                         BasicSwingTestCase.isHarmony() ? beforeTabWidth : 0,
-                         0, 1, metrics.getHeight());
-
+        assertRectEquals(viewAt0F, beforeTabWidth, 0, 1, metrics.getHeight());
+        assertRectEquals((Rectangle) view.modelToView(0, shape, Bias.Backward),
+                BasicSwingTestCase.isHarmony() ? beforeTabWidth : 0, 0, 1, metrics.getHeight());
     }
 
     public void testModelToView02() throws Exception {
-        Rectangle viewAt1F = (Rectangle)view.modelToView(1, shape,
-                                                         Bias.Forward);
-        Rectangle viewAt1B = (Rectangle)view.modelToView(1, shape,
-                                                         Bias.Backward);
+        Rectangle viewAt1F = (Rectangle) view.modelToView(1, shape, Bias.Forward);
+        Rectangle viewAt1B = (Rectangle) view.modelToView(1, shape, Bias.Backward);
         assertEquals(viewAt1F, viewAt1B);
-
-        assertRectEquals(viewAt1F,
-                         metrics.stringWidth(doc.getText(1, 1)), 0, 1,
-                         metrics.getHeight());
+        assertRectEquals(viewAt1F, metrics.stringWidth(doc.getText(1, 1)), 0, 1, metrics
+                .getHeight());
     }
 
     public void testViewToModel() throws Exception {
         assertEquals(2, view.viewToModel(rtlWidth, 0, shape, bias));
-        assertSame(Bias.Forward, bias[0]);      bias[0] = null;
+        assertSame(Bias.Forward, bias[0]);
+        bias[0] = null;
         assertEquals(2, view.viewToModel(0, 0, shape, bias));
-        assertSame(Bias.Backward, bias[0]);      bias[0] = null;
-
+        assertSame(Bias.Backward, bias[0]);
+        bias[0] = null;
         assertEquals(0, view.viewToModel(rtlWidth - 1, 0, shape, bias));
-        assertSame(Bias.Forward, bias[0]);      bias[0] = null;
-
+        assertSame(Bias.Forward, bias[0]);
+        bias[0] = null;
         assertEquals(2, view.viewToModel(rtlWidth + 1, 0, shape, bias));
-        assertSame(Bias.Forward, bias[0]);      bias[0] = null;
+        assertSame(Bias.Forward, bias[0]);
+        bias[0] = null;
     }
 
     public void testViewToModelRTL() throws Exception {
@@ -284,14 +266,15 @@
         }
         assertEquals(0, rtl.getStartOffset());
         assertEquals(2, rtl.getEndOffset());
-
         assertEquals(2, rtl.viewToModel(0, 0, shape, bias));
-        assertSame(Bias.Backward, bias[0]);      bias[0] = null;
+        assertSame(Bias.Backward, bias[0]);
+        bias[0] = null;
         assertEquals(2, rtl.viewToModel(rtlWidth, 0, shape, bias));
-        assertSame(Bias.Forward, bias[0]);      bias[0] = null;
-
+        assertSame(Bias.Forward, bias[0]);
+        bias[0] = null;
         assertEquals(2, rtl.viewToModel(rtlWidth + 1, 0, shape, bias));
-        assertSame(Bias.Forward, bias[0]);      bias[0] = null;
+        assertSame(Bias.Forward, bias[0]);
+        bias[0] = null;
     }
 
     public void testViewToModelLTR() throws Exception {
@@ -303,22 +286,20 @@
         }
         assertEquals(2, ltr.getStartOffset());
         assertEquals(3, ltr.getEndOffset());
-
         assertEquals(2, ltr.viewToModel(rtlWidth, 0, shape, bias));
-        assertSame(Bias.Forward, bias[0]);      bias[0] = null;
-
+        assertSame(Bias.Forward, bias[0]);
+        bias[0] = null;
         assertEquals(2, ltr.viewToModel(rtlWidth - 1, 0, shape, bias));
-        assertSame(Bias.Forward, bias[0]);      bias[0] = null;
-
+        assertSame(Bias.Forward, bias[0]);
+        bias[0] = null;
         assertEquals(2, ltr.viewToModel(rtlWidth + 1, 0, shape, bias));
-        assertSame(Bias.Forward, bias[0]);      bias[0] = null;
-
-        Object tabProperty =
-            view.getDocument().getProperty(PlainDocument.tabSizeAttribute);
-        int tab = metrics.charWidth('m') * ((Integer)tabProperty).intValue();
-
-        assertEquals(BasicSwingTestCase.isHarmony() ? 3 : 2,
-                     ltr.viewToModel(tab, 0, shape, bias));
-        assertSame(Bias.Forward, bias[0]);      bias[0] = null;
+        assertSame(Bias.Forward, bias[0]);
+        bias[0] = null;
+        Object tabProperty = view.getDocument().getProperty(PlainDocument.tabSizeAttribute);
+        int tab = metrics.charWidth('m') * ((Integer) tabProperty).intValue();
+        assertEquals(BasicSwingTestCase.isHarmony() ? 3 : 2, ltr.viewToModel(tab, 0, shape,
+                bias));
+        assertSame(Bias.Forward, bias[0]);
+        bias[0] = null;
     }
 }

Modified: harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/text/PlainViewI18N_VisualPositionTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/text/PlainViewI18N_VisualPositionTest.java?view=diff&rev=479418&r1=479417&r2=479418
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/text/PlainViewI18N_VisualPositionTest.java (original)
+++ harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/text/PlainViewI18N_VisualPositionTest.java Sun Nov 26 12:15:43 2006
@@ -14,7 +14,6 @@
  *  See the License for the specific language governing permissions and
  *  limitations under the License.
  */
-
 /**
  * @author Alexey A. Ivanov
  * @version $Revision$
@@ -22,7 +21,6 @@
 package javax.swing.text;
 
 import java.awt.Rectangle;
-
 import javax.swing.JFrame;
 import javax.swing.JTextArea;
 import javax.swing.SwingConstants;
@@ -35,145 +33,123 @@
  *
  */
 public class PlainViewI18N_VisualPositionTest extends SwingTestCase {
-    private Document    doc;
-    private View        view;
-    private Rectangle   shape;
-    private JFrame      frame;
-    private JTextArea   area;
-    private Bias[]      bias;
-    private int         length;
+    private Document doc;
+
+    private View view;
+
+    private Rectangle shape;
+
+    private JFrame frame;
+
+    private JTextArea area;
+
+    private Bias[] bias;
+
+    private int length;
 
     private static final Bias FW = Bias.Forward;
+
     private static final Bias BW = Bias.Backward;
 
-    private int[] nextPositionEF =
-        {1,   2,  3,  4,  5,  7,  7,  8,  9, 10,
-         11, 14, 14, 12, 15, 18, 15, 16, 19, 20,
-         21, 22, 22};
+    private int[] nextPositionEF = { 1, 2, 3, 4, 5, 7, 7, 8, 9, 10, 11, 14, 14, 12, 15, 18, 15,
+            16, 19, 20, 21, 22, 22 };
+
     //    0   1   2   3   4   5   6   7   8   9
-    private int[] nextPositionEB =
-        {-1,  2,  1,  4,  3,  6,  7,  6,  9, 10,
-         11, 10, 14, 12, 13, 18, 15, 16, 17, 20,
-         21, 22, 22};
-    private int[] nextPositionWF =
-        {0,   2,  1,  4,  3,  4,  7,  6,  7,  8,
-         11, 10, 13, 14, 12, 16, 17, 18, 15, 18,
-         19, 20, 21};
+    private int[] nextPositionEB = { -1, 2, 1, 4, 3, 6, 7, 6, 9, 10, 11, 10, 14, 12, 13, 18,
+            15, 16, 17, 20, 21, 22, 22 };
+
+    private int[] nextPositionWF = { 0, 2, 1, 4, 3, 4, 7, 6, 7, 8, 11, 10, 13, 14, 12, 16, 17,
+            18, 15, 18, 19, 20, 21 };
+
     //    0   1   2   3   4   5   6   7   8   9
-    private int[] nextPositionWB =
-        {0,   0,  1,  2,  3,  4,  5,  5,  7,  8,
-          9, 10, 11, 14, 11, 14, 17, 18, 15, 18,
-         19, 20, 21};
-    private Bias[] nextBiasEF =
-        {BW, FW, BW, FW, FW, BW, FW, FW, FW, BW,
-         FW, BW, FW, FW, BW, FW, FW, FW, FW, FW,
-         FW, FW, FW};
+    private int[] nextPositionWB = { 0, 0, 1, 2, 3, 4, 5, 5, 7, 8, 9, 10, 11, 14, 11, 14, 17,
+            18, 15, 18, 19, 20, 21 };
+
+    private Bias[] nextBiasEF = { BW, FW, BW, FW, FW, BW, FW, FW, FW, BW, FW, BW, FW, FW, BW,
+            FW, FW, FW, FW, FW, FW, FW, FW };
+
     //    0   1   2   3   4   5   6   7   8   9
-    private Bias[] nextBiasEB =
-        {FW, BW, FW, BW, FW, FW, BW, FW, FW, FW,
-         BW, FW, BW, FW, FW, BW, FW, FW, FW, FW,
-         FW, FW, FW};
-    private Bias[] nextBiasWF =
-        {FW, BW, FW, BW, FW, FW, BW, FW, FW, FW,
-         BW, FW, FW, BW, FW, FW, FW, BW, FW, FW,
-         FW, FW, FW};
+    private Bias[] nextBiasEB = { FW, BW, FW, BW, FW, FW, BW, FW, FW, FW, BW, FW, BW, FW, FW,
+            BW, FW, FW, FW, FW, FW, FW, FW };
+
+    private Bias[] nextBiasWF = { FW, BW, FW, BW, FW, FW, BW, FW, FW, FW, BW, FW, FW, BW, FW,
+            FW, FW, BW, FW, FW, FW, FW, FW };
+
     //    0   1   2   3   4   5   6   7   8   9
-    private Bias[] nextBiasWB =
-        {FW, FW, BW, FW, BW, FW, FW, FW, FW, FW,
-         FW, BW, FW, FW, FW, FW, FW, FW, BW, FW,
-         FW, FW, FW};
+    private Bias[] nextBiasWB = { FW, FW, BW, FW, BW, FW, FW, FW, FW, FW, FW, BW, FW, FW, FW,
+            FW, FW, FW, BW, FW, FW, FW, FW };
 
+    @Override
     protected void setUp() throws Exception {
         super.setUp();
         frame = new JFrame("PlainViewI18N Visual Position Test");
         area = new JTextArea("a\u05DCb\u05DDc\n" +
         //                    01     23     45
-                             "\u05DE123\u05DF\n" +
-        //                    6     7890     1
-                             "\u05DC\u05DD\t\u05DE\u05DF\u05E0abcd");
+                "\u05DE123\u05DF\n" +
+                //                    6     7890     1
+                "\u05DC\u05DD\t\u05DE\u05DF\u05E0abcd");
         //                    2     3     4 5     6     7     8901
         frame.getContentPane().add(area);
         frame.setSize(150, 100);
         frame.pack();
-
-        doc    = area.getDocument();
+        doc = area.getDocument();
         length = doc.getLength();
-        view   = area.getUI().getRootView(area).getView(0);
-        shape  = area.getVisibleRect();
-        bias   = new Bias[1];
+        view = area.getUI().getRootView(area).getView(0);
+        shape = area.getVisibleRect();
+        bias = new Bias[1];
     }
 
+    @Override
     protected void tearDown() throws Exception {
         frame.dispose();
         super.tearDown();
     }
 
-    public void testGetNextVisualPositionEastForward()
-        throws BadLocationException {
-
+    public void testGetNextVisualPositionEastForward() throws BadLocationException {
         if (!isHarmony()) {
             return;
         }
-
         for (int i = 0; i <= length; i++) {
-            int next = view.getNextVisualPositionFrom(i, FW, shape,
-                                                      SwingConstants.EAST,
-                                                      bias);
+            int next = view.getNextVisualPositionFrom(i, FW, shape, SwingConstants.EAST, bias);
             assertEquals("@ " + i, nextPositionEF[i], next);
             assertSame("@ " + i, nextBiasEF[i], bias[0]);
             bias[0] = null;
         }
     }
 
-    public void testGetNextVisualPositionEastBackward()
-        throws BadLocationException {
-
+    public void testGetNextVisualPositionEastBackward() throws BadLocationException {
         if (!isHarmony()) {
             return;
         }
-
         for (int i = 0; i <= length; i++) {
-            int next = view.getNextVisualPositionFrom(i, BW, shape,
-                                                      SwingConstants.EAST,
-                                                      bias);
+            int next = view.getNextVisualPositionFrom(i, BW, shape, SwingConstants.EAST, bias);
             assertEquals("@ " + i, nextPositionEB[i], next);
             assertSame("@ " + i, nextBiasEB[i], bias[0]);
             bias[0] = null;
         }
     }
 
-    public void testGetNextVisualPositionWestForward()
-        throws BadLocationException {
-
+    public void testGetNextVisualPositionWestForward() throws BadLocationException {
         if (!isHarmony()) {
             return;
         }
-
         for (int i = 0; i <= length; i++) {
-            int next = view.getNextVisualPositionFrom(i, FW, shape,
-                                                      SwingConstants.WEST,
-                                                      bias);
+            int next = view.getNextVisualPositionFrom(i, FW, shape, SwingConstants.WEST, bias);
             assertEquals("@ " + i, nextPositionWF[i], next);
-            assertSame("@ " + i,   nextBiasWF[i], bias[0]);
+            assertSame("@ " + i, nextBiasWF[i], bias[0]);
             bias[0] = null;
         }
     }
 
-    public void testGetNextVisualPositionWestBackward()
-        throws BadLocationException {
-
+    public void testGetNextVisualPositionWestBackward() throws BadLocationException {
         if (!isHarmony()) {
             return;
         }
-
         for (int i = 0; i <= length; i++) {
-            int next = view.getNextVisualPositionFrom(i, BW, shape,
-                                                      SwingConstants.WEST,
-                                                      bias);
+            int next = view.getNextVisualPositionFrom(i, BW, shape, SwingConstants.WEST, bias);
             assertEquals("@ " + i, nextPositionWB[i], next);
-            assertSame("@ " + i,   nextBiasWB[i], bias[0]);
+            assertSame("@ " + i, nextBiasWB[i], bias[0]);
             bias[0] = null;
         }
     }
-
 }

Modified: harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/text/PlainViewTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/text/PlainViewTest.java?view=diff&rev=479418&r1=479417&r2=479418
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/text/PlainViewTest.java (original)
+++ harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/text/PlainViewTest.java Sun Nov 26 12:15:43 2006
@@ -14,7 +14,6 @@
  *  See the License for the specific language governing permissions and
  *  limitations under the License.
  */
-
 /**
  * @author Alexey A. Ivanov
  * @version $Revision$
@@ -25,7 +24,6 @@
 import java.awt.Graphics;
 import java.awt.Rectangle;
 import java.awt.Shape;
-
 import javax.swing.JFrame;
 import javax.swing.JTextArea;
 import javax.swing.SwingTestCase;
@@ -39,80 +37,71 @@
  */
 public class PlainViewTest extends SwingTestCase {
     private JTextArea area;
-    private Document  doc;
-    private JFrame    frame;
-    private Shape     shape;
+
+    private Document doc;
+
+    private JFrame frame;
+
+    private Shape shape;
+
     private PlainView view;
 
     public void testDrawSelectedText() throws BadLocationException {
         area.setText("line1\nline2");
-        Graphics    g = view.getGraphics();
+        Graphics g = view.getGraphics();
         FontMetrics m = view.metrics;
         g.setFont(m.getFont());
         assertEquals(m.charWidth('l'), view.drawSelectedText(g, 0, 0, 0, 1));
-        assertEquals(m.stringWidth("line1"),
-                     view.drawSelectedText(g, 0, 0, 0, 5));
-        assertEquals(m.stringWidth("line1\nli"),
-                     view.drawSelectedText(g, 0, 0, 0, 8));
-
+        assertEquals(m.stringWidth("line1"), view.drawSelectedText(g, 0, 0, 0, 5));
+        assertEquals(m.stringWidth("line1\nli"), view.drawSelectedText(g, 0, 0, 0, 8));
         try {
             view.drawSelectedText(g, 0, 0, -1, 1);
-
             fail("BadLocationException expected");
-        } catch (BadLocationException e) { }
-
+        } catch (BadLocationException e) {
+        }
         try {
             view.drawUnselectedText(g, 0, 0, 13, 13);
-
             fail("BadLocationException expected");
-        } catch (BadLocationException e) { }
-
+        } catch (BadLocationException e) {
+        }
         try {
             view.drawSelectedText(g, 0, 0, 10, 2);
-
             fail("BadLocationException expected");
-        } catch (BadLocationException e) { }
+        } catch (BadLocationException e) {
+        }
     }
 
     public void testDrawUnselectedText() throws BadLocationException {
         area.setText("line1\nline2");
-        Graphics    g = view.getGraphics();
+        Graphics g = view.getGraphics();
         FontMetrics m = view.metrics;
         g.setFont(m.getFont());
         assertEquals(m.charWidth('l'), view.drawUnselectedText(g, 0, 0, 0, 1));
-        assertEquals(5 + m.charWidth('l'),
-                     view.drawUnselectedText(g, 5, 0, 0, 1));
-        assertEquals(m.stringWidth("line1"),
-                     view.drawUnselectedText(g, 0, 0, 0, 5));
-        assertEquals(m.stringWidth("line1\nli"),
-                     view.drawUnselectedText(g, 0, 0, 0, 8));
-
+        assertEquals(5 + m.charWidth('l'), view.drawUnselectedText(g, 5, 0, 0, 1));
+        assertEquals(m.stringWidth("line1"), view.drawUnselectedText(g, 0, 0, 0, 5));
+        assertEquals(m.stringWidth("line1\nli"), view.drawUnselectedText(g, 0, 0, 0, 8));
         try {
             view.drawUnselectedText(g, 0, 0, -1, 1);
-
             fail("BadLocationException expected");
-        } catch (BadLocationException e) { }
-
+        } catch (BadLocationException e) {
+        }
         try {
             view.drawUnselectedText(g, 0, 0, 13, 13);
-
             fail("BadLocationException expected");
-        } catch (BadLocationException e) { }
-
+        } catch (BadLocationException e) {
+        }
         try {
             view.drawUnselectedText(g, 0, 0, 10, 2);
-
             fail("BadLocationException expected");
-        } catch (BadLocationException e) { }
+        } catch (BadLocationException e) {
+        }
     }
 
     public void testGetPreferredSpan() {
         area.setText("1: 0\n2: 012345\n3:\n");
         assertEquals(view.metrics.stringWidth("2: 012345"), // longest line
                 view.getPreferredSpan(View.X_AXIS), 0.00001f);
-        assertEquals(view.metrics.getHeight() * 4,
-                view.getPreferredSpan(View.Y_AXIS), 0.00001f);
-
+        assertEquals(view.metrics.getHeight() * 4, view.getPreferredSpan(View.Y_AXIS), 0.00001f);
         area.setText("\ttext\t1");
         float length = view.nextTabStop(0, 0);
         length += view.metrics.stringWidth("text");
@@ -127,68 +116,47 @@
     public void testModelToViewintShapeBias01() throws BadLocationException {
         area.setText("1: 0\n2: 012345\n3:\n");
         //            01234 5678901234 567
-
-        assertTrue(view.modelToView(0, shape,
-                Position.Bias.Backward) instanceof Rectangle);
-
-        assertEquals(new Rectangle(1, view.metrics.getHeight()),
-                view.modelToView(0, shape, Position.Bias.Forward));
-        assertEquals(new Rectangle(1, view.metrics.getHeight()),
-                view.modelToView(0, shape, Position.Bias.Backward));
-
-        assertEquals(new Rectangle(view.metrics.charWidth('1'), 0, 1,
-                view.metrics.getHeight()),
+        assertTrue(view.modelToView(0, shape, Position.Bias.Backward) instanceof Rectangle);
+        assertEquals(new Rectangle(1, view.metrics.getHeight()), view.modelToView(0, shape,
+                Position.Bias.Forward));
+        assertEquals(new Rectangle(1, view.metrics.getHeight()), view.modelToView(0, shape,
+                Position.Bias.Backward));
+        assertEquals(
+                new Rectangle(view.metrics.charWidth('1'), 0, 1, view.metrics.getHeight()),
                 view.modelToView(1, shape, Position.Bias.Forward));
-        assertEquals(new Rectangle(view.metrics.charWidth('1'), 0, 1,
-                view.metrics.getHeight()),
+        assertEquals(
+                new Rectangle(view.metrics.charWidth('1'), 0, 1, view.metrics.getHeight()),
                 view.modelToView(1, shape, Position.Bias.Backward));
-
         assertEquals(new Rectangle(view.metrics.stringWidth("2: 012"),
-                view.metrics.getHeight(), 1,
-                view.metrics.getHeight()),
-                view.modelToView(11, shape, Position.Bias.Forward));
-
+                view.metrics.getHeight(), 1, view.metrics.getHeight()), view.modelToView(11,
+                shape, Position.Bias.Forward));
         try {
             view.modelToView(-1, shape, Position.Bias.Forward);
-
             fail("BadLocationException is expected");
-        } catch (BadLocationException e) { }
-
+        } catch (BadLocationException e) {
+        }
         assertEquals(new Rectangle(view.metrics.charWidth('\n')/*0*/,
-                                   view.metrics.getHeight() * 3,
-                                   1, view.metrics.getHeight()),
-                     view.modelToView(doc.getLength() + 1, shape,
-                                      Position.Bias.Forward));
-
+                view.metrics.getHeight() * 3, 1, view.metrics.getHeight()), view.modelToView(
+                doc.getLength() + 1, shape, Position.Bias.Forward));
         try {
             view.modelToView(doc.getLength() + 2, shape, Position.Bias.Forward);
-
             fail("BadLocationException is expected");
-        } catch (BadLocationException e) { }
-
-//        try {
-            view.modelToView(0, shape, null);
-
-            // isn't thrown
-            //fail("IllegalArgumentException must be thrown");
-//        } catch (IllegalArgumentException e) { }
-
+        } catch (BadLocationException e) {
+        }
+        //        try {
+        view.modelToView(0, shape, null);
+        // isn't thrown
+        //fail("IllegalArgumentException must be thrown");
+        //        } catch (IllegalArgumentException e) { }
         doc.insertString(1, "\t", null);
-        assertEquals(new Rectangle(view.metrics.charWidth('1'), 0, 1,
-                view.metrics.getHeight()),
+        assertEquals(
+                new Rectangle(view.metrics.charWidth('1'), 0, 1, view.metrics.getHeight()),
                 view.modelToView(1, shape, Position.Bias.Forward));
-
-        assertEquals(new Rectangle(
-                (int)view.nextTabStop(view.metrics.charWidth('1'), 0), 0, 1,
-                view.metrics.getHeight()),
-                view.modelToView(2, shape, Position.Bias.Forward));
-
-        assertEquals(new Rectangle(
-                (int)view.nextTabStop(view.metrics.charWidth('1'), 0) +
-                view.metrics.charWidth(':'), 0, 1,
-                view.metrics.getHeight()),
-                view.modelToView(3, shape, Position.Bias.Forward));
-
+        assertEquals(new Rectangle((int) view.nextTabStop(view.metrics.charWidth('1'), 0), 0,
+                1, view.metrics.getHeight()), view.modelToView(2, shape, Position.Bias.Forward));
+        assertEquals(new Rectangle((int) view.nextTabStop(view.metrics.charWidth('1'), 0)
+                + view.metrics.charWidth(':'), 0, 1, view.metrics.getHeight()), view
+                .modelToView(3, shape, Position.Bias.Forward));
     }
 
     /**
@@ -198,14 +166,10 @@
      */
     public void testModelToViewintShapeBias02() throws BadLocationException {
         area.setText("1: 0\n2: 012345\n3:\n");
-
-        ((Rectangle)shape).setLocation(7, 10);
-
-        assertFalse(((Rectangle)shape).x == 0);
-
-        assertEquals(new Rectangle(((Rectangle)shape).x, ((Rectangle)shape).y,
-                1, view.metrics.getHeight()),
-                view.modelToView(0, shape, Position.Bias.Forward));
+        ((Rectangle) shape).setLocation(7, 10);
+        assertFalse(((Rectangle) shape).x == 0);
+        assertEquals(new Rectangle(((Rectangle) shape).x, ((Rectangle) shape).y, 1,
+                view.metrics.getHeight()), view.modelToView(0, shape, Position.Bias.Forward));
     }
 
     /**
@@ -215,24 +179,20 @@
     public void testModelToViewintShapeBias03() throws BadLocationException {
         area.setText("");
         assertEquals(0, view.getDocument().getLength());
-
-        assertEquals(new Rectangle(1, view.metrics.getHeight()),
-                     view.modelToView(0, shape, Position.Bias.Forward));
-
-        assertEquals(new Rectangle(1, view.metrics.getHeight()),
-                     view.modelToView(1, shape, Position.Bias.Forward));
-
+        assertEquals(new Rectangle(1, view.metrics.getHeight()), view.modelToView(0, shape,
+                Position.Bias.Forward));
+        assertEquals(new Rectangle(1, view.metrics.getHeight()), view.modelToView(1, shape,
+                Position.Bias.Forward));
         try {
             view.modelToView(-1, shape, Position.Bias.Forward);
-
             fail("BadLocationException is expected");
-        } catch (BadLocationException e) { }
-
+        } catch (BadLocationException e) {
+        }
         try {
             view.modelToView(2, shape, Position.Bias.Forward);
-
             fail("BadLocationException is expected");
-        } catch (BadLocationException e) { }
+        } catch (BadLocationException e) {
+        }
     }
 
     /**
@@ -245,13 +205,11 @@
         assertEquals(tabPos, view.nextTabStop(10.0f, 0), 0.00001f);
         assertEquals(tabPos, view.nextTabStop(tabPos - 1, 0), 0.00001f);
         assertEquals(tabPos * 2, view.nextTabStop(tabPos, 0), 0.00001f);
-
         // Setting tab size to 4 has no effect on already initialized view
         doc.putProperty(PlainDocument.tabSizeAttribute, new Integer(4));
         assertEquals(4, view.getTabSize());
         // The change has no effect
         assertEquals(tabPos, view.nextTabStop(0.0f, 0), 0.00001f);
-
         // But after metrics have been updated...
         view.updateMetrics();
         if (isHarmony()) {
@@ -265,92 +223,78 @@
     /*
      * int viewToModel(float, float, Shape, Position.Bias[])
      */
-    public void testViewToModelfloatfloatShapeBiasArray()
-        throws BadLocationException {
-
+    public void testViewToModelfloatfloatShapeBiasArray() throws BadLocationException {
         area.setText("1: 0\n2: 012345\n3:\n");
         //            01234 5678901234 567
-
         int h = view.metrics.getHeight();
         int w = view.metrics.charWidth('1');
-
         Position.Bias[] bias = new Position.Bias[1];
         assertNull(bias[0]);
-
         assertEquals(0, view.viewToModel(0f, 0f, shape, bias));
-        assertSame(Position.Bias.Forward, bias[0]);   bias[0] = null;
-
+        assertSame(Position.Bias.Forward, bias[0]);
+        bias[0] = null;
         assertEquals(0, view.viewToModel(w / 4f, h / 4f, shape, bias));
-        assertSame(Position.Bias.Forward, bias[0]);   bias[0] = null;
-
-
-        assertEquals(1, view.viewToModel(w - 1f, h / 2f,
-                shape, bias));
-        assertSame(Position.Bias.Forward, bias[0]);   bias[0] = null;
-        assertEquals(1, view.viewToModel(w - w / 4f, h / 2f,
-                shape, bias));
-        assertSame(Position.Bias.Forward, bias[0]);   bias[0] = null;
-
+        assertSame(Position.Bias.Forward, bias[0]);
+        bias[0] = null;
+        assertEquals(1, view.viewToModel(w - 1f, h / 2f, shape, bias));
+        assertSame(Position.Bias.Forward, bias[0]);
+        bias[0] = null;
+        assertEquals(1, view.viewToModel(w - w / 4f, h / 2f, shape, bias));
+        assertSame(Position.Bias.Forward, bias[0]);
+        bias[0] = null;
         w = view.metrics.charWidth('2');
-
         // Negative coordinates
         assertEquals(0, view.viewToModel(-1f, h - 0.1f, shape, bias));
-        assertSame(Position.Bias.Forward, bias[0]);   bias[0] = null;
-
+        assertSame(Position.Bias.Forward, bias[0]);
+        bias[0] = null;
         assertEquals(5, view.viewToModel(-1f, h, shape, bias));
-        assertSame(Position.Bias.Forward, bias[0]);   bias[0] = null;
-
+        assertSame(Position.Bias.Forward, bias[0]);
+        bias[0] = null;
         assertEquals(5, view.viewToModel(-1f, h + 0.1f, shape, bias));
-        assertSame(Position.Bias.Forward, bias[0]);   bias[0] = null;
-
+        assertSame(Position.Bias.Forward, bias[0]);
+        bias[0] = null;
         assertEquals(0, view.viewToModel(1f, -1f, shape, bias));
-        assertSame(Position.Bias.Forward, bias[0]);   bias[0] = null;
-
+        assertSame(Position.Bias.Forward, bias[0]);
+        bias[0] = null;
         assertEquals(0, view.viewToModel(w + 1f, -1f, shape, bias));
-        assertSame(Position.Bias.Forward, bias[0]);   bias[0] = null;
-
-
+        assertSame(Position.Bias.Forward, bias[0]);
+        bias[0] = null;
         // Past last character of line 1
-        assertEquals(4, view.viewToModel(view.metrics.stringWidth("1: 0") + 1f,
-                h / 2, shape, bias));
-        assertEquals(4, view.viewToModel(view.metrics.stringWidth("1: 0") + 1f,
-                h - 0.1f, shape, bias));
-        assertSame(Position.Bias.Forward, bias[0]);   bias[0] = null;
-
-        assertEquals(9, view.viewToModel(view.metrics.stringWidth("1: 0"),
-                h, shape, bias));
-        assertSame(Position.Bias.Forward, bias[0]);   bias[0] = null;
-
-        assertEquals(9, view.viewToModel(view.metrics.stringWidth("1: 0"),
-                h + 0.1f, shape, bias));
-        assertSame(Position.Bias.Forward, bias[0]);   bias[0] = null;
-
-
+        assertEquals(4, view.viewToModel(view.metrics.stringWidth("1: 0") + 1f, h / 2, shape,
+                bias));
+        assertEquals(4, view.viewToModel(view.metrics.stringWidth("1: 0") + 1f, h - 0.1f,
+                shape, bias));
+        assertSame(Position.Bias.Forward, bias[0]);
+        bias[0] = null;
+        assertEquals(9, view.viewToModel(view.metrics.stringWidth("1: 0"), h, shape, bias));
+        assertSame(Position.Bias.Forward, bias[0]);
+        bias[0] = null;
+        assertEquals(9, view.viewToModel(view.metrics.stringWidth("1: 0"), h + 0.1f, shape,
+                bias));
+        assertSame(Position.Bias.Forward, bias[0]);
+        bias[0] = null;
         // Below last line
-        h = (int)view.getPreferredSpan(View.Y_AXIS);
+        h = (int) view.getPreferredSpan(View.Y_AXIS);
         int pos = doc.getLength();
         assertEquals(pos, view.viewToModel(0f, h - 0.1f, shape, bias));
-        assertSame(Position.Bias.Forward, bias[0]);   bias[0] = null;
-
+        assertSame(Position.Bias.Forward, bias[0]);
+        bias[0] = null;
         assertEquals(pos, view.viewToModel(0f, h, shape, bias));
-        assertSame(Position.Bias.Forward, bias[0]);   bias[0] = null;
-
+        assertSame(Position.Bias.Forward, bias[0]);
+        bias[0] = null;
         assertEquals(pos, view.viewToModel(0f, h + 0.1f, shape, bias));
-        assertSame(Position.Bias.Forward, bias[0]);   bias[0] = null;
-
-
+        assertSame(Position.Bias.Forward, bias[0]);
+        bias[0] = null;
         // Test with tab
         w = view.metrics.charWidth('1');
         doc.insertString(1, "\t", null);
-
-        int tab = (int)view.nextTabStop(w, 0);
+        int tab = (int) view.nextTabStop(w, 0);
         int tabSize = tab - w;
         assertEquals(1, view.viewToModel(w + tabSize / 2f - 0.5f, 0f, shape, bias));
-        assertEquals(2, view.viewToModel(w + tabSize / 2f + 0.5f, 0f,
-                                         shape, bias));
+        assertEquals(2, view.viewToModel(w + tabSize / 2f + 0.5f, 0f, shape, bias));
         assertEquals(2, view.viewToModel(tab - 1f, 0f, shape, bias));
-        assertEquals(3, view.viewToModel(tab +
-                view.metrics.charWidth(':') - 1f, 0, shape, bias));
+        assertEquals(3, view
+                .viewToModel(tab + view.metrics.charWidth(':') - 1f, 0, shape, bias));
     }
 
     /**
@@ -358,6 +302,7 @@
      * into it and initializes <code>doc</code>, <code>root</code>,
      * <code>view</code>, and <code>shape</code> using JTextArea methods.
      */
+    @Override
     protected void setUp() throws Exception {
         super.setUp();
         frame = new JFrame("PlainView Test");
@@ -365,26 +310,25 @@
         frame.getContentPane().add(area);
         frame.setSize(100, 150);
         frame.pack();
-
-        doc   = area.getDocument();
-        view  = (PlainView)area.getUI().getRootView(area).getView(0);
+        doc = area.getDocument();
+        view = (PlainView) area.getUI().getRootView(area).getView(0);
         shape = area.getVisibleRect();
     }
 
     /*
      * @see TestCase#tearDown()
      */
+    @Override
     protected void tearDown() throws Exception {
         super.tearDown();
         frame.dispose();
     }
-
     // Painting methods are not tested
     /*
-    public void testDrawLine() {
-    }
+     public void testDrawLine() {
+     }
 
-    public void testPaint() {
-    }
-    */
+     public void testPaint() {
+     }
+     */
 }

Modified: harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/text/PlainView_ChangesRTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/text/PlainView_ChangesRTest.java?view=diff&rev=479418&r1=479417&r2=479418
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/text/PlainView_ChangesRTest.java (original)
+++ harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/text/PlainView_ChangesRTest.java Sun Nov 26 12:15:43 2006
@@ -24,25 +24,27 @@
 import java.awt.Container;
 import java.awt.Rectangle;
 import java.awt.Shape;
-
 import javax.swing.BasicSwingTestCase;
 import javax.swing.JTextArea;
 import javax.swing.event.DocumentEvent;
 import javax.swing.event.DocumentListener;
 import javax.swing.text.PlainView_ChangesTest.LineRange;
 
-public class PlainView_ChangesRTest extends BasicSwingTestCase
-    implements DocumentListener {
-
+public class PlainView_ChangesRTest extends BasicSwingTestCase implements DocumentListener {
     private boolean callSuperDamageRange;
+
     private Container container;
 
     private Document doc;
+
     private DocumentEvent event;
 
     private LineRange lineRange;
+
     private Rectangle paintRect;
+
     private Element root;
+
     private Shape shape;
 
     private PlainView view;
@@ -57,7 +59,6 @@
     public void testInsertUpdateNPE() throws BadLocationException {
         doc.insertString(0, "1:0123\n2:\n3:abcdefg", null);
         view.updateMetrics();
-
         doc.insertString(0, "^", null);
         view.insertUpdate(event, shape, null);
     }
@@ -75,7 +76,6 @@
     public void testInsertUpdateExtraRepaint() throws BadLocationException {
         doc.insertString(0, "1:0123\n2:\n3:abcdefg", null);
         view.updateMetrics();
-
         doc.insertString(0, "^", null);
         view.insertUpdate(event, shape, null);
         lineRange.check(0, 0, shape, container);
@@ -91,30 +91,29 @@
      */
     public void testNextTabStop05() {
         assertNull(view.metrics);
-
         if (isHarmony()) {
             // Call to nextTabStop will lead to updateMetrics()
-            assertTrue("nextTabStop() must return value > 0",
-                       view.nextTabStop(0, 0) > view.getTabSize());
+            assertTrue("nextTabStop() must return value > 0", view.nextTabStop(0, 0) > view
+                    .getTabSize());
         }
-
         view.setSize(100, 200);
-
-        assertNotNull("Metrics must be not null after setSize",
-                      view.metrics);
+        assertNotNull("Metrics must be not null after setSize", view.metrics);
     }
 
+    @Override
     protected void setUp() throws Exception {
         super.setUp();
-
-        doc  = new PlainDocument();
+        doc = new PlainDocument();
         root = doc.getDefaultRootElement();
         view = new PlainView(root) {
+            @Override
             public Container getContainer() {
                 if (container == null) {
                     container = new JTextArea() {
-                        public void repaint(final int x, final int y,
-                                            final int w, final int h) {
+                        private static final long serialVersionUID = 1L;
+
+                        @Override
+                        public void repaint(final int x, final int y, final int w, final int h) {
                             if (paintRect == null) {
                                 paintRect = new Rectangle(x, y, w, h);
                             } else {
@@ -123,13 +122,12 @@
                         }
                     };
                 }
-
                 return container;
             }
 
-            protected void damageLineRange(final int line0, final int line1,
-                                           final Shape shape,
-                                           final Component host) {
+            @Override
+            protected void damageLineRange(final int line0, final int line1, final Shape shape,
+                    final Component host) {
                 if (callSuperDamageRange) {
                     super.damageLineRange(line0, line1, shape, host);
                 } else {
@@ -138,7 +136,6 @@
             }
         };
         shape = new Rectangle(500, 500);
-
         doc.addDocumentListener(this);
     }
 



Mime
View raw message