harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hinde...@apache.org
Subject svn commit: r496045 - in /harmony/enhanced/classlib/trunk/modules/swing: make/ src/main/java/common/javax/swing/ src/test/api/java/common/javax/swing/
Date Sun, 14 Jan 2007 09:22:28 GMT
Author: hindessm
Date: Sun Jan 14 01:22:27 2007
New Revision: 496045

URL: http://svn.apache.org/viewvc?view=rev&rev=496045
Log:
Applying patches from "[#HARMONY-2668] [classlib][swing] new test-cases for
j.s.Spring and j.s.SpringLayout".

Modified:
    harmony/enhanced/classlib/trunk/modules/swing/make/exclude.linux.x86.drl
    harmony/enhanced/classlib/trunk/modules/swing/make/exclude.linux.x86.ibm
    harmony/enhanced/classlib/trunk/modules/swing/make/exclude.linux.x86_64.drl
    harmony/enhanced/classlib/trunk/modules/swing/make/exclude.linux.x86_64.ibm
    harmony/enhanced/classlib/trunk/modules/swing/make/exclude.windows.x86.drl
    harmony/enhanced/classlib/trunk/modules/swing/make/exclude.windows.x86.ibm
    harmony/enhanced/classlib/trunk/modules/swing/make/exclude.windows.x86_64.drl
    harmony/enhanced/classlib/trunk/modules/swing/make/exclude.windows.x86_64.ibm
    harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/SpringLayout.java
    harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/SpringLayoutTest.java
    harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/SpringTest.java

Modified: harmony/enhanced/classlib/trunk/modules/swing/make/exclude.linux.x86.drl
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/swing/make/exclude.linux.x86.drl?view=diff&rev=496045&r1=496044&r2=496045
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/swing/make/exclude.linux.x86.drl (original)
+++ harmony/enhanced/classlib/trunk/modules/swing/make/exclude.linux.x86.drl Sun Jan 14 01:22:27 2007
@@ -8,7 +8,6 @@
 javax/swing/JInternalFrame_MultithreadedTest.java
 javax/swing/JTextField_NotifyActionRTest.java
 javax/swing/ProgressMonitorTest.java
-javax/swing/SpringTest.java
 javax/swing/plaf/basic/BasicDesktopPaneUIActionsTest.java
 javax/swing/plaf/basic/BasicMenuUI_MultithreadedTest.java
 javax/swing/plaf/basic/BasicOptionPaneUITest.java

Modified: harmony/enhanced/classlib/trunk/modules/swing/make/exclude.linux.x86.ibm
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/swing/make/exclude.linux.x86.ibm?view=diff&rev=496045&r1=496044&r2=496045
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/swing/make/exclude.linux.x86.ibm (original)
+++ harmony/enhanced/classlib/trunk/modules/swing/make/exclude.linux.x86.ibm Sun Jan 14 01:22:27 2007
@@ -8,7 +8,6 @@
 javax/swing/JInternalFrame_MultithreadedTest.java
 javax/swing/JTextField_NotifyActionRTest.java
 javax/swing/ProgressMonitorTest.java
-javax/swing/SpringTest.java
 javax/swing/plaf/basic/BasicDesktopPaneUIActionsTest.java
 javax/swing/plaf/basic/BasicMenuUI_MultithreadedTest.java
 javax/swing/plaf/basic/BasicOptionPaneUITest.java

Modified: harmony/enhanced/classlib/trunk/modules/swing/make/exclude.linux.x86_64.drl
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/swing/make/exclude.linux.x86_64.drl?view=diff&rev=496045&r1=496044&r2=496045
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/swing/make/exclude.linux.x86_64.drl (original)
+++ harmony/enhanced/classlib/trunk/modules/swing/make/exclude.linux.x86_64.drl Sun Jan 14 01:22:27 2007
@@ -11,7 +11,6 @@
 javax/swing/JInternalFrame_MultithreadedTest.java
 javax/swing/JTextField_NotifyActionRTest.java
 javax/swing/ProgressMonitorTest.java
-javax/swing/SpringTest.java
 javax/swing/plaf/basic/BasicDesktopPaneUIActionsTest.java
 javax/swing/plaf/basic/BasicMenuUI_MultithreadedTest.java
 javax/swing/plaf/basic/BasicOptionPaneUITest.java

Modified: harmony/enhanced/classlib/trunk/modules/swing/make/exclude.linux.x86_64.ibm
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/swing/make/exclude.linux.x86_64.ibm?view=diff&rev=496045&r1=496044&r2=496045
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/swing/make/exclude.linux.x86_64.ibm (original)
+++ harmony/enhanced/classlib/trunk/modules/swing/make/exclude.linux.x86_64.ibm Sun Jan 14 01:22:27 2007
@@ -8,7 +8,6 @@
 javax/swing/JInternalFrame_MultithreadedTest.java
 javax/swing/JTextField_NotifyActionRTest.java
 javax/swing/ProgressMonitorTest.java
-javax/swing/SpringTest.java
 javax/swing/plaf/basic/BasicDesktopPaneUIActionsTest.java
 javax/swing/plaf/basic/BasicMenuUI_MultithreadedTest.java
 javax/swing/plaf/basic/BasicOptionPaneUITest.java

Modified: harmony/enhanced/classlib/trunk/modules/swing/make/exclude.windows.x86.drl
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/swing/make/exclude.windows.x86.drl?view=diff&rev=496045&r1=496044&r2=496045
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/swing/make/exclude.windows.x86.drl (original)
+++ harmony/enhanced/classlib/trunk/modules/swing/make/exclude.windows.x86.drl Sun Jan 14 01:22:27 2007
@@ -12,7 +12,6 @@
 javax/swing/JInternalFrame_MultithreadedTest.java
 javax/swing/JTextField_NotifyActionRTest.java
 javax/swing/ProgressMonitorTest.java
-javax/swing/SpringTest.java
 javax/swing/plaf/basic/BasicDesktopPaneUIActionsTest.java
 javax/swing/plaf/basic/BasicMenuUI_MultithreadedTest.java
 javax/swing/plaf/basic/BasicOptionPaneUITest.java

Modified: harmony/enhanced/classlib/trunk/modules/swing/make/exclude.windows.x86.ibm
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/swing/make/exclude.windows.x86.ibm?view=diff&rev=496045&r1=496044&r2=496045
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/swing/make/exclude.windows.x86.ibm (original)
+++ harmony/enhanced/classlib/trunk/modules/swing/make/exclude.windows.x86.ibm Sun Jan 14 01:22:27 2007
@@ -19,7 +19,6 @@
 javax/swing/JInternalFrame_MultithreadedTest.java
 javax/swing/JTextField_NotifyActionRTest.java
 javax/swing/ProgressMonitorTest.java
-javax/swing/SpringTest.java
 javax/swing/plaf/basic/BasicDesktopPaneUIActionsTest.java
 javax/swing/plaf/basic/BasicMenuUI_MultithreadedTest.java
 javax/swing/plaf/basic/BasicOptionPaneUITest.java

Modified: harmony/enhanced/classlib/trunk/modules/swing/make/exclude.windows.x86_64.drl
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/swing/make/exclude.windows.x86_64.drl?view=diff&rev=496045&r1=496044&r2=496045
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/swing/make/exclude.windows.x86_64.drl (original)
+++ harmony/enhanced/classlib/trunk/modules/swing/make/exclude.windows.x86_64.drl Sun Jan 14 01:22:27 2007
@@ -8,7 +8,6 @@
 javax/swing/JInternalFrame_MultithreadedTest.java
 javax/swing/JTextField_NotifyActionRTest.java
 javax/swing/ProgressMonitorTest.java
-javax/swing/SpringTest.java
 javax/swing/plaf/basic/BasicDesktopPaneUIActionsTest.java
 javax/swing/plaf/basic/BasicMenuUI_MultithreadedTest.java
 javax/swing/plaf/basic/BasicOptionPaneUITest.java

Modified: harmony/enhanced/classlib/trunk/modules/swing/make/exclude.windows.x86_64.ibm
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/swing/make/exclude.windows.x86_64.ibm?view=diff&rev=496045&r1=496044&r2=496045
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/swing/make/exclude.windows.x86_64.ibm (original)
+++ harmony/enhanced/classlib/trunk/modules/swing/make/exclude.windows.x86_64.ibm Sun Jan 14 01:22:27 2007
@@ -8,7 +8,6 @@
 javax/swing/JInternalFrame_MultithreadedTest.java
 javax/swing/JTextField_NotifyActionRTest.java
 javax/swing/ProgressMonitorTest.java
-javax/swing/SpringTest.java
 javax/swing/plaf/basic/BasicDesktopPaneUIActionsTest.java
 javax/swing/plaf/basic/BasicMenuUI_MultithreadedTest.java
 javax/swing/plaf/basic/BasicOptionPaneUITest.java

Modified: harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/SpringLayout.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/SpringLayout.java?view=diff&rev=496045&r1=496044&r2=496045
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/SpringLayout.java (original)
+++ harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/SpringLayout.java Sun Jan 14 01:22:27 2007
@@ -26,8 +26,8 @@
 import java.awt.LayoutManager2;
 import java.util.HashMap;
 import java.util.HashSet;
-import java.util.Iterator;
 import java.util.Map;
+import java.util.Set;
 
 public class SpringLayout implements LayoutManager2 {
     public static class Constraints {
@@ -270,25 +270,28 @@
             this.component = component;
         }
 
+        @Override
         public int getMinimumValue() {
             return getSpring().getMinimumValue();
         }
 
+        @Override
         public int getPreferredValue() {
             return getSpring().getPreferredValue();
         }
 
+        @Override
         public int getMaximumValue() {
             return getSpring().getMaximumValue();
         }
 
+        @Override
         public int getValue() {
             final Spring s = getSpring();
             if (layout.calculatedSprings.containsKey(s)) {
-                return ((Integer)layout.calculatedSprings.get(s)).intValue();
+                return layout.calculatedSprings.get(s).intValue();
             }
             if (layout.markedSprings.contains(s)) {
-                printCycles();
                 return 0;
             }
             layout.markedSprings.add(s);
@@ -297,16 +300,17 @@
             return value;
         }
 
+        @Override
         public void setValue(final int value) {
             final Spring s = getSpring();
             if (layout.markedSprings.contains(s)) {
-                printCycles();
                 return;
             }
             layout.markedSprings.add(s);
             s.setValue(value);
         }
 
+        @Override
         public String toString() {
             String edgeName;
             switch (edgeType) {
@@ -347,13 +351,6 @@
                 return null;
             }
         }
-
-        private void printCycles() {
-            final Iterator iterator = layout.markedSprings.iterator();
-            while (iterator.hasNext()) {
-                System.err.println(iterator.next() + " is cyclic.");
-            }
-        }
     }
 
     public static final String WEST = "West";
@@ -369,9 +366,9 @@
     private static final byte WIDTH = 4;
     private static final byte HEIGHT = 5;
 
