harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mloe...@apache.org
Subject svn commit: r440748 [25/25] - in /incubator/harmony/enhanced/classlib/trunk/modules: accessibility/src/main/java/javax/accessibility/ awt/ awt/make/ awt/src/main/java/common/java/awt/ awt/src/main/java/common/java/awt/datatransfer/ awt/src/main/java/co...
Date Wed, 06 Sep 2006 16:06:30 GMT
Modified: incubator/harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/tree/AbstractLayoutCache.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/tree/AbstractLayoutCache.java?view=diff&rev=440748&r1=440747&r2=440748
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/tree/AbstractLayoutCache.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/tree/AbstractLayoutCache.java Wed Sep  6 09:06:15 2006
@@ -57,28 +57,38 @@
         }
 
         public void add(final StateNode child, final int index) {
-            children.add(index, child);
-            child.invalidateTreePartBelow();
+            synchronized (AbstractLayoutCache.this) {
+                children.add(index, child);
+                child.invalidateTreePartBelow();
+            }
         }
 
         public void add(final StateNode child) {
-            add(child, children.size());
-            child.invalidateTreePartBelow();
+            synchronized (AbstractLayoutCache.this) {
+                add(child, children.size());
+                child.invalidateTreePartBelow();
+            }
         }
 
         public void remove(final int index) {
-            children.remove(index);
-            invalidateTreePartBelow();
+            synchronized (AbstractLayoutCache.this) {
+                children.remove(index);
+                invalidateTreePartBelow();
+            }
         }
 
         public void remove(final StateNode child) {
-            children.remove(child);
-            invalidateTreePartBelow();
+            synchronized (AbstractLayoutCache.this) {
+                children.remove(child);
+                invalidateTreePartBelow();
+            }
         }
 
         public void removeAll() {
-            children.clear();
-            invalidateTreePartBelow();
+            synchronized (AbstractLayoutCache.this) {
+                children.clear();
+                invalidateTreePartBelow();
+            }
         }
 
         public StateNode getParent() {
@@ -115,7 +125,6 @@
             return -1;
         }
 
