harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ndbe...@apache.org
Subject svn commit: r479418 [31/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/JTextComponentTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/text/JTextComponentTest.java?view=diff&rev=479418&r1=479417&r2=479418
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/text/JTextComponentTest.java (original)
+++ harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/text/JTextComponentTest.java Sun Nov 26 12:15:43 2006
@@ -47,7 +47,6 @@
 import java.io.StringReader;
 import java.io.StringWriter;
 import java.util.Vector;
-
 import javax.swing.Action;
 import javax.swing.JFrame;
 import javax.swing.JTextArea;
@@ -106,7 +105,6 @@
 
         public void caretPositionChanged(final InputMethodEvent e) {
             strOrderProcessInputMethodEventCaret += name;
-
         }
 
         public void inputMethodTextChanged(final InputMethodEvent e) {
@@ -126,7 +124,6 @@
         }
         assertTrue(cond);
         assertEquals(count, k);
-
     }
 
     void assertEqualsPropertyChangeEvent(final String name, final Object oldValue,
@@ -192,12 +189,14 @@
 
         public void removeKeyStrokeBinding(final KeyStroke arg0) {
         }
-
     }
 
     class JTextComp extends JTextComponent {
+        private static final long serialVersionUID = 1L;
+
         String UIClassId = "TextCompUIFirst";
 
+        @Override
         public String getUIClassID() {
             return (UIClassId != null) ? UIClassId : "TextCompUIFirst";
         }
@@ -222,7 +221,6 @@
             if (e.getPropertyName() != "ancestor") {
                 event = e;
             }
-
         }
 
         PropertyChangeEvent getEvent() {
@@ -233,10 +231,12 @@
     }
 
     class SimpleTransferHandler extends TransferHandler {
-
+        private static final long serialVersionUID = 1L;
     }
 
     private class SimpleTextAction extends TextAction {
+        private static final long serialVersionUID = 1L;
+
         public SimpleTextAction(final String name) {
             super(name);
         }
@@ -249,6 +249,7 @@
         setIgnoreNotImplemented(true);
     }
 
+    @Override
     protected void setUp() throws Exception {
         jf = new JFrame();
         bWasException = false;
@@ -267,6 +268,7 @@
         jf.pack();
     }
 
+    @Override
     protected void tearDown() throws Exception {
         jf.dispose();
         super.tearDown();
@@ -282,22 +284,17 @@
         jf.getContentPane().add(jtc);
         jf.setVisible(true);
         jf.pack();
-
         rect = null;
         try {
             rect = jtc.modelToView(0);
         } catch (BadLocationException e) {
         }
-
         assertNotNull(rect);
         MouseEvent me = new MouseEvent(jtc, MouseEvent.MOUSE_PRESSED, 0,
-                InputEvent.BUTTON1_MASK, jtc.getX() + rect.x, jtc.getY()
-                        + rect.y, 0, false, MouseEvent.BUTTON1);
-
-        assertEquals(
-                jtc.getUI().getToolTipText(jtc, new Point(rect.x, rect.y)), jtc
-                        .getToolTipText(me));
-
+                InputEvent.BUTTON1_MASK, jtc.getX() + rect.x, jtc.getY() + rect.y, 0, false,
+                MouseEvent.BUTTON1);
+        assertEquals(jtc.getUI().getToolTipText(jtc, new Point(rect.x, rect.y)), jtc
+                .getToolTipText(me));
         String s = "ToolTipText";
         jtc.setToolTipText(s);
         assertEquals(s, jtc.getToolTipText(me));
@@ -313,8 +310,7 @@
         assertNotNull(keyMap1);
         SimpleKeyMap keyMap2 = new SimpleKeyMap("Second");
         jtc.setKeymap(keyMap2);
-        assertEqualsPropertyChangeEvent("keymap", keyMap1, keyMap2,
-                pChListener.event);
+        assertEqualsPropertyChangeEvent("keymap", keyMap1, keyMap2, pChListener.event);
         assertEquals(keyMap2, jtc.getKeymap());
     }
 
@@ -322,10 +318,8 @@
         DefaultHighlighter dh1 = (DefaultHighlighter) jtc.getHighlighter();
         DefaultHighlighter dh2 = new DefaultHighlighter();
         assertTrue(jtc.getHighlighter() instanceof DefaultHighlighter);
-
         jtc.setHighlighter(dh2);
-        assertEqualsPropertyChangeEvent("highlighter", dh1, dh2,
-                pChListener.event);
+        assertEqualsPropertyChangeEvent("highlighter", dh1, dh2, pChListener.event);
         assertEquals(dh2, jtc.getHighlighter());
     }
 
@@ -333,22 +327,19 @@
         assertNotNull(jtc.getDocument());
         jtc.setText("testSetGetDocument");
         Highlighter highlighter = jtc.getHighlighter();
-        Highlighter.HighlightPainter painter =
-            new Highlighter.HighlightPainter() {
-                public void paint(Graphics g, int p1, int p2, Shape shape,
-                                  JTextComponent c) {
-                }
-            };
+        Highlighter.HighlightPainter painter = new Highlighter.HighlightPainter() {
+            public void paint(Graphics g, int p1, int p2, Shape shape, JTextComponent c) {
+            }
+        };
         highlighter.addHighlight(0, 3, painter);
         highlighter.addHighlight(2, 5, painter);
         Document oldDoc = jtc.getDocument();
         PlainDocument doc = new PlainDocument();
         jtc.setDocument(doc);
         if (isHarmony()) {
-           assertEquals(0, jtc.getHighlighter().getHighlights().length);
+            assertEquals(0, jtc.getHighlighter().getHighlights().length);
         }
-        assertEqualsPropertyChangeEvent("document", oldDoc, doc,
-                pChListener.event);
+        assertEqualsPropertyChangeEvent("document", oldDoc, doc, pChListener.event);
         assertEquals(doc, jtc.getDocument());
     }
 
@@ -356,14 +347,12 @@
         DefaultCaret dc1 = (DefaultCaret) jtc.getCaret();
         DefaultCaret dc2 = new DefaultCaret();
         assertTrue(jtc.getCaret() instanceof DefaultCaret);
-
         jtc.setCaret(dc2);
         assertEqualsPropertyChangeEvent("caret", dc1, dc2, pChListener.event);
         assertEquals(dc2, jtc.getCaret());
-
     }
 
