test/jdk/java/awt/GridBagLayout/GridBagLayoutIpadXYTest/GridBagLayoutIpadXYTest.java
author serb
Wed, 27 Feb 2019 18:46:55 -0800
changeset 54231 e4813eded7cb
parent 50834 9cf279436b9d
permissions -rw-r--r--
8213110: Remove the use of applets in automatic tests Reviewed-by: prr
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
3087
e5f156d403ad 6851646: test/closed/java/awt/GridBagLayout/GridBagLayoutIpadXYTest/GridBagLayoutIpadXYTest.java can fail
anthony
parents:
diff changeset
     1
/*
50834
9cf279436b9d 8205153: Delete "standard instructions" machinery in the open automated tests
serb
parents: 47216
diff changeset
     2
 * Copyright (c) 2009, 2018, Oracle and/or its affiliates. All rights reserved.
3087
e5f156d403ad 6851646: test/closed/java/awt/GridBagLayout/GridBagLayoutIpadXYTest/GridBagLayoutIpadXYTest.java can fail
anthony
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
e5f156d403ad 6851646: test/closed/java/awt/GridBagLayout/GridBagLayoutIpadXYTest/GridBagLayoutIpadXYTest.java can fail
anthony
parents:
diff changeset
     4
 *
e5f156d403ad 6851646: test/closed/java/awt/GridBagLayout/GridBagLayoutIpadXYTest/GridBagLayoutIpadXYTest.java can fail
anthony
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
e5f156d403ad 6851646: test/closed/java/awt/GridBagLayout/GridBagLayoutIpadXYTest/GridBagLayoutIpadXYTest.java can fail
anthony
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
e5f156d403ad 6851646: test/closed/java/awt/GridBagLayout/GridBagLayoutIpadXYTest/GridBagLayoutIpadXYTest.java can fail
anthony
parents:
diff changeset
     7
 * published by the Free Software Foundation.
e5f156d403ad 6851646: test/closed/java/awt/GridBagLayout/GridBagLayoutIpadXYTest/GridBagLayoutIpadXYTest.java can fail
anthony
parents:
diff changeset
     8
 *
e5f156d403ad 6851646: test/closed/java/awt/GridBagLayout/GridBagLayoutIpadXYTest/GridBagLayoutIpadXYTest.java can fail
anthony
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
e5f156d403ad 6851646: test/closed/java/awt/GridBagLayout/GridBagLayoutIpadXYTest/GridBagLayoutIpadXYTest.java can fail
anthony
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
e5f156d403ad 6851646: test/closed/java/awt/GridBagLayout/GridBagLayoutIpadXYTest/GridBagLayoutIpadXYTest.java can fail
anthony
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
e5f156d403ad 6851646: test/closed/java/awt/GridBagLayout/GridBagLayoutIpadXYTest/GridBagLayoutIpadXYTest.java can fail
anthony
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
e5f156d403ad 6851646: test/closed/java/awt/GridBagLayout/GridBagLayoutIpadXYTest/GridBagLayoutIpadXYTest.java can fail
anthony
parents:
diff changeset
    13
 * accompanied this code).
e5f156d403ad 6851646: test/closed/java/awt/GridBagLayout/GridBagLayoutIpadXYTest/GridBagLayoutIpadXYTest.java can fail
anthony
parents:
diff changeset
    14
 *
e5f156d403ad 6851646: test/closed/java/awt/GridBagLayout/GridBagLayoutIpadXYTest/GridBagLayoutIpadXYTest.java can fail
anthony
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
e5f156d403ad 6851646: test/closed/java/awt/GridBagLayout/GridBagLayoutIpadXYTest/GridBagLayoutIpadXYTest.java can fail
anthony
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
e5f156d403ad 6851646: test/closed/java/awt/GridBagLayout/GridBagLayoutIpadXYTest/GridBagLayoutIpadXYTest.java can fail
anthony
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
e5f156d403ad 6851646: test/closed/java/awt/GridBagLayout/GridBagLayoutIpadXYTest/GridBagLayoutIpadXYTest.java can fail
anthony
parents:
diff changeset
    18
 *
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 3087
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 3087
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 3087
diff changeset
    21
 * questions.
3087
e5f156d403ad 6851646: test/closed/java/awt/GridBagLayout/GridBagLayoutIpadXYTest/GridBagLayoutIpadXYTest.java can fail
anthony
parents:
diff changeset
    22
 */
