test/jdk/java/awt/Frame/DisposeStressTest/DisposeStressTest.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:
27504
cc601183753e 8062021: NPE in sun/lwawt/macosx/CPlatformWindow::toFront after JDK-8060146
mcherkas
parents:
diff changeset
     1
/*
50834
9cf279436b9d 8205153: Delete "standard instructions" machinery in the open automated tests
serb
parents: 47216
diff changeset
     2
 * Copyright (c) 2014, 2018, Oracle and/or its affiliates. All rights reserved.
27504
cc601183753e 8062021: NPE in sun/lwawt/macosx/CPlatformWindow::toFront after JDK-8060146
mcherkas
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
cc601183753e 8062021: NPE in sun/lwawt/macosx/CPlatformWindow::toFront after JDK-8060146
mcherkas
parents:
diff changeset
     4
 *
cc601183753e 8062021: NPE in sun/lwawt/macosx/CPlatformWindow::toFront after JDK-8060146
mcherkas
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
cc601183753e 8062021: NPE in sun/lwawt/macosx/CPlatformWindow::toFront after JDK-8060146
mcherkas
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
cc601183753e 8062021: NPE in sun/lwawt/macosx/CPlatformWindow::toFront after JDK-8060146
mcherkas
parents:
diff changeset
     7
 * published by the Free Software Foundation.
cc601183753e 8062021: NPE in sun/lwawt/macosx/CPlatformWindow::toFront after JDK-8060146
mcherkas
parents:
diff changeset
     8
 *
cc601183753e 8062021: NPE in sun/lwawt/macosx/CPlatformWindow::toFront after JDK-8060146
mcherkas
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
cc601183753e 8062021: NPE in sun/lwawt/macosx/CPlatformWindow::toFront after JDK-8060146
mcherkas
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
cc601183753e 8062021: NPE in sun/lwawt/macosx/CPlatformWindow::toFront after JDK-8060146
mcherkas
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
cc601183753e 8062021: NPE in sun/lwawt/macosx/CPlatformWindow::toFront after JDK-8060146
mcherkas
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
cc601183753e 8062021: NPE in sun/lwawt/macosx/CPlatformWindow::toFront after JDK-8060146
mcherkas
parents:
diff changeset
    13
 * accompanied this code).
cc601183753e 8062021: NPE in sun/lwawt/macosx/CPlatformWindow::toFront after JDK-8060146
mcherkas
parents:
diff changeset
    14
 *
cc601183753e 8062021: NPE in sun/lwawt/macosx/CPlatformWindow::toFront after JDK-8060146
mcherkas
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
cc601183753e 8062021: NPE in sun/lwawt/macosx/CPlatformWindow::toFront after JDK-8060146
mcherkas
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
cc601183753e 8062021: NPE in sun/lwawt/macosx/CPlatformWindow::toFront after JDK-8060146
mcherkas
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
cc601183753e 8062021: NPE in sun/lwawt/macosx/CPlatformWindow::toFront after JDK-8060146
mcherkas
parents:
diff changeset
    18
 *
cc601183753e 8062021: NPE in sun/lwawt/macosx/CPlatformWindow::toFront after JDK-8060146
mcherkas
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
cc601183753e 8062021: NPE in sun/lwawt/macosx/CPlatformWindow::toFront after JDK-8060146
mcherkas
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
cc601183753e 8062021: NPE in sun/lwawt/macosx/CPlatformWindow::toFront after JDK-8060146
mcherkas
parents:
diff changeset
    21
 * questions.
cc601183753e 8062021: NPE in sun/lwawt/macosx/CPlatformWindow::toFront after JDK-8060146
mcherkas
parents:
diff changeset
    22
 */
cc601183753e 8062021: NPE in sun/lwawt/macosx/CPlatformWindow::toFront after JDK-8060146
mcherkas
parents:
diff changeset
    23
cc601183753e 8062021: NPE in sun/lwawt/macosx/CPlatformWindow::toFront after JDK-8060146
mcherkas
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
e4813eded7cb 8213110: Remove the use of applets in automatic tests
serb
parents: 50834
diff changeset
    27
  @bug 4051487 4145670
27504
cc601183753e 8062021: NPE in sun/lwawt/macosx/CPlatformWindow::toFront after JDK-8060146
mcherkas
parents:
diff changeset
    28
  @summary Tests that disposing of an empty Frame or a Frame with a MenuBar
cc601183753e 8062021: NPE in sun/lwawt/macosx/CPlatformWindow::toFront after JDK-8060146
mcherkas
parents:
diff changeset
    29
           while it is being created does not crash the VM.
54231
e4813eded7cb 8213110: Remove the use of applets in automatic tests
serb
parents: 50834
diff changeset
    30
  @run main/timeout=7200 DisposeStressTest