-    public void assertEquals(final Vector listeners1, final CaretListener[] listeners2) {
+    public void assertEquals(final Vector<SimpleCaretListener> listeners1, final CaretListener[] listeners2) {
         assertNotNull(listeners1);
         assertNotNull(listeners2);
         assertEquals(listeners1.size(), listeners2.length);
@@ -377,27 +366,22 @@
         SimpleCaretListener listener1 = new SimpleCaretListener("1");
         SimpleCaretListener listener2 = new SimpleCaretListener("2");
         SimpleCaretListener listener3 = new SimpleCaretListener("3");
-        Vector listeners = new Vector();
-
+        Vector<SimpleCaretListener> listeners = new Vector<SimpleCaretListener>();
         jtc.addCaretListener(listener1);
         listeners.add(listener1);
         assertEquals(listeners, jtc.getCaretListeners());
-
         jtc.addCaretListener(listener2);
         listeners.add(0, listener2);
         assertEquals(listeners, jtc.getCaretListeners());
-
         jtc.addCaretListener(listener3);
         listeners.add(0, listener3);
         assertEquals(listeners, jtc.getCaretListeners());
         jtc.removeCaretListener(listener2);
         listeners.remove(listener2);
         assertEquals(listeners, jtc.getCaretListeners());
-
         jtc.removeCaretListener(listener3);
         listeners.remove(listener3);
         assertEquals(listeners, jtc.getCaretListeners());
-
         jtc.removeCaretListener(listener1);
         listeners.remove(listener1);
         assertEquals(listeners, jtc.getCaretListeners());
@@ -405,7 +389,6 @@
 
     public void testFireCaretUpdate() throws Exception {
         jtc.setText("JTextComponent");
-
         SimpleCaretListener listener1 = new SimpleCaretListener("1");
         SimpleCaretListener listener2 = new SimpleCaretListener("2");
         SimpleCaretListener listener3 = new SimpleCaretListener("3");
@@ -422,7 +405,6 @@
         assertTrue(jtc.getText().equals(""));
         jtc.setText("JTextComponent");
         assertTrue(jtc.getText().equals("JTextComponent"));
-
         String str = "";
         try {
             str = jtc.getText(5, 3);
@@ -430,7 +412,6 @@
             bWasException = true;
             s = e.getMessage();
         }
-
         assertFalse("Unexpected exception: " + s, bWasException);
         assertTrue(str.equals("Com"));
     }
@@ -445,7 +426,6 @@
         jtc.replaceSelection("XXX");
         assertNull(jtc.getSelectedText());
         assertEquals("JTextXXXent", jtc.getText());
-
         jtc.setText("JTextComponent");
         jtc.setCaretPosition(2);
         jtc.replaceSelection("XXX");
@@ -457,16 +437,13 @@
         String s = "JTextComponent\nRead\nWrite\n";
         String sProperty = "CurrentStreamDescriptionProperty";
         StringWriter writer = new StringWriter();
-
         jtc.setText(s);
         try {
             jtc.write(writer);
         } catch (IOException e) {
         }
-
         jtc.setText("temporary");
         assertEquals("temporary", jtc.getText());
-
         StringReader reader = new StringReader(writer.toString());
         try {
             jtc.read(reader, sProperty);
@@ -476,7 +453,6 @@
         assertEquals(sProperty, jtc.getDocument().getProperty(
                 Document.StreamDescriptionProperty));
         assertTrue(jtc.getDocument() instanceof PlainDocument);
-
     }
 
     public void testAddInputMethodListener() {
@@ -517,89 +493,64 @@
         imEventTest(InputMethodEvent.INPUT_METHOD_TEXT_CHANGED, "", "123");
         imEventTest(InputMethodEvent.INPUT_METHOD_FIRST, "", "123");
         imEventTest(InputMethodEvent.INPUT_METHOD_LAST, "123", "");
-
     }
 
     public void testSetGetMargin() throws Exception {
-
         Insets insets1 = new Insets(0, 0, 0, 0);
         assertEquals(insets1, jtc.getMargin());
         Insets insets2 = new Insets(10, 20, 30, 40);
         jtc.setMargin(insets2);
-        assertEqualsPropertyChangeEvent("margin", insets1, insets2,
-                pChListener.event);
+        assertEqualsPropertyChangeEvent("margin", insets1, insets2, pChListener.event);
         assertEquals(insets2, jtc.getMargin());
-
     }
 
     public void testSetGetComponentOrientation() throws Exception {
-        assertEquals(ComponentOrientation.UNKNOWN, jtc
-                .getComponentOrientation());
-
+        assertEquals(ComponentOrientation.UNKNOWN, jtc.getComponentOrientation());
         docXXX = (AbstractDocument) jtc.getDocument();
         jtc.setComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT);
-        assertEquals(new Boolean(true), docXXX
-                .getProperty(TextAttribute.RUN_DIRECTION));
+        assertEquals(new Boolean(true), docXXX.getProperty(TextAttribute.RUN_DIRECTION));
         jtc.setText("JTextComponent");
         assertEquals(2, docXXX.getBidiRootElement().getElementCount());
-        assertEquals(ComponentOrientation.RIGHT_TO_LEFT, jtc
-                .getComponentOrientation());
-
+        assertEquals(ComponentOrientation.RIGHT_TO_LEFT, jtc.getComponentOrientation());
         jtc.setComponentOrientation(ComponentOrientation.LEFT_TO_RIGHT);
-        assertEquals(new Boolean(false), docXXX
-                .getProperty(TextAttribute.RUN_DIRECTION));
+        assertEquals(new Boolean(false), docXXX.getProperty(TextAttribute.RUN_DIRECTION));
         jtc.setText("JTextComponent");
-        assertEquals(ComponentOrientation.LEFT_TO_RIGHT, jtc
-                .getComponentOrientation());
-
+        assertEquals(ComponentOrientation.LEFT_TO_RIGHT, jtc.getComponentOrientation());
         jtc.setComponentOrientation(ComponentOrientation.UNKNOWN);
-        assertEquals(new Boolean(false), docXXX
-                .getProperty(TextAttribute.RUN_DIRECTION));
+        assertEquals(new Boolean(false), docXXX.getProperty(TextAttribute.RUN_DIRECTION));
         jtc.setText("JTextComponent");
-        assertEquals(ComponentOrientation.UNKNOWN, jtc
-                .getComponentOrientation());
-
+        assertEquals(ComponentOrientation.UNKNOWN, jtc.getComponentOrientation());
     }
 
     public void testSetGetColors() throws Exception {
         Color color1 = getColorProperty("caretForeground");
         assertEquals(color1, jtc.getCaretColor());
         jtc.setCaretColor(color);
-        assertEqualsPropertyChangeEvent("caretColor", color1, color,
-                pChListener.event);
+        assertEqualsPropertyChangeEvent("caretColor", color1, color, pChListener.event);
         assertEquals(color, jtc.getCaretColor());
-
         color1 = getColorProperty("selectionBackground");
         assertEquals(color1, jtc.getSelectionColor());
         jtc.setSelectionColor(color);
-        assertEqualsPropertyChangeEvent("selectionColor", color1, color,
-                pChListener.event);
+        assertEqualsPropertyChangeEvent("selectionColor", color1, color, pChListener.event);
         assertEquals(color, jtc.getSelectionColor());
-
         color1 = getColorProperty("inactiveForeground");
         assertEquals(color1, jtc.getDisabledTextColor());
         jtc.setDisabledTextColor(color);
-        assertEqualsPropertyChangeEvent("disabledTextColor", color1, color,
-                pChListener.event);
+        assertEqualsPropertyChangeEvent("disabledTextColor", color1, color, pChListener.event);
         assertEquals(color, jtc.getDisabledTextColor());
-
         color1 = getColorProperty("selectionForeground");
         assertEquals(color1, jtc.getSelectedTextColor());
         jtc.setSelectedTextColor(color);
-        assertEqualsPropertyChangeEvent("selectedTextColor", color1, color,
-                pChListener.event);
+        assertEqualsPropertyChangeEvent("selectedTextColor", color1, color, pChListener.event);
         assertEquals(color, jtc.getSelectedTextColor());
-
     }
 
     public void testSetIsEditable() throws Exception {
-
         assertTrue(jtc.isEditable());
         jtc.setEditable(false);
-        assertEqualsPropertyChangeEvent("editable", new Boolean(true),
-                new Boolean(false), pChListener.event);
+        assertEqualsPropertyChangeEvent("editable", new Boolean(true), new Boolean(false),
+                pChListener.event);
         assertFalse(jtc.isEditable());
-
     }
 
     public void testSetGetDragEnabled() throws Exception {
@@ -648,39 +599,31 @@
     }
 
     public void testSelect() throws Exception {
-
         jtc.setText("JTextComponent");
-
         jtc.select(5, 8);
         assertEquals("Com", jtc.getSelectedText());
         assertEquals(5, jtc.getCaret().getMark());
         assertEquals(8, jtc.getCaret().getDot());
-
         jtc.select(-2, -1);
         assertNull(jtc.getSelectedText());
         assertEquals(0, jtc.getCaret().getMark());
         assertEquals(0, jtc.getCaret().getDot());
-
         jtc.select(-5, 16);
         assertEquals("JTextComponent", jtc.getSelectedText());
         assertEquals(0, jtc.getCaret().getMark());
         assertEquals(14, jtc.getCaret().getDot());
-
         jtc.select(17, 18);
         assertNull(jtc.getSelectedText());
         assertEquals(14, jtc.getCaret().getMark());
         assertEquals(14, jtc.getCaret().getDot());
-
         jtc.select(8, 5);
         assertNull(jtc.getSelectedText());
         assertEquals(8, jtc.getCaret().getMark());
         assertEquals(8, jtc.getCaret().getDot());
-
         jtc.select(8, 8);
         assertNull(jtc.getSelectedText());
         assertEquals(8, jtc.getCaret().getMark());
         assertEquals(8, jtc.getCaret().getDot());
-
     }
 
     public void testSetGetSelectionStartEnd() throws Exception {
@@ -692,16 +635,13 @@
         jtc.setText("JTextComponent");
         assertEquals(14, jtc.getSelectionStart());
         assertEquals(14, jtc.getSelectionEnd());
-
         jtc.setSelectionStart(5);
         jtc.setSelectionEnd(8);
-
         assertEquals("Com", jtc.getSelectedText());
         assertEquals(5, jtc.getSelectionStart());
         assertEquals(8, jtc.getSelectionEnd());
         assertEquals(8, jtc.getCaret().getDot());
         assertEquals(5, jtc.getCaret().getMark());
-
         jtc.setSelectionStart(8);
         jtc.setSelectionEnd(5);
         assertNull(jtc.getSelectedText());
@@ -709,50 +649,40 @@
         assertEquals(5, jtc.getSelectionEnd());
         assertEquals(5, jtc.getCaret().getDot());
         assertEquals(5, jtc.getCaret().getMark());
-
         jtc.setCaretPosition(4);
         jtc.moveCaretPosition(6);
-
         assertEquals(4, jtc.getSelectionStart());
         assertEquals(6, jtc.getSelectionEnd());
-
         jtc.setCaretPosition(6);
         jtc.moveCaretPosition(3);
-
         assertEquals(3, jtc.getSelectionStart());
         assertEquals(6, jtc.getSelectionEnd());
-
         jtc.setSelectionStart(4);
         assertEquals(4, jtc.getCaret().getDot());
         assertEquals(6, jtc.getCaret().getMark());
         assertEquals(4, jtc.getSelectionStart());
         assertEquals(6, jtc.getSelectionEnd());
-
         jtc.setSelectionEnd(3);
         assertEquals(3, jtc.getCaret().getDot());
         assertEquals(3, jtc.getCaret().getMark());
         assertEquals(3, jtc.getSelectionStart());
         assertEquals(3, jtc.getSelectionEnd());
         assertNull(jtc.getSelectedText());
-
         jtc.setSelectionStart(8);
         assertEquals(8, jtc.getCaret().getDot());
         assertEquals(8, jtc.getCaret().getMark());
         assertEquals(8, jtc.getSelectionStart());
         assertEquals(8, jtc.getSelectionEnd());
-
         jtc.setSelectionEnd(10);
         assertEquals(10, jtc.getCaret().getDot());
         assertEquals(8, jtc.getCaret().getMark());
         assertEquals(8, jtc.getSelectionStart());
         assertEquals(10, jtc.getSelectionEnd());
-
         jtc.setSelectionStart(9);
         assertEquals(9, jtc.getCaret().getDot());
         assertEquals(10, jtc.getCaret().getMark());
         assertEquals(9, jtc.getSelectionStart());
         assertEquals(10, jtc.getSelectionEnd());
-
         jtc.setCaretPosition(8);
         jtc.moveCaretPosition(4);
         assertEquals("tCom", jtc.getSelectedText());
@@ -761,21 +691,14 @@
         assertEquals(4, jtc.getCaret().getMark());
         assertEquals(4, jtc.getSelectionStart());
         assertEquals(6, jtc.getSelectionEnd());
-
     }
 
     public void testSetGetCaretPosition() throws Exception {
-
         assertEquals(0, jtc.getCaretPosition());
-
         jtc.setText("JTextComponent");
-
         assertEquals(14, jtc.getCaretPosition());
-
         jtc.setCaretPosition(5);
-
         assertEquals(5, jtc.getCaretPosition());
-
         bWasException = false;
         s = null;
         try {
@@ -786,7 +709,6 @@
         }
         assertTrue(bWasException);
         assertEquals("bad position: -2", s);
-
         bWasException = false;
         s = null;
         try {
@@ -797,16 +719,13 @@
         }
         assertTrue(bWasException);
         assertEquals("bad position: 20", s);
-
     }
 
     public void testMoveCaretPosition() throws Exception {
-
         jtc.setText("JTextComponent");
         jtc.setCaretPosition(5);
         jtc.moveCaretPosition(8);
         assertEquals(8, jtc.getCaretPosition());
-
         bWasException = false;
         s = null;
         try {
@@ -817,7 +736,6 @@
         }
         assertTrue(bWasException);
         assertEquals("bad position: -2", s);
-
         bWasException = false;
         s = null;
         try {
@@ -828,11 +746,9 @@
         }
         assertTrue(bWasException);
         assertEquals("bad position: 20", s);
-
     }
 
     public void testSetGetFocusAccelerator() throws Exception {
-
         //TODO It's very strange but in 1.5.0 PropertyChangeEvent's
         //name doesn't equal JTextComponent.FOCUS_ACCELERATOR_KEY
         String name = JTextComponent.FOCUS_ACCELERATOR_KEY;
@@ -840,18 +756,16 @@
         assertEquals('\0', jtc.getFocusAccelerator());
         jtc.setFocusAccelerator('a');
         assertSame(name, pChListener.event.getPropertyName());
-        assertEqualsPropertyChangeEvent(name, new Character('\0'),
-                new Character('A'), pChListener.event);
+        assertEqualsPropertyChangeEvent(name, new Character('\0'), new Character('A'),
+                pChListener.event);
         assertEquals('A', jtc.getFocusAccelerator());
         jtc.setFocusAccelerator('B');
-        assertEqualsPropertyChangeEvent(name, new Character('A'),
-                new Character('B'), pChListener.event);
+        assertEqualsPropertyChangeEvent(name, new Character('A'), new Character('B'),
+                pChListener.event);
         assertEquals('B', jtc.getFocusAccelerator());
-
     }
 
     public void testSelectAll() throws Exception {
-
         jtc.selectAll();
         assertNull(jtc.getSelectedText());
         jtc.setText("JTextComponent");
@@ -863,53 +777,52 @@
         jtc.selectAll();
         assertEquals(4, jtc.getCaret().getDot());
         assertEquals(0, jtc.getCaret().getMark());
-
     }
 
     public void testPaste() throws Exception {
         // TODO: uncomment when System clipboard is properly supported
-//        if (jtc.getToolkit().getSystemClipboard() == null)
-//            return;
-//        jtc.setText("JTextComponent");
-//        setClipboardString(jtc, "XXX");
-//        jtc.setCaretPosition(5);
-//        jtc.paste();
-//        assertEquals("XXX", getClipboardString(jtc));
-//        assertNull(jtc.getSelectedText());
-//        assertEquals("JTextXXXComponent", jtc.getText());
-//
-//        jtc.select(10, 14);
-//        setClipboardString(jtc, "YYY");
-//        jtc.paste();
-//        assertEquals("YYY", getClipboardString(jtc));
-//        assertNull(jtc.getSelectedText());
-//        assertEquals("JTextXXXCoYYYent", jtc.getText());
-//
-//        jtc.select(14, 16);
-//        setClipboardString(jtc, "");
-//        jtc.paste();
-//        assertEquals("", getClipboardString(jtc));
-//        //TODO ??
-//        assertNull(jtc.getSelectedText());
-//        assertEquals("JTextXXXCoYYYe", jtc.getText());
+        //        if (jtc.getToolkit().getSystemClipboard() == null)
+        //            return;
+        //        jtc.setText("JTextComponent");
+        //        setClipboardString(jtc, "XXX");
+        //        jtc.setCaretPosition(5);
+        //        jtc.paste();
+        //        assertEquals("XXX", getClipboardString(jtc));
+        //        assertNull(jtc.getSelectedText());
+        //        assertEquals("JTextXXXComponent", jtc.getText());
+        //
+        //        jtc.select(10, 14);
+        //        setClipboardString(jtc, "YYY");
+        //        jtc.paste();
+        //        assertEquals("YYY", getClipboardString(jtc));
+        //        assertNull(jtc.getSelectedText());
+        //        assertEquals("JTextXXXCoYYYent", jtc.getText());
+        //
+        //        jtc.select(14, 16);
+        //        setClipboardString(jtc, "");
+        //        jtc.paste();
+        //        assertEquals("", getClipboardString(jtc));
+        //        //TODO ??
+        //        assertNull(jtc.getSelectedText());
+        //        assertEquals("JTextXXXCoYYYe", jtc.getText());
     }
 
     public void testCut() throws Exception {
         // TODO: uncomment when System clipboard is properly supported
-//        if (jtc.getToolkit().getSystemClipboard() == null)
-//            return;
-//        jtc.setText("JTextComponent");
-//        setClipboardString(jtc, "XXX");
-//        jtc.cut();
-//        assertEquals("XXX", getClipboardString(jtc));
-//        assertNull(jtc.getSelectedText());
-//        assertEquals("JTextComponent", jtc.getText());
-//
-//        jtc.select(4, 8);
-//        jtc.cut();
-//        assertEquals("tCom", getClipboardString(jtc));
-//        assertNull(jtc.getSelectedText());
-//        assertEquals("JTexponent", jtc.getText());
+        //        if (jtc.getToolkit().getSystemClipboard() == null)
+        //            return;
+        //        jtc.setText("JTextComponent");
+        //        setClipboardString(jtc, "XXX");
+        //        jtc.cut();
+        //        assertEquals("XXX", getClipboardString(jtc));
+        //        assertNull(jtc.getSelectedText());
+        //        assertEquals("JTextComponent", jtc.getText());
+        //
+        //        jtc.select(4, 8);
+        //        jtc.cut();
+        //        assertEquals("tCom", getClipboardString(jtc));
+        //        assertNull(jtc.getSelectedText());
+        //        assertEquals("JTexponent", jtc.getText());
     }
 
     String getClipboardString(final JTextComponent jtc) {
@@ -918,13 +831,11 @@
         Clipboard clipboard = toolkit.getSystemClipboard();
         DataFlavor dataFlavor = DataFlavor.stringFlavor;
         try {
-            content = (String) clipboard.getContents(null).getTransferData(
-                    dataFlavor);
+            content = (String) clipboard.getContents(null).getTransferData(dataFlavor);
         } catch (UnsupportedFlavorException e) {
         } catch (IOException e) {
         }
         return content;
-
     }
 
     void setClipboardString(final JTextComponent jtc, final String content) {
@@ -932,29 +843,27 @@
         Clipboard clipboard = toolkit.getSystemClipboard();
         StringSelection dataFlavor = new StringSelection(content);
         clipboard.setContents(dataFlavor, dataFlavor);
-
     }
 
     public void testCopy() throws Exception {
         // TODO: uncomment when System clipboard is properly supported
-//        if (jtc.getToolkit().getSystemClipboard() == null)
-//            return;
-//        jtc.setText("JTextComponent");
-//        setClipboardString(jtc, "XXX");
-//        jtc.copy();
-//        assertEquals("XXX", getClipboardString(jtc));
-//        assertNull(jtc.getSelectedText());
-//        assertEquals("JTextComponent", jtc.getText());
-//
-//        jtc.select(4, 8);
-//        jtc.copy();
-//        assertEquals("tCom", getClipboardString(jtc));
-//        assertEquals("tCom", jtc.getSelectedText());
-//        assertEquals("JTextComponent", jtc.getText());
+        //        if (jtc.getToolkit().getSystemClipboard() == null)
+        //            return;
+        //        jtc.setText("JTextComponent");
+        //        setClipboardString(jtc, "XXX");
+        //        jtc.copy();
+        //        assertEquals("XXX", getClipboardString(jtc));
+        //        assertNull(jtc.getSelectedText());
+        //        assertEquals("JTextComponent", jtc.getText());
+        //
+        //        jtc.select(4, 8);
+        //        jtc.copy();
+        //        assertEquals("tCom", getClipboardString(jtc));
+        //        assertEquals("tCom", jtc.getSelectedText());
+        //        assertEquals("JTextComponent", jtc.getText());
     }
 
     public void testAddRemoveKeymaps() throws Exception {
-
         Keymap keyMap = jtc.getKeymap();
         Keymap keyMap1 = JTextComponent.addKeymap("First", keyMap);
         assertEquals("First", keyMap1.getName());
@@ -964,6 +873,7 @@
         Keymap keyMap4 = JTextComponent.addKeymap(null, null);
         assertEquals("Third", keyMap3.getName());
         Keymap keyMap5 = JTextComponent.addKeymap("Fifth", keyMap2);
+        assertNotNull(keyMap5);
         assertEquals(keyMap, keyMap1.getResolveParent());
         assertEquals(keyMap2.getResolveParent(), keyMap1);
         assertNull(keyMap3.getResolveParent());
@@ -972,7 +882,6 @@
         assertEquals(keyMap2, JTextComponent.getKeymap("Second"));
         assertEquals(keyMap3, JTextComponent.getKeymap("Third"));
         assertNull(JTextComponent.getKeymap("Fourth"));
-
         JTextComponent.removeKeymap("First");
         assertNull(JTextComponent.getKeymap("First"));
         //assertEquals(keyMap,JTextComponent.getKeymap("Second").//TODO
@@ -983,69 +892,46 @@
         assertNull(JTextComponent.getKeymap("Second"));
         assertNull(JTextComponent.getKeymap("Third"));
         assertNull(JTextComponent.getKeymap("Fifth"));
-
     }
 
     public void testLoadKeymap() throws Exception {
-
         JTextArea jta = new JTextArea();
         Keymap k = jta.getKeymap();
-        KeyStroke keyStroke1 = KeyStroke.getKeyStroke(KeyEvent.VK_A,
-                InputEvent.CTRL_MASK);
-        KeyStroke keyStroke2 = KeyStroke.getKeyStroke(KeyEvent.VK_B,
-                InputEvent.CTRL_MASK);
-        KeyStroke keyStroke3 = KeyStroke.getKeyStroke(KeyEvent.VK_C,
-                InputEvent.CTRL_MASK);
-        KeyStroke keyStroke4 = KeyStroke.getKeyStroke(KeyEvent.VK_D,
-                InputEvent.CTRL_MASK);
-        KeyStroke keyStroke5 = KeyStroke.getKeyStroke(KeyEvent.VK_E,
-                InputEvent.CTRL_MASK);
-        KeyStroke keyStroke6 = KeyStroke.getKeyStroke(KeyEvent.VK_F,
-                InputEvent.CTRL_MASK);
-
+        KeyStroke keyStroke1 = KeyStroke.getKeyStroke(KeyEvent.VK_A, InputEvent.CTRL_MASK);
+        KeyStroke keyStroke2 = KeyStroke.getKeyStroke(KeyEvent.VK_B, InputEvent.CTRL_MASK);
+        KeyStroke keyStroke3 = KeyStroke.getKeyStroke(KeyEvent.VK_C, InputEvent.CTRL_MASK);
+        KeyStroke keyStroke4 = KeyStroke.getKeyStroke(KeyEvent.VK_D, InputEvent.CTRL_MASK);
+        KeyStroke keyStroke5 = KeyStroke.getKeyStroke(KeyEvent.VK_E, InputEvent.CTRL_MASK);
+        KeyStroke keyStroke6 = KeyStroke.getKeyStroke(KeyEvent.VK_F, InputEvent.CTRL_MASK);
         JTextComponent.KeyBinding keyBindings[] = {
-                new JTextComponent.KeyBinding(keyStroke1,
-                        "first"),
-                new JTextComponent.KeyBinding(keyStroke2,
-                        DefaultEditorKit.copyAction),
-                new JTextComponent.KeyBinding(keyStroke3,
-                        "second"),
-                new JTextComponent.KeyBinding(keyStroke4,
-                        DefaultEditorKit.pasteAction),
-                new JTextComponent.KeyBinding(keyStroke6,
-                        "first"),
-                new JTextComponent.KeyBinding(keyStroke5,
-                        "first")};
-        Action actions[] = {new SimpleTextAction("first"),
-                new SimpleTextAction("second"),
-                new DefaultEditorKit.CopyAction(),
-                new DefaultEditorKit.CutAction() };
-
+                new JTextComponent.KeyBinding(keyStroke1, "first"),
+                new JTextComponent.KeyBinding(keyStroke2, DefaultEditorKit.copyAction),
+                new JTextComponent.KeyBinding(keyStroke3, "second"),
+                new JTextComponent.KeyBinding(keyStroke4, DefaultEditorKit.pasteAction),
+                new JTextComponent.KeyBinding(keyStroke6, "first"),
+                new JTextComponent.KeyBinding(keyStroke5, "first") };
+        Action actions[] = { new SimpleTextAction("first"), new SimpleTextAction("second"),
+                new DefaultEditorKit.CopyAction(), new DefaultEditorKit.CutAction() };
         JTextComponent.loadKeymap(k, keyBindings, actions);
         assertEquals(5, k.getBoundActions().length);
         assertEquals(5, k.getBoundKeyStrokes().length);
-
         isElement(k.getBoundActions(), actions[0], 3);
         isElement(k.getBoundActions(), actions[1], 1);
         isElement(k.getBoundActions(), actions[2], 1);
-
         isElement(k.getBoundKeyStrokes(), keyStroke1, 1);
         isElement(k.getBoundKeyStrokes(), keyStroke2, 1);
         isElement(k.getBoundKeyStrokes(), keyStroke3, 1);
         isElement(k.getBoundKeyStrokes(), keyStroke5, 1);
         isElement(k.getBoundKeyStrokes(), keyStroke6, 1);
-
         assertEquals(actions[0], k.getAction(keyStroke1));
         assertEquals(actions[2], k.getAction(keyStroke2));
         assertEquals(actions[1], k.getAction(keyStroke3));
         assertEquals(actions[0], k.getAction(keyStroke5));
         assertEquals(actions[0], k.getAction(keyStroke6));
         assertNull(k.getAction(keyStroke4));
-
         assertEquals(3, k.getKeyStrokesForAction(actions[0]).length);
         assertEquals(1, k.getKeyStrokesForAction(actions[1]).length);
         assertEquals(1, k.getKeyStrokesForAction(actions[2]).length);
-
         isElement(k.getKeyStrokesForAction(actions[0]), keyStroke1, 1);
         isElement(k.getKeyStrokesForAction(actions[0]), keyStroke5, 1);
         isElement(k.getKeyStrokesForAction(actions[0]), keyStroke6, 1);
@@ -1056,89 +942,77 @@
 
     public void testConstants() {
         assertEquals("default", JTextComponent.DEFAULT_KEYMAP);
-        assertEquals("focusAcceleratorKey",
-                JTextComponent.FOCUS_ACCELERATOR_KEY);
+        assertEquals("focusAcceleratorKey", JTextComponent.FOCUS_ACCELERATOR_KEY);
     }
 
     public void testJTextComponent_KeyBinding() {
-        KeyStroke keyStroke = KeyStroke.getKeyStroke(KeyEvent.VK_F,
-                InputEvent.CTRL_MASK);
-
-        String name = DefaultEditorKit.selectAllAction;
-        JTextComponent.KeyBinding keyBinding = new JTextComponent.KeyBinding(
-                keyStroke, s);
+        KeyStroke keyStroke = KeyStroke.getKeyStroke(KeyEvent.VK_F, InputEvent.CTRL_MASK);
+        JTextComponent.KeyBinding keyBinding = new JTextComponent.KeyBinding(keyStroke, s);
         assertNotNull(keyBinding);
         assertEquals(keyStroke, keyBinding.key);
         assertEquals(s, keyBinding.actionName);
     }
+
     // Serialization is not supported now by Swing
     /*public void testSerialization() throws Exception {
-        jtc.setText("JTextComponent");
-        jtc.setCaretColor(color);
-        jtc.setSelectionColor(color);
-        jtc.setSelectedTextColor(color);
-        jtc.setDisabledTextColor(color);
-        //jtc.select(5,8);
-        jtc.setMargin(new Insets(10, 20, 30, 40));
-        //jtc.setKeymap(new SimpleKeyMap("KeyMap"));
-        jtc.setKeymap(JTextComponent.addKeymap("KeyMap", null));
-        jtc.setEditable(false);
-        jtc.setDragEnabled(true);
-        jtc.addInputMethodListener(new SimpleInputMethodListener("1"));
-        jtc.addCaretListener(new SimpleCaretListener("1"));
-        jtc.setFocusAccelerator('a');
-        jtc.setComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT);
-
-        JTextArea jtc1 = new JTextArea();
-
-        try {
-            FileOutputStream fo = new FileOutputStream("tmp");
-            ObjectOutputStream so = new ObjectOutputStream(fo);
-            so.writeObject(jtc);
-            so.flush();
-            so.close();
-            FileInputStream fi = new FileInputStream("tmp");
-            ObjectInputStream si = new ObjectInputStream(fi);
-            jtc1 = (JTextArea) si.readObject();
-            si.close();
-        } catch (Exception e) {
-            assertTrue("seralization failed" + e.getMessage(),false);
-        }
-
-        assertEquals("JTextComponent", jtc1.getText());
-        assertEquals(color, jtc1.getCaretColor());
-        assertEquals(color, jtc1.getSelectionColor());
-        assertEquals(color, jtc1.getSelectedTextColor());
-        assertEquals(color, jtc1.getDisabledTextColor());
-        assertNull(jtc1.getSelectedText());
-        assertEquals(0, jtc1.getCaretPosition());
-        assertEquals(new Insets(10, 20, 30, 40), jtc1.getMargin());
-        assertNotSame("KeyMap", jtc1.getKeymap().getName());
-        assertFalse(jtc1.isEditable());
-        assertTrue(jtc1.getDragEnabled());
-        assertEquals(0, jtc1.getCaretListeners().length);
-        assertEquals(0, jtc1.getInputMethodListeners().length);
-        assertEquals('A', jtc1.getFocusAccelerator());
-        assertNotSame(ComponentOrientation.RIGHT_TO_LEFT, jtc1
-                .getComponentOrientation());
-        assertEquals(0, jtc1.getHighlighter().getHighlights().length);
-    } */
-
+     jtc.setText("JTextComponent");
+     jtc.setCaretColor(color);
+     jtc.setSelectionColor(color);
+     jtc.setSelectedTextColor(color);
+     jtc.setDisabledTextColor(color);
+     //jtc.select(5,8);
+     jtc.setMargin(new Insets(10, 20, 30, 40));
+     //jtc.setKeymap(new SimpleKeyMap("KeyMap"));
+     jtc.setKeymap(JTextComponent.addKeymap("KeyMap", null));
+     jtc.setEditable(false);
+     jtc.setDragEnabled(true);
+     jtc.addInputMethodListener(new SimpleInputMethodListener("1"));
+     jtc.addCaretListener(new SimpleCaretListener("1"));
+     jtc.setFocusAccelerator('a');
+     jtc.setComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT);
+
+     JTextArea jtc1 = new JTextArea();
+
+     try {
+     FileOutputStream fo = new FileOutputStream("tmp");
+     ObjectOutputStream so = new ObjectOutputStream(fo);
+     so.writeObject(jtc);
+     so.flush();
+     so.close();
+     FileInputStream fi = new FileInputStream("tmp");
+     ObjectInputStream si = new ObjectInputStream(fi);
+     jtc1 = (JTextArea) si.readObject();
+     si.close();
+     } catch (Exception e) {
+     assertTrue("seralization failed" + e.getMessage(),false);
+     }
+
+     assertEquals("JTextComponent", jtc1.getText());
+     assertEquals(color, jtc1.getCaretColor());
+     assertEquals(color, jtc1.getSelectionColor());
+     assertEquals(color, jtc1.getSelectedTextColor());
+     assertEquals(color, jtc1.getDisabledTextColor());
+     assertNull(jtc1.getSelectedText());
+     assertEquals(0, jtc1.getCaretPosition());
+     assertEquals(new Insets(10, 20, 30, 40), jtc1.getMargin());
+     assertNotSame("KeyMap", jtc1.getKeymap().getName());
+     assertFalse(jtc1.isEditable());
+     assertTrue(jtc1.getDragEnabled());
+     assertEquals(0, jtc1.getCaretListeners().length);
+     assertEquals(0, jtc1.getInputMethodListeners().length);
+     assertEquals('A', jtc1.getFocusAccelerator());
+     assertNotSame(ComponentOrientation.RIGHT_TO_LEFT, jtc1
+     .getComponentOrientation());
+     assertEquals(0, jtc1.getHighlighter().getHighlights().length);
+     } */
     public void testKeyMap() throws Exception {
-        KeyStroke keyStrokeA = KeyStroke.getKeyStroke(KeyEvent.VK_A,
-                InputEvent.CTRL_MASK);
-        KeyStroke keyStrokeB = KeyStroke.getKeyStroke(KeyEvent.VK_B,
-                InputEvent.CTRL_MASK);
-        KeyStroke keyStrokeC = KeyStroke.getKeyStroke(KeyEvent.VK_C,
-                InputEvent.CTRL_MASK);
-        KeyStroke keyStrokeD = KeyStroke.getKeyStroke(KeyEvent.VK_D,
-                InputEvent.CTRL_MASK);
-
+        KeyStroke keyStrokeA = KeyStroke.getKeyStroke(KeyEvent.VK_A, InputEvent.CTRL_MASK);
+        KeyStroke keyStrokeB = KeyStroke.getKeyStroke(KeyEvent.VK_B, InputEvent.CTRL_MASK);
+        KeyStroke keyStrokeC = KeyStroke.getKeyStroke(KeyEvent.VK_C, InputEvent.CTRL_MASK);
         TextAction A = new DefaultEditorKit.CopyAction();
         TextAction B = new DefaultEditorKit.CutAction();
         TextAction C = new DefaultEditorKit.PasteAction();
         TextAction D = new DefaultEditorKit.DefaultKeyTypedAction();
-
         Keymap grand_parent = JTextComponent.addKeymap("grand_parent", null);
         grand_parent.addActionForKeyStroke(keyStrokeA, A);
         Keymap parent = JTextComponent.addKeymap("parent", grand_parent);
@@ -1146,7 +1020,6 @@
         parent.setDefaultAction(D);
         Keymap keymap = JTextComponent.addKeymap("test", parent);
         keymap.addActionForKeyStroke(keyStrokeC, C);
-
         assertFalse(keymap.isLocallyDefined(keyStrokeB));
         assertFalse(keymap.isLocallyDefined(keyStrokeA));
         assertTrue(keymap.isLocallyDefined(keyStrokeC));
@@ -1155,13 +1028,11 @@
         assertEquals(C, keymap.getAction(keyStrokeC));
         assertEquals(D, keymap.getDefaultAction());
     }