-    private Map calculatedSprings = new HashMap();
-    private Map constraintsMap = new HashMap();
-    private HashSet markedSprings = new HashSet();
+    private Map<Spring, Integer> calculatedSprings = new HashMap<Spring, Integer>();
+    private Map<Component, Constraints> constraintsMap = new HashMap<Component, Constraints>();
+    private Set<Spring> markedSprings = new HashSet<Spring>();
 
     public SpringLayout() {
     }
@@ -431,7 +428,7 @@
     public void addLayoutComponent(final Component component,
                                    final Object constraints) {
         if (constraints != null && constraints instanceof Constraints) {
-            constraintsMap.put(component, constraints);
+            constraintsMap.put(component, (Constraints)constraints);
         }
     }
 
@@ -482,9 +479,9 @@
     }
 
     public Constraints getConstraints(final Component component) {
-        Constraints constraints = (Constraints)constraintsMap.get(component);
+        Constraints constraints = constraintsMap.get(component);
         if (constraints != null) {
-            return (Constraints) constraints;
+            return constraints;
         }
 
         constraints = new Constraints(Spring.constant(0),
@@ -554,7 +551,7 @@
             calculatedSprings.put(s, new Integer(value));
             return value;
         }
-        return ((Integer)calculatedSprings.get(s)).intValue();
+        return calculatedSprings.get(s).intValue();
     }
 
     private void initTargetConstrains(final Container target,

Modified: harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/SpringLayoutTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/SpringLayoutTest.java?view=diff&rev=496045&r1=496044&r2=496045
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/SpringLayoutTest.java (original)
+++ harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/SpringLayoutTest.java Sun Jan 14 01:22:27 2007
@@ -14,32 +14,62 @@
  *  See the License for the specific language governing permissions and
  *  limitations under the License.
  */
-/**
- * @author Roman I. Chernyatchik
- * @version $Revision$
- */
 package javax.swing;
 
 import java.awt.Component;
 import java.awt.Container;
+import java.awt.Dimension;
+import java.awt.Rectangle;
+import java.awt.TextField;
+
 import javax.swing.SpringLayout.Constraints;
 
 public class SpringLayoutTest extends SwingTestCase {
     private Component component;
-
     private SpringLayout layout;
+    private JPanel container;
+    private JButton button;
+    private JTextField textField;
+    private JPanel panel;
+    private JButton innerButton;
 
     @Override
     protected void setUp() throws Exception {
         super.setUp();
         layout = new SpringLayout();
         component = new JLabel("label");
+        container = new JPanel(layout);
+        button = new JButton();
+        textField = new JTextField();
+        panel = new JPanel();
+        innerButton = new JButton();
+
+        container.add(button);
+        container.add(panel);
+        container.add(textField);
+
+        panel.add(innerButton);
+
+        setComponentSizes(container, Spring.constant(0, 5, Integer.MAX_VALUE),
+                          Spring.constant(0, 5, Integer.MAX_VALUE));
+
+        setComponentSizes(button, Spring.constant(2, 5, 100),
+                          Spring.constant(2, 5, 100));
+
+        setComponentSizes(textField, Spring.constant(2, 10, Integer.MAX_VALUE),
+                          Spring.constant(2, 10, Integer.MAX_VALUE));
+
+        setComponentSizes(panel, Spring.constant(1, 3, Integer.MAX_VALUE),
+                          Spring.constant(1, 3, Integer.MAX_VALUE));
+
+        setComponentSizes(innerButton, Spring.constant(2, 10, 60),
+                          Spring.constant(2, 10, 60));
     }
 
     public void testSpringLayout() {
         SpringLayout.Constraints constrains = new SpringLayout.Constraints();
-        //        assertNull(constrains.getX());
-        //        assertNull(constrains.getY());
+        assertNull(constrains.getX());
+        assertNull(constrains.getY());
         assertNull(constrains.getWidth());
         assertNull(constrains.getHeight());
         constrains = new SpringLayout.Constraints(Spring.width(component), Spring.constant(0));
@@ -68,7 +98,6 @@
         SpringTest.assertSizes(4, 4, 4, 4, constrains.getHeight());
         constrains = new SpringLayout.Constraints(Spring.constant(1), null);
         SpringTest.assertSizes(1, 1, 1, 1, constrains.getX());
-        //  assertNull(constrains.getY());
         Container container = new JPanel();
         container.setLayout(layout);
         container.add(new JLabel(""));
@@ -83,37 +112,23 @@
                 constrains.getHeight());
     }
 
-    public void testRemoveLayoutComponent() {
-        layout.removeLayoutComponent(null);
-        layout.removeLayoutComponent(new JLabel());
-        layout.addLayoutComponent(component, new SpringLayout.Constraints(component));
-        layout.removeLayoutComponent(null);
-        layout.removeLayoutComponent(new JLabel());
-        JPanel panel = new JPanel();
-        panel.add(component);
-        assertSame(panel, component.getParent());
-        layout.removeLayoutComponent(component);
-        assertNotNull(component.getParent());
-        Constraints constraints = layout.getConstraints(component);
-        SpringTest.assertSizes(0, 0, 0, 0, constraints.getX());
-        SpringTest.assertSizes(0, 0, 0, 0, constraints.getY());
-    }
-
     public void testGetLayoutAlignmentX() {
-        new JPanel().add(component);
+        JPanel container = new JPanel(layout);
         assertEquals(0.5f, layout.getLayoutAlignmentX(null), 0.01);
-        assertEquals(0.5f, layout.getLayoutAlignmentX(component.getParent()), 0.01);
+        assertEquals(0.5f, layout.getLayoutAlignmentX(container), 0.01);
     }
 
     public void testGetLayoutAlignmentY() {
-        new JPanel().add(component);
+        JPanel container = new JPanel(layout);
         assertEquals(0.5f, layout.getLayoutAlignmentY(null), 0.01);
-        assertEquals(0.5f, layout.getLayoutAlignmentY(component.getParent()), 0.01);
+        assertEquals(0.5f, layout.getLayoutAlignmentY(container), 0.01);
     }
 
-    public void testGetConstraints_ForComponent() {
+    public void testGetConstraints() {
+        Constraints constraints = layout.getConstraints(null);
+        assertNotNull(constraints);
         layout.addLayoutComponent(component, "not_constraints");
-        Constraints constraints = layout.getConstraints(component);
+        constraints = layout.getConstraints(component);
         assertNotNull(constraints);
         SpringTest.assertSizes(0, 0, 0, constraints.getX());
         SpringTest.assertSizes(0, 0, 0, constraints.getY());
@@ -123,7 +138,6 @@
         SpringTest.assertSizes(component.getMinimumSize().height,
                 component.getPreferredSize().height, component.getMaximumSize().height,
                 constraints.getHeight());
-        layout = new SpringLayout();
         layout.addLayoutComponent(component, null);
         constraints = layout.getConstraints(component);
         assertNotNull(constraints);
@@ -143,5 +157,1061 @@
         SpringTest.assertValues(componentConstraints.getY(), constraints.getY());
         SpringTest.assertValues(componentConstraints.getWidth(), constraints.getWidth());
         SpringTest.assertValues(componentConstraints.getHeight(), constraints.getHeight());
+
+        assertNotNull(layout.getConstraints(new JLabel()));
+    }
+
+    public void testGetConstraint() {
+        layout.putConstraint(SpringLayout.SOUTH, button, Spring.constant(5),
+                             SpringLayout.NORTH, container);
+        layout.putConstraint(SpringLayout.EAST, button, Spring.constant(5),
+                             SpringLayout.WEST, container);
+
+        layout.layoutContainer(container);
+
+        Spring constraint = layout.getConstraint(SpringLayout.WEST, button);
+        assertEquals(0, constraint.getValue());
+        layout.getConstraints(button).setConstraint(SpringLayout.EAST, Spring.constant(100));
+        layout.layoutContainer(container);
+        assertEquals(95, constraint.getValue());
+
+        assertNotNull(layout.getConstraint(SpringLayout.EAST, new JLabel()));
+    }
+
+    public void testPutConstraint_Cycles() throws Exception {
+        if (isHarmony()) {
+          layout.putConstraint(SpringLayout.EAST, button, 5, SpringLayout.WEST, panel);
+          layout.putConstraint(SpringLayout.EAST, panel, 5, SpringLayout.WEST, textField);
+          layout.putConstraint(SpringLayout.EAST, textField, 5, SpringLayout.WEST, button);
+          layout.layoutContainer(container);
+          layout.layoutContainer(container);
+
+          layout.getConstraints(button);
+
+          assertEdges(layout.getConstraints(button), -3, 2, 0, 5);
+          assertEdges(layout.getConstraints(panel), -3, 0, 0, 3);
+          assertEdges(layout.getConstraints(textField), -5, 5, 0, 10);
+
+          layout.putConstraint(SpringLayout.EAST, textField, 5, SpringLayout.WEST, container);
+          layout.layoutContainer(container);
+        }
+    }
+
+    public void testPutConstraint() throws Exception {
+        JFrame frame = new JFrame("testPutConstraint");
+        container.setLayout(layout);
+        layout.putConstraint(SpringLayout.SOUTH, button, 5, SpringLayout.NORTH, container);
+        layout.putConstraint(SpringLayout.EAST, button, Spring.constant(5),
+                             SpringLayout.WEST, container);
+
+        frame.pack();
+        frame.setVisible(true);
+        frame.setSize(100, 200);
+        assertEquals(0, button.getX());
+        assertEquals(0, button.getY());
+
+        layout.putConstraint(SpringLayout.EAST, button, Spring.constant(15),
+                             SpringLayout.WEST, container);
+
+        layout.layoutContainer(container);
+        assertEquals(10, button.getX());
+        assertEquals(0, button.getY());
+
+        layout.putConstraint(SpringLayout.SOUTH, button,
+                             null,
+                             SpringLayout.NORTH, container);
+
+        testExceptionalCase(new NullPointerCase() {
+            @Override
+            public void exceptionalAction() throws Exception {
+               layout.layoutContainer(container);
+            }
+
+        });
+        assertEquals(10, button.getX());
+        assertEquals(0, button.getY());
+
+
+        //Independence from constraints order
+        layout = new SpringLayout();
+        container.setLayout(layout);
+        JTextField textField = new JTextField();
+        textField.getInsets().set(5, 5, 5, 5);
+        setComponentSizes(textField, Spring.constant(2, 10, Integer.MAX_VALUE),
+                          Spring.constant(2, 10, Integer.MAX_VALUE));
+        container.add(textField);
+
+        layout.getConstraints(button).setHeight(Spring.constant(50));
+
+        layout.putConstraint(SpringLayout.NORTH, textField, Spring.constant(5),
+                             SpringLayout.SOUTH, button);
+
+        layout.putConstraint(SpringLayout.SOUTH, textField, Spring.constant(-10),
+                             SpringLayout.SOUTH, container);
+
+        container.setSize(200, 200);
+        layout.layoutContainer(container);
+        if (isHarmony()) {
+            assertEquals(135, textField.getHeight());
+        } else {
+            assertEquals(10, textField.getHeight());
+        }
+
+        layout = new SpringLayout();
+        textField = new JTextField();
+        container.add(textField);
+        container.setLayout(layout);
+        layout.getConstraints(button).setHeight(Spring.constant(50));
+
+        layout.putConstraint(SpringLayout.SOUTH, textField, Spring.constant(-10),
+                             SpringLayout.SOUTH, container);
+
+        layout.putConstraint(SpringLayout.NORTH, textField, Spring.constant(5),
+                             SpringLayout.SOUTH, button);
+
+        container.setSize(200, 200);
+        layout.layoutContainer(container);
+        assertEquals(135, textField.getHeight());
+
+        component = new TextField();
+        layout.putConstraint(SpringLayout.NORTH, textField, Spring.constant(5),
+                             SpringLayout.SOUTH, component);
+        layout.layoutContainer(container);
+        assertEquals(185, textField.getHeight());
+    }
+
+    public void testAddLayoutComponent() throws Exception {
+        Constraints constraints = new Constraints(Spring.constant(1), Spring.constant(2),
+                                                  Spring.constant(3), Spring.constant(4));
+        layout.addLayoutComponent(null, constraints);
+        Constraints componentCnstraints = layout.getConstraints(null);
+        assertNotNull(componentCnstraints);
+        assertSame(componentCnstraints, constraints);
+
+        layout.addLayoutComponent(button, null);
+        componentCnstraints = layout.getConstraints(button);
+        assertNotNull(componentCnstraints);
+        assertEquals(componentCnstraints.getX().getValue(), 0);
+        assertEquals(componentCnstraints.getY().getValue(), 0);
+        assertEquals(componentCnstraints.getWidth().getValue(), button.getPreferredSize().width);
+        assertEquals(componentCnstraints.getHeight().getValue(), button.getPreferredSize().height);
+
+        layout.addLayoutComponent(button, constraints);
+        componentCnstraints = layout.getConstraints(button);
+        assertSame(componentCnstraints, constraints);
+    }
+
+    public void testRemoveLayoutComponent() {
+        layout.removeLayoutComponent(null);
+        layout.removeLayoutComponent(new JLabel());
+
+        layout.addLayoutComponent(component, new SpringLayout.Constraints(component));
+        layout.removeLayoutComponent(null);
+        layout.removeLayoutComponent(new JLabel());
+
+        JPanel panel = new JPanel(layout);
+        panel.add(component);
+        Constraints constraints1 = layout.getConstraints(component);
+        layout.removeLayoutComponent(component);
+
+        Constraints constraints2 = layout.getConstraints(component);
+        assertNotSame(constraints1, constraints2);
+        SpringTest.assertSizes(0, 0, 0, 0, constraints2.getX());
+        SpringTest.assertSizes(0, 0, 0, 0, constraints2.getY());
+
+        component = new JTextField();
+        JLabel label = new JLabel("label");
+        setComponentSizes(label, Spring.constant(5), Spring.constant(10));
+        panel.add(component);
+        panel.add(label);
+
+        layout.getConstraints(label).setX(Spring.constant(15));
+        layout.putConstraint(SpringLayout.WEST, component,
+                             5,
+                             SpringLayout.EAST, label);
+        layout.layoutContainer(panel);
+        assertEquals(15, label.getX());
+
+        layout.removeLayoutComponent(label);
+        layout.layoutContainer(panel);
+        assertEquals(0, label.getX());
+    }
+
+    public void testInvalidateLayout() throws Exception {
+        JFrame frame = new JFrame("testMinimumLayoutSize");
+        frame.setContentPane(container);
+        layout = new SpringLayout();
+        container.setLayout(layout);
+        Constraints buttonConstraints = layout.getConstraints(button);
+        buttonConstraints.setHeight(Spring.constant(33, 34, 35));
+        Constraints containerConstraints = layout.getConstraints(container);
+        containerConstraints.setConstraint(SpringLayout.SOUTH,
+                                           buttonConstraints.getConstraint(SpringLayout.SOUTH));
+        containerConstraints.setConstraint(SpringLayout.EAST,
+                                           buttonConstraints.getConstraint(SpringLayout.EAST));
+        containerConstraints.setConstraint(SpringLayout.WEST, Spring.constant(3));        
+        frame.pack();
+        frame.setVisible(true);
+        frame.setSize(100, 200);
+
+        Spring width = buttonConstraints.getWidth();
+        if (isHarmony()) {
+            assertEquals(5, width.getValue());
+        } else {
+            assertEquals(115, width.getValue());
+        }
+        frame.setSize(200, 300);
+        layout.invalidateLayout(container);
+        assertSame(width, buttonConstraints.getWidth());
+        if (isHarmony()) {
+            assertEquals(5, width.getValue());
+        } else {
+            assertEquals(115, width.getValue());
+        }
+    }
+
+    public void testLayoutContainer() throws Exception {
+        button.setPreferredSize(new Dimension(11, 12));
+
+        Constraints buttonConstraints = layout.getConstraints(button);
+        buttonConstraints.setHeight(Spring.constant(35));
+        Constraints containerConstraints = layout.getConstraints(container);
+        containerConstraints.setConstraint(SpringLayout.SOUTH,
+                                           buttonConstraints.getConstraint(SpringLayout.SOUTH));
+        container.setSize(100, 200);
+        layout.layoutContainer(container);
+        assertBounds(0, 0, 11, 35, button.getBounds());
+
+        containerConstraints.setConstraint(SpringLayout.EAST, buttonConstraints.getWidth());
+        layout.layoutContainer(container);
+        assertBounds(0, 0, 100, 35, button.getBounds());
+
+        container.setSize(101, 201);
+        buttonConstraints.setHeight(Spring.constant(40));
+        layout.layoutContainer(innerButton);
+        assertBounds(0, 0, 100, 35, button.getBounds());
+
+        container.setSize(102, 202);
+        buttonConstraints.setHeight(Spring.constant(50));
+        layout.layoutContainer(textField);
+        assertBounds(0, 0, 100, 35, button.getBounds());
+
+        //putConstraints()
+        layout = new SpringLayout();
+        container.setLayout(layout);
+        layout.putConstraint(SpringLayout.SOUTH, button, Spring.constant(5),
+                             SpringLayout.NORTH, panel);
+        layout.putConstraint(SpringLayout.SOUTH, button, Spring.constant(15),
+                             SpringLayout.NORTH, panel);
+        layout.putConstraint(SpringLayout.SOUTH, textField, Spring.constant(55),
+                             SpringLayout.SOUTH, button);
+        layout.putConstraint(SpringLayout.EAST, button, Spring.constant(15),
+                             SpringLayout.WEST, panel);
+
+        layout.putConstraint(SpringLayout.EAST, textField, Spring.constant(55),
+                             SpringLayout.EAST, button);
+        container.setSize(100, 200);
+        layout.layoutContainer(container);
+
+        Spring y = Spring.sum(Spring.sum(layout.getConstraint(SpringLayout.SOUTH, button),
+                                         Spring.constant(55)),
+                              Spring.minus(Spring.height(textField)));
+        Spring height = Spring.height(textField);
+        assertBounds(4, 3, 11, 12, button.getBounds());
+        assertBounds(60, y.getValue(), 10, height.getValue(), textField.getBounds());
+
+        layout = new SpringLayout();
+        container.setLayout(layout);
+        layout.putConstraint(SpringLayout.NORTH, button, Spring.constant(5),
+                             SpringLayout.NORTH, panel);
+        layout.putConstraint(SpringLayout.NORTH, button, Spring.constant(15),
+                             SpringLayout.NORTH, panel);
+        layout.putConstraint(SpringLayout.NORTH, textField, Spring.constant(55),
+                             SpringLayout.SOUTH, button);
+        layout.putConstraint(SpringLayout.WEST, button, Spring.constant(15),
+                             SpringLayout.WEST, panel);
+        layout.putConstraint(SpringLayout.WEST, textField, Spring.constant(55),
+                             SpringLayout.EAST, button);
+        layout.layoutContainer(container);
+        y = Spring.sum(layout.getConstraint(SpringLayout.SOUTH, button),
+                       Spring.constant(55));
+        height = Spring.height(textField);
+        assertBounds(15, 15, 11, 12, button.getBounds());
+        assertBounds(81, y.getValue(), 10, height.getValue(), textField.getBounds());
+    }
+
+    public void testMinimumLayoutSize() throws Exception {
+        //container
+        setComponentSizes(button, Spring.constant(2, 5, 100), Spring.constant(3, 6, 101));
+        Constraints buttonConstraints = layout.getConstraints(button);
+        buttonConstraints.setHeight(Spring.constant(33, 34, 35));
+        Constraints containerConstraints = layout.getConstraints(container);
+        containerConstraints.setConstraint(SpringLayout.SOUTH,
+                                           buttonConstraints.getConstraint(SpringLayout.SOUTH));
+        containerConstraints.setConstraint(SpringLayout.EAST,
+                                           buttonConstraints.getConstraint(SpringLayout.EAST));
+        containerConstraints.setConstraint(SpringLayout.WEST, Spring.constant(3));
+        layout.layoutContainer(container);
+        assertEquals(2, layout.minimumLayoutSize(container).width);
+        assertEquals(33, layout.minimumLayoutSize(container).height);
+
+        //putConstraints()
+        assertEquals(button.getInsets().left + button.getInsets().right,
+                     layout.minimumLayoutSize(button).width);
+
+        assertEquals(panel.getInsets().left + panel.getInsets().right,
+                     layout.minimumLayoutSize(panel).width);
+
+        assertEquals(innerButton.getInsets().left + innerButton.getInsets().right,
+                     layout.minimumLayoutSize(innerButton).width);
+
+        buttonConstraints.setX(Spring.constant(20));
+        assertEquals(button.getInsets().left + button.getInsets().right,
+                     layout.minimumLayoutSize(button).width);
+        assertEquals(0, layout.getConstraint(SpringLayout.EAST, button).getPreferredValue());
+
+        buttonConstraints.setWidth(Spring.constant(100));
+        assertEquals(100 + button.getInsets().left + button.getInsets().right,
+                     layout.minimumLayoutSize(button).width);
+
+        layout.getConstraints(innerButton).setX(Spring.constant(20));
+        assertEquals(innerButton.getInsets().left + innerButton.getInsets().right,
+                     layout.minimumLayoutSize(innerButton).width);
+
+        layout.getConstraints(innerButton).setWidth(Spring.constant(100));
+        assertEquals(100 + innerButton.getInsets().left + innerButton.getInsets().right,
+                     layout.minimumLayoutSize(innerButton).width);
+
+        layout.getConstraints(panel).setX(Spring.constant(20));
+        assertEquals(panel.getInsets().left + panel.getInsets().right,
+                     layout.minimumLayoutSize(panel).width);
+        assertEquals(0, layout.getConstraint(SpringLayout.EAST, panel).getPreferredValue());
+
+        layout.getConstraints(panel).setWidth(Spring.constant(100));
+        assertEquals(100 + panel.getInsets().left + panel.getInsets().right,
+                     layout.minimumLayoutSize(panel).width);
+        assertEquals(100, layout.getConstraint(SpringLayout.EAST, panel).getPreferredValue());
+
+
+        layout = new SpringLayout();
+        container.setLayout(layout);
+        layout.putConstraint(SpringLayout.SOUTH, button, Spring.constant(15),
+                             SpringLayout.NORTH, container);
+        layout.putConstraint(SpringLayout.EAST, button, Spring.constant(5),
+                             SpringLayout.WEST, container);
+        assertEquals(panel.getInsets().left + panel.getInsets().right,
+                     layout.minimumLayoutSize(panel).width);
+        assertEquals(innerButton.getInsets().left + innerButton.getInsets().right,
+                     layout.minimumLayoutSize(innerButton).width);
+
+        assertEquals(5 + button.getInsets().left + button.getInsets().right,
+                     layout.minimumLayoutSize(button).width);
+    }
+
+    public void testPreferredLayoutSize() throws Exception {
+        //container
+        setComponentSizes(button,
+                          Spring.constant(2, 5, 100),
+                          Spring.constant(3, 6, 101));
+        Constraints buttonConstraints = layout.getConstraints(button);
+        buttonConstraints.setHeight(Spring.constant(33, 34, 35));
+        Constraints containerConstraints = layout.getConstraints(container);
+        containerConstraints.setConstraint(SpringLayout.SOUTH,
+                                           buttonConstraints
+                                               .getConstraint(SpringLayout.SOUTH));
+        containerConstraints.setConstraint(SpringLayout.EAST,
+                                           buttonConstraints
+                                               .getConstraint(SpringLayout.EAST));
+        containerConstraints.setConstraint(SpringLayout.WEST,
+                                           Spring.constant(3));
+        layout.layoutContainer(container);
+        assertEquals(5, layout.preferredLayoutSize(container).width);
+        assertEquals(34, layout.preferredLayoutSize(container).height);
+
+        //putConstraints()
+        assertEquals(button.getInsets().left
+                     + button.getInsets().right,
+                     layout.preferredLayoutSize(button).width);
+
+        assertEquals(panel.getInsets().left
+                     + panel.getInsets().right,
+                     layout.preferredLayoutSize(panel).width);
+
+        assertEquals(innerButton.getInsets().left
+                     + innerButton.getInsets().right,
+                     layout.preferredLayoutSize(innerButton).width);
+
+        buttonConstraints.setX(Spring.constant(20));
+        assertEquals(button.getInsets().left
+                     + button.getInsets().right,
+                     layout.preferredLayoutSize(button).width);
+        assertEquals(0,
+                     layout.getConstraint(SpringLayout.EAST, button)
+                        .getPreferredValue());
+
+        buttonConstraints.setWidth(Spring.constant(100));
+        assertEquals(100
+                     + button.getInsets().left
+                     + button.getInsets().right,
+                     layout.preferredLayoutSize(button).width);
+
+        layout.getConstraints(innerButton).setX(Spring.constant(20));
+        assertEquals(innerButton.getInsets().left
+                     + innerButton.getInsets().right,
+                     layout.preferredLayoutSize(innerButton).width);
+
+        layout.getConstraints(innerButton).setWidth(Spring.constant(100));
+        assertEquals(100
+                     + innerButton.getInsets().left
+                     + innerButton.getInsets().right,
+                     layout.preferredLayoutSize(innerButton).width);
+
+        layout.getConstraints(panel).setX(Spring.constant(20));
+        assertEquals(panel.getInsets().left
+                     + panel.getInsets().right,
+                     layout.preferredLayoutSize(panel).width);
+
+        assertEquals(0,
+                     layout.getConstraint(SpringLayout.EAST, panel)
+                        .getPreferredValue());
+
+        layout.getConstraints(panel).setWidth(Spring.constant(100));
+        assertEquals(100
+                     + panel.getInsets().left
+                     + panel.getInsets().right,
+                     layout.preferredLayoutSize(panel).width);
+        assertEquals(100,
+                     layout.getConstraint(SpringLayout.EAST, panel)
+                        .getPreferredValue());
+
+        layout = new SpringLayout();
+        container.setLayout(layout);
+        layout.putConstraint(SpringLayout.SOUTH, button,
+                             Spring.constant(15),
+                             SpringLayout.NORTH, container);
+
+
+        layout.putConstraint(SpringLayout.EAST, button,
+                             Spring.constant(5),
+                             SpringLayout.WEST, container);
+
+        assertEquals(panel.getInsets().left
+                     + panel.getInsets().right,
+                     layout.preferredLayoutSize(panel).width);
+
+        assertEquals(innerButton.getInsets().left
+                     + innerButton.getInsets().right,
+                     layout.preferredLayoutSize(innerButton).width);
+
+        assertEquals(5
+                     + button.getInsets().left
+                     + button.getInsets().right,
+                     layout.preferredLayoutSize(button).width);
+    }
+
+    public void testMaximumLayoutSize() throws Exception {
+        //container
+        setComponentSizes(button,
+                          Spring.constant(2, 5, 100),
+                          Spring.constant(3, 6, 101));
+        Constraints buttonConstraints = layout.getConstraints(button);
+        buttonConstraints.setHeight(Spring.constant(33, 34, 35));
+        Constraints containerConstraints = layout.getConstraints(container);
+        containerConstraints.setConstraint(SpringLayout.SOUTH,
+                                           buttonConstraints
+                                               .getConstraint(SpringLayout.SOUTH));
+        containerConstraints.setConstraint(SpringLayout.EAST,
+                                           buttonConstraints
+                                               .getConstraint(SpringLayout.EAST));
+        containerConstraints.setConstraint(SpringLayout.WEST,
+                                           Spring.constant(3));
+        layout.layoutContainer(container);
+        assertEquals(100, layout.maximumLayoutSize(container).width);
+        assertEquals(35, layout.maximumLayoutSize(container).height);
+
+        //putConstraints()
+        assertEquals(Integer.MAX_VALUE
+                     + button.getInsets().left
+                     + button.getInsets().right,
+                     layout.maximumLayoutSize(button).width);
+
+        assertEquals(Integer.MAX_VALUE
+                     + panel.getInsets().left
+                     + panel.getInsets().right,
+                     layout.maximumLayoutSize(panel).width);
+
+        assertEquals(Integer.MAX_VALUE
+                     + innerButton.getInsets().left
+                     + innerButton.getInsets().right,
+                     layout.maximumLayoutSize(innerButton).width);
+
+        buttonConstraints.setX(Spring.constant(20));
+        assertEquals(Integer.MAX_VALUE
+                     + button.getInsets().left
+                     + button.getInsets().right,
+                     layout.maximumLayoutSize(button).width);
+        assertEquals(0,
+                     layout.getConstraint(SpringLayout.EAST, button)
+                        .getPreferredValue());
+
+        buttonConstraints.setWidth(Spring.constant(100));
+        assertEquals(100
+                     + button.getInsets().left
+                     + button.getInsets().right,
+                     layout.maximumLayoutSize(button).width);
+
+        layout.getConstraints(innerButton).setX(Spring.constant(20));
+        assertEquals(Integer.MAX_VALUE
+                     + innerButton.getInsets().left
+                     + innerButton.getInsets().right,
+                     layout.maximumLayoutSize(innerButton).width);
+
+        layout.getConstraints(innerButton).setWidth(Spring.constant(100));
+        assertEquals(100
+                     + innerButton.getInsets().left
+                     + innerButton.getInsets().right,
+                     layout.maximumLayoutSize(innerButton).width);
+
+        layout.getConstraints(panel).setX(Spring.constant(20));
+        assertEquals(Integer.MAX_VALUE
+                     + panel.getInsets().left
+                     + panel.getInsets().right,
+                     layout.maximumLayoutSize(panel).width);
+
+        assertEquals(0,
+                     layout.getConstraint(SpringLayout.EAST, panel)
+                        .getPreferredValue());
+
+        layout.getConstraints(panel).setWidth(Spring.constant(100));
+        assertEquals(100
+                     + panel.getInsets().left
+                     + panel.getInsets().right,
+                     layout.maximumLayoutSize(panel).width);
+        assertEquals(100,
+                     layout.getConstraint(SpringLayout.EAST, panel)
+                        .getPreferredValue());
+
+        layout = new SpringLayout();
+        container.setLayout(layout);
+        layout.putConstraint(SpringLayout.SOUTH, button,
+                             Spring.constant(15),
+                             SpringLayout.NORTH, container);
+
+        layout.putConstraint(SpringLayout.EAST, button,
+                             Spring.constant(5),
+                             SpringLayout.WEST, container);
+
+        assertEquals(Integer.MAX_VALUE
+                     + panel.getInsets().left
+                     + panel.getInsets().right,
+                     layout.maximumLayoutSize(panel).width);
+
+        assertEquals(Integer.MAX_VALUE
+                     + innerButton.getInsets().left
+                     + innerButton.getInsets().right,
+                     layout.maximumLayoutSize(innerButton).width);
+
+        assertEquals(5
+                     + button.getInsets().left
+                     + button.getInsets().right,
+                     layout.maximumLayoutSize(button).width);
+    }
+
+    public void testConstraints_Constraints() throws Exception {
+        Constraints constraints;
+
+        //SpringLayout.Constraints()
+        constraints = new SpringLayout.Constraints();
+        assertNull(constraints.getConstraint(SpringLayout.WEST));
+        assertNull(constraints.getConstraint(SpringLayout.EAST));
+        assertNull(constraints.getConstraint(SpringLayout.NORTH));
+        assertNull(constraints.getConstraint(SpringLayout.SOUTH));
+        assertNull(constraints.getWidth());
+        assertNull(constraints.getHeight());
+        assertNull(constraints.getX());
+        assertNull(constraints.getY());
+
+        //SpringLayout.Constraints(Spring x, Spring y)
+        constraints = new SpringLayout.Constraints(Spring.constant(1),
+                                                   Spring.constant(2));
+        SpringTest.assertSizes(1, 1, 1,
+                               constraints.getConstraint(SpringLayout.WEST));
+        assertNull(constraints.getConstraint(SpringLayout.EAST));
+        SpringTest.assertSizes(2, 2, 2,
+                               constraints.getConstraint(SpringLayout.NORTH));
+        assertNull(constraints.getConstraint(SpringLayout.SOUTH));
+        assertNull(constraints.getWidth());
+        assertNull(constraints.getHeight());
+        SpringTest.assertSizes(1, 1, 1, constraints.getX());
+        SpringTest.assertSizes(2, 2, 2, constraints.getY());
+
+        //SpringLayout.Constraints(Spring x, Spring y,
+        //                         Spring width, Spring height)
+        constraints = new SpringLayout.Constraints(Spring.constant(1),
+                                                   Spring.constant(2),
+                                                   Spring.constant(10),
+                                                   Spring.constant(20));
+        SpringTest.assertSizes(1, 1, 1, 1,
+                               constraints.getConstraint(SpringLayout.WEST));
+        SpringTest.assertSizes(11, 11, 11, 11,
+                               constraints.getConstraint(SpringLayout.EAST));
+        SpringTest.assertSizes(2, 2, 2, 2,
+                               constraints.getConstraint(SpringLayout.NORTH));
+        SpringTest.assertSizes(22, 22, 22, 22,
+                               constraints.getConstraint(SpringLayout.SOUTH));
+        SpringTest.assertSizes(1, 1, 1, 1, constraints.getX());
+        SpringTest.assertSizes(2, 2, 2, 2, constraints.getY());
+        SpringTest.assertSizes(10, 10, 10, 10, constraints.getWidth());
+        SpringTest.assertSizes(20, 20, 20, 20, constraints.getHeight());
+
+        //SpringLayout.Constraints(Component c)
+        setComponentSizes(button,
+                          Spring.constant(1, 2, 3),
+                          Spring.constant(11, 12, 13));
+        constraints = new SpringLayout.Constraints(button);
+
+        SpringTest.assertSizes(0, 0, 0, 0,
+                               constraints.getConstraint(SpringLayout.WEST));
+        SpringTest.assertSizes(1, 2, 3, 2,
+                               constraints.getConstraint(SpringLayout.EAST));
+        SpringTest.assertSizes(0, 0, 0, 0,
+                               constraints.getConstraint(SpringLayout.NORTH));
+        SpringTest.assertSizes(11, 12, 13, 12,
+                               constraints.getConstraint(SpringLayout.SOUTH));
+        SpringTest.assertSizes(0, 0, 0, 0, constraints.getX());
+        SpringTest.assertSizes(0, 0, 0, 0, constraints.getY());
+
+        SpringTest.assertSizes(1, 2, 3, 2, constraints.getWidth());
+        SpringTest.assertSizes(11, 12, 13, 12, constraints.getHeight());
+    }
+
+    public void testConstraints_SetConstraint() throws Exception {
+        Constraints constraints;
+        layout.getConstraints(container).setConstraint(SpringLayout.WEST,
+                                                      Spring.constant(5));
+
+        layout.getConstraints(button).setConstraint(SpringLayout.WEST,
+                                                    Spring.constant(6));
+        layout.getConstraints(button).setX(Spring.constant(7));
+
+        constraints = layout.getConstraints(textField);
+        constraints.setX(Spring.constant(8));
+        constraints.setWidth(Spring.constant(10));
+        constraints.setConstraint(SpringLayout.EAST, Spring.constant(30));
+
+        layout.getConstraints(panel).setConstraint(SpringLayout.WEST,
+                                                   Spring.constant(7));
+        constraints.setWidth(Spring.constant(20));
+        layout.getConstraints(panel).setConstraint(SpringLayout.EAST,
+                                                   Spring.constant(17));
+
+        constraints = layout.getConstraints(innerButton);
+        constraints.setX(Spring.constant(18));
+        constraints.setWidth(Spring.constant(20));
+        constraints.setConstraint(SpringLayout.EAST, Spring.constant(50));
+
+        container.setSize(200, 300);
+        layout.layoutContainer(container);
+
+        assertEdges(layout.getConstraints(container),
+                    0, 200, 0, 300);
+
+        assertEdges(layout.getConstraints(button),
+                    7, 12, 0, 5);
+
+        assertEdges(layout.getConstraints(textField),
+                    10, 30, 0, 10);
+
+        if (isHarmony()) {
+            assertEdges(layout.getConstraints(panel),
+                        7, 17, 0, 3);
+        } else {
+            assertEdges(layout.getConstraints(panel),
+                        14, 17, 0, 3);
+        }
+
+        assertEdges(layout.getConstraints(innerButton),
+                    30, 50, 0, 10);
+
+        component = new JPanel();
+        setComponentSizes(component, Spring.constant(10), Spring.constant(5));
+        layout.getConstraints(panel).setConstraint(SpringLayout.NORTH,
+                                                   Spring.constant(1));
+        assertEdges(layout.getConstraints(component),
+                    0, 10, 0, 5);
+    }
+
+    public void testConstraints_GetConstraint() throws Exception {
+        Constraints constraints;
+        layout.getConstraints(container).setConstraint(SpringLayout.WEST,
+                                                      Spring.constant(5));
+
+        layout.getConstraints(button).setConstraint(SpringLayout.WEST,
+                                                    Spring.constant(6));
+        layout.getConstraints(button).setX(Spring.constant(7));
+
+        constraints = layout.getConstraints(textField);
+        constraints.setX(Spring.constant(8));
+        constraints.setWidth(Spring.constant(10));
+        constraints.setConstraint(SpringLayout.EAST, Spring.constant(30));
+
+        layout.getConstraints(panel).setConstraint(SpringLayout.WEST,
+                                                   Spring.constant(7));
+        constraints.setWidth(Spring.constant(20));
+        layout.getConstraints(panel).setConstraint(SpringLayout.EAST,
+                                                   Spring.constant(17));
+
+        constraints = layout.getConstraints(innerButton);
+        constraints.setX(Spring.constant(18));
+        constraints.setWidth(Spring.constant(20));
+        constraints.setConstraint(SpringLayout.EAST, Spring.constant(50));
+
+        container.setSize(200, 300);
+        layout.layoutContainer(container);
+
+        constraints = layout.getConstraints(container);
+        SpringTest.assertSizes(0, 0, 0, 0,
+                               constraints.getConstraint(SpringLayout.WEST));
+        SpringTest.assertSizes(0, 0, Integer.MAX_VALUE, 200,
+                               constraints.getConstraint(SpringLayout.EAST));
+
+        constraints = layout.getConstraints(button);
+        Spring west = constraints.getConstraint(SpringLayout.WEST);
+        Spring east = constraints.getConstraint(SpringLayout.EAST);
+        SpringTest.assertSizes(7, 7, 7, 7, west);
+        SpringTest.assertSizes(9, 12, 107, 12, east);
+
+        constraints.setConstraint(SpringLayout.WEST,
+                                  Spring.constant(200));
+        constraints.setConstraint(SpringLayout.EAST,
+                                  Spring.constant(100));
+        constraints.setWidth(Spring.constant(7));
+        layout.layoutContainer(container);
+        SpringTest.assertSizes(7, 7, 7, 7, west);
+        SpringTest.assertSizes(9, 12, 107, 12, east);
+
+        constraints.getConstraint("wrong value");
+
+        constraints = layout.getConstraints(innerButton);
+        west = constraints.getConstraint(SpringLayout.WEST);
+        east = constraints.getConstraint(SpringLayout.EAST);
+        SpringTest.assertSizes(30, 30, 30, 30, west);
+        SpringTest.assertSizes(50, 50, 50, 50, east);
+
+        constraints = new SpringLayout.Constraints();
+        constraints.setConstraint(SpringLayout.EAST,
+                                  Spring.constant(5));
+        assertNull(constraints.getConstraint(SpringLayout.WEST));
+        SpringTest.assertSizes(5, 5, 5,
+                               constraints.getConstraint(SpringLayout.EAST));
+        assertNull(constraints.getWidth());
+
+        constraints.setY(Spring.constant(3));
+        SpringTest.assertSizes(3, 3, 3, constraints.getY());
+        SpringTest.assertSizes(3, 3, 3,
+                               constraints.getConstraint(SpringLayout.NORTH));
+        assertNull(constraints.getConstraint(SpringLayout.SOUTH));
+
+        constraints = new SpringLayout.Constraints();
+        constraints.setHeight(Spring.constant(3));
+        assertNull(constraints.getY());
+        assertNull(constraints.getConstraint(SpringLayout.SOUTH));
+        assertNull(constraints.getConstraint(SpringLayout.NORTH));
+
+        constraints = new SpringLayout.Constraints(Spring.constant(1),
+                                                   Spring.constant(2));
+        constraints.setWidth(Spring.constant(10));
+        SpringTest.assertSizes(11, 11, 11,
+                               constraints.getConstraint(SpringLayout.EAST));
+
+    }
+
+    public void testConstraints_SetHeight() throws Exception {
+        layout.getConstraints(container).setHeight(Spring.constant(5));
+        layout.getConstraints(button).setHeight(Spring.constant(6));
+        layout.getConstraints(button).setHeight(Spring.constant(8));
+
+        Constraints constraints = layout.getConstraints(textField);
+        constraints.setHeight(Spring.constant(8));
+        constraints.setY(Spring.constant(10));
+        constraints.setConstraint(SpringLayout.EAST, Spring.constant(40));
+
+        layout.getConstraints(panel).setHeight(Spring.constant(6));
+        constraints.setY(Spring.constant(20));
+
+
+        layout.getConstraints(innerButton).setHeight(Spring.constant(15));
+
+        container.setSize(200, 300);
+        layout.layoutContainer(container);
+
+        assertEquals(300, container.getHeight());
+        assertEquals(8, button.getHeight());
+        assertEquals(8, textField.getHeight());
+        assertEquals(6, panel.getHeight());
+        assertEquals(0, innerButton.getHeight());
+    }
+
+    public void testConstraints_GetHeight() throws Exception {
+        layout.getConstraints(container).setHeight(Spring.constant(5));
+        layout.getConstraints(button).setHeight(Spring.constant(6));
+        layout.getConstraints(button).setHeight(Spring.constant(8));
+
+        Constraints constraints = layout.getConstraints(textField);
+        constraints.setHeight(Spring.constant(8));
+        constraints.setY(Spring.constant(10));
+        constraints.setConstraint(SpringLayout.EAST, Spring.constant(40));
+
+        layout.getConstraints(panel).setHeight(Spring.constant(6));
+        constraints.setY(Spring.constant(20));
+
+
+        layout.getConstraints(innerButton).setHeight(Spring.constant(15));
+
+        container.setSize(200, 300);
+        layout.layoutContainer(container);
+
+        SpringTest.assertSizes(5, 5, 5,
+                               layout.getConstraints(container).getHeight());
+        SpringTest.assertSizes(8, 8, 8,
+                               layout.getConstraints(button).getHeight());
+        SpringTest.assertSizes(8, 8, 8,
+                               layout.getConstraints(textField).getHeight());
+        SpringTest.assertSizes(6, 6, 6,
+                               layout.getConstraints(panel).getHeight());
+        SpringTest.assertSizes(15, 15, 15,
+                               layout.getConstraints(innerButton).getHeight());
+
+        container.setSize(200, 300);
+        layout.layoutContainer(button);
+        SpringTest.assertSizes(8, 8, 8,
+                               layout.getConstraints(button).getHeight());
+
+    }
+
+    public void testConstraints_SetWidth() throws Exception {
+        layout.getConstraints(container).setWidth(Spring.constant(5));
+        layout.getConstraints(button).setWidth(Spring.constant(6));
+        layout.getConstraints(button).setWidth(Spring.constant(8));
+
+        Constraints constraints = layout.getConstraints(textField);
+        constraints.setWidth(Spring.constant(8));
+        constraints.setX(Spring.constant(10));
+        constraints.setConstraint(SpringLayout.EAST, Spring.constant(40));
+
+        layout.getConstraints(panel).setWidth(Spring.constant(6));
+        constraints.setX(Spring.constant(20));
+
+
+        layout.getConstraints(innerButton).setWidth(Spring.constant(15));
+
+        container.setSize(200, 300);
+        layout.layoutContainer(container);
+
+        assertEquals(200, container.getWidth());
+        assertEquals(8, button.getWidth());
+        assertEquals(20, textField.getWidth());
+        assertEquals(6, panel.getWidth());
+        assertEquals(0, innerButton.getWidth());
+    }
+
+    public void testConstraints_GetWidth() throws Exception {
+        layout.getConstraints(container).setWidth(Spring.constant(5));
+        layout.getConstraints(button).setWidth(Spring.constant(6));
+        layout.getConstraints(button).setWidth(Spring.constant(8));
+
+        Constraints constraints = layout.getConstraints(textField);
+        constraints.setWidth(Spring.constant(8));
+        constraints.setX(Spring.constant(10));
+        constraints.setConstraint(SpringLayout.EAST, Spring.constant(40));
+
+        layout.getConstraints(panel).setWidth(Spring.constant(6));
+        constraints.setX(Spring.constant(20));
+
+
+        layout.getConstraints(innerButton).setWidth(Spring.constant(15));
+
+        container.setSize(200, 300);
+        layout.layoutContainer(container);
+
+        SpringTest.assertSizes(5, 5, 5,
+                               layout.getConstraints(container).getWidth());
+        SpringTest.assertSizes(8, 8, 8,
+                               layout.getConstraints(button).getWidth());
+        SpringTest.assertSizes(20, 20, 20,
+                               layout.getConstraints(textField).getWidth());
+        SpringTest.assertSizes(6, 6, 6,
+                               layout.getConstraints(panel).getWidth());
+        SpringTest.assertSizes(15, 15, 15,
+                               layout.getConstraints(innerButton).getWidth());
+
+        container.setSize(200, 300);
+        layout.layoutContainer(button);
+        SpringTest.assertSizes(8, 8, 8,
+                               layout.getConstraints(button).getWidth());
+    }
+
+    public void testConstraints_SetX() throws Exception {
+        layout.getConstraints(container).setX(Spring.constant(5));
+        layout.getConstraints(button).setX(Spring.constant(6));
+        layout.getConstraints(button).setX(Spring.constant(7));
+
+        Constraints constraints = layout.getConstraints(textField);
+        constraints.setX(Spring.constant(8));
+        constraints.setWidth(Spring.constant(10));
+        constraints.setConstraint(SpringLayout.EAST, Spring.constant(30));
+
+        layout.getConstraints(panel).setX(Spring.constant(7));
+        constraints.setWidth(Spring.constant(20));
+
+
+        layout.getConstraints(innerButton).setX(Spring.constant(17));
+
+        container.setSize(200, 300);
+        layout.layoutContainer(container);
+
+        assertEquals(0, container.getX());
+        assertEquals(7, button.getX());
+        assertEquals(10, textField.getX());
+        assertEquals(7, panel.getX());
+        assertEquals(0, innerButton.getX());
+    }
+
+    public void testConstraints_GetX() throws Exception {
+        layout.getConstraints(container).setX(Spring.constant(5));
+        layout.getConstraints(button).setX(Spring.constant(6));
+        layout.getConstraints(button).setX(Spring.constant(7));
+
+        Constraints constraints = layout.getConstraints(textField);
+        constraints.setX(Spring.constant(8));
+        constraints.setWidth(Spring.constant(10));
+        constraints.setConstraint(SpringLayout.EAST, Spring.constant(30));
+
+        layout.getConstraints(panel).setX(Spring.constant(7));
+        constraints.setWidth(Spring.constant(20));
+
+
+        layout.getConstraints(innerButton).setX(Spring.constant(17));
+
+        container.setSize(200, 300);
+        layout.layoutContainer(container);
+
+        SpringTest.assertSizes(0, 0, 0,
+                               layout.getConstraints(container).getX());
+        SpringTest.assertSizes(7, 7, 7,
+                               layout.getConstraints(button).getX());
+        SpringTest.assertSizes(10, 10, 10,
+                               layout.getConstraints(textField).getX());
+        SpringTest.assertSizes(7, 7, 7,
+                               layout.getConstraints(panel).getX());
+        SpringTest.assertSizes(17, 17, 17,
+                               layout.getConstraints(innerButton).getX());
+
+        container.setSize(200, 300);
+        layout.layoutContainer(button);
+        SpringTest.assertSizes(0, 0, 0,
+                               layout.getConstraints(button).getX());
+    }
+
+    public void testConstraints_SetY() throws Exception {
+        layout.getConstraints(container).setY(Spring.constant(5));
+        layout.getConstraints(button).setY(Spring.constant(6));
+        layout.getConstraints(button).setY(Spring.constant(8));
+
+        Constraints constraints = layout.getConstraints(textField);
+        constraints.setY(Spring.constant(8));
+        constraints.setHeight(Spring.constant(10));
+        constraints.setConstraint(SpringLayout.SOUTH, Spring.constant(40));
+
+        layout.getConstraints(panel).setY(Spring.constant(6));
+        constraints.setHeight(Spring.constant(20));
+
+
+        layout.getConstraints(innerButton).setY(Spring.constant(15));
+
+        container.setSize(200, 300);
+        layout.layoutContainer(container);
+
+        assertEquals(0, container.getY());
+        assertEquals(8, button.getY());
+        assertEquals(20, textField.getY());
+        assertEquals(6, panel.getY());
+        assertEquals(0, innerButton.getY());
+    }
+
+    public void testConstraints_GetY() throws Exception {
+        layout.getConstraints(container).setY(Spring.constant(5));
+        layout.getConstraints(button).setY(Spring.constant(6));
+        layout.getConstraints(button).setY(Spring.constant(8));
+
+        Constraints constraints = layout.getConstraints(textField);
+        constraints.setY(Spring.constant(8));
+        constraints.setHeight(Spring.constant(10));
+        constraints.setConstraint(SpringLayout.SOUTH, Spring.constant(40));
+
+        layout.getConstraints(panel).setY(Spring.constant(6));
+        constraints.setHeight(Spring.constant(20));
+
+
+        layout.getConstraints(innerButton).setY(Spring.constant(15));
+
+        container.setSize(200, 300);
+        layout.layoutContainer(container);
+
+        SpringTest.assertSizes(0, 0, 0,
+                               layout.getConstraints(container).getY());
+        SpringTest.assertSizes(8, 8, 8,
+                               layout.getConstraints(button).getY());
+        SpringTest.assertSizes(20, 20, 20,
+                               layout.getConstraints(textField).getY());
+        SpringTest.assertSizes(6, 6, 6,
+                               layout.getConstraints(panel).getY());
+        SpringTest.assertSizes(15, 15, 15,
+                               layout.getConstraints(innerButton).getY());
+
+        container.setSize(200, 300);
+        layout.layoutContainer(button);
+        SpringTest.assertSizes(0, 0, 0, layout.getConstraints(button).getY());
+    }
+
+    public static void setComponentSizes(final Component component,
+                                   final Spring width, final Spring height) {
+       component.setMinimumSize(new Dimension(width.getMinimumValue(),
+                                              height.getMinimumValue()));
+       component.setPreferredSize(new Dimension(width.getPreferredValue(),
+                                                height.getPreferredValue()));
+       component.setMaximumSize(new Dimension(width.getMaximumValue(),
+                                              height.getMaximumValue()));
+    }
+
+    private void assertBounds(final int x, final int y,
+                              final int width, final int height,
+                              final Rectangle bounds) {
+        assertLocation(x, y, bounds);
+        assertSize(width, height, bounds);
+    }
+
+    private void assertEdges(final Constraints constraints,
+                                 final int west, final int east,
+                                 final int north, final int south) {
+            assertEquals(west,
+                         constraints.getConstraint(SpringLayout.WEST).getValue());
+            assertEquals(east,
+                         constraints.getConstraint(SpringLayout.EAST).getValue());
+            assertEquals(north,
+                         constraints.getConstraint(SpringLayout.NORTH).getValue());
+            assertEquals(south,
+                         constraints.getConstraint(SpringLayout.SOUTH).getValue());
+        }
+    private void assertLocation(final int x, final int y,
+                              final Rectangle bounds) {
+        assertEquals(x, bounds.x);
+        assertEquals(y, bounds.y);
+    }
+
+    private void assertSize(final int width, final int height,
+                            final Rectangle bounds) {
+        assertEquals(width, bounds.width);
+        assertEquals(height, bounds.height);
     }
 }

Modified: harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/SpringTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/SpringTest.java?view=diff&rev=496045&r1=496044&r2=496045
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/SpringTest.java (original)
+++ harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/SpringTest.java Sun Jan 14 01:22:27 2007
@@ -14,39 +14,30 @@
  *  See the License for the specific language governing permissions and
  *  limitations under the License.
  */
-/**
- * @author Roman I. Chernyatchik
- * @version $Revision$
- */
 package javax.swing;
 
 import java.awt.Component;
 import java.awt.Dimension;
 
-/**
- * @version $Revision$
- */
 public class SpringTest extends SwingTestCase {
     private Spring spring;
-
     private Spring spring1;
-
     private Spring spring2;
 
     private Component component;
 
-    final Marker componentGetMinimumSizeCalled = new Marker();
-
-    final Marker componentGetPreferedSizeCalled = new Marker();
-
-    final Marker componentGetMaximumSizeCalled = new Marker();
+    private Marker componentGetMinimumSizeCalled;
+    private Marker componentGetPreferedSizeCalled;
+    private Marker componentGetMaximumSizeCalled;
 
     @Override
     protected void setUp() throws Exception {
         super.setUp();
-        componentGetMinimumSizeCalled.reset();
-        componentGetPreferedSizeCalled.reset();
-        componentGetMaximumSizeCalled.reset();
+
+        componentGetMinimumSizeCalled = new Marker();
+        componentGetPreferedSizeCalled = new Marker();
+        componentGetMaximumSizeCalled = new Marker();
+
         component = new JButton("test");
         initComponentSizes(component);
     }
@@ -61,6 +52,9 @@
         assertSizes(1, 2, 3, 2, spring);
         spring.setValue(10);
         assertSizes(1, 2, 3, 10, spring);
+        spring1 = Spring.constant(5);
+        spring2 = Spring.constant(5);
+        assertFalse(spring1.equals(spring2));
     }
 
     public void testConstant_UNSET() throws Exception {
@@ -91,17 +85,17 @@
         });
         spring1 = Spring.constant(12, 13, 15);
         spring = Spring.minus(spring1);