27504
cc601183753e 8062021: NPE in sun/lwawt/macosx/CPlatformWindow::toFront after JDK-8060146
mcherkas
parents:
diff changeset
    31
*/
cc601183753e 8062021: NPE in sun/lwawt/macosx/CPlatformWindow::toFront after JDK-8060146
mcherkas
parents:
diff changeset
    32
54231
e4813eded7cb 8213110: Remove the use of applets in automatic tests
serb
parents: 50834
diff changeset
    33
import java.awt.Frame;
e4813eded7cb 8213110: Remove the use of applets in automatic tests
serb
parents: 50834
diff changeset
    34
import java.awt.Menu;
e4813eded7cb 8213110: Remove the use of applets in automatic tests
serb
parents: 50834
diff changeset
    35
import java.awt.MenuBar;
e4813eded7cb 8213110: Remove the use of applets in automatic tests
serb
parents: 50834
diff changeset
    36
import java.awt.MenuItem;
27504
cc601183753e 8062021: NPE in sun/lwawt/macosx/CPlatformWindow::toFront after JDK-8060146
mcherkas
parents:
diff changeset
    37
54231
e4813eded7cb 8213110: Remove the use of applets in automatic tests
serb
parents: 50834
diff changeset
    38
public class DisposeStressTest {
27504
cc601183753e 8062021: NPE in sun/lwawt/macosx/CPlatformWindow::toFront after JDK-8060146
mcherkas
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) {
27504
cc601183753e 8062021: NPE in sun/lwawt/macosx/CPlatformWindow::toFront after JDK-8060146
mcherkas
parents:
diff changeset
    41
        for (int i = 0; i < 1000; i++) {
cc601183753e 8062021: NPE in sun/lwawt/macosx/CPlatformWindow::toFront after JDK-8060146
mcherkas
parents:
diff changeset
    42
            Frame f = new Frame();
cc601183753e 8062021: NPE in sun/lwawt/macosx/CPlatformWindow::toFront after JDK-8060146
mcherkas
parents:
diff changeset
    43
            f.setBounds(10, 10, 10, 10);
cc601183753e 8062021: NPE in sun/lwawt/macosx/CPlatformWindow::toFront after JDK-8060146
mcherkas
parents:
diff changeset
    44
            f.show();
cc601183753e 8062021: NPE in sun/lwawt/macosx/CPlatformWindow::toFront after JDK-8060146
mcherkas
parents:
diff changeset
    45
            f.dispose();
cc601183753e 8062021: NPE in sun/lwawt/macosx/CPlatformWindow::toFront after JDK-8060146
mcherkas
parents:
diff changeset
    46
cc601183753e 8062021: NPE in sun/lwawt/macosx/CPlatformWindow::toFront after JDK-8060146
mcherkas
parents:
diff changeset
    47
            Frame f2 = new Frame();
cc601183753e 8062021: NPE in sun/lwawt/macosx/CPlatformWindow::toFront after JDK-8060146
mcherkas
parents:
diff changeset
    48
            f2.setBounds(10, 10, 100, 100);
cc601183753e 8062021: NPE in sun/lwawt/macosx/CPlatformWindow::toFront after JDK-8060146
mcherkas
parents:
diff changeset
    49
            MenuBar bar = new MenuBar();
cc601183753e 8062021: NPE in sun/lwawt/macosx/CPlatformWindow::toFront after JDK-8060146
mcherkas
parents:
diff changeset
    50
            Menu menu = new Menu();
cc601183753e 8062021: NPE in sun/lwawt/macosx/CPlatformWindow::toFront after JDK-8060146
mcherkas
parents:
diff changeset
    51
            menu.add(new MenuItem("foo"));
cc601183753e 8062021: NPE in sun/lwawt/macosx/CPlatformWindow::toFront after JDK-8060146
mcherkas
parents:
diff changeset
    52
            bar.add(menu);
cc601183753e 8062021: NPE in sun/lwawt/macosx/CPlatformWindow::toFront after JDK-8060146
mcherkas
parents:
diff changeset
    53
            f2.setMenuBar(bar);
cc601183753e 8062021: NPE in sun/lwawt/macosx/CPlatformWindow::toFront after JDK-8060146
mcherkas
parents:
diff changeset
    54
            f2.show();
cc601183753e 8062021: NPE in sun/lwawt/macosx/CPlatformWindow::toFront after JDK-8060146
mcherkas
parents:
diff changeset
    55
            f2.dispose();
cc601183753e 8062021: NPE in sun/lwawt/macosx/CPlatformWindow::toFront after JDK-8060146
mcherkas
parents:
diff changeset
    56
        }
54231
e4813eded7cb 8213110: Remove the use of applets in automatic tests
serb
parents: 50834
diff changeset
    57
    }
e4813eded7cb 8213110: Remove the use of applets in automatic tests
serb
parents: 50834
diff changeset
    58
}