-
         public Object[] getModelChildren() {
             if (modelChildren == null) {
                 int childCount = getModel().getChildCount(getModelNode());
@@ -128,11 +137,15 @@
         }
 
         public int getChildCount() {
-            return children.size();
+            synchronized (AbstractLayoutCache.this) {
+                return unsyncGetChildCount();
+            }
         }
 
         public boolean isLeaf() {
-            return children.size() == 0;
+            synchronized (AbstractLayoutCache.this) {
+                return unsyncIsLeaf();
+            }
         }
 
         public void setExpanded() {
@@ -150,49 +163,60 @@
         }
 
         public List children() {
-            return children;
+            synchronized (AbstractLayoutCache.this) {
+                return children;
+            }
         }
 
         public StateNode get(final int index) {
-            return (StateNode)children.get(index);
+            synchronized (AbstractLayoutCache.this) {
+                return unsyncGet(index);
+            }
         }
 
         public StateNode getChild(final Object modelNode) {
-            for (Iterator it = children.iterator(); it.hasNext();) {
-                StateNode stateNode = (StateNode)it.next();
-                if (stateNode.getModelNode().equals(modelNode)) {
-                    return stateNode;
+            synchronized (AbstractLayoutCache.this) {
+                for (Iterator it = children.iterator(); it.hasNext();) {
+                    StateNode stateNode = (StateNode)it.next();
+                    if (stateNode.getModelNode().equals(modelNode)) {
+                        return stateNode;
+                    }
                 }
-            }
 
-            return null;
+                return null;
+            }
         }
 
         public StateNode addChild(final Object modelChildNode) {
-            int childModelIndex = getModelIndexOfChild(modelChildNode);
-            int insertionIndex;
-            for (insertionIndex = 0; insertionIndex < children.size(); insertionIndex++) {
-                StateNode childStateNode = (StateNode)children.get(insertionIndex);
-                int childModelIndexForStateNode = getModelIndexOfChild(childStateNode.getModelNode());
-                if (childModelIndexForStateNode == childModelIndex) {
-                    return childStateNode;
-                }
-                if (childModelIndexForStateNode > childModelIndex) {
-                    break;
+            synchronized (AbstractLayoutCache.this) {
+                int childModelIndex = getModelIndexOfChild(modelChildNode);
+                int insertionIndex;
+                for (insertionIndex = 0; insertionIndex < children.size(); insertionIndex++) {
+                    StateNode childStateNode = (StateNode)children.get(insertionIndex);
+                    int childModelIndexForStateNode = getModelIndexOfChild(childStateNode.getModelNode());
+                    if (childModelIndexForStateNode == childModelIndex) {
+                        return childStateNode;
+                    }
+                    if (childModelIndexForStateNode > childModelIndex) {
+                        break;
+                    }
                 }
+                StateNode newChildStateNode = createStateNode(this, getModelPath().pathByAddingChild(modelChildNode));
+                add(newChildStateNode, insertionIndex);
+
+                return newChildStateNode;
             }
-            StateNode newChildStateNode = createStateNode(this, getModelPath().pathByAddingChild(modelChildNode));
-            add(newChildStateNode, insertionIndex);
-            return newChildStateNode;
         }
 
         public StateNode getNextSibling() {
-            if (getParent() == null) {
-                return null;
+            synchronized (AbstractLayoutCache.this) {
+                if (getParent() == null) {
+                    return null;
+                }
+                int index = getParent().children().indexOf(this);
+                return index + 1 < getParent().getChildCount() ? getParent().get(index + 1)
+                        : null;
             }
-            int index = getParent().children().indexOf(this);
-            return index + 1 < getParent().getChildCount() ? getParent().get(index + 1)
-                                                           : null;
         }
 
         public int getTotalChildrenCount() {
@@ -204,32 +228,73 @@
             return isValid;
         }
 
+        public void validate() {
+            synchronized (AbstractLayoutCache.this) {
+                if (isValid) {
+                    return;
+                }
+
+                // validation should go hierarchically, from the top to leaves
+                // therefore a parent shoul dbe validated first
+                if (getParent() != null) {
+                    getParent().validate();
+                }
+
+                // validation of the parent can cause children validation.
+                // In this case we don't need to validate this children again
+                if (isValid) {
+                    return;
+                }
+
+                // important to be BEFORE validateData() to get rid of potential cycling
+                isValid = true;
+                validateData();
+            }
+        }
+
+        public String toString() {
+            return getModelNode().toString();
+        }
+
         public void invalidate() {
-            isValid = false;
-            resetCachedData();
-            if (parent != null) {
-                parent.invalidate();
+            synchronized (AbstractLayoutCache.this) {
+                isValid = false;
+                resetCachedData();
+                if (parent != null) {
+                    parent.invalidate();
+                }
             }
         }
 
         public void invalidateSubtree() {
             invalidate();
-            for (int i = 0; i < getChildCount(); i++) {
-                get(i).invalidateSubtree();
+            synchronized (AbstractLayoutCache.this) {
+                for (int i = 0; i < unsyncGetChildCount(); i++) {
+                    unsyncInvalidateSubtree(unsyncGet(i));
+                }
             }
         }
-
+        
         public void invalidateTreePartBelow() {
-            invalidate();
+            synchronized (AbstractLayoutCache.this) {
+                unsyncInvalidateTreePartBelow(this);
+            }
+        }
+
+        protected void validateData() {
+        }
 
-            if (!isLeaf()) {
-                get(0).invalidateTreePartBelow();
+        private void unsyncInvalidateTreePartBelow(final StateNode node) {
+            node.invalidate();
+            
+            if (!node.unsyncIsLeaf()) {
+                unsyncInvalidateTreePartBelow(node.unsyncGet(0));
             } else {
-                StateNode currentNode = this;
+                StateNode currentNode = node;
                 while(currentNode != null) {
                     StateNode sibling = currentNode.getNextSibling();
                     if (sibling != null) {
-                        sibling.invalidateTreePartBelow();
+                        unsyncInvalidateTreePartBelow(sibling);
                         break;
                     }
                     currentNode = currentNode.getParent();
@@ -237,39 +302,27 @@
             }
         }
 
-
-        public void validate() {
-            if (isValid) {
-                return;
-            }
-
-            // validation should go hierarchically, from the top to leaves
-            // therefore a parent shoul dbe validated first
-            if (getParent() != null) {
-                getParent().validate();
-            }
-
-            // validation of the parent can cause children validation.
-            // In this case we don't need to validate this children again
-            if (isValid) {
-                return;
-            }
-
-            // important to be BEFORE validateData() to get rid of potential cycling
-            isValid = true;
-            validateData();
+        private boolean unsyncIsLeaf() {
+            return children.size() == 0;
         }
 
-        public String toString() {
-            return getModelNode().toString();
+        private void resetCachedData() {
+            modelChildren = null;
         }
 
-        protected void validateData() {
+        private void unsyncInvalidateSubtree(final StateNode root) {
+            root.invalidate();
+            for (int i = 0; i < root.unsyncGetChildCount(); i++) {
+                unsyncInvalidateSubtree(root.unsyncGet(i));
+            }
         }
 
+        private StateNode unsyncGet(final int index) {
+            return (StateNode)children.get(index);
+        }
 
-        private void resetCachedData() {
-            modelChildren = null;
+        private int unsyncGetChildCount() {
+            return children.size();
         }
     }
 
@@ -309,14 +362,7 @@
 
     public void setModel(final TreeModel model) {
         treeModel = model;
-        if (model != null && model.getRoot() != null) {
-            stateRoot = createStateNode(null, new TreePath(model.getRoot()));
-            if (model.isLeaf(model.getRoot())) {
-                stateRoot.setCollapsed();
-            }
-        } else {
-            stateRoot = null;
-        }
+        resetRoot(model);
     }
 
     public TreeModel getModel() {
@@ -657,6 +703,9 @@
     }
 
     void treeStructureChangedImpl(final TreeModelEvent e) {
+        if (stateRoot.getModelNode() != treeModel.getRoot()) {
+            resetRoot(treeModel);
+        }
         TreePath path = e.getTreePath();
         StateNode node = getStateNodeForPath(path);
         if (node == null) {
@@ -729,6 +778,17 @@
     private void resetRowSelection() {
         if (getSelectionModel() != null) {
             getSelectionModel().resetRowSelection();
+        }
+    }
+
+    private void resetRoot(final TreeModel model) {
+        if (model != null && model.getRoot() != null) {
+            stateRoot = createStateNode(null, new TreePath(model.getRoot()));
+            if (model.isLeaf(model.getRoot())) {
+                stateRoot.setCollapsed();
+            }
+        } else {
+            stateRoot = null;
         }
     }
 }

Modified: incubator/harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/tree/DefaultTreeCellRenderer.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/tree/DefaultTreeCellRenderer.java?view=diff&rev=440748&r1=440747&r2=440748
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/tree/DefaultTreeCellRenderer.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/tree/DefaultTreeCellRenderer.java Wed Sep  6 09:06:15 2006
@@ -49,6 +49,7 @@
 
     private Font font;
     private Color textDisabledColor;
+    private boolean drawsFocusBorderAroundIcon;
 
     public DefaultTreeCellRenderer() {
         setHorizontalAlignment(SwingConstants.LEFT);
@@ -61,6 +62,7 @@
         backgroundNonSelectionColor = UIManager.getColor("Tree.textBackground");
         borderSelectionColor = UIManager.getColor("Tree.selectionBorderColor");
         textDisabledColor = UIManager.getColor("Label.disabledForeground");
+        drawsFocusBorderAroundIcon = UIManager.getBoolean("Tree.drawsFocusBorderAroundIcon");
     }
 
     public Icon getDefaultOpenIcon() {
@@ -203,7 +205,11 @@
 
         if (hasFocus) {
             g.setColor(getBorderSelectionColor());
-            g.drawRect(x, 0, getWidth() - textOffest - 1, getHeight() - 1);
+            if (drawsFocusBorderAroundIcon) {
+                g.drawRect(0, 0, getWidth() - 1, getHeight() - 1);
+            } else {
+                g.drawRect(x, 0, getWidth() - textOffest - 1, getHeight() - 1);
+            }
         }
 
         g.setColor(oldColor);

Modified: incubator/harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/org/apache/harmony/x/swing/StringConstants.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/org/apache/harmony/x/swing/StringConstants.java?view=diff&rev=440748&r1=440747&r2=440748
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/org/apache/harmony/x/swing/StringConstants.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/org/apache/harmony/x/swing/StringConstants.java Wed Sep  6 09:06:15 2006
@@ -71,6 +71,7 @@
     String VIEWPORT_PROPERTY = "viewport";
     String COMPONENT_ORIENTATION = "componentOrientation";
     String OPAQUE_PROPERTY = "opaque";
+    String IS_TABLE_EDITOR = "isTableEditor";
 
     String INTERNAL_FRAME_ICONABLE_PROPERTY = "iconable";
     String INTERNAL_FRAME_MAXIMIZABLE_PROPERTY = "maximizable";
@@ -103,4 +104,5 @@
     String INDETERMINATE_PROPERTY = "indeterminate";
 
     String VALUE_PROPERTY_NAME = "value";
+    String LIGHTWEIGHT_POPUP_ENABLED_PROPERTY_CHANGED = "lightWeightPopupEnabled";
 }

Modified: incubator/harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/org/apache/harmony/x/swing/Utilities.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/org/apache/harmony/x/swing/Utilities.java?view=diff&rev=440748&r1=440747&r2=440748
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/org/apache/harmony/x/swing/Utilities.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/org/apache/harmony/x/swing/Utilities.java Wed Sep  6 09:06:15 2006
@@ -57,6 +57,7 @@
 import javax.swing.plaf.UIResource;
 import javax.swing.plaf.basic.BasicComboPopup;
 import javax.swing.plaf.basic.BasicGraphicsUtils;
+import javax.swing.text.Position;
 
 /**
  * SwingUtilities extension. This class provides utility
@@ -64,6 +65,77 @@
  *
  */
 public class Utilities implements SwingConstants {
+    /**
+     * This interface allows to access list data
+     */
+    public interface ListModelAccessor {
+        /**
+         * Returns the list data element according to specified index
+         * 
+         * @param index of the element
+         * @return element, specified by index
+         */
+        public Object getElementAt(final int index);
+        
+        /**
+         * Returns the size of the list
+         * @return size of the list
+         */
+        public int getSize();
+    }
+    
+    /**
+     * Returns the index of the next element of the list according to specified
+     * prefix, start index and bias
+     * 
+     * @param model of the list
+     * @param prefix of the list element
+     * @param startIndex index to start search from
+     * @param bias
+     * @return index of the next element
+     */
+    public static int getNextMatch(final ListModelAccessor model, final String prefix, 
+                            final int startIndex, final Position.Bias bias) {
+        if (prefix == null) {
+            throw new IllegalArgumentException("Prefix must be not null");
+        }
+
+        if (startIndex < 0 || startIndex >= model.getSize()) {
+            throw new IllegalArgumentException("Incorrect start index");
+        }
+
+        String ucPrefix = prefix.toUpperCase();
+        if (Position.Bias.Forward == bias) {
+            for (int i = startIndex; i < model.getSize(); i++) {
+                String elementAsString = model.getElementAt(i).toString().toUpperCase();
+                if (elementAsString.startsWith(ucPrefix)) {
+                    return i;
+                }
+            }
+            for (int i = 0; i < startIndex; i++) {
+                String elementAsString = model.getElementAt(i).toString().toUpperCase();
+                if (elementAsString.startsWith(ucPrefix)) {
+                    return i;
+                }
+            }
+        } else if (Position.Bias.Backward == bias) {
+            for (int i = startIndex; i >= 0; i--) {
+                String elementAsString = model.getElementAt(i).toString().toUpperCase();
+                if (elementAsString.startsWith(ucPrefix)) {
+                    return i;
+                }
+            }
+            for (int i = model.getSize() - 1; i > startIndex; i--) {
+                String elementAsString = model.getElementAt(i).toString().toUpperCase();
+                if (elementAsString.startsWith(ucPrefix)) {
+                    return i;
+                }
+            }
+        }
+
+        return -1;
+    }
+
     /**
     * Clips string due to the width of an area available for painting the text.
     *

Modified: incubator/harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/org/apache/harmony/x/swing/plaf/resources/basic/BasicResourceBundle.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/org/apache/harmony/x/swing/plaf/resources/basic/BasicResourceBundle.java?view=diff&rev=440748&r1=440747&r2=440748
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/org/apache/harmony/x/swing/plaf/resources/basic/BasicResourceBundle.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/org/apache/harmony/x/swing/plaf/resources/basic/BasicResourceBundle.java Wed Sep  6 09:06:15 2006
@@ -76,7 +76,6 @@
                        
                        { "FileChooser.acceptAllFileFilterText", "All Files" },
                        { "FileChooser.cancelButtonText", "Cancel" },
-                       { "FileChooser.cancelButtonMnemonic", new Integer(KeyEvent.VK_C) },
                        { "FileChooser.cancelButtonToolTipText", "Cancel file chooser dialog" },
                        { "FileChooser.directoryDescriptionText", "Directory" },
                        { "FileChooser.directoryOpenButtonText", "Open" },
@@ -89,17 +88,14 @@
                        { "FileChooser.newFolderErrorSeparator", ": " },
                        { "FileChooser.newFolderErrorText", "Error creating folder" },
                        { "FileChooser.openButtonText", "Open" },
-                       { "FileChooser.openButtonMnemonic", new Integer(KeyEvent.VK_O) },
                        { "FileChooser.openButtonToolTipText", "Open file" },
                        { "FileChooser.openDialogTitleText", "Open" },
                        { "FileChooser.other.newFolder", "NewFolder" },
                        { "FileChooser.other.newFolder.subsequent", "NewFolder.{0}" },
                        { "FileChooser.saveButtonText", "Save" },
-                       { "FileChooser.saveButtonMnemonic", new Integer(KeyEvent.VK_S) },
                        { "FileChooser.saveButtonToolTipText", "Save file" },
                        { "FileChooser.saveDialogTitleText", "Save" },
                        { "FileChooser.updateButtonText", "Refresh" },
-                       { "FileChooser.updateButtonMnemonic", new Integer(KeyEvent.VK_R) },
                        { "FileChooser.updateButtonToolTipText", "Refresh directory listing" },
                        { "FileChooser.win32.newFolder", "New Folder" },
                        { "FileChooser.win32.newFolder.subsequent", "New Folder ({0})" },

Modified: incubator/harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/org/apache/harmony/x/swing/plaf/resources/metal/MetalResourceBundle.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/org/apache/harmony/x/swing/plaf/resources/metal/MetalResourceBundle.java?view=diff&rev=440748&r1=440747&r2=440748
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/org/apache/harmony/x/swing/plaf/resources/metal/MetalResourceBundle.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/org/apache/harmony/x/swing/plaf/resources/metal/MetalResourceBundle.java Wed Sep  6 09:06:15 2006
@@ -38,7 +38,7 @@
                    { "FileChooser.fileAttrHeaderText", "Attributes" },
                    { "FileChooser.fileDateHeaderText", "Date Modified" },
                    { "FileChooser.fileNameHeaderText", "Filename" },
-                   { "FileChooser.fileNameLabelText", "Filename:" },
+                   { "FileChooser.fileNameLabelText", "File Name:" },
                    { "FileChooser.fileNameLabelMnemonic", new Integer(KeyEvent.VK_N) },
                    { "FileChooser.fileSizeHeaderText", "File size" },
                    { "FileChooser.filesOfTypeLabelText", "Files of Type:" },
@@ -55,11 +55,11 @@
                    { "FileChooser.saveInLabelText", "Save To:" },
                    { "FileChooser.upFolderAccessibleName", "Up" },
                    { "FileChooser.upFolderToolTipText", "Go Up One Level" },
-                   
+
                    { "InternalFrameTitlePane.closeButtonAccessibleName", "Close" },
                    { "InternalFrameTitlePane.iconifyButtonAccessibleName", "Iconify" },
                    { "InternalFrameTitlePane.maximizeButtonAccessibleName", "Maximize" },
-                   
+
                    { "MetalTitlePane.closeMnemonic", new Integer(KeyEvent.VK_C) },
                    { "MetalTitlePane.closeTitle", "Close" },
                    { "MetalTitlePane.iconifyMnemonic", new Integer(KeyEvent.VK_E) },

Added: incubator/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/DebugGraphicsTest.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/DebugGraphicsTest.java?view=auto&rev=440748
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/DebugGraphicsTest.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/DebugGraphicsTest.java Wed Sep  6 09:06:15 2006
@@ -0,0 +1,47 @@
+/*
+ *  Copyright 2005 - 2006 The Apache Software Software Foundation or its licensors, as applicable.
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+/**
+ * @author Dennis Ushakov
+ * @version $Revision$
+ */
+package javax.swing;
+
+import java.awt.image.BufferedImage;
+
+public class DebugGraphicsTest extends BasicSwingTestCase {
+    private DebugGraphics debugGraphics;
+    
+    public void setUp() throws Exception {
+        super.setUp();
+        debugGraphics = new DebugGraphics(new BufferedImage(10, 10, BufferedImage.TYPE_INT_RGB).getGraphics());        
+    }
+    
+    public void testGetSetDebugOptions() {
+        assertEquals(0, debugGraphics.getDebugOptions());
+        debugGraphics.setDebugOptions(DebugGraphics.BUFFERED_OPTION);
+        assertTrue((debugGraphics.getDebugOptions() & DebugGraphics.BUFFERED_OPTION) != 0);
+        debugGraphics.setDebugOptions(DebugGraphics.LOG_OPTION);
+        assertTrue((debugGraphics.getDebugOptions() & DebugGraphics.BUFFERED_OPTION) != 0);
+        assertTrue((debugGraphics.getDebugOptions() & DebugGraphics.LOG_OPTION) != 0);
+        debugGraphics.setDebugOptions(DebugGraphics.NONE_OPTION);
+        assertEquals(0, debugGraphics.getDebugOptions());
+    }
+    
+    public void testCreate() {
+        DebugGraphics result = (DebugGraphics)debugGraphics.create();
+        assertEquals(debugGraphics.getDebugOptions(), result.getDebugOptions());
+    }
+}

Added: incubator/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/SizeSequenceTest.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/SizeSequenceTest.java?view=auto&rev=440748
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/SizeSequenceTest.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/SizeSequenceTest.java Wed Sep  6 09:06:15 2006
@@ -0,0 +1,152 @@
+/**
+ * @author Dennis Ushakov
+ * @version $Revision$
+ */
+package javax.swing;
+
+import java.util.Arrays;
+
+
+public class SizeSequenceTest extends BasicSwingTestCase {
+    private SizeSequence sizeSequence;
+    private int[] sizes;
+    
+    protected void setUp() throws Exception {
+        super.setUp();
+        sizes = new int[]{1, 2, 3, 4, 5};
+        sizeSequence = new SizeSequence(sizes);
+    }
+    
+    protected void tearDown() throws Exception {
+        super.tearDown();
+        sizeSequence = null;
+        sizes = null;
+    }
+    
+    public void testSizeSequence() throws Exception {             
+        sizeSequence = new SizeSequence();
+        assertEquals(0, sizeSequence.getSizes().length);        
+        
+        sizeSequence = new SizeSequence(10);
+        assertEquals(10, sizeSequence.getSizes().length);
+        assertEquals(10, sizeSequence.getIndex(0));
+        for (int i = 0; i < 10; i++) {
+            assertEquals(0, sizeSequence.getSizes()[i]);
+        }
+        
+        sizeSequence = new SizeSequence(10, 13);
+        assertEquals(10, sizeSequence.getSizes().length);
+        for (int i = 0; i < 10; i++) {
+            assertEquals(13, sizeSequence.getSizes()[i]);
+        }
+        
+        int[] sizes = new int[]{1, 2, 3, 4, 5};
+        sizeSequence = new SizeSequence(sizes);
+        assertEquals(5, sizeSequence.getSizes().length);
+        assertNotSame(sizes, sizeSequence.getSizes());        
+    }
+    
+    public void testGetIndex() {
+        assertEquals(2, sizeSequence.getIndex(3));
+        assertEquals(3, sizeSequence.getIndex(6));
+        assertEquals(4, sizeSequence.getIndex(11));
+        assertEquals(5, sizeSequence.getIndex(100));
+        assertEquals(0, sizeSequence.getIndex(-100));
+    }
+    
+    public void testGetPosition() {
+        assertEquals(0, sizeSequence.getPosition(0));
+        assertEquals(1, sizeSequence.getPosition(1));
+        assertEquals(3, sizeSequence.getPosition(2));
+        assertEquals(6, sizeSequence.getPosition(3));
+        assertEquals(10, sizeSequence.getPosition(4));        
+        assertEquals(15, sizeSequence.getPosition(100));
+        assertEquals(0, sizeSequence.getPosition(-100));
+        
+        sizeSequence = new SizeSequence();
+        assertEquals(0, sizeSequence.getPosition(5));
+    }
+    
+    public void testGetSetSize() {
+        assertEquals(1, sizeSequence.getSize(0));
+        
+        sizeSequence.setSize(0, 10);
+        assertEquals(10, sizeSequence.getSize(0));
+        assertEquals(10, sizeSequence.getPosition(1));
+        assertEquals(12, sizeSequence.getPosition(2));
+        assertEquals(24, sizeSequence.getPosition(5));
+        assertEquals(1, sizeSequence.getIndex(11));
+        assertEquals(3, sizeSequence.getIndex(15));
+        
+        sizeSequence.setSize(0, -10);
+        assertEquals(-10, sizeSequence.getSize(0));
+        assertEquals(-10, sizeSequence.getPosition(1));
+        
+        sizeSequence.setSize(10, 1);
+        assertEquals(0, sizeSequence.getSize(10));
+    }
+    
+    public void testGetSetSizes() {
+        int[] first = sizeSequence.getSizes();
+        assertNotSame(first, sizeSequence.getSizes());
+        
+        sizes[0] = 5;
+        assertEquals(1, sizeSequence.getSizes()[0]);
+        
+        sizes = new int[]{1, 2, 3, 4, 5, 6};
+        sizeSequence.setSizes(sizes);
+        assertEquals(sizes.length, sizeSequence.getSizes().length);
+        assertNotSame(sizes, sizeSequence.getSizes());
+        for (int i = 0; i < sizes.length; i++) {
+            assertEquals(sizes[i], sizeSequence.getSizes()[i]);
+            assertEquals(sizes[i], sizeSequence.getSize(i));
+        }
+    }
+    
+    public void testInsertRemoveEntries() {
+        sizeSequence.removeEntries(0, 3);
+        assertEquals(2, sizeSequence.getSizes().length);
+        assertEquals(5, sizeSequence.getSize(1));
+        
+        testExceptionalCase(new ExceptionalCase() {
+            public void exceptionalAction() throws Exception {
+                sizeSequence.removeEntries(10, 11);
+            }
+            public Class expectedExceptionClass() {
+                return NegativeArraySizeException.class;
+            }
+        });                                
+        testExceptionalCase(new ExceptionalCase() {
+            public void exceptionalAction() throws Exception {
+                sizeSequence.removeEntries(10, -1);
+            }
+            public Class expectedExceptionClass() {
+                return ArrayIndexOutOfBoundsException.class;
+            }
+        });                
+     
+        sizeSequence = new SizeSequence(sizes);        
+        sizeSequence.insertEntries(2, 3, 2);
+        assertEquals(3 + sizes.length, sizeSequence.getSizes().length);        
+        assertEquals(2, sizeSequence.getSize(2));
+        assertEquals(2, sizeSequence.getIndex(3));
+        assertEquals(5, sizeSequence.getSize(7));
+        
+        testExceptionalCase(new ExceptionalCase() {
+            public void exceptionalAction() throws Exception {
+                sizeSequence.insertEntries(10, 11, 0);
+            }
+            public Class expectedExceptionClass() {
+                return ArrayIndexOutOfBoundsException.class;
+            }
+        });        
+        testExceptionalCase(new ExceptionalCase() {
+            public void exceptionalAction() throws Exception {
+                sizeSequence.insertEntries(0, -1, 0);
+            }
+            public Class expectedExceptionClass() {
+                return ArrayIndexOutOfBoundsException.class;
+            }
+        });        
+    }
+}

Modified: incubator/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/text/AbstractDocument_AbstractElementRTest.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/text/AbstractDocument_AbstractElementRTest.java?view=diff&rev=440748&r1=440747&r2=440748
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/text/AbstractDocument_AbstractElementRTest.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/text/AbstractDocument_AbstractElementRTest.java Wed Sep  6 09:06:15 2006
@@ -22,6 +22,7 @@
 import java.util.Enumeration;
 
 import javax.swing.text.AbstractDocument.AbstractElement;
+import javax.swing.text.AbstractDocument.BranchElement;
 
 import junit.framework.TestCase;
 
@@ -112,6 +113,19 @@
             element.getName();
             fail("ClassCastException is expected");
         } catch (ClassCastException e) { }
+    }
+    
+    public void testGetNameParent() throws Exception {
+        final String parentName = "parentName";
+        attrs.addAttribute(AbstractDocument.ElementNameAttribute, parentName);
+        BranchElement parent = doc.new BranchElement(null, attrs);
+        AbstractElement element = new AbstractElementImpl(doc, parent, null);
+        
+        assertTrue(parent.isDefined(AbstractDocument.ElementNameAttribute));
+        assertEquals(parentName, parent.getName());
+        
+        assertFalse(element.isDefined(AbstractDocument.ElementNameAttribute));
+        assertNull(element.getName());
     }
 
     protected void setUp() throws Exception {

Modified: incubator/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/text/CompositeViewTest.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/text/CompositeViewTest.java?view=diff&rev=440748&r1=440747&r2=440748
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/text/CompositeViewTest.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/text/CompositeViewTest.java Wed Sep  6 09:06:15 2006
@@ -252,6 +252,36 @@
         assertFalse(childrenLoaded);
     }
 
+    public void testSetParentNull() throws Exception {
+        view = new CompositeViewImpl(root) {
+            protected void loadChildren(final ViewFactory factory) {
+                childrenLoaded = true;
+                assertSame(getViewFactory(), factory);
+                super.loadChildren(factory);
+            }
+        };
+        assertEquals(0, view.getViewCount());
+        assertFalse(childrenLoaded);
+        view.setParent(null);
+        assertFalse(childrenLoaded);
+    }
+
+    public void testSetParentNoViewFactory() throws Exception {
+        view = new CompositeViewImpl(root) {
+            protected void loadChildren(final ViewFactory factory) {
+                childrenLoaded = true;
+                assertNull(factory);
+                super.loadChildren(factory);
+            }
+        };
+        assertEquals(0, view.getViewCount());
+        assertFalse(childrenLoaded);
+        final PlainView parent = new PlainView(root);
+        assertNull(parent.getViewFactory());
+        view.setParent(parent);
+        assertTrue(childrenLoaded);
+    }
+
     public void testCompositeView() {
         view = new CompositeViewImpl(root);
         assertEquals(0, view.getViewCount());
@@ -386,6 +416,13 @@
         assertEquals(root.getElementCount(), view.getViewCount());
         assertSame(view, view.getView(0).getParent());
         assertSame(root.getElement(0), view.getView(0).getElement());
+    }
+
+    public void testLoadChildrenNull() {
+        view = new CompositeViewImpl(root);
+        assertEquals(0, view.getViewCount());
+        view.loadChildren(null);
+        assertEquals(0, view.getViewCount());
     }
 
     /**

Modified: incubator/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/text/DefaultEditorKitRTest.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/text/DefaultEditorKitRTest.java?view=diff&rev=440748&r1=440747&r2=440748
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/text/DefaultEditorKitRTest.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/text/DefaultEditorKitRTest.java Wed Sep  6 09:06:15 2006
@@ -22,7 +22,11 @@
 import java.awt.Dimension;
 import java.awt.event.ActionEvent;
 import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
 import java.io.InputStream;
+import java.io.Reader;
+import java.io.Writer;
 import java.lang.reflect.InvocationTargetException;
 
 import javax.swing.Action;
@@ -33,6 +37,7 @@
 import javax.swing.JViewport;
 import javax.swing.SwingUtilities;
 
+
 public class DefaultEditorKitRTest extends BasicSwingTestCase {
 
     protected DefaultEditorKit kit = null;
@@ -121,6 +126,28 @@
         c = getInitedComponent(2, 7, "0123456789");
         performAction(c, action, null);
         assertEquals("resulted string", "0123456789", c.getText());
+    }
+
+    public void testReadInputStreamDocumentint() throws Exception {
+        final Marker readerMarker = new Marker();
+        DefaultEditorKit kit = new DefaultEditorKit() {
+            public void read(Reader in, Document doc, int pos) throws IOException, BadLocationException {
+                readerMarker.setOccurred();
+            }
+        };
+        kit.read(new ByteArrayInputStream(new byte[10]), new DefaultStyledDocument(), 0);
+        assertTrue(readerMarker.isOccurred());
+    }
+    
+    public void testWriteOutputStreamDocumentintint() throws Exception {
+        final Marker writeMarker = new Marker();
+        DefaultEditorKit kit = new DefaultEditorKit() {
+            public void write(Writer out, Document doc, int pos, int len) throws IOException, BadLocationException {
+                writeMarker.setOccurred();
+            }
+        };
+        kit.write(new ByteArrayOutputStream(), new DefaultStyledDocument(), 0, 1);
+        assertTrue(writeMarker.isOccurred());
     }
 
     public void testInsertContentActionPerformed_NullEvent() throws Exception {

Modified: incubator/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/text/DefaultEditorKitTest.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/text/DefaultEditorKitTest.java?view=diff&rev=440748&r1=440747&r2=440748
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/text/DefaultEditorKitTest.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/text/DefaultEditorKitTest.java Wed Sep  6 09:06:15 2006
@@ -222,6 +222,52 @@
             }
         });
     }
+    
+    public void testWriteWriterFlush() throws Exception {
+        final String str = "Test text";
+        final Document doc = kit.createDefaultDocument();
+        doc.insertString(0, str, null);
+
+        final Marker flushMarker = new Marker();
+        final Marker closeMarker = new Marker();
+        StringWriter writer = new StringWriter() {
+            public void close() throws IOException {
+                closeMarker.setOccurred();
+                super.close();
+            }
+            public void flush() {
+                flushMarker.setOccurred();
+                super.flush();
+            }
+        };
+        kit.write(writer, doc, 0, doc.getLength());
+
+        assertFalse(closeMarker.isOccurred());
+        assertTrue(flushMarker.isOccurred());
+    }
+    
+    public void testWriteOutputStreamFlush() throws Exception {
+        final String str = "Test text";
+        final Document doc = kit.createDefaultDocument();
+        doc.insertString(0, str, null);
+
+        final Marker flushMarker = new Marker();
+        final Marker closeMarker = new Marker();
+        OutputStream stream = new ByteArrayOutputStream() {
+            public void close() throws IOException {
+                closeMarker.setOccurred();
+                super.close();
+            }
+            public void flush() throws IOException {
+                flushMarker.setOccurred();
+                super.flush();
+            }
+        };
+        kit.write(stream, doc, 0, doc.getLength());
+
+        assertFalse(closeMarker.isOccurred());
+        assertTrue(flushMarker.isOccurred());
+    }
 
     public void testNewLineReader() throws IOException, BadLocationException {
         String str1 = "This is a very \r\nshort plain-text document.\r\nIt's to be read only by the \r\ntest.";

Modified: incubator/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/text/DefaultStyledDocumentRTest.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/text/DefaultStyledDocumentRTest.java?view=diff&rev=440748&r1=440747&r2=440748
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/text/DefaultStyledDocumentRTest.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/text/DefaultStyledDocumentRTest.java Wed Sep  6 09:06:15 2006
@@ -20,21 +20,31 @@
 package javax.swing.text;
 
 import javax.swing.BasicSwingTestCase;
+import javax.swing.text.AbstractDocument.BranchElement;
+import javax.swing.text.AbstractDocument.DefaultDocumentEvent;
+import javax.swing.text.AbstractDocument.LeafElement;
+import javax.swing.text.DefStyledDoc_Helpers.ElementBufferWithLogging;
+import javax.swing.text.DefaultStyledDocument.ElementBuffer;
+import javax.swing.text.DefaultStyledDocument.ElementSpec;
 
 public class DefaultStyledDocumentRTest extends BasicSwingTestCase {
-    private Document doc;
+    private static final String ELEMENT_NAME = AbstractDocument.ElementNameAttribute;
+    private DefaultStyledDocument doc;
     private Element root;
     private Element paragraph;
     private Element child;
     private int insertOffset = 5;
     private MutableAttributeSet attrs;
 
+    private ElementBuffer buf;
+    private ElementSpec[] specs;
+
     /**
      * Insert one space with attributes containing element name
      * <code>"icon"</code>.
      */
     public void testIconElement() throws Exception {
-        attrs.addAttribute(AbstractDocument.ElementNameAttribute, "icon");
+        attrs.addAttribute(ELEMENT_NAME, "icon");
         doc.insertString(insertOffset, " ", attrs);
 
         assertEquals(3, paragraph.getElementCount());
@@ -55,7 +65,7 @@
      * <code>"icon"</code>.
      */
     public void testIconElementTwoSpaces() throws Exception {
-        attrs.addAttribute(AbstractDocument.ElementNameAttribute, "icon");
+        attrs.addAttribute(ELEMENT_NAME, "icon");
         doc.insertString(insertOffset, "  ", attrs);
 
         assertEquals(3, paragraph.getElementCount());
@@ -76,7 +86,7 @@
      * <code>"icon"</code>.
      */
     public void testIconElementNotSpaces() throws Exception {
-        attrs.addAttribute(AbstractDocument.ElementNameAttribute, "icon");
+        attrs.addAttribute(ELEMENT_NAME, "icon");
         doc.insertString(insertOffset, "ab", attrs);
 
         assertEquals(3, paragraph.getElementCount());
@@ -98,7 +108,7 @@
      * <code>"component"</code>.
      */
     public void testComponentElement() throws Exception {
-        attrs.addAttribute(AbstractDocument.ElementNameAttribute, "component");
+        attrs.addAttribute(ELEMENT_NAME, "component");
         doc.insertString(insertOffset, "ab", attrs);
 
         assertEquals(3, paragraph.getElementCount());
@@ -115,6 +125,337 @@
         assertEquals(AbstractDocument.ContentElementName, child.getName());
     }
 
+    public void testDeepTreeInsertString01() throws Exception {
+        initStructure();
+        attrs.addAttribute(ELEMENT_NAME, "content");
+        doc.insertString(1, "\n", attrs);
+
+        assertEquals(7, specs.length);
+        assertSpec(specs[0], ElementSpec.EndTagType,
+                   ElementSpec.OriginateDirection, 0, 0);
+        assertSpec(specs[1], ElementSpec.EndTagType,
+                   ElementSpec.OriginateDirection, 0, 0);
+        assertSpec(specs[2], ElementSpec.StartTagType,
+                   ElementSpec.JoinNextDirection, 0, 0);
+        assertSpec(specs[3], ElementSpec.StartTagType,
+                   ElementSpec.OriginateDirection, 0, 0);
+        assertSpec(specs[4], ElementSpec.ContentType,
+                   ElementSpec.OriginateDirection, 0, 1);
+        assertSpec(specs[5], ElementSpec.EndTagType,
+                   ElementSpec.OriginateDirection, 0, 0);
+        assertSpec(specs[6], ElementSpec.StartTagType,
+                   ElementSpec.JoinNextDirection, 0, 0);
+    }
+
+    public void testDeepTreeInsertString02() throws Exception {
+        initStructure();
+        attrs.addAttribute(ELEMENT_NAME, "content");
+        doc.insertString(1, "^", attrs);
+
+        assertEquals(5, specs.length);
+        assertSpec(specs[0], ElementSpec.EndTagType,
+                   ElementSpec.OriginateDirection, 0, 0);
+        assertSpec(specs[1], ElementSpec.EndTagType,
+                   ElementSpec.OriginateDirection, 0, 0);
+        assertSpec(specs[2], ElementSpec.StartTagType,
+                   ElementSpec.JoinNextDirection, 0, 0);
+        assertSpec(specs[3], ElementSpec.StartTagType,
+                   ElementSpec.JoinNextDirection, 0, 0);
+        assertSpec(specs[4], ElementSpec.ContentType,
+                   ElementSpec.OriginateDirection, 0, 1);
+    }
+
+
+    public void testDeepTreeInsert01() throws Exception {
+        initStructure();
+        ElementSpec[] specs = {
+            new ElementSpec(null, ElementSpec.EndTagType),      // 0
+            new ElementSpec(null, ElementSpec.EndTagType),      // 1
+            new ElementSpec(null, ElementSpec.StartTagType),    // 2
+            new ElementSpec(null, ElementSpec.StartTagType),    // 3
+            new ElementSpec(null, ElementSpec.ContentType,      // 4
+                            "\n".toCharArray(), 0, 1),
+            new ElementSpec(null, ElementSpec.EndTagType),      // 5
+            new ElementSpec(null, ElementSpec.StartTagType),    // 6
+        };
+        specs[2].setDirection(ElementSpec.JoinNextDirection);
+        specs[6].setDirection(ElementSpec.JoinNextDirection);
+
+        doc.insert(1, specs);
+
+        final Element html = doc.getDefaultRootElement();
+        assertEquals(2, html.getElementCount());
+
+        final Element head = html.getElement(0);
+        assertEquals(1, head.getElementCount());
+
+        Element p = head.getElement(0);
+        assertChildren(p, new int[] {0, 1});
+
+        final Element body = html.getElement(1);
+        assertEquals(2, body.getElementCount());
+
+        p = body.getElement(0);
+        assertEquals("paragraph", p.getName());
+        assertChildren(p, new int[] {1, 2});
+
+        p = body.getElement(1);
+        assertEquals("p1", p.getName());
+        assertChildren(p, new int[] {2, 6, 6, 7});
+    }
+
+    public void testDeepTreeInsert02() throws Exception {
+        initStructure();
+        ElementSpec[] specs = {
+            new ElementSpec(null, ElementSpec.EndTagType),      // 0
+            new ElementSpec(null, ElementSpec.EndTagType),      // 1
+            new ElementSpec(null, ElementSpec.StartTagType),    // 2
+            new ElementSpec(null, ElementSpec.StartTagType),    // 3
+            new ElementSpec(null, ElementSpec.ContentType,      // 4
+                            "^".toCharArray(), 0, 1),
+        };
+        specs[2].setDirection(ElementSpec.JoinNextDirection);
+        specs[3].setDirection(ElementSpec.JoinNextDirection);
+
+        doc.insert(1, specs);
+
+        final Element html = doc.getDefaultRootElement();
+        assertEquals(2, html.getElementCount());
+
+        final Element head = html.getElement(0);
+        assertEquals(1, head.getElementCount());
+
+        Element p = head.getElement(0);
+        assertChildren(p, new int[] {0, 1});
+
+        final Element body = html.getElement(1);
+        assertEquals(1, body.getElementCount());
+
+        p = body.getElement(0);
+        assertEquals("p1", p.getName());
+        assertChildren(p, new int[] {1, 2, 2, 6, 6, 7});
+    }
+
+    public void testDeepTreeInsertSpecs() throws Exception {
+        initStructure();
+        ElementSpec[] specs = {
+            new ElementSpec(null, ElementSpec.ContentType,
+                            "\n".toCharArray(), 0, 1),
+            new ElementSpec(null, ElementSpec.EndTagType),
+            new ElementSpec(null, ElementSpec.EndTagType),
+        };
+        doc.insert(0, specs);
+
+        final Element html = doc.getDefaultRootElement();
+        assertEquals(2, html.getElementCount());
+
+        final Element head = html.getElement(0);
+        assertEquals(1, head.getElementCount());
+
+        Element p = head.getElement(0);
+        assertChildren(p, new int[] {0, 1, 1, 2});
+        assertEquals("\n\n", doc.getText(0, 2));
+
+        final Element body = html.getElement(1);
+        assertEquals(1, body.getElementCount());
+
+        p = body.getElement(0);
+        assertEquals("p1", p.getName());
+        assertChildren(p, new int[] {2, 6, 6, 7});
+    }
+
+    public void testHTMLInsert() throws Exception {
+        createEmptyHTMLStructure();
+        doc.insertString(0, "0000", DefStyledDoc_Helpers.bold);
+        ElementSpec[] specs = {
+            new ElementSpec(null, ElementSpec.EndTagType),
+            new ElementSpec(null, ElementSpec.ContentType,
+                            "^^^^".toCharArray(), 0, 4),
+        };
+        doc.insert(0, specs);
+
+        final Element html = doc.getDefaultRootElement();
+        assertEquals(1, html.getElementCount());
+
+        final Element body = html.getElement(0);
+        assertEquals(2, body.getElementCount());
+
+        Element child = body.getElement(0);
+        assertEquals("content", child.getName());
+        assertTrue(child.isLeaf());
+
+        child = body.getElement(1);
+        assertEquals("p", child.getName());
+        assertChildren(child, new int[] {4, 8, 8, 9});
+    }
+
+    public void testCreate01() throws Exception {
+        ElementSpec[] specs = {
+            new ElementSpec(null, ElementSpec.StartTagType),
+            new ElementSpec(null, ElementSpec.ContentType,
+                            "^".toCharArray(), 0, 1),
+            new ElementSpec(null, ElementSpec.EndTagType),
+        };
+        doc.create(specs);
+
+        root = doc.getDefaultRootElement();
+        assertEquals(2, root.getElementCount());
+
+        Element child = root.getElement(0);
+        assertTrue(child.isLeaf());
+        assertEquals(0, child.getStartOffset());
+        assertEquals(1, child.getEndOffset());
+
+        child = root.getElement(1);
+        assertFalse(child.isLeaf());
+        assertEquals(1, child.getStartOffset());
+        assertEquals(2, child.getEndOffset());
+        assertEquals(1, child.getElementCount());
+        assertTrue(child.getElement(0).isLeaf());
+    }
+
+    public void testCreate02() throws Exception {
+        ElementSpec[] specs = {
+            new ElementSpec(null, ElementSpec.StartTagType),
+            new ElementSpec(null, ElementSpec.StartTagType),
+            new ElementSpec(null, ElementSpec.StartTagType),
+            new ElementSpec(null, ElementSpec.ContentType,
+                            "^".toCharArray(), 0, 1),
+            new ElementSpec(null, ElementSpec.EndTagType),
+            new ElementSpec(null, ElementSpec.EndTagType),
+        };
+        doc.create(specs);
+
+        root = doc.getDefaultRootElement();
+        assertEquals(2, root.getElementCount());
+
+        Element child = root.getElement(0);
+        assertFalse(child.isLeaf());
+        assertEquals(0, child.getStartOffset());
+        assertEquals(1, child.getEndOffset());
+        assertEquals(1, child.getElementCount());
+
+        child = child.getElement(0);
+        assertFalse(child.isLeaf());
+        assertEquals(1, child.getElementCount());
+        assertTrue(child.getElement(0).isLeaf());
+
+
+        child = root.getElement(1);
+        assertFalse(child.isLeaf());
+        assertEquals(1, child.getStartOffset());
+        assertEquals(2, child.getEndOffset());
+        assertEquals(1, child.getElementCount());
+        assertTrue(child.getElement(0).isLeaf());
+    }
+
+    /**
+     * Tests insertion of a character at the start of a paragraph where
+     * the previous paragraph and the character inserted have equal attribute
+     * sets whereas the next paragraph to which the character inserted should
+     * belong has other attribute set.
+     * @throws BadLocationException
+     */
+    public void testInsertString01() throws BadLocationException {
+        doc.remove(0, doc.getLength());
+        doc.buffer = new ElementBufferWithLogging(doc, root) {
+            public void insert(int offset, int length, ElementSpec[] spec,
+                               DefaultDocumentEvent event) {
+                specs = spec;
+                super.insert(offset, length, spec, event);
+            }
+        };
+        StyleConstants.setBold(attrs, true);
+        doc.insertString(0, "b", attrs);
+        doc.insertString(0, "\n", null);
+
+        doc.insertString(1, "1", null);
+
+        ElementSpec[] ess = {
+            new ElementSpec(null, ElementSpec.EndTagType),
+            new ElementSpec(null, ElementSpec.StartTagType),
+            new ElementSpec(null, ElementSpec.ContentType, 1)
+        };
+        ess[1].setDirection(ElementSpec.JoinNextDirection);
+
+        assertEquals(ess.length, specs.length);
+        for (int i = 0; i < ess.length; i++) {
+            assertEquals("@ " + i, ess[i].getType(), specs[i].getType());
+            assertEquals("@ " + i, ess[i].getDirection(),
+                         specs[i].getDirection());
+        }
+
+        int[][] offsets = {
+            {0, 1},
+            {1, 2, 2, 3, 3, 4}
+        };
+
+        for (int i = 0; i < root.getElementCount(); i++) {
+            Element paragraph = root.getElement(i);
+            for (int j = 0, oi = 0; j < paragraph.getElementCount(); j++) {
+                Element content = paragraph.getElement(j);
+                assertEquals("root[" + i + "].start",
+                             offsets[i][oi++], content.getStartOffset());
+                assertEquals("root[" + i + "].end",
+                             offsets[i][oi++], content.getEndOffset());
+                if (i == 1 && j == 1) {
+                    assertTrue(StyleConstants.isBold(content.getAttributes()));
+                } else {
+                    assertEquals(0, content.getAttributes().getAttributeCount());
+                }
+            }
+        }
+    }
+
+    /**
+     * Tests insertion of a character at the start of a styled run where
+     * the previous run and the character inserted have equal attribute
+     * sets whereas the next run has other attribute set.
+     * @throws BadLocationException
+     */
+    public void testInsertString02() throws BadLocationException {
+        doc.remove(0, doc.getLength());
+        doc.buffer = new ElementBufferWithLogging(doc, root) {
+            public void insert(int offset, int length, ElementSpec[] spec,
+                               DefaultDocumentEvent event) {
+                specs = spec;
+                super.insert(offset, length, spec, event);
+            }
+        };
+        StyleConstants.setBold(attrs, true);
+        doc.insertString(0, "b", attrs);
+        doc.insertString(0, "\n", null);
+        doc.insertString(1, "1", null);
+
+        doc.insertString(2, "1", null);
+
+        assertEquals(1, specs.length);
+        assertEquals(ElementSpec.ContentType, specs[0].getType());
+        assertEquals(ElementSpec.JoinPreviousDirection,
+                     specs[0].getDirection());
+
+        int[][] offsets = {
+            {0, 1},
+            {1, 3, 3, 4, 4, 5}
+        };
+
+        for (int i = 0; i < root.getElementCount(); i++) {
+            Element paragraph = root.getElement(i);
+            for (int j = 0, oi = 0; j < paragraph.getElementCount(); j++) {
+                Element content = paragraph.getElement(j);
+                assertEquals("root[" + i + "].start",
+                             offsets[i][oi++], content.getStartOffset());
+                assertEquals("root[" + i + "].end",
+                             offsets[i][oi++], content.getEndOffset());
+                if (i == 1 && j == 1) {
+                    assertTrue(StyleConstants.isBold(content.getAttributes()));
+                } else {
+                    assertEquals(0, content.getAttributes().getAttributeCount());
+                }
+            }
+        }
+     }
+
     protected void setUp() throws Exception {
         super.setUp();
         doc = new DefStyledDoc_Helpers.DefStyledDocWithLogging();
@@ -124,4 +465,101 @@
         attrs = new SimpleAttributeSet();
     }
 
+    private void initStructure() throws BadLocationException {
+        doc = new DefStyledDoc_Helpers.DefStyledDocWithLogging();
+        root = doc.getDefaultRootElement();
+        buf = new DefStyledDoc_Helpers.ElementBufferWithLogging(doc, root) {
+            public void insert(int offset, int length, ElementSpec[] spec,
+                               DefaultDocumentEvent event) {
+                super.insert(offset, length, specs = spec, event);
+            }
+        };
+        doc.buffer = buf;
+
+        doc.writeLock();
+        try {
+            doc.getContent().insertString(0, "\n0000");
+
+            final BranchElement html = (BranchElement)root;
+            html.addAttribute(ELEMENT_NAME, "html");
+
+            final BranchElement head = createBranch(html);
+            head.addAttribute(ELEMENT_NAME, "head");
+
+            final BranchElement implied = createBranch(head);
+            implied.addAttribute(ELEMENT_NAME, "p-implied");
+            final LeafElement content0 = createLeaf(implied, 0, 1);
+            content0.addAttribute(ELEMENT_NAME, "head-content");
+
+
+            final BranchElement body = createBranch(html);
+            body.addAttribute(ELEMENT_NAME, "body");
+
+            final BranchElement p1 = createBranch(body);
+            p1.addAttribute(ELEMENT_NAME, "p1");
+            final LeafElement content1 = createLeaf(p1, 1, 5);
+            content1.addAttribute(ELEMENT_NAME, "leaf1");
+            final LeafElement content2 = createLeaf(p1, 5, 6);
+            content2.addAttribute(ELEMENT_NAME, "leaf2");
+            implied.replace(0, 0, new Element[] {content0});
+            p1.replace(0, 0, new Element[] {content1, content2});
+            head.replace(0, 0, new Element[] {implied});
+            body.replace(0, 0, new Element[] {p1});
+            html.replace(0, 1, new Element[] {head, body});
+        } finally {
+            doc.writeUnlock();
+        }
+    }
+
+    private void createEmptyHTMLStructure() {
+        doc = new DefStyledDoc_Helpers.DefStyledDocWithLogging();
+        root = doc.getDefaultRootElement();
+        buf = new DefStyledDoc_Helpers.ElementBufferWithLogging(doc, root) {
+            public void insert(int offset, int length, ElementSpec[] spec,
+                               DefaultDocumentEvent event) {
+                super.insert(offset, length, specs = spec, event);
+            }
+        };
+        doc.buffer = buf;
+
+        doc.writeLock();
+        try {
+            final BranchElement html = (BranchElement)root;
+            html.addAttribute(ELEMENT_NAME, "html");
+
+            final BranchElement body = createBranch(html);
+            body.addAttribute(ELEMENT_NAME, "body");
+
+            final BranchElement p = createBranch(body);
+            p.addAttribute(ELEMENT_NAME, "p");
+            final LeafElement content = createLeaf(p, 0, 1);
+            content.addAttribute(ELEMENT_NAME, "leaf1");
+            p.replace(0, 0, new Element[] {content});
+            body.replace(0, 0, new Element[] {p});
+            html.replace(0, 1, new Element[] {body});
+        } finally {
+            doc.writeUnlock();
+        }
+    }
+
+    private BranchElement createBranch(final Element parent) {
+        return (BranchElement)doc.createBranchElement(parent, null);
+    }
+
+    private LeafElement createLeaf(final Element parent,
+                                   final int start, final int end) {
+        return (LeafElement)doc.createLeafElement(parent, null, start, end);
+    }
+
+
+    private static void assertChildren(final Element element,
+                                       final int[] offsets) {
+        DefStyledDoc_Helpers.assertChildren(element, offsets);
+    }
+
+    private static void assertSpec(final ElementSpec spec, final short type,
+                                   final short direction, final int offset,
+                                   final int length) {
+        DefStyledDoc_Helpers.assertSpec(spec, type, direction, offset, length);
+    }
 }

Modified: incubator/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/text/FlowViewTest.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/text/FlowViewTest.java?view=diff&rev=440748&r1=440747&r2=440748
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/text/FlowViewTest.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/text/FlowViewTest.java Wed Sep  6 09:06:15 2006
@@ -303,7 +303,7 @@
                                                                    null);
         assertEquals(-19, xSR.minimum);
         assertEquals(-13, xSR.preferred);
-        assertEquals(Short.MAX_VALUE, xSR.maximum);
+        assertEquals(Integer.MAX_VALUE, xSR.maximum);
         assertEquals(0.5f, xSR.alignment, 1e-5f);
 
         SizeRequirements ySR = view.calculateMinorAxisRequirements(View.Y_AXIS,
@@ -311,7 +311,7 @@
         assertSame(xSR, ySR);
         assertEquals(7, xSR.minimum);
         assertEquals(13, xSR.preferred);
-        assertEquals(Short.MAX_VALUE, xSR.maximum);
+        assertEquals(Integer.MAX_VALUE, xSR.maximum);
         assertEquals(0.5f, xSR.alignment, 1e-5f);
     }
 
@@ -407,7 +407,7 @@
         assertNotNull(view.strategy);
 
         FlowView other = new FlowViewImpl(root, View.Y_AXIS);
-        assertNotSame(view.strategy, other.strategy);
+        assertSame(view.strategy, other.strategy);
     }
 
     public void testGetFlowAxis() {
@@ -453,6 +453,203 @@
         assertEquals(-10, view.getFlowSpan(0));
         assertEquals(-10, view.getFlowSpan(1));
         assertEquals(-10, view.getFlowSpan(2));
+    }
+
+    public void testGetSpanNoRow() throws Exception {
+        view = new FlowViewImplWithFactory(root, View.Y_AXIS);
+        view.loadChildren(null);
+        assertEquals(0, view.getViewCount());
+
+        view.layoutPool.replace(1, view.layoutPool.getViewCount() - 1, null);
+        assertEquals(1, view.layoutPool.getViewCount());
+
+        final View child = view.layoutPool.getView(0);
+        int childX = (int)child.getPreferredSpan(View.X_AXIS);
+        int childY = (int)child.getPreferredSpan(View.Y_AXIS);
+        assertEquals(childX, (int)child.getMinimumSpan(View.X_AXIS));
+        assertEquals(childY, (int)child.getMinimumSpan(View.Y_AXIS));
+        assertEquals(childX, (int)child.getMaximumSpan(View.X_AXIS));
+        assertEquals(childY, (int)child.getMaximumSpan(View.Y_AXIS));
+
+        assertEquals(0, (int)view.layoutPool.getMinimumSpan(View.X_AXIS));
+        assertEquals(0, (int)view.layoutPool.getMinimumSpan(View.Y_AXIS));
+        assertEquals(childX, (int)view.layoutPool.getPreferredSpan(View.X_AXIS));
+        assertEquals(childY, (int)view.layoutPool.getPreferredSpan(View.Y_AXIS));
+        assertEquals(childX, (int)view.layoutPool.getMaximumSpan(View.X_AXIS));
+        assertEquals(childY, (int)view.layoutPool.getMaximumSpan(View.Y_AXIS));
+
+        assertEquals(0, (int)view.getMinimumSpan(View.X_AXIS));
+        assertEquals(0, (int)view.getMinimumSpan(View.Y_AXIS));
+        assertEquals(childX, (int)view.getPreferredSpan(View.X_AXIS));
+        assertEquals(0, (int)view.getPreferredSpan(View.Y_AXIS));
+        assertEquals(Integer.MAX_VALUE, (int)view.getMaximumSpan(View.X_AXIS));
+        assertEquals(0, (int)view.getMaximumSpan(View.Y_AXIS));
+    }
+
+    public void testGetSpanOneRowNoChildren() throws Exception {
+        view = new FlowViewImplWithFactory(root, View.Y_AXIS);
+        view.loadChildren(null);
+        assertEquals(0, view.getViewCount());
+
+        view.layoutPool.replace(1, view.layoutPool.getViewCount() - 1, null);
+        assertEquals(1, view.layoutPool.getViewCount());
+        final View row = view.createRow();
+        view.append(row);
+
+        final View child = view.layoutPool.getView(0);
+        int childX = (int)child.getPreferredSpan(View.X_AXIS);
+        int childY = (int)child.getPreferredSpan(View.Y_AXIS);
+        assertEquals(childX, (int)child.getMinimumSpan(View.X_AXIS));
+        assertEquals(childY, (int)child.getMinimumSpan(View.Y_AXIS));
+        assertEquals(childX, (int)child.getMaximumSpan(View.X_AXIS));
+        assertEquals(childY, (int)child.getMaximumSpan(View.Y_AXIS));
+
+        assertEquals(0, (int)view.layoutPool.getMinimumSpan(View.X_AXIS));
+        assertEquals(0, (int)view.layoutPool.getMinimumSpan(View.Y_AXIS));
+        assertEquals(childX, (int)view.layoutPool.getPreferredSpan(View.X_AXIS));
+        assertEquals(childY, (int)view.layoutPool.getPreferredSpan(View.Y_AXIS));
+        assertEquals(childX, (int)view.layoutPool.getMaximumSpan(View.X_AXIS));
+        assertEquals(childY, (int)view.layoutPool.getMaximumSpan(View.Y_AXIS));
+
+        assertEquals(0, (int)view.getMinimumSpan(View.X_AXIS));
+        assertEquals(0, (int)view.getMinimumSpan(View.Y_AXIS));
+        assertEquals(childX, (int)view.getPreferredSpan(View.X_AXIS));
+        assertEquals(0, (int)view.getPreferredSpan(View.Y_AXIS));
+        assertEquals(Integer.MAX_VALUE, (int)view.getMaximumSpan(View.X_AXIS));
+        assertEquals(Integer.MAX_VALUE, (int)view.getMaximumSpan(View.Y_AXIS));
+    }
+
+    public void testGetSpanOneRowOneChild() throws Exception {
+        view = new FlowViewImplWithFactory(root, View.Y_AXIS);
+        view.loadChildren(null);
+        assertEquals(0, view.getViewCount());
+
+        view.layoutPool.replace(1, view.layoutPool.getViewCount() - 1, null);
+        assertEquals(1, view.layoutPool.getViewCount());
+
+        final View row = view.createRow();
+        view.append(row);
+        final View child = view.layoutPool.getView(0);
+        row.append(child);
+
+        int childX = (int)child.getPreferredSpan(View.X_AXIS);
+        int childY = (int)child.getPreferredSpan(View.Y_AXIS);
+        assertEquals(childX, (int)child.getMinimumSpan(View.X_AXIS));
+        assertEquals(childY, (int)child.getMinimumSpan(View.Y_AXIS));
+        assertEquals(childX, (int)child.getMaximumSpan(View.X_AXIS));
+        assertEquals(childY, (int)child.getMaximumSpan(View.Y_AXIS));
+
+        assertEquals(0, (int)view.layoutPool.getMinimumSpan(View.X_AXIS));
+        assertEquals(0, (int)view.layoutPool.getMinimumSpan(View.Y_AXIS));
+        assertEquals(childX, (int)view.layoutPool.getPreferredSpan(View.X_AXIS));
+        assertEquals(childY, (int)view.layoutPool.getPreferredSpan(View.Y_AXIS));
+        assertEquals(childX, (int)view.layoutPool.getMaximumSpan(View.X_AXIS));
+        assertEquals(childY, (int)view.layoutPool.getMaximumSpan(View.Y_AXIS));
+
+        assertEquals(0, (int)view.getMinimumSpan(View.X_AXIS));
+        assertEquals(childY, (int)view.getMinimumSpan(View.Y_AXIS));
+        assertEquals(childX, (int)view.getPreferredSpan(View.X_AXIS));
+        assertEquals(childY, (int)view.getPreferredSpan(View.Y_AXIS));
+        assertEquals(Integer.MAX_VALUE, (int)view.getMaximumSpan(View.X_AXIS));
+        assertEquals(Integer.MAX_VALUE, (int)view.getMaximumSpan(View.Y_AXIS));
+    }
+
+    public void testGetSpanNoRowFlexible() throws Exception {
+        ChildrenFactory factory = new ChildrenFactory();
+        factory.makeFlexible();
+        view = new FlowViewImplWithFactory(root, View.Y_AXIS, factory);
+        view.loadChildren(null);
+        assertEquals(0, view.getViewCount());
+
+        view.layoutPool.replace(1, view.layoutPool.getViewCount() - 1, null);
+        assertEquals(1, view.layoutPool.getViewCount());
+        final View child = view.layoutPool.getView(0);
+        int childPrefX = (int)child.getPreferredSpan(View.X_AXIS);
+        int childPrefY = (int)child.getPreferredSpan(View.Y_AXIS);
+
+        assertEquals(0, (int)view.layoutPool.getMinimumSpan(View.X_AXIS));
+        assertEquals(0, (int)view.layoutPool.getMinimumSpan(View.Y_AXIS));
+        assertEquals(childPrefX, (int)view.layoutPool.getPreferredSpan(View.X_AXIS));
+        assertEquals(childPrefY, (int)view.layoutPool.getPreferredSpan(View.Y_AXIS));
+        assertEquals(childPrefX, (int)view.layoutPool.getMaximumSpan(View.X_AXIS));
+        assertEquals(childPrefY, (int)view.layoutPool.getMaximumSpan(View.Y_AXIS));
+
+        assertEquals(0, (int)view.getMinimumSpan(View.X_AXIS));
+        assertEquals(0, (int)view.getMinimumSpan(View.Y_AXIS));
+        assertEquals(childPrefX, (int)view.getPreferredSpan(View.X_AXIS));
+        assertEquals(0, (int)view.getPreferredSpan(View.Y_AXIS));
+        assertEquals(Integer.MAX_VALUE, (int)view.getMaximumSpan(View.X_AXIS));
+        assertEquals(0, (int)view.getMaximumSpan(View.Y_AXIS));
+    }
+
+    public void testGetSpanOneRowNoChildrenFlexible() throws Exception {
+        ChildrenFactory factory = new ChildrenFactory();
+        factory.makeFlexible();
+        view = new FlowViewImplWithFactory(root, View.Y_AXIS, factory);
+        view.loadChildren(null);
+        assertEquals(0, view.getViewCount());
+
+        view.layoutPool.replace(1, view.layoutPool.getViewCount() - 1, null);
+        assertEquals(1, view.layoutPool.getViewCount());
+        final View row = view.createRow();
+        view.append(row);
+        final View child = view.layoutPool.getView(0);
+        int childPrefX = (int)child.getPreferredSpan(View.X_AXIS);
+        int childPrefY = (int)child.getPreferredSpan(View.Y_AXIS);
+
+        assertEquals(0, (int)view.layoutPool.getMinimumSpan(View.X_AXIS));
+        assertEquals(0, (int)view.layoutPool.getMinimumSpan(View.Y_AXIS));
+        assertEquals(childPrefX, (int)view.layoutPool.getPreferredSpan(View.X_AXIS));
+        assertEquals(childPrefY, (int)view.layoutPool.getPreferredSpan(View.Y_AXIS));
+        assertEquals(childPrefX, (int)view.layoutPool.getMaximumSpan(View.X_AXIS));
+        assertEquals(childPrefY, (int)view.layoutPool.getMaximumSpan(View.Y_AXIS));
+
+        assertEquals(0, (int)view.getMinimumSpan(View.X_AXIS));
+        assertEquals(0, (int)view.getMinimumSpan(View.Y_AXIS));
+        assertEquals(childPrefX, (int)view.getPreferredSpan(View.X_AXIS));
+        assertEquals(0, (int)view.getPreferredSpan(View.Y_AXIS));
+        assertEquals(Integer.MAX_VALUE, (int)view.getMaximumSpan(View.X_AXIS));
+        assertEquals(Integer.MAX_VALUE, (int)view.getMaximumSpan(View.Y_AXIS));
+    }
+
+    public void testGetSpanOneRowOneChildFlexible() throws Exception {
+        ChildrenFactory factory = new ChildrenFactory();
+        factory.makeFlexible();
+        view = new FlowViewImplWithFactory(root, View.Y_AXIS, factory);
+        view.loadChildren(null);
+        assertEquals(0, view.getViewCount());
+
+        view.layoutPool.replace(1, view.layoutPool.getViewCount() - 1, null);
+        assertEquals(1, view.layoutPool.getViewCount());
+        final View row = view.createRow();
+        view.append(row);
+        final View child = view.layoutPool.getView(0);
+        row.append(child);
+        int childMinY = (int)child.getMinimumSpan(View.Y_AXIS);
+        int childPrefX = (int)child.getPreferredSpan(View.X_AXIS);
+        int childPrefY = (int)child.getPreferredSpan(View.Y_AXIS);
+
+        assertEquals(0, (int)view.layoutPool.getMinimumSpan(View.X_AXIS));
+        assertEquals(0, (int)view.layoutPool.getMinimumSpan(View.Y_AXIS));
+        assertEquals(childPrefX, (int)view.layoutPool.getPreferredSpan(View.X_AXIS));
+        assertEquals(childPrefY, (int)view.layoutPool.getPreferredSpan(View.Y_AXIS));
+        assertEquals(childPrefX, (int)view.layoutPool.getMaximumSpan(View.X_AXIS));
+        assertEquals(childPrefY, (int)view.layoutPool.getMaximumSpan(View.Y_AXIS));
+
+        assertEquals(0, (int)view.getMinimumSpan(View.X_AXIS));
+        assertEquals(childMinY, (int)view.getMinimumSpan(View.Y_AXIS));
+        assertEquals(childPrefX, (int)view.getPreferredSpan(View.X_AXIS));
+        assertEquals(childPrefY, (int)view.getPreferredSpan(View.Y_AXIS));
+        assertEquals(Integer.MAX_VALUE, (int)view.getMaximumSpan(View.X_AXIS));
+        assertEquals(Integer.MAX_VALUE, (int)view.getMaximumSpan(View.Y_AXIS));
+    }
+
+    public void testGetAttributesLayoutPool() {
+        view = new FlowViewImplWithFactory(root, View.Y_AXIS);
+        view.loadChildren(null);
+        assertSame(view.getAttributes(), view.layoutPool.getAttributes());
+        view.layoutPool.setParent(null);
+        assertNull(view.layoutPool.getAttributes());
     }
 
     private int getSpanY() {

Modified: incubator/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/text/ParagraphViewTest.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/text/ParagraphViewTest.java?view=diff&rev=440748&r1=440747&r2=440748
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/text/ParagraphViewTest.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/text/ParagraphViewTest.java Wed Sep  6 09:06:15 2006
@@ -1011,6 +1011,13 @@
         params.check(end, Bias.Forward, SwingConstants.NORTH, 0, 0);
     }
 
+    public void testGetAttributesRow() {
+        final View row = view.createRow();
+        assertNull(row.getAttributes());
+        row.setParent(view);
+        assertSame(view.getAttributes(), row.getAttributes());
+    }
+
     private static AttributeSet getInsetsAttributeSet() {
         MutableAttributeSet attrs = new SimpleAttributeSet();
         StyleConstants.setSpaceAbove(attrs, 9.53f);

Modified: incubator/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/text/StyleContextTest.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/text/StyleContextTest.java?view=diff&rev=440748&r1=440747&r2=440748
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/text/StyleContextTest.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/text/StyleContextTest.java Wed Sep  6 09:06:15 2006
@@ -283,6 +283,14 @@
                        style.getResolveParent());
         }
     }
+    
+    public void testAddStyleTwice() {
+        final String styleName = "styleName";
+        final Style style = sc.addStyle(styleName, null);
+        final Style another = sc.addStyle(styleName, null);
+        assertNotSame(style, another);
+        assertSame(another, sc.getStyle(styleName));
+    }
 
     public void testCreateSmallAttributeSet() {
         AttributeSet as = sc.createSmallAttributeSet(sc.getEmptySet());



Mime
View raw message