-        assertSizes((-1) * spring1.getMaximumValue(), (-1) * spring1.getPreferredValue(), (-1)
-                * spring1.getMinimumValue(), (-1) * spring1.getValue(), spring);
+        assertSizes(-spring1.getMaximumValue(), -spring1.getPreferredValue(),
+                    -spring1.getMinimumValue(), -spring1.getValue(), spring);
         component = new JButton("Test");
         setComponentSizes(component, new Dimension(59, 25));
         spring1 = Spring.width(component);
         spring = Spring.minus(spring1);
-        assertSizes((-1) * spring1.getMaximumValue(), (-1) * spring1.getPreferredValue(), (-1)
-                * spring1.getMinimumValue(), (-1) * spring1.getValue(), spring);
-        assertFalse(spring.getMinimumValue() == component.getMinimumSize().width);
+        assertSizes(-spring1.getMaximumValue(), -spring1.getPreferredValue(),
+                    -spring1.getMinimumValue(), -spring1.getValue(), spring);
+        assertEquals(-spring.getMinimumValue(), component.getMinimumSize().width);
         component.setMinimumSize(new Dimension(111, 112));
-        assertEquals((-1) * spring.getMaximumValue(), component.getMinimumSize().width);
+        assertEquals(-spring.getMaximumValue(), component.getMinimumSize().width);
         spring.setValue(333);
         assertEquals(-333, spring1.getValue());
         spring1.setValue(1);
