public void test2(TestHarness harness)
{
// Test getPreferredSize(int, int) method.
TextField field = new TextField();
// Show that if the values passed are <=, ==, >= or negative,
// then no exceptions are thrown.
harness.check(field.getSize(), new Dimension());
harness.check(field.getPreferredSize(7), new Dimension());
harness.check(field.getPreferredSize(0), new Dimension());
harness.check(field.getPreferredSize(-7), new Dimension());
// Check that if preferred size not been set, then a
// Dimension with size (width, height) is returned.
harness.check(field.isPreferredSizeSet(), false);
field.setSize(new Dimension(3, 4));
harness.check(field.getPreferredSize(2), new Dimension(3, 4));
// Check that if preferred size has been set, then a
// those values are returned.
field.setSize(new Dimension(-3, 5));
harness.check(field.getSize(), new Dimension(-3, 5));
field.setPreferredSize(new Dimension(1, 9));
harness.check(field.isPreferredSizeSet());
harness.check(field.getPreferredSize(-1), new Dimension(1, 9));
}