e5f156d403ad 6851646: test/closed/java/awt/GridBagLayout/GridBagLayoutIpadXYTest/GridBagLayoutIpadXYTest.java can fail
anthony
parents:
diff changeset
    23
e5f156d403ad 6851646: test/closed/java/awt/GridBagLayout/GridBagLayoutIpadXYTest/GridBagLayoutIpadXYTest.java can fail
anthony
parents:
diff changeset
    24
/*
54231
e4813eded7cb 8213110: Remove the use of applets in automatic tests
serb
parents: 50834
diff changeset
    25
  @test
e4813eded7cb 8213110: Remove the use of applets in automatic tests
serb
parents: 50834
diff changeset
    26
  @key headful
3087
e5f156d403ad 6851646: test/closed/java/awt/GridBagLayout/GridBagLayoutIpadXYTest/GridBagLayoutIpadXYTest.java can fail
anthony
parents:
diff changeset
    27
  @bug 5004032
e5f156d403ad 6851646: test/closed/java/awt/GridBagLayout/GridBagLayoutIpadXYTest/GridBagLayoutIpadXYTest.java can fail
anthony
parents:
diff changeset
    28
  @summary GridBagConstraints.ipad(x|y) defined in a new way
54231
e4813eded7cb 8213110: Remove the use of applets in automatic tests
serb
parents: 50834
diff changeset
    29
  @run main GridBagLayoutIpadXYTest
3087
e5f156d403ad 6851646: test/closed/java/awt/GridBagLayout/GridBagLayoutIpadXYTest/GridBagLayoutIpadXYTest.java can fail
anthony
parents:
diff changeset
    30
*/
e5f156d403ad 6851646: test/closed/java/awt/GridBagLayout/GridBagLayoutIpadXYTest/GridBagLayoutIpadXYTest.java can fail
anthony
parents:
diff changeset
    31
e5f156d403ad 6851646: test/closed/java/awt/GridBagLayout/GridBagLayoutIpadXYTest/GridBagLayoutIpadXYTest.java can fail
anthony
parents:
diff changeset
    32
import java.awt.*;
e5f156d403ad 6851646: test/closed/java/awt/GridBagLayout/GridBagLayoutIpadXYTest/GridBagLayoutIpadXYTest.java can fail
anthony
parents:
diff changeset
    33
54231
e4813eded7cb 8213110: Remove the use of applets in automatic tests
serb
parents: 50834
diff changeset
    34