@@ -126,7 +120,7 @@
         if (isHarmony()) {
             assertEquals(Spring.TRIMMED_MIN_VALUE, spring.getMaximumValue());
         } else {
-            assertEquals(Integer.MAX_VALUE * (-1), spring.getMaximumValue());
+            assertEquals(-Integer.MAX_VALUE, spring.getMaximumValue());
         }
         spring = Spring.minus(Spring.width(component));
         component.setMinimumSize(new Dimension(Integer.MIN_VALUE, Integer.MIN_VALUE));
@@ -182,6 +176,31 @@
                 Spring.max(null, Spring.constant(11)).getValue();
             }
         });
+        Component c1 = new JLabel("ss");
+        c1.setPreferredSize(new Dimension(15, 15));
+        c1.setMaximumSize(new Dimension(15, 15));
+        c1.setMinimumSize(new Dimension(15, 15));
+        Component c2 = new JTextField("ss");
+        c2.setPreferredSize(new Dimension(19, 19));
+        c2.setMinimumSize(new Dimension(19, 19));
+        Spring max = Spring.max(Spring.max(Spring.constant(0), Spring.height(c1)),
+                                Spring.height(c2));
+        Spring max6 = Spring.sum(max, Spring.constant(6));
+        spring1 = Spring.sum(Spring.sum(Spring.sum(Spring.constant(6), max6), max6), max6);
+
+        spring2 = max6;
+        spring = Spring.sum(spring1, spring2);
+        spring.setValue(418);
+        assertEquals(315, spring1.getValue()); //314
+        assertEquals(103, spring2.getValue()); //103
+
+        spring1 = Spring.constant(24, 81, 3 * Spring.TRIMMED_MAX_VALUE);
+        spring2 = Spring.constant(6, 25, Spring.TRIMMED_MAX_VALUE);
+        spring = Spring.sum(spring1, spring2);
+        spring.setValue(418);
+        assertEquals(314, spring1.getValue()); //314
+        assertEquals(104, spring2.getValue()); //103
+
         checkStrains(Spring.constant(2), Spring.constant(1, 2, 3), 2, 2, 0);
         checkStrains(Spring.constant(1, 2, 3), Spring.constant(2), 2, 0, 2);
         checkStrains(Spring.constant(2), Spring.constant(1, 2, 3), 4, 2, 2);
