RFR: 8281569: Create tests for Frame.setMinimumSize() method [v6]

Alexey Ivanov aivanov at openjdk.java.net
Tue Mar 1 16:15:08 UTC 2022


On Mon, 28 Feb 2022 11:45:32 GMT, Srinivas Mandalika <smandalika at openjdk.org> wrote:

>> Create tests for setMinimumSize functionality
>> Create a test which verifies that on increasing the Frame's minimumSize, it gets reflected in the subsequent getSize call
>> Create a test which verifies that on frame resizes back to minimumSize on calling pack.
>
> Srinivas Mandalika has updated the pull request incrementally with one additional commit since the last revision:
> 
>   Review comments fixed, removed redundant waitForIdle

Changes requested by aivanov (Reviewer).

test/jdk/java/awt/Frame/SetMinimumSizeTest/SetMinimumSizeTest1.java line 40:

> 38: 
> 39:     private static Frame frame;
> 40:     private static volatile Dimension dimension, actualDimension;

In Java, each field should be declared on its own line.

test/jdk/java/awt/Frame/SetMinimumSizeTest/SetMinimumSizeTest1.java line 42:

> 40:     private static volatile Dimension dimension, actualDimension;
> 41: 
> 42:     public static void createGUI(Frame _frame) {

The `_frame` parameter is never used, please remove it.

test/jdk/java/awt/Frame/SetMinimumSizeTest/SetMinimumSizeTest1.java line 61:

> 59:                 dimension = frame.getSize();
> 60:                 dimension.width = dimension.width + 20;
> 61:                 dimension.height = dimension.height + 20;

Suggestion:

                dimension.width += 20;
                dimension.height += 20;

test/jdk/java/awt/Frame/SetMinimumSizeTest/SetMinimumSizeTest1.java line 73:

> 71:             });
> 72: 
> 73:             robot.waitForIdle();

At line 73, `waitForIdle` doesn't affect anything, it should be removed.

test/jdk/java/awt/Frame/SetMinimumSizeTest/SetMinimumSizeTest1.java line 81:

> 79:             }
> 80:         }
> 81:         finally {

Suggestion:

        } finally {


The finally-block as well as catch- and else-blocks should be at the same line as the closing brace from the previous block.

test/jdk/java/awt/Frame/SetMinimumSizeTest/SetMinimumSizeTest2.java line 42:

> 40:     private static volatile Dimension dimension, actualDimension;
> 41: 
> 42:     public static void createGUI(Frame _frame) {

The same as for test1: field declarations are on its own lines, `_frame` parameter removed.

test/jdk/java/awt/Frame/SetMinimumSizeTest/SetMinimumSizeTest2.java line 63:

> 61: 
> 62:             EventQueue.invokeAndWait(() -> {
> 63:                 frame.setSize(new Dimension(dimension.width + 20, dimension.height + 20));

You can call `setSize(int, int)` method without creating a new `Dimension` object. This way is also fine.

test/jdk/java/awt/Frame/SetMinimumSizeTest/SetMinimumSizeTest2.java line 82:

> 80:             });
> 81: 
> 82:             robot.waitForIdle();

At line 82, `waitForIdle` is not needed.

-------------

PR: https://git.openjdk.java.net/jdk/pull/7444



More information about the client-libs-dev mailing list