public class GridBagLayoutIpadXYTest {
e4813eded7cb 8213110: Remove the use of applets in automatic tests
serb
parents: 50834
diff changeset
    35
    static Frame frame = new Frame();
e4813eded7cb 8213110: Remove the use of applets in automatic tests
serb
parents: 50834
diff changeset
    36
    static TextField jtf = null;
e4813eded7cb 8213110: Remove the use of applets in automatic tests
serb
parents: 50834
diff changeset
    37
    static final int customIpadx = 300;
e4813eded7cb 8213110: Remove the use of applets in automatic tests
serb
parents: 50834
diff changeset
    38
    static final int customIpady = 40;
3087
e5f156d403ad 6851646: test/closed/java/awt/GridBagLayout/GridBagLayoutIpadXYTest/GridBagLayoutIpadXYTest.java can fail
anthony
parents:
diff changeset
    39
54231
e4813eded7cb 8213110: Remove the use of applets in automatic tests
serb
parents: 50834
diff changeset
    40
    public static void main(final String[] args) {
3087
e5f156d403ad 6851646: test/closed/java/awt/GridBagLayout/GridBagLayoutIpadXYTest/GridBagLayoutIpadXYTest.java can fail
anthony
parents:
diff changeset
    41
        frame.setLayout(new GridBagLayout());
e5f156d403ad 6851646: test/closed/java/awt/GridBagLayout/GridBagLayoutIpadXYTest/GridBagLayoutIpadXYTest.java can fail
anthony
parents:
diff changeset
    42
        GridBagConstraints gc = new GridBagConstraints();
e5f156d403ad 6851646: test/closed/java/awt/GridBagLayout/GridBagLayoutIpadXYTest/GridBagLayoutIpadXYTest.java can fail
anthony
parents:
diff changeset
    43
        Insets fieldInsets = new Insets(0,5,5,0);
e5f156d403ad 6851646: test/closed/java/awt/GridBagLayout/GridBagLayoutIpadXYTest/GridBagLayoutIpadXYTest.java can fail
anthony
parents:
diff changeset
    44
e5f156d403ad 6851646: test/closed/java/awt/GridBagLayout/GridBagLayoutIpadXYTest/GridBagLayoutIpadXYTest.java can fail
anthony
parents:
diff changeset
    45
        gc.anchor = gc.NORTH;
e5f156d403ad 6851646: test/closed/java/awt/GridBagLayout/GridBagLayoutIpadXYTest/GridBagLayoutIpadXYTest.java can fail
anthony
parents:
diff changeset
    46
        gc.fill = gc.HORIZONTAL;
e5f156d403ad 6851646: test/closed/java/awt/GridBagLayout/GridBagLayoutIpadXYTest/GridBagLayoutIpadXYTest.java can fail
anthony
parents:
diff changeset
    47
        gc.gridx = 1;
e5f156d403ad 6851646: test/closed/java/awt/GridBagLayout/GridBagLayoutIpadXYTest/GridBagLayoutIpadXYTest.java can fail
anthony
parents:
diff changeset
    48
        gc.gridy = 0;
e5f156d403ad 6851646: test/closed/java/awt/GridBagLayout/GridBagLayoutIpadXYTest/GridBagLayoutIpadXYTest.java can fail
anthony
parents:
diff changeset
    49
        gc.weightx = 1;
e5f156d403ad 6851646: test/closed/java/awt/GridBagLayout/GridBagLayoutIpadXYTest/GridBagLayoutIpadXYTest.java can fail
anthony
parents:
diff changeset
    50
        gc.ipadx = customIpadx;
e5f156d403ad 6851646: test/closed/java/awt/GridBagLayout/GridBagLayoutIpadXYTest/GridBagLayoutIpadXYTest.java can fail
anthony
parents:
diff changeset
    51
        gc.ipady = customIpady;
e5f156d403ad 6851646: test/closed/java/awt/GridBagLayout/GridBagLayoutIpadXYTest/GridBagLayoutIpadXYTest.java can fail
anthony
parents:
diff changeset
    52
        gc.insets = fieldInsets;
e5f156d403ad 6851646: test/closed/java/awt/GridBagLayout/GridBagLayoutIpadXYTest/GridBagLayoutIpadXYTest.java can fail
anthony
parents:
diff changeset
    53
        jtf = new TextField();
e5f156d403ad 6851646: test/closed/java/awt/GridBagLayout/GridBagLayoutIpadXYTest/GridBagLayoutIpadXYTest.java can fail
anthony
parents:
diff changeset
    54
        frame.add(jtf, gc);
e5f156d403ad 6851646: test/closed/java/awt/GridBagLayout/GridBagLayoutIpadXYTest/GridBagLayoutIpadXYTest.java can fail
anthony
parents:
diff changeset
    55
e5f156d403ad 6851646: test/closed/java/awt/GridBagLayout/GridBagLayoutIpadXYTest/GridBagLayoutIpadXYTest.java can fail
anthony
parents:
diff changeset
    56
        frame.pack();
54231
e4813eded7cb 8213110: Remove the use of applets in automatic tests
serb
parents: 50834
diff changeset
    57
        frame.setLocationRelativeTo(null);
3087
e5f156d403ad 6851646: test/closed/java/awt/GridBagLayout/GridBagLayoutIpadXYTest/GridBagLayoutIpadXYTest.java can fail
anthony
parents:
diff changeset
    58
        frame.setVisible(true);
e5f156d403ad 6851646: test/closed/java/awt/GridBagLayout/GridBagLayoutIpadXYTest/GridBagLayoutIpadXYTest.java can fail
anthony
parents:
diff changeset
    59
27763
1fba965925e8 8063102: Change open awt regression tests to avoid sun.awt.SunToolkit.realSync, part 1
yan
parents: 5506
diff changeset
    60
        Robot robot;
1fba965925e8 8063102: Change open awt regression tests to avoid sun.awt.SunToolkit.realSync, part 1
yan
parents: 5506
diff changeset
    61
        try {
1fba965925e8 8063102: Change open awt regression tests to avoid sun.awt.SunToolkit.realSync, part 1
yan
parents: 5506
diff changeset
    62
            robot = new Robot();
1fba965925e8 8063102: Change open awt regression tests to avoid sun.awt.SunToolkit.realSync, part 1
yan
parents: 5506
diff changeset
    63
            robot.waitForIdle();
1fba965925e8 8063102: Change open awt regression tests to avoid sun.awt.SunToolkit.realSync, part 1
yan
parents: 5506
diff changeset
    64
        }catch(Exception ex) {
1fba965925e8 8063102: Change open awt regression tests to avoid sun.awt.SunToolkit.realSync, part 1
yan
parents: 5506
diff changeset
    65
            ex.printStackTrace();
1fba965925e8 8063102: Change open awt regression tests to avoid sun.awt.SunToolkit.realSync, part 1
yan
parents: 5506
diff changeset
    66
            throw new RuntimeException("Unexpected failure");
1fba965925e8 8063102: Change open awt regression tests to avoid sun.awt.SunToolkit.realSync, part 1
yan
parents: 5506
diff changeset
    67
        }
3087
e5f156d403ad 6851646: test/closed/java/awt/GridBagLayout/GridBagLayoutIpadXYTest/GridBagLayoutIpadXYTest.java can fail
anthony
parents:
diff changeset
    68
e5f156d403ad 6851646: test/closed/java/awt/GridBagLayout/GridBagLayoutIpadXYTest/GridBagLayoutIpadXYTest.java can fail
anthony
parents:
diff changeset
    69
        Dimension minSize = jtf.getMinimumSize();
e5f156d403ad 6851646: test/closed/java/awt/GridBagLayout/GridBagLayoutIpadXYTest/GridBagLayoutIpadXYTest.java can fail
anthony
parents:
diff changeset
    70
        if ( minSize.width + customIpadx != jtf.getSize().width ||
e5f156d403ad 6851646: test/closed/java/awt/GridBagLayout/GridBagLayoutIpadXYTest/GridBagLayoutIpadXYTest.java can fail
anthony
parents:
diff changeset
    71
             minSize.height + customIpady != jtf.getSize().height ){
e5f156d403ad 6851646: test/closed/java/awt/GridBagLayout/GridBagLayoutIpadXYTest/GridBagLayoutIpadXYTest.java can fail
anthony
parents:
diff changeset
    72
            System.out.println("TextField originally has min size = " + jtf.getMinimumSize());
e5f156d403ad 6851646: test/closed/java/awt/GridBagLayout/GridBagLayoutIpadXYTest/GridBagLayoutIpadXYTest.java can fail
anthony
parents:
diff changeset
    73
            System.out.println("TextField supplied with ipadx =  300, ipady =40");
e5f156d403ad 6851646: test/closed/java/awt/GridBagLayout/GridBagLayoutIpadXYTest/GridBagLayoutIpadXYTest.java can fail
anthony
parents:
diff changeset
    74
            System.out.println("Frame size: " + frame.getSize());
e5f156d403ad 6851646: test/closed/java/awt/GridBagLayout/GridBagLayoutIpadXYTest/GridBagLayoutIpadXYTest.java can fail
anthony
parents:
diff changeset
    75
            System.out.println(" Fields's size is "+jtf.getSize());
e5f156d403ad 6851646: test/closed/java/awt/GridBagLayout/GridBagLayoutIpadXYTest/GridBagLayoutIpadXYTest.java can fail
anthony
parents:
diff changeset
    76
e5f156d403ad 6851646: test/closed/java/awt/GridBagLayout/GridBagLayoutIpadXYTest/GridBagLayoutIpadXYTest.java can fail
anthony
parents:
diff changeset
    77
            throw new RuntimeException("Test Failed. TextField has incorrect width. ");
e5f156d403ad 6851646: test/closed/java/awt/GridBagLayout/GridBagLayoutIpadXYTest/GridBagLayoutIpadXYTest.java can fail
anthony
parents:
diff changeset
    78
        }
e5f156d403ad 6851646: test/closed/java/awt/GridBagLayout/GridBagLayoutIpadXYTest/GridBagLayoutIpadXYTest.java can fail
anthony
parents:
diff changeset
    79
        System.out.println("Test Passed.");
54231
e4813eded7cb 8213110: Remove the use of applets in automatic tests
serb
parents: 50834
diff changeset
    80
    }
3087
e5f156d403ad 6851646: test/closed/java/awt/GridBagLayout/GridBagLayoutIpadXYTest/GridBagLayoutIpadXYTest.java can fail
anthony
parents:
diff changeset
    81
}