+
     public void testKeymapToString() {
-        KeyStroke keyStrokeX = KeyStroke.getKeyStroke(KeyEvent.VK_X,
-                InputEvent.CTRL_MASK);
-        KeyStroke keyStrokeY = KeyStroke.getKeyStroke(KeyEvent.VK_Y,
-                InputEvent.CTRL_MASK);
-        KeyStroke keyStrokeZ = KeyStroke.getKeyStroke(KeyEvent.VK_Z,
-                InputEvent.CTRL_MASK);
+        KeyStroke keyStrokeX = KeyStroke.getKeyStroke(KeyEvent.VK_X, InputEvent.CTRL_MASK);
+        KeyStroke keyStrokeY = KeyStroke.getKeyStroke(KeyEvent.VK_Y, InputEvent.CTRL_MASK);
+        KeyStroke keyStrokeZ = KeyStroke.getKeyStroke(KeyEvent.VK_Z, InputEvent.CTRL_MASK);
         Action a = new SimpleTextAction("a");//DefaultEditorKit.selectWordDoing;
         Action b = new SimpleTextAction("b");//DefaultEditorKit.selectLineDoing;
         jtc.getKeymap().addActionForKeyStroke(keyStrokeX, a);
@@ -1171,14 +1042,12 @@
         String sample2 = (keyStrokeX + "=" + a).replaceFirst("[/$]", "");
         String sample3 = (keyStrokeZ + "=" + b).replaceFirst("[/$]", "");
         String test = jtc.getKeymap().toString().replaceAll("[/$]", "");
-
         assertTrue(test.indexOf(sample1) > 0);
         assertTrue(test.indexOf(sample2) > 0);
         assertTrue(test.indexOf(sample3) > 0);
-        test = test.replaceFirst(sample1, "").replaceFirst(sample2, "")
-                .replaceFirst(sample3, "");
+        test = test.replaceFirst(sample1, "").replaceFirst(sample2, "").replaceFirst(sample3,
+                "");
         assertEquals("Keymap[BasicTextAreaUI]{, , }", test);
-
         jtc.getKeymap().removeKeyStrokeBinding(keyStrokeX);
         jtc.getKeymap().removeKeyStrokeBinding(keyStrokeY);
         jtc.getKeymap().removeKeyStrokeBinding(keyStrokeZ);

Modified: harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/text/JTextComponent_AccessibleJTextComponentTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/text/JTextComponent_AccessibleJTextComponentTest.java?view=diff&rev=479418&r1=479417&r2=479418
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/text/JTextComponent_AccessibleJTextComponentTest.java (original)
+++ harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/text/JTextComponent_AccessibleJTextComponentTest.java Sun Nov 26 12:15:43 2006
@@ -30,7 +30,6 @@
 import java.beans.PropertyChangeListener;
 import java.io.IOException;
 import java.util.Vector;
-
 import javax.accessibility.AccessibleContext;
 import javax.accessibility.AccessibleRole;
 import javax.accessibility.AccessibleState;
@@ -43,8 +42,7 @@
 import javax.swing.text.JTextComponentTest.JTextComp;
 import javax.swing.text.JTextComponentTest.SimplePropertyChangeListener;
 
-public class JTextComponent_AccessibleJTextComponentTest extends
-        SwingTestCase {
+public class JTextComponent_AccessibleJTextComponentTest extends SwingTestCase {
     JFrame jf;
 
     JTextComponent jtc;
@@ -80,7 +78,7 @@
     String text;
 
     class AccessiblePropertyChangeListener implements PropertyChangeListener {
-        Vector PropertyNames = new Vector();
+        Vector<String> PropertyNames = new Vector<String>();
 
         Object oldValues[] = new Object[5];
 
@@ -97,13 +95,12 @@
 
         public void propertyChange(final PropertyChangeEvent e) {
             for (int i = 0; i < PropertyNames.size(); i++) {
-                if (e.getPropertyName() == (String) PropertyNames.get(i)) {
+                if (e.getPropertyName() == PropertyNames.get(i)) {
                     oldValues[i] = e.getOldValue();
                     newValues[i] = e.getNewValue();
                     wasPropertyChange[i] = true;
                 }
             }
-
         }
 
         public void reset() {
@@ -129,11 +126,11 @@
         }
         assertTrue(cond);
         assertEquals(count, k);
-
     }
 
     void assertEqualsPropertyChange(final AccessiblePropertyChangeListener listener,
-            final String s[], final Object oldValues[], final Object newValues[], final boolean b[]) {
+            final String s[], final Object oldValues[], final Object newValues[],
+            final boolean b[]) {
         for (int i = 0; i < listener.PropertyNames.size(); i++) {
             for (int j = 0; j < s.length; j++) {
                 if (s[j] == listener.PropertyNames.get(i)) {
@@ -154,22 +151,20 @@
         assertEquals(newValue, e.getNewValue());
     }
 
-
     public JTextComponent_AccessibleJTextComponentTest() {
         setIgnoreNotImplemented(true);
     }
 
+    @Override
     protected void setUp() throws Exception {
         super.setUp();
         jf = new JFrame();
         bWasException = false;
         str = null;
         listener = new AccessiblePropertyChangeListener();
-        text = ("JTextComponent\n" + "\u05dc"
-                + "JTextComponent.AccessibleJTextComponent");
+        text = ("JTextComponent\n" + "\u05dc" + "JTextComponent.AccessibleJTextComponent");
         jtc = new JTextArea(text);
-        accessible = (JTextComponent.AccessibleJTextComponent) jtc
-                .getAccessibleContext();
+        accessible = (JTextComponent.AccessibleJTextComponent) jtc.getAccessibleContext();
         accessible.addPropertyChangeListener(listener);
         jf.getContentPane().add(jtc);
         jf.setLocation(200, 300);
@@ -177,6 +172,7 @@
         jf.pack();
     }
 
+    @Override
     protected void tearDown() throws Exception {
         jf.dispose();
         super.tearDown();
@@ -207,12 +203,10 @@
         sas.addAttribute(name1, value1);
         sas.addAttribute(name2, value2);
         doc = (AbstractDocument) jtc.getDocument();
-
-        for (int i = 0; i < 20; i++)
+        for (int i = 0; i < 20; i++) {
             samples[i] = getAttributeSetByIndex(doc, i);
-
+        }
         accessible.setAttributes(4, 6, sas);
-
         for (int i = 4; i < 7; i++) {
             as = getAttributeSetByIndex(doc, i);
             assertFalse(as.containsAttribute(name1, value1));
@@ -223,53 +217,44 @@
             assertEquals(as, accessible.getCharacterAttribute(i));
             assertEquals(as, getAttributeSetByIndex(doc, i));
         }
-
         jtc.setDocument(new DefaultStyledDocument());
-
         listener.reset();
         listener.InterestProperty(AccessibleContext.ACCESSIBLE_CARET_PROPERTY);
         jtc.setText("JTEXT_COMPONENT\n JTEXTCOMPONENT");
         obj_old[0] = new Integer(0);
         obj_new[0] = new Integer(31);
-
         assertEqualsPropertyChange(listener,
-                new String[] { AccessibleContext.ACCESSIBLE_CARET_PROPERTY },
-                obj_old, obj_new, was);
-
+                new String[] { AccessibleContext.ACCESSIBLE_CARET_PROPERTY }, obj_old, obj_new,
+                was);
         accessible.setAttributes(5, 8, sas);
         doc = (AbstractDocument) jtc.getDocument();
-
-        for (int i = 0; i < 20; i++)
+        for (int i = 0; i < 20; i++) {
             samples[i] = getAttributeSetByIndex(doc, i);
-
+        }
         for (int i = 5; i < 8; i++) {
             as = getAttributeSetByIndex(doc, i);
             assertEquals(sas, as);
             assertEquals(as, accessible.getCharacterAttribute(i));
         }
-
         for (int i = 0; i < 20; i++) {
-            if (i >= 5 && i < 7)
+            if (i >= 5 && i < 7) {
                 continue;
+            }
             as = samples[i];
             assertEquals(as, accessible.getCharacterAttribute(i));
             assertEquals(as, getAttributeSetByIndex(doc, i));
         }
-
     }
 
     public void testRemoveUpdate() throws Exception {
         listener.InterestProperty(AccessibleContext.ACCESSIBLE_TEXT_PROPERTY);
-
         try {
             jtc.getDocument().remove(0, 4);
         } catch (BadLocationException e) {
         }
         obj_new[0] = new Integer(0);
         assertEqualsPropertyChange(listener, s, obj_old, obj_new, was);
-
         listener.reset();
-
         try {
             jtc.getDocument().remove(5, 3);
         } catch (BadLocationException e) {
@@ -280,34 +265,27 @@
 
     public void testInsertUpdate() throws Exception {
         listener.InterestProperty(AccessibleContext.ACCESSIBLE_TEXT_PROPERTY);
-
         try {
             jtc.getDocument().insertString(0, "TEST", null);
         } catch (BadLocationException e) {
         }
-
         obj_new[0] = new Integer(0);
         assertEqualsPropertyChange(listener,
-                new String[] { AccessibleContext.ACCESSIBLE_TEXT_PROPERTY },
-                obj_old, obj_new, was);
-
+                new String[] { AccessibleContext.ACCESSIBLE_TEXT_PROPERTY }, obj_old, obj_new,
+                was);
         listener.reset();
-
         try {
             jtc.getDocument().insertString(3, "TEST", null);
         } catch (BadLocationException e) {
         }
-
         obj_new[0] = new Integer(3);
         assertEqualsPropertyChange(listener,
-                new String[] { AccessibleContext.ACCESSIBLE_TEXT_PROPERTY },
-                obj_old, obj_new, was);
-
+                new String[] { AccessibleContext.ACCESSIBLE_TEXT_PROPERTY }, obj_old, obj_new,
+                was);
     }
 
     public void testChangedUpdate() throws Exception {
         listener.InterestProperty(AccessibleContext.ACCESSIBLE_TEXT_PROPERTY);
-
         try {
             ((AbstractDocument) jtc.getDocument()).replace(0, 3, "TEST", null);
         } catch (BadLocationException e) {
@@ -315,23 +293,18 @@
         obj_new[0] = new Integer(0);
         assertEqualsPropertyChange(listener, s, obj_old, obj_new, was);
         listener.reset();
-
         try {
             ((AbstractDocument) jtc.getDocument()).replace(4, 5, "TEST", null);
         } catch (BadLocationException e) {
         }
-
         obj_new[0] = new Integer(4);
         assertEqualsPropertyChange(listener, s, obj_old, obj_new, was);
     }
 
     public void testCaretUpdate() throws Exception {
         listener.InterestProperty(AccessibleContext.ACCESSIBLE_CARET_PROPERTY);
-        listener
-                .InterestProperty(AccessibleContext.ACCESSIBLE_SELECTION_PROPERTY);
-
-        String s[] = new String[] {
-                AccessibleContext.ACCESSIBLE_CARET_PROPERTY,
+        listener.InterestProperty(AccessibleContext.ACCESSIBLE_SELECTION_PROPERTY);
+        String s[] = new String[] { AccessibleContext.ACCESSIBLE_CARET_PROPERTY,
                 AccessibleContext.ACCESSIBLE_SELECTION_PROPERTY };
         obj_old = new Object[] { null, null };
         obj_new = new Object[2];
@@ -340,7 +313,6 @@
         obj_new[0] = new Integer(4);
         obj_old[0] = new Integer(0);
         assertEqualsPropertyChange(listener, s, obj_old, obj_new, was);
-
         listener.reset();
         jtc.moveCaretPosition(7);
         obj_old[0] = new Integer(4);
@@ -348,14 +320,12 @@
         was[1] = true;
         obj_new[1] = "tCo";
         assertEqualsPropertyChange(listener, s, obj_old, obj_new, was);
-
         listener.reset();
         jtc.moveCaretPosition(6);
         obj_old[0] = new Integer(7);
         obj_new[0] = new Integer(6);
         obj_new[1] = "tC";
         assertEqualsPropertyChange(listener, s, obj_old, obj_new, was);
-
         listener.reset();
         jtc.moveCaretPosition(4);
         obj_old[0] = new Integer(6);
@@ -374,18 +344,24 @@
     }
 
     private void checkStateSet(final AccessibleStateSet ass) {
-        if (jtc.isEnabled())
-           checkState(ass, AccessibleState.ENABLED);
-        if (jtc.isFocusable())
+        if (jtc.isEnabled()) {
+            checkState(ass, AccessibleState.ENABLED);
+        }
+        if (jtc.isFocusable()) {
             checkState(ass, AccessibleState.FOCUSABLE);
-        if (jtc.isVisible())
+        }
+        if (jtc.isVisible()) {
             checkState(ass, AccessibleState.VISIBLE);
-        if (jtc.isShowing())
+        }
+        if (jtc.isShowing()) {
             checkState(ass, AccessibleState.SHOWING);
-        if (jtc.isFocusOwner())
+        }
+        if (jtc.isFocusOwner()) {
             checkState(ass, AccessibleState.FOCUSED);
-        if (jtc.isOpaque())
+        }
+        if (jtc.isOpaque()) {
             checkState(ass, AccessibleState.OPAQUE);
+        }
         assertEquals(0, ass.toArray().length);
     }
 
@@ -396,9 +372,7 @@
         ass.remove(AccessibleState.MULTI_LINE);
         ass.remove(AccessibleState.EDITABLE);
         checkStateSet(ass);
-
         jtc.setEditable(false);
-
         ass = accessible.getAccessibleStateSet();
         assertTrue(ass.contains(AccessibleState.MULTI_LINE));
         ass.remove(AccessibleState.MULTI_LINE);
@@ -427,16 +401,16 @@
         jtc.setDocument(new DefaultStyledDocument());
         jtc.setText(text);
         accessible.insertTextAtIndex(2, "SSS");
-        assertEquals(text.substring(0, 2) + "SSS"
-                + text.substring(2, text.length()), jtc.getText());
+        assertEquals(text.substring(0, 2) + "SSS" + text.substring(2, text.length()), jtc
+                .getText());
     }
 
     public void testReplaceText() throws Exception {
         accessible.replaceText(5, 8, "XXX");
         assertEquals(text.replaceFirst("Com", "XXX"), jtc.getText());
         try {
-           accessible.replaceText(8, 5, "ZZZ");
-           assertEquals(text.replaceFirst("Com", "XXXZZZ"), jtc.getText());
+            accessible.replaceText(8, 5, "ZZZ");
+            assertEquals(text.replaceFirst("Com", "XXXZZZ"), jtc.getText());
         } catch (IllegalArgumentException e) {
             bWasException = true;
         }
@@ -447,14 +421,14 @@
 
     public void testGetTextRange() {
         assertEquals("JTextCo", accessible.getTextRange(0, 7));
-        assertEquals("omponent\n" + "\u05dc" + "JTe", accessible.getTextRange(
-                6, 19));
+        assertEquals("omponent\n" + "\u05dc" + "JTe", accessible.getTextRange(6, 19));
     }
 
     public void testGetAccessibleActionDescription() {
-        for (int i = 0; i < jtc.getActions().length; i++)
+        for (int i = 0; i < jtc.getActions().length; i++) {
             assertEquals(jtc.getActions()[i].getValue(Action.NAME), accessible
                     .getAccessibleActionDescription(i));
+        }
     }
 
     public void testGetSelectedText() throws Exception {
@@ -462,13 +436,11 @@
         assertNull(accessible.getSelectedText());
         jtc.moveCaretPosition(8);
         assertEquals("Com", accessible.getSelectedText());
-
     }
 
     public void testSelectText() throws Exception {
         accessible.selectText(5, 8);
         assertEquals("Com", accessible.getSelectedText());
-
     }
 
     public void testDelete() throws Exception {
@@ -485,7 +457,6 @@
         if (isHarmony()) {
             assertTrue(bWasException);
         }
-
         bWasException = false;
         try {
             accessible.delete(-6, -4);
@@ -493,7 +464,6 @@
         } catch (IllegalArgumentException e) {
             bWasException = true;
         }
-
         if (isHarmony()) {
             assertTrue(bWasException);
         }
@@ -505,8 +475,7 @@
         Clipboard clipboard = toolkit.getSystemClipboard();
         DataFlavor dataFlavor = DataFlavor.stringFlavor;
         try {
-            content = (String) clipboard.getContents(null).getTransferData(
-                    dataFlavor);
+            content = (String) clipboard.getContents(null).getTransferData(dataFlavor);
         } catch (UnsupportedFlavorException e) {
         } catch (IOException e) {
         }
@@ -522,22 +491,22 @@
 
     public void testCut() throws Exception {
         // TODO: uncomment when System clipboard is properly supported
-//        if (jtc.getToolkit().getSystemClipboard() == null)
-//            return;
-//        setClipboardString(jtc, "XXX");
-//        accessible.cut(2, 2);
-//        assertEquals("XXX", getClipboardString(jtc));
-//        assertEquals(2, jtc.getCaretPosition());
-//        assertEquals(text, jtc.getText());
-//
-//        accessible.cut(5, 8);
-//        assertEquals(5, jtc.getCaretPosition());
-//        assertEquals("Com", getClipboardString(jtc));
-//        assertEquals(text.replaceFirst("Com", ""), jtc.getText());
-//
-//        accessible.cut(9, 4);
-//        assertEquals(9, jtc.getCaretPosition());
-//        assertEquals(text.replaceFirst("Com", ""), jtc.getText());
+        //        if (jtc.getToolkit().getSystemClipboard() == null)
+        //            return;
+        //        setClipboardString(jtc, "XXX");
+        //        accessible.cut(2, 2);
+        //        assertEquals("XXX", getClipboardString(jtc));
+        //        assertEquals(2, jtc.getCaretPosition());
+        //        assertEquals(text, jtc.getText());
+        //
+        //        accessible.cut(5, 8);
+        //        assertEquals(5, jtc.getCaretPosition());
+        //        assertEquals("Com", getClipboardString(jtc));
+        //        assertEquals(text.replaceFirst("Com", ""), jtc.getText());
+        //
+        //        accessible.cut(9, 4);
+        //        assertEquals(9, jtc.getCaretPosition());
+        //        assertEquals(text.replaceFirst("Com", ""), jtc.getText());
     }
 
     public void testDoAccessibleAction() {
@@ -548,16 +517,16 @@
 
     public void testPaste() throws Exception {
         // TODO: uncomment when System clipboard is properly supported
-//        if (jtc.getToolkit().getSystemClipboard() == null)
-//            return;
-//        setClipboardString(jtc, "XXX");
-//        accessible.paste(5);
-//        assertEquals(text.substring(0, 5) + "XXX"
-//                + text.substring(5, text.length()), jtc.getText());
-//        assertEquals(8, jtc.getCaretPosition());
-//        setClipboardString(jtc, "");
-//        accessible.paste(10);
-//        assertEquals(10, jtc.getCaretPosition());
+        //        if (jtc.getToolkit().getSystemClipboard() == null)
+        //            return;
+        //        setClipboardString(jtc, "XXX");
+        //        accessible.paste(5);
+        //        assertEquals(text.substring(0, 5) + "XXX"
+        //                + text.substring(5, text.length()), jtc.getText());
+        //        assertEquals(8, jtc.getCaretPosition());
+        //        setClipboardString(jtc, "");
+        //        accessible.paste(10);
+        //        assertEquals(10, jtc.getCaretPosition());
     }
 
     public void testGetSelectionStartEnd() throws Exception {

Modified: harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/text/JTextComponent_AccessibleJTextComponent_variousTextTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/text/JTextComponent_AccessibleJTextComponent_variousTextTest.java?view=diff&rev=479418&r1=479417&r2=479418
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/text/JTextComponent_AccessibleJTextComponent_variousTextTest.java (original)
+++ harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/text/JTextComponent_AccessibleJTextComponent_variousTextTest.java Sun Nov 26 12:15:43 2006
@@ -23,55 +23,60 @@
 import java.awt.Point;
 import java.awt.Rectangle;
 import javax.accessibility.AccessibleText;
+import javax.swing.BasicSwingTestCase;
 import javax.swing.JFrame;
 import javax.swing.JTextArea;
 import javax.swing.JTextField;
-import javax.swing.SwingTestCase;
 import javax.swing.SwingUtilities;
 import junit.framework.TestCase;
 
-
 public class JTextComponent_AccessibleJTextComponent_variousTextTest extends TestCase {
     JFrame jf;
+
     JTextComponent jtc;
+
     JTextComponent.AccessibleJTextComponent accessible;
+
     boolean bWasException;
+
     String str;
+
     JTextField jep;
+
     Rectangle rect;
+
     String text;
 
+    @Override
     protected void setUp() throws Exception {
         super.setUp();
         jf = new JFrame();
         bWasException = false;
         jtc = new JTextArea();
-        text = ("JTextComponent\n"+  "cJTextComponent.AccessibleJTextComponent");
+        text = ("JTextComponent\n" + "cJTextComponent.AccessibleJTextComponent");
         jtc.setText(text);
-        accessible = (JTextComponent.AccessibleJTextComponent)jtc.getAccessibleContext();
+        accessible = (JTextComponent.AccessibleJTextComponent) jtc.getAccessibleContext();
         jf.getContentPane().add(jtc);
-        jf.setLocation(200,300);
-        jf.setSize(200,300);
+        jf.setLocation(200, 300);
+        jf.setSize(200, 300);
         jf.pack();
     }
 
-
+    @Override
     protected void tearDown() throws Exception {
         jf.dispose();
         super.tearDown();
     }
 
-    private Rectangle getCharBounds(final JTextComponent component,final int ind) {
+    private Rectangle getCharBounds(final JTextComponent component, final int ind) {
         Rectangle rect1 = null;
         Rectangle rect2 = null;
         try {
-            rect1 = component.getUI().modelToView(component, ind,
-                    Position.Bias.Forward);
+            rect1 = component.getUI().modelToView(component, ind, Position.Bias.Forward);
         } catch (BadLocationException e) {
         }
         try {
-            rect2 = component.getUI().modelToView(component,
-                    ind + 1, Position.Bias.Backward);
+            rect2 = component.getUI().modelToView(component, ind + 1, Position.Bias.Backward);
         } catch (BadLocationException e) {
         }
         assertNotNull(rect1);
@@ -81,77 +86,57 @@
         return rect1;
     }
 
-
     public void testGetBeforeAfterAtIndex() throws Exception {
         Runnable test = new Runnable() {
             public void run() {
-                jtc.setText("In\n" +
-                        " this test. for AccessibleJTextComponent\n" +
-                        "LALALA");
+                jtc.setText("In\n" + " this test. for AccessibleJTextComponent\n" + "LALALA");
             }
         };
         SwingUtilities.invokeAndWait(test);
-
-        assertEquals("t",accessible.getAtIndex(AccessibleText.CHARACTER,4));
-        assertEquals("this",accessible.getAtIndex(AccessibleText.WORD,4));
-        assertEquals(" this test. for AccessibleJTextComponent\n",
-            accessible.getAtIndex(AccessibleText.SENTENCE, 4));
-
-        assertEquals(" ",accessible.getAtIndex(AccessibleText.CHARACTER,3));
-        assertEquals(" ",accessible.getAtIndex(AccessibleText.WORD,3));
-        assertEquals(" this test. for AccessibleJTextComponent\n",
-                accessible.getAtIndex(AccessibleText.SENTENCE, 3));
-
-        assertEquals(" ",accessible.getAtIndex(AccessibleText.CHARACTER,8));
-        assertEquals(" ",accessible.getAtIndex(AccessibleText.WORD,8));
-        assertEquals(" this test. for AccessibleJTextComponent\n",
-                accessible.getAtIndex(AccessibleText.SENTENCE, 8));
-
-        assertEquals("h",accessible.getAfterIndex(AccessibleText.CHARACTER,4));
-        assertEquals("LALALA\n",
-            accessible.getAfterIndex(AccessibleText.SENTENCE, 4));
-
-        assertEquals("t",accessible.getAfterIndex(AccessibleText.CHARACTER,3));
-        assertEquals("this",accessible.getAfterIndex(AccessibleText.WORD,3));
-        assertEquals("LALALA\n",
-            accessible.getAfterIndex(AccessibleText.SENTENCE, 3));
-
-        assertEquals("t",accessible.getAfterIndex(AccessibleText.CHARACTER,8));
-        assertEquals("test",accessible.getAfterIndex(AccessibleText.WORD,8));
-        assertEquals("LALALA\n",
-                accessible.getAfterIndex(AccessibleText.SENTENCE, 8));
-        assertNull(accessible.getAfterIndex(AccessibleText.SENTENCE,
-                jtc.getDocument().getLength() -2));
-
-        assertEquals(" ",accessible.getBeforeIndex(AccessibleText.CHARACTER,4));
-        assertEquals(" ",accessible.getBeforeIndex(AccessibleText.WORD,4));
-        assertEquals("In\n",
-            accessible.getBeforeIndex(AccessibleText.SENTENCE, 4));
-
-        assertEquals("\n",accessible.getBeforeIndex(AccessibleText.CHARACTER,3));
-        assertEquals("\n",accessible.getBeforeIndex(AccessibleText.WORD,3));
-        assertEquals("In\n",
-                accessible.getBeforeIndex(AccessibleText.SENTENCE, 3));
-
-        assertEquals("s",accessible.getBeforeIndex(AccessibleText.CHARACTER,8));
-        assertEquals("this",accessible.getBeforeIndex(AccessibleText.WORD,8));
-        assertEquals("In\n",
-                accessible.getBeforeIndex(AccessibleText.SENTENCE, 8));
+        assertEquals("t", accessible.getAtIndex(AccessibleText.CHARACTER, 4));
+        assertEquals("this", accessible.getAtIndex(AccessibleText.WORD, 4));
+        assertEquals(" this test. for AccessibleJTextComponent\n", accessible.getAtIndex(
+                AccessibleText.SENTENCE, 4));
+        assertEquals(" ", accessible.getAtIndex(AccessibleText.CHARACTER, 3));
+        assertEquals(" ", accessible.getAtIndex(AccessibleText.WORD, 3));
+        assertEquals(" this test. for AccessibleJTextComponent\n", accessible.getAtIndex(
+                AccessibleText.SENTENCE, 3));
+        assertEquals(" ", accessible.getAtIndex(AccessibleText.CHARACTER, 8));
+        assertEquals(" ", accessible.getAtIndex(AccessibleText.WORD, 8));
+        assertEquals(" this test. for AccessibleJTextComponent\n", accessible.getAtIndex(
+                AccessibleText.SENTENCE, 8));
+        assertEquals("h", accessible.getAfterIndex(AccessibleText.CHARACTER, 4));
+        assertEquals("LALALA\n", accessible.getAfterIndex(AccessibleText.SENTENCE, 4));
+        assertEquals("t", accessible.getAfterIndex(AccessibleText.CHARACTER, 3));
+        assertEquals("this", accessible.getAfterIndex(AccessibleText.WORD, 3));
+        assertEquals("LALALA\n", accessible.getAfterIndex(AccessibleText.SENTENCE, 3));
+        assertEquals("t", accessible.getAfterIndex(AccessibleText.CHARACTER, 8));
+        assertEquals("test", accessible.getAfterIndex(AccessibleText.WORD, 8));
+        assertEquals("LALALA\n", accessible.getAfterIndex(AccessibleText.SENTENCE, 8));
+        assertNull(accessible.getAfterIndex(AccessibleText.SENTENCE, jtc.getDocument()
+                .getLength() - 2));
+        assertEquals(" ", accessible.getBeforeIndex(AccessibleText.CHARACTER, 4));
+        assertEquals(" ", accessible.getBeforeIndex(AccessibleText.WORD, 4));
+        assertEquals("In\n", accessible.getBeforeIndex(AccessibleText.SENTENCE, 4));
+        assertEquals("\n", accessible.getBeforeIndex(AccessibleText.CHARACTER, 3));
+        assertEquals("\n", accessible.getBeforeIndex(AccessibleText.WORD, 3));
+        assertEquals("In\n", accessible.getBeforeIndex(AccessibleText.SENTENCE, 3));
+        assertEquals("s", accessible.getBeforeIndex(AccessibleText.CHARACTER, 8));
+        assertEquals("this", accessible.getBeforeIndex(AccessibleText.WORD, 8));
+        assertEquals("In\n", accessible.getBeforeIndex(AccessibleText.SENTENCE, 8));
         assertNull(accessible.getBeforeIndex(AccessibleText.SENTENCE, 1));
     }
 
-
-
-    public void testGetCharacterBounds()  throws Exception{
-        Runnable test = new Runnable(){
-            public void run(){
+    public void testGetCharacterBounds() throws Exception {
+        Runnable test = new Runnable() {
+            public void run() {
                 jtc.setText("\u05dc" + "\u0061" + "\u05dc" + "\u0061");
             }
         };
         SwingUtilities.invokeAndWait(test);
-        if (SwingTestCase.isHarmony()) {
-            assertEquals(getCharBounds(jtc,1),accessible.getCharacterBounds(1));
-            assertEquals(getCharBounds(jtc,2),accessible.getCharacterBounds(2));
+        if (BasicSwingTestCase.isHarmony()) {
+            assertEquals(getCharBounds(jtc, 1), accessible.getCharacterBounds(1));
+            assertEquals(getCharBounds(jtc, 2), accessible.getCharacterBounds(2));
         }
     }
 
@@ -164,19 +149,19 @@
             }
         };
         SwingUtilities.invokeAndWait(test);
-
         rect = null;
         try {
             rect = jtc.modelToView(1);
-        } catch (BadLocationException e){}
+        } catch (BadLocationException e) {
+        }
         assertNotNull(rect);
-        assertEquals(1,accessible.getIndexAtPoint(new Point(rect.x,rect.y)));
-
+        assertEquals(1, accessible.getIndexAtPoint(new Point(rect.x, rect.y)));
         rect = null;
         try {
             rect = jtc.modelToView(2);
-        } catch (BadLocationException e){}
+        } catch (BadLocationException e) {
+        }
         assertNotNull(rect);
-        assertEquals(2,accessible.getIndexAtPoint(new Point(rect.x,rect.y)));
+        assertEquals(2, accessible.getIndexAtPoint(new Point(rect.x, rect.y)));
     }
 }

Modified: harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/text/JTextComponent_IMLocationTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/text/JTextComponent_IMLocationTest.java?view=diff&rev=479418&r1=479417&r2=479418
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/text/JTextComponent_IMLocationTest.java (original)
+++ harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/text/JTextComponent_IMLocationTest.java Sun Nov 26 12:15:43 2006
@@ -19,6 +19,7 @@
  * @version $Revision$
  */
 package javax.swing.text;
+
 import java.awt.Color;
 import java.awt.Point;
 import java.awt.Rectangle;
@@ -27,39 +28,48 @@
 import java.awt.im.InputMethodRequests;
 import java.text.AttributedCharacterIterator;
 import java.text.AttributedString;
+import java.text.AttributedCharacterIterator.Attribute;
 import java.util.HashMap;
 import java.util.Map;
-
 import javax.swing.JFrame;
 import javax.swing.JTextArea;
 import javax.swing.SwingWaitTestCase;
-
 import org.apache.harmony.awt.text.ComposedTextParams;
 import org.apache.harmony.awt.text.PropertyNames;
 
 public class JTextComponent_IMLocationTest extends SwingWaitTestCase {
     JTextArea jta;
+
     JFrame jf;
+
     InputMethodEvent ime;
-    Map map;
+
+    Map<Attribute, Object> map;
+
     AbstractDocument doc;
+
     AttributedCharacterIterator iter;
+
     AttributedString attrString;
-    static final AttributedCharacterIterator.Attribute SEGMENT_ATTRIBUTE =
-        AttributedCharacterIterator.Attribute.INPUT_METHOD_SEGMENT;
+
+    static final AttributedCharacterIterator.Attribute SEGMENT_ATTRIBUTE = AttributedCharacterIterator.Attribute.INPUT_METHOD_SEGMENT;
+
     static final String initialContent = "IM test";
+
     boolean bWasException;
+
     InputMethodRequests imr;
-    String message;
 
+    String message;
 
+    @Override
     protected void setUp() throws Exception {
         super.setUp();
-        map = new HashMap();
+        map = new HashMap<Attribute, Object>();
         jf = new JFrame();
         jta = new JTextArea();
         jta.setText(initialContent);
-        doc = (AbstractDocument)jta.getDocument();
+        doc = (AbstractDocument) jta.getDocument();
         imr = jta.getInputMethodRequests();
         bWasException = false;
         message = null;
@@ -69,33 +79,31 @@
         component = jf;
     }
 
+    @Override
     protected void tearDown() throws Exception {
         jf.dispose();
         super.tearDown();
     }
 
     private InputMethodEvent getTextEvent(AttributedCharacterIterator text,
-                                          int committedCharacterCount,
-                                          TextHitInfo caret,
-                                          TextHitInfo visiblePosition) {
-         return getEvent(InputMethodEvent.INPUT_METHOD_TEXT_CHANGED,
-                         text, committedCharacterCount,
-                         caret, visiblePosition);
-    }
-    private InputMethodEvent getEvent(final int id,
-                                      final AttributedCharacterIterator text,
-                                      final int committedCharacterCount,
-                                      final TextHitInfo caret,
-                                      final TextHitInfo visiblePosition) {
-        return new InputMethodEvent(jta, id, text, committedCharacterCount,
-                             caret, visiblePosition);
+            int committedCharacterCount, TextHitInfo caret, TextHitInfo visiblePosition) {
+        return getEvent(InputMethodEvent.INPUT_METHOD_TEXT_CHANGED, text,
+                committedCharacterCount, caret, visiblePosition);
     }
-    private Map putSegmentAttribute(final Map map, final Object value) {
+
+    private InputMethodEvent getEvent(final int id, final AttributedCharacterIterator text,
+            final int committedCharacterCount, final TextHitInfo caret,
+            final TextHitInfo visiblePosition) {
+        return new InputMethodEvent(jta, id, text, committedCharacterCount, caret,
+                visiblePosition);
+    }
+
+    private Map<Attribute, Object> putSegmentAttribute(final Map<Attribute, Object> map, final Object value) {
         map.put(SEGMENT_ATTRIBUTE, value);
         return map;
     }
-    private AttributedCharacterIterator getIterator(final String text,
-                                                    final Map map) {
+
+    private AttributedCharacterIterator getIterator(final String text, final Map<Attribute, Object> map) {
         attrString = new AttributedString(text, map);
         return attrString.getIterator();
     }
@@ -103,61 +111,53 @@
     private void setComposedText() {
         String content = "12345";
         iter = getIterator(content, putSegmentAttribute(map, Color.RED));
-        ime = getTextEvent(iter,0,TextHitInfo.afterOffset(0),
-                           TextHitInfo.afterOffset(0));
+        ime = getTextEvent(iter, 0, TextHitInfo.afterOffset(0), TextHitInfo.afterOffset(0));
         jta.processInputMethodEvent(ime);
         assertEquals(7, jta.getCaretPosition());
         checkComposedTextParams(true, 7, 5);
         assertEquals(initialContent + content, jta.getText());
     }
 
-    private void checkComposedTextParams(final boolean shouldBe,
-                                         final int start,
-                                         final int length) {
+    private void checkComposedTextParams(final boolean shouldBe, final int start,
+            final int length) {
         if (isHarmony()) {
             Object value = doc.getProperty(PropertyNames.COMPOSED_TEXT_PROPERTY);
-            if (! shouldBe) {
+            if (!shouldBe) {
                 assertNull(value);
                 return;
             }
             assertTrue(value instanceof ComposedTextParams);
-
             ComposedTextParams params = (ComposedTextParams) value;
             assertEquals(start, params.getComposedTextStart());
             assertEquals(length, params.getComposedTextLength());
             AttributedString text = params.getComposedText();
             AttributedCharacterIterator iter1 = attrString.getIterator();
             AttributedCharacterIterator iter2 = text.getIterator();
-
             assertEquals(iter1.getAttributes(), iter2.getAttributes());
-
-            assertEquals(iter1.getRunStart(SEGMENT_ATTRIBUTE),
-                         iter2.getRunStart(SEGMENT_ATTRIBUTE));
-
-            assertEquals(Math.min(iter1.getRunLimit(SEGMENT_ATTRIBUTE),
-                                  iter2.getEndIndex()),
-                         iter2.getRunLimit(SEGMENT_ATTRIBUTE));
+            assertEquals(iter1.getRunStart(SEGMENT_ATTRIBUTE), iter2
+                    .getRunStart(SEGMENT_ATTRIBUTE));
+            assertEquals(Math.min(iter1.getRunLimit(SEGMENT_ATTRIBUTE), iter2.getEndIndex()),
+                    iter2.getRunLimit(SEGMENT_ATTRIBUTE));
         }
     }
 
-
     public void testGetLocationOffset() {
         try {
             setComposedText();
             Rectangle rect;
             Point location = jta.getLocationOnScreen();
-            for(int i = 0; i < 7; i ++) {
+            for (int i = 0; i < 7; i++) {
                 rect = jta.modelToView(i);
                 rect.translate(location.x, location.y);
                 assertNull(imr.getLocationOffset(rect.x, rect.y));
             }
-            for(int i = 7; i < 13; i ++) {
+            for (int i = 7; i < 13; i++) {
                 rect = jta.modelToView(i);
                 rect.translate(location.x, location.y);
-                assertEquals(TextHitInfo.afterOffset(i - 7),
-                             imr.getLocationOffset(rect.x, rect.y));
+                assertEquals(TextHitInfo.afterOffset(i - 7), imr.getLocationOffset(rect.x,
+                        rect.y));
             }
-        } catch(BadLocationException e) {
+        } catch (BadLocationException e) {
         }
     }
 
@@ -168,33 +168,22 @@
             Rectangle rect = jta.modelToView(pos);
             Point location = jta.getLocationOnScreen();
             rect.translate(location.x, location.y);
-            for(int i = 0; i < 10; i ++) {
-                assertEquals(rect,
-                             imr.getTextLocation(TextHitInfo.beforeOffset(i)));
-                assertEquals(rect,
-                             imr.getTextLocation(TextHitInfo.afterOffset(i)));
+            for (int i = 0; i < 10; i++) {
+                assertEquals(rect, imr.getTextLocation(TextHitInfo.beforeOffset(i)));
+                assertEquals(rect, imr.getTextLocation(TextHitInfo.afterOffset(i)));
             }
-
-            iter = getIterator("klnoprst",
-                               putSegmentAttribute(map, Color.BLACK));
-            ime = getTextEvent(iter, 5, TextHitInfo.afterOffset(0),
-                               TextHitInfo.afterOffset(0));
+            iter = getIterator("klnoprst", putSegmentAttribute(map, Color.BLACK));
+            ime = getTextEvent(iter, 5, TextHitInfo.afterOffset(0), TextHitInfo.afterOffset(0));
             jta.processInputMethodEvent(ime);
-
             pos = 12;
             rect = jta.modelToView(pos);
             rect.translate(location.x, location.y);
-
-            for(int i = 0; i < 10; i ++) {
-                assertEquals(rect,
-                             imr.getTextLocation(TextHitInfo.beforeOffset(i)));
-                assertEquals(rect,
-                             imr.getTextLocation(TextHitInfo.afterOffset(i)));
+            for (int i = 0; i < 10; i++) {
+                assertEquals(rect, imr.getTextLocation(TextHitInfo.beforeOffset(i)));
+                assertEquals(rect, imr.getTextLocation(TextHitInfo.afterOffset(i)));
             }
-
-        } catch(BadLocationException e){
-            assertFalse("unexpectedException",true);
+        } catch (BadLocationException e) {
+            assertFalse("unexpectedException", true);
         }
     }
-
 }



Mime
View raw message