@@ -207,36 +226,74 @@
         checkStrains(Spring.constant(1, 1, 3), Spring.constant(1, 3, 1), 2, 1, 1);
         checkStrains(Spring.constant(1, 3, 1), Spring.constant(1, 1, 3), 4, 3, 1);
         checkStrains(Spring.constant(1, 1, 3), Spring.constant(1, 3, 1), 4, 1, 3);
-        checkStrains(Spring.constant(1, 3, 1), Spring.constant(1, 1, 3), 6, Spring.UNSET + 3,
-                6 - Spring.UNSET - 3);
+        if (isHarmony()) {
+            checkStrains(Spring.constant(1, 3, 1), Spring.constant(1, 1, 3), 6,
+                         Spring.TRIMMED_MAX_VALUE + 3, 6 - Spring.TRIMMED_MAX_VALUE - 3);
+        } else {
+            checkStrains(Spring.constant(1, 3, 1), Spring.constant(1, 1, 3), 6,
+                         Spring.UNSET + 3, 6 - Spring.UNSET - 3);
+        }
         checkStrains(Spring.constant(1, 1, 3), Spring.constant(1, 3, 1), 6, 1, 5);
         checkStrains(Spring.constant(1, 3, 1), Spring.constant(0, 1, 3), 2, 2, 0);
         checkStrains(Spring.constant(0, 1, 3), Spring.constant(1, 3, 1), 2, 1, 1);
         checkStrains(Spring.constant(1, 3, 1), Spring.constant(0, 1, 3), 4, 3, 1);
         checkStrains(Spring.constant(0, 1, 3), Spring.constant(1, 3, 1), 4, 1, 3);
         checkStrains(Spring.constant(0, 3, 1), Spring.constant(1, 1, 3), 4, 3, 1);
-        checkStrains(Spring.constant(1, 3, 1), Spring.constant(0, 1, 3), 6, Spring.UNSET + 3,
-                6 - Spring.UNSET - 3);
+        if (isHarmony()) {
+            checkStrains(Spring.constant(1, 3, 1), Spring.constant(0, 1, 3), 6,
+                         Spring.TRIMMED_MAX_VALUE + 3, 6 - Spring.TRIMMED_MAX_VALUE - 3);
+        } else {
+            checkStrains(Spring.constant(1, 3, 1), Spring.constant(0, 1, 3), 6,
+                         Spring.UNSET + 3, 6 - Spring.UNSET - 3);
+        }
         checkStrains(Spring.constant(0, 1, 3), Spring.constant(1, 3, 1), 6, 1, 5);
-        checkStrains(Spring.constant(0, 3, 1), Spring.constant(1, 1, 3), 6, Spring.UNSET + 3,
-                6 - Spring.UNSET - 3);
+        if (isHarmony()) {
+            checkStrains(Spring.constant(0, 3, 1), Spring.constant(1, 1, 3), 6,
+                         Spring.TRIMMED_MAX_VALUE + 3, 6 - Spring.TRIMMED_MAX_VALUE - 3);
+        } else {
+             checkStrains(Spring.constant(0, 3, 1), Spring.constant(1, 1, 3), 6,
+                          Spring.UNSET + 3, 6 - Spring.UNSET - 3);
+        }
         checkStrains(Spring.constant(3, 1, 3), Spring.constant(1, 3, 1), 2, 1, 1);
