JDK-6848424 : java/awt/Frame/FrameSize/TestFrameSize.java needs improvement
  • Type: Bug
  • Component: client-libs
  • Sub-Component: java.awt
  • Affected Version: 7
  • Priority: P4
  • Status: Resolved
  • Resolution: Fixed
  • OS: generic
  • CPU: generic
  • Submitted: 2009-06-05
  • Updated: 2011-01-19
  • Resolved: 2009-08-05
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 7
7 b68Fixed
Related Reports
Relates :  
Relates :  
Description
The test creates a frame, sets its preferred size, calls pack() and expects that the getSize() method returns a size not less/greater than the preferred size +/- a margin. The margin value is hard-codded as 15 pixels.

The pack() method actually calls the addNotify() which creates the peer for the frame. When the peer is created it may report more or less correct insets for the frame (this is especially important for the X11 platform). For some window managers/themes the insets may be quite large making the size of the frame greater than the preferred size + 15, which may make the test failing.

Comments
EVALUATION Actually the pack() method (as it works currently, and going to work after the 6689983 gets fixed), indeed preserves the size of the window as it was specified with the window's preferred size. So the test is quite correct. However the test can still be improved: 1. We don't need a MARGIN value. The getSize() called after pack() should return exactly the preferred size set with the setPreferredSize() initially. So we may check for strict equality of the sizes. 2. We can also calculate the client size of the window just after pack() returns. Later we can make the window visible, and recalculate the client size. The sizes should match.
10-07-2009

EVALUATION The test should use either a Window object to avoid any hard-codded margins, or the Frame.getInsets() method and then perform an exact comparision of the getSize() with the getPreferredSize() + getInsets() values. The approach abs(getSize() - getPreferredSize()) < MARGIN with a small hard-codded margin value is way unreliable to leave the test as is.
05-06-2009