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));
}