-        checkStrains(Spring.constant(1, 3, 1), Spring.constant(3, 1, 3), 2, Spring.UNSET + 3,
-                2 - Spring.UNSET - 3);
+        if (isHarmony()) {
+            checkStrains(Spring.constant(1, 3, 1), Spring.constant(3, 1, 3), 2,
+                         Spring.TRIMMED_MAX_VALUE + 3, 2 - Spring.TRIMMED_MAX_VALUE - 3);
+        } else {
+            checkStrains(Spring.constant(1, 3, 1), Spring.constant(3, 1, 3), 2,
+                         Spring.UNSET + 3, 2 - Spring.UNSET - 3);
+        }
         checkStrains(Spring.constant(3, 1, 3), Spring.constant(1, 3, 1), 4, 1, 3);
         checkStrains(Spring.constant(1, 3, 1), Spring.constant(3, 1, 3), 4, 3, 1);
         checkStrains(Spring.constant(3, 1, 3), Spring.constant(1, 3, 1), 6, 1, 5);
-        checkStrains(Spring.constant(1, 3, 1), Spring.constant(3, 1, 3), 6, Spring.UNSET + 3,
-                6 - Spring.UNSET - 3);
+        if (isHarmony()) {
+            checkStrains(Spring.constant(1, 3, 1), Spring.constant(3, 1, 3), 6,
+                         Spring.TRIMMED_MAX_VALUE + 3, 6 - Spring.TRIMMED_MAX_VALUE - 3);
+        } else {
+            checkStrains(Spring.constant(1, 3, 1), Spring.constant(3, 1, 3), 6,
+                         Spring.UNSET + 3, 6 - Spring.UNSET - 3);
+        }
         checkStrains(Spring.constant(2, 2, 5), Spring.constant(3), 3, 2, 1);
         checkStrains(Spring.constant(3), Spring.constant(2, 2, 5), 3, 3, 0);
         checkStrains(Spring.constant(2, 2, 5), Spring.constant(3), 5, 2, 3);
         checkStrains(Spring.constant(3), Spring.constant(2, 2, 5), 5, 3, 2);
         checkStrains(Spring.constant(2, 2, 5), Spring.constant(3), 7, 4, 3);
         checkStrains(Spring.constant(3), Spring.constant(2, 2, 5), 7, 3, 4);
-        checkStrains(Spring.constant(2, 4, 3), Spring.constant(3, 1, 0), 2, Spring.UNSET + 4,
-                2 - Spring.UNSET - 4);
+        if (isHarmony()) {
+            checkStrains(Spring.constant(2, 4, 3), Spring.constant(3, 1, 0), 2,
+                         Spring.TRIMMED_MAX_VALUE + 4, 2 - Spring.TRIMMED_MAX_VALUE - 4);
+        } else {
+            checkStrains(Spring.constant(2, 4, 3), Spring.constant(3, 1, 0), 2,
+                         Spring.UNSET + 4, 2 - Spring.UNSET - 4);
+        }
+        if (isHarmony()) {
+            checkStrains(Spring.constant(2, 4, 3), Spring.constant(3, 1, 0), 2,
+                         Spring.TRIMMED_MAX_VALUE + 4, 2 - Spring.TRIMMED_MAX_VALUE - 4);
+        } else {
+            checkStrains(Spring.constant(2, 4, 3), Spring.constant(3, 1, 0), 2,
+                         Spring.UNSET + 4, 2 - Spring.UNSET - 4);
+        }
         checkStrains(Spring.constant(2, 3, 4), Spring.constant(3, 1, 1), 2, 5, -3);
+
         if (isHarmony()) {
             checkStrains(Spring.constant(2, 3, 3), Spring.constant(3, 1, 0), 2, 5, -3);
         } else {
@@ -252,30 +309,22 @@
         assertEquals(Short.MAX_VALUE, spring.getMaximumValue());
         spring1 = Spring.constant(4, 5, 6);
         spring = Spring.sum(spring1, spring2);
-        if (isHarmony()) {
-            assertEquals(Short.MAX_VALUE, spring.getMaximumValue());
-        } else {
-            assertEquals(Short.MAX_VALUE + 6, spring.getMaximumValue());
-        }
+        assertEquals(Short.MAX_VALUE + 6, spring.getMaximumValue());
         spring1 = Spring.constant(4, 5, Integer.MAX_VALUE);
         spring = Spring.sum(spring1, spring2);
-        if (isHarmony()) {
-            assertEquals(Spring.TRIMMED_MAX_VALUE, spring.getMaximumValue());
-        } else {
-            assertEquals(Integer.MAX_VALUE + Short.MAX_VALUE, spring.getMaximumValue());
-        }
+        assertEquals(Integer.MAX_VALUE + Short.MAX_VALUE, spring.getMaximumValue());
         component.setMaximumSize(new Dimension(Integer.MIN_VALUE, Integer.MIN_VALUE));
         spring1 = Spring.constant(4, 5, -6);
         spring = Spring.sum(spring1, spring2);
         if (isHarmony()) {
-            assertEquals(Spring.TRIMMED_MIN_VALUE, spring.getMaximumValue());
+            assertEquals(Spring.TRIMMED_MIN_VALUE - 6, spring.getMaximumValue());
         } else {
             assertEquals(Integer.MIN_VALUE - 6, spring.getMaximumValue());
         }
         spring1 = Spring.constant(4, 5, Integer.MIN_VALUE);
         spring = Spring.sum(spring1, spring2);
         if (isHarmony()) {
-            assertEquals(Spring.TRIMMED_MIN_VALUE, spring.getMaximumValue());
+            assertEquals(Spring.TRIMMED_MIN_VALUE + Integer.MIN_VALUE, spring.getMaximumValue());
         } else {
             assertEquals(0, spring.getMaximumValue());
         }
@@ -285,42 +334,22 @@
         spring1 = Spring.constant(4, 5, 6);
         spring2 = Spring.width(component);
         spring = Spring.sum(spring1, spring2);
-        if (isHarmony()) {
-            assertSizes(6, 80, Short.MAX_VALUE, spring);
-        } else {
-            assertSizes(6, 80, Short.MAX_VALUE + 6, spring);
-        }
+        assertSizes(6, 80, Short.MAX_VALUE + 6, spring);
         setComponentSizes(component, new Dimension(1, 1));
-        if (isHarmony()) {
-            assertSizes(6, 80, Short.MAX_VALUE, spring);
-        } else {
-            assertSizes(6, 80, Short.MAX_VALUE + 6, spring);
-        }
+        assertSizes(6, 80, Short.MAX_VALUE + 6, spring);
         spring2.setValue(0);
         assertEquals(5, spring.getValue());
         assertEquals(5, spring1.getValue());
         assertEquals(0, spring2.getValue());
         spring.setValue(3);
-        if (isHarmony()) {
-            assertSizes(6, 80, Short.MAX_VALUE, spring);
-        } else {
-            assertSizes(6, 80, Short.MAX_VALUE + 6, spring);
-        }
+        assertSizes(6, 80, Short.MAX_VALUE + 6, spring);
         assertEquals(3, spring.getValue());
         assertEquals(4, spring1.getValue());
         assertEquals(-1, spring2.getValue());
-        if (isHarmony()) {
-            assertSizes(6, 80, Short.MAX_VALUE, spring);
-        } else {
-            assertSizes(6, 80, Short.MAX_VALUE + 6, spring);
-        }
+        assertSizes(6, 80, Short.MAX_VALUE + 6, spring);
         spring1.setValue(3);
         assertEquals(3, spring.getValue());
-        if (isHarmony()) {
-            assertSizes(6, 80, Short.MAX_VALUE, spring);
-        } else {
-            assertSizes(6, 80, Short.MAX_VALUE + 6, spring);
-        }
+        assertSizes(6, 80, Short.MAX_VALUE + 6, spring);
         spring.setValue(Spring.UNSET);
         assertSizes(5, 6, 7, 6, spring);
         spring1.setValue(10);
@@ -366,8 +395,8 @@
     public void testSum_UNSET() throws Exception {
         spring1 = Spring.constant(2, 4, 5);
         spring2 = Spring.constant(5);
-        spring1.setValue(1);
-        spring2.setValue(1);
+        spring1.setValue(4);
+        spring2.setValue(5);
         spring = Spring.sum(spring1, spring2);
         spring.getValue();
         spring.setValue(Spring.UNSET);
@@ -418,6 +447,26 @@
                 Spring.max(null, Spring.constant(11)).getValue();
             }
         });
+
+        spring1 = Spring.constant(12, 13, 15);
+        spring2 = Spring.constant(11, 11, 13);
+        spring = Spring.max(spring1, spring2);
+        spring.setValue(100);
+        assertEquals(100, spring1.getValue());
+        assertEquals(11, spring2.getValue());
+        assertEquals(100, spring.getValue());
+
+        spring.setValue(10);
+        assertEquals(10, spring1.getValue());
+        assertEquals(10, spring2.getValue());
+        assertEquals(10, spring.getValue());
+
+        spring.setValue(Spring.UNSET);
+        spring.setValue(10);
+        assertEquals(10, spring1.getValue());
+        assertEquals(10, spring2.getValue());
+        assertEquals(10, spring.getValue());
+
         spring1 = Spring.constant(12, 13, 15);
         spring2 = Spring.constant(11, 12, 13);
         spring = Spring.max(spring1, spring2);
@@ -431,6 +480,11 @@
         } else {
             assertEquals(335, spring2.getValue());
         }
+
+        spring1 = Spring.constant(6, 13, 24);
+        spring2 = Spring.constant(11, 12, 13);
+        spring = Spring.max(spring1, spring2);
+        assertSizes(11, 13, 24, 13, spring);
     }
 
     public void testMax_SizesCashing() throws Exception {
@@ -493,6 +547,25 @@
         assertSizes(30, 100, 5, spring);
     }
 
+    public void testMax_Overlow() throws Exception {
+        spring1 = Spring.constant(6, 13, 24);
+        spring2 = Spring.constant(11, 12, Integer.MAX_VALUE);
+        spring = Spring.max(spring1, spring2);
+        if (isHarmony()) {
+            assertSizes(11, 13, Spring.TRIMMED_MAX_VALUE, 13, spring);
+        } else {
+            assertSizes(11, 13, Integer.MAX_VALUE, 13, spring);
+        }
+        spring1 = Spring.constant(6, 13, Integer.MAX_VALUE);
+        spring2 = Spring.constant(11, 12, 13);
+        spring = Spring.max(spring1, spring2);
+        if (isHarmony()) {
+            assertSizes(11, 13, Spring.TRIMMED_MAX_VALUE, 13, spring);
+        } else {
+            assertSizes(11, 13, Integer.MAX_VALUE, 13, spring);
+        }
+    }
+
     public void testMax_UNSET() throws Exception {
         spring1 = Spring.constant(5);
         spring2 = Spring.constant(4);
@@ -556,7 +629,6 @@
         testScale(-1.3f);
         testScale(-1.5f);
         testScale(-1.7f);
-        //testScale(Spring.UNSET);
     }
 
     public void testScale_Overflow() throws Exception {
@@ -639,6 +711,15 @@
                 Spring.width(null).getValue();
             }
         });
+        spring1 = Spring.width(new JButton());
+        spring2 = Spring.width(new JButton());
+        assertFalse(spring1.equals(spring2));
+
+        component = new JButton();
+        spring1 = Spring.width(component);
+        spring2 = Spring.width(component);
+        assertFalse(spring1.equals(spring2));
+
         final Marker getMinimumSizeCalled = new Marker();
         final Marker getMaximumSizeCalled = new Marker();
         final Marker getPreferedSizeCalled = new Marker();
@@ -734,6 +815,7 @@
                 Spring.height(null).getValue();
             }
         });
+
         component = new JButton("Test") {
             private static final long serialVersionUID = 1L;
 
@@ -823,15 +905,15 @@
         if (isHarmony()) {
             assertEquals("[1, 2, 3]", spring1.toString());
             assertEquals("[5, 5, 5]", Spring.constant(5).toString());
-            assertEquals("Width of javax.swing.JButton: [59, 59, 59]", spring2.toString());
-            assertEquals("Height of javax.swing.JButton: [25, 25, 25]", Spring
-                    .height(component).toString());
-            assertEquals("-[[1, 2, 3]]", Spring.minus(spring1).toString());
-            assertEquals("[[1, 2, 3]] + [Width of javax.swing.JButton: " + "[59, 59, 59]]",
-                    Spring.sum(spring1, spring2).toString());
-            assertEquals("max([[1, 2, 3]], [Width of javax.swing.JButton: " + "[59, 59, 59]])",
-                    Spring.max(spring1, spring2).toString());
-            assertEquals("0.3 * [[1, 2, 3]]", Spring.scale(spring1, 0.3f).toString());
+            assertEquals("[Width of javax.swing.JButton: (59, 59, 59)]", spring2.toString());
+            assertEquals("[Height of javax.swing.JButton: (25, 25, 25)]",
+                         Spring.height(component).toString());
+            assertEquals("(-[1, 2, 3])", Spring.minus(spring1).toString());
+            assertEquals("([1, 2, 3] + [Width of javax.swing.JButton: (59, 59, 59)])",
+                         Spring.sum(spring1, spring2).toString());
+            assertEquals("max([1, 2, 3], [Width of javax.swing.JButton: (59, 59, 59)])",
+                         Spring.max(spring1, spring2).toString());
+            assertEquals("(0.3 * [1, 2, 3])", Spring.scale(spring1, 0.3f).toString());
         }
     }
 
@@ -875,15 +957,15 @@
         spring1 = Spring.constant(12, 13, 15);
         spring = Spring.scale(spring1, factor);
         if (factor > 0) {
-            assertSizes(Math.round(factor * spring1.getMinimumValue()), Math.round(factor
-                    * spring1.getPreferredValue()), Math.round(factor
-                    * spring1.getMaximumValue()), Math.round(factor * spring1.getValue()),
-                    spring);
-        } else {
-            assertSizes(Math.round(factor * spring1.getMaximumValue()), Math.round(factor
-                    * spring1.getPreferredValue()), Math.round(factor
-                    * spring1.getMinimumValue()), Math.round(factor * spring1.getValue()),
-                    spring);
+            assertSizes(Math.round(factor * spring1.getMinimumValue()),
+                        Math.round(factor * spring1.getPreferredValue()),
+                        Math.round(factor * spring1.getMaximumValue()),
+                        Math.round(factor * spring1.getValue()), spring);
+        } else {
+            assertSizes(Math.round(factor * spring1.getMaximumValue()),
+                        Math.round(factor * spring1.getPreferredValue()),
+                        Math.round(factor * spring1.getMinimumValue()),
+                        Math.round(factor * spring1.getValue()), spring);
         }
         assertFalse(Integer.MAX_VALUE == spring1.getMinimumValue());
         assertFalse(Integer.MAX_VALUE == spring1.getMaximumValue());



Mime
View raw message