test/jdk/java/awt/Menu/OpensWithNoGrab/OpensWithNoGrab.java
author serb
Sun, 24 Jun 2018 16:35:21 -0700
changeset 50834 9cf279436b9d
parent 47216 71c04702a3d5
child 51637 e9177e7749e7
permissions -rw-r--r--
8205153: Delete "standard instructions" machinery in the open automated tests Reviewed-by: prr
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
50834
9cf279436b9d 8205153: Delete "standard instructions" machinery in the open automated tests
serb
parents: 47216
diff changeset
     2
 * Copyright (c) 2005, 2018, Oracle and/or its affiliates. All rights reserved.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     4
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
90ce3da70b43 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
90ce3da70b43 Initial load
duke
parents:
diff changeset
     7
 * published by the Free Software Foundation.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
90ce3da70b43 Initial load
duke
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
90ce3da70b43 Initial load
duke
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    13
 * accompanied this code).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    14
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
90ce3da70b43 Initial load
duke
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    18
 *
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    21
 * questions.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    22
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    23
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
  @test
39056
d99e63b6d962 8159690: [TESTBUG] Mark headful tests with @key headful.
goetz
parents: 31448
diff changeset
    26
  @key headful
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
  @bug 6354721
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
  @summary REG: Menu does not disappear when clicked, keeping Choice's drop-down open, XToolkit
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
  @author andrei.dmitriev: area=awt.menu
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
  @library ../../regtesthelpers
29514
973914c573fc 8074092: Newly introduced unnecessary dependencies on internal API in client regtests
yan
parents: 23010
diff changeset
    31
  @library ../../../../lib/testlibrary
31448
1066345d2a8a 8076468: Add @modules to tests in jdk_desktop test group
yan
parents: 29514
diff changeset
    32
  @modules java.desktop/sun.awt
29514
973914c573fc 8074092: Newly introduced unnecessary dependencies on internal API in client regtests
yan
parents: 23010
diff changeset
    33
  @build jdk.testlibrary.OSInfo
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
  @build Util
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
  @run main OpensWithNoGrab
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
*/
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
import java.awt.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
import java.awt.event.*;
21796
66b60a81cfff 8024161: [TEST_BUG] [macosx] java/awt/Menu/OpensWithNoGrab/OpensWithNoGrab.java failed "menu was opened by first click after opened Choice"
pchelko
parents: 5506
diff changeset
    40
29514
973914c573fc 8074092: Newly introduced unnecessary dependencies on internal API in client regtests
yan
parents: 23010
diff changeset
    41
import jdk.testlibrary.OSInfo;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
import test.java.awt.regtesthelpers.Util;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
public class OpensWithNoGrab
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
    final static int delay = 50;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
    private static void init()
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
    {
21796
66b60a81cfff 8024161: [TEST_BUG] [macosx] java/awt/Menu/OpensWithNoGrab/OpensWithNoGrab.java failed "menu was opened by first click after opened Choice"
pchelko
parents: 5506
diff changeset
    49
        if (!(OSInfo.getOSType().equals(OSInfo.OSType.LINUX)
66b60a81cfff 8024161: [TEST_BUG] [macosx] java/awt/Menu/OpensWithNoGrab/OpensWithNoGrab.java failed "menu was opened by first click after opened Choice"
pchelko
parents: 5506
diff changeset
    50
                || OSInfo.getOSType().equals(OSInfo.OSType.SOLARIS))) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
            System.out.println("This test is for XAWT/Motif only");
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
            OpensWithNoGrab.pass();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
        Choice ch = new Choice ();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
        Frame f = new Frame ("OpensWithNoGrab");
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
        Robot robot;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
        Point framePt, choicePt;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
        ch.add("line 1");
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
        ch.add("line 2");
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
        ch.add("line 3");
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
        ch.add("line 4");
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
        ch.setBackground(Color.red);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
        f.add(ch);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
        Menu file = new Menu ("file");
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
        MenuBar mb = new MenuBar();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
        mb.add(file);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
        file.add(new MenuItem ("            "));
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
        file.add(new MenuItem ("            "));
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
        file.add(new MenuItem ("            "));
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
        file.add(new MenuItem ("            "));
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
        file.add(new MenuItem ("            "));
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
        file.add(new MenuItem ("            "));
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
        file.add(new MenuItem ("            "));
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
        f.setMenuBar(mb);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
        f.setBackground(Color.green);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
        f.setForeground(Color.green);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
        f.setSize(300, 200);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
        f.setVisible(true);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
            robot = new Robot();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
            robot.setAutoWaitForIdle(true);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
            robot.setAutoDelay(50);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
            Util.waitForIdle(robot);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
            // press on Choice
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
            choicePt = ch.getLocationOnScreen();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
            robot.mouseMove(choicePt.x + ch.getWidth()/2, choicePt.y + ch.getHeight()/2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
            robot.delay(delay);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
            robot.mousePress(InputEvent.BUTTON1_MASK);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
            robot.delay(delay);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
            robot.mouseRelease(InputEvent.BUTTON1_MASK);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
            robot.delay(delay);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
            // press on Menu
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
            framePt = f.getLocationOnScreen();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
            robot.mouseMove(choicePt.x + 10, choicePt.y - 15);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
            robot.delay(10*delay);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
            robot.mousePress(InputEvent.BUTTON1_MASK);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
            robot.delay(delay);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
            robot.mouseRelease(InputEvent.BUTTON1_MASK);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
            robot.delay(delay);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
            robot.mouseMove(choicePt.x + 15, choicePt.y + 15);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
            Util.waitForIdle(robot);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
            Color c = robot.getPixelColor(choicePt.x + 15, choicePt.y + 15);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
            System.out.println("Color obtained under opened menu is: "+c );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
            if (!c.equals(Color.red)){
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
                OpensWithNoGrab.fail("Failed: menu was opened by first click after opened Choice.");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
        }catch(Exception e){
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
            e.printStackTrace();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
            OpensWithNoGrab.fail("Failed: exception occur "+e);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
        OpensWithNoGrab.pass();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
    }//End  init()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
    /*****************************************************
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
     * Standard Test Machinery Section
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
     * DO NOT modify anything in this section -- it's a
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
     * standard chunk of code which has all of the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
     * synchronisation necessary for the test harness.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
     * By keeping it the same in all tests, it is easier
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
     * to read and understand someone else's test, as
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
     * well as insuring that all tests behave correctly
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
     * with the test harness.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
     * There is a section following this for test-
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
     * classes
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
     ******************************************************/
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
    private static boolean theTestPassed = false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
    private static boolean testGeneratedInterrupt = false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
    private static String failureMessage = "";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
    private static Thread mainThread = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
    private static int sleepTime = 300000;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
    // Not sure about what happens if multiple of this test are
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
    //  instantiated in the same VM.  Being static (and using
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
    //  static vars), it aint gonna work.  Not worrying about
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
    //  it for now.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
    public static void main( String args[] ) throws InterruptedException
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
        mainThread = Thread.currentThread();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
        try
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
            {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
                init();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
        catch( TestPassedException e )
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
            {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
                //The test passed, so just return from main and harness will
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
                // interepret this return as a pass
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
                return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
        //At this point, neither test pass nor test fail has been
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
        // called -- either would have thrown an exception and ended the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
        // test, so we know we have multiple threads.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
        //Test involves other threads, so sleep and wait for them to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
        // called pass() or fail()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
        try
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
            {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
                Thread.sleep( sleepTime );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
                //Timed out, so fail the test
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
                throw new RuntimeException( "Timed out after " + sleepTime/1000 + " seconds" );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
        catch (InterruptedException e)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
            {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
                //The test harness may have interrupted the test.  If so, rethrow the exception
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
                // so that the harness gets it and deals with it.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
                if( ! testGeneratedInterrupt ) throw e;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
                //reset flag in case hit this code more than once for some reason (just safety)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
                testGeneratedInterrupt = false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
                if ( theTestPassed == false )
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
                    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
                        throw new RuntimeException( failureMessage );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
    }//main
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
    public static synchronized void setTimeoutTo( int seconds )
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
        sleepTime = seconds * 1000;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
    public static synchronized void pass()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
    {
50834
9cf279436b9d 8205153: Delete "standard instructions" machinery in the open automated tests
serb
parents: 47216
diff changeset
   199
        System.out.println( "The test passed." );
9cf279436b9d 8205153: Delete "standard instructions" machinery in the open automated tests
serb
parents: 47216
diff changeset
   200
        System.out.println( "The test is over, hit  Ctl-C to stop Java VM" );
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
        //first check if this is executing in main thread
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
        if ( mainThread == Thread.currentThread() )
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
            {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
                //Still in the main thread, so set the flag just for kicks,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
                // and throw a test passed exception which will be caught
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
                // and end the test.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
                theTestPassed = true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
                throw new TestPassedException();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
        theTestPassed = true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
        testGeneratedInterrupt = true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
        mainThread.interrupt();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
    }//pass()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
    public static synchronized void fail()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
        //test writer didn't specify why test failed, so give generic
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
        fail( "it just plain failed! :-)" );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
    public static synchronized void fail( String whyFailed )
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
    {
50834
9cf279436b9d 8205153: Delete "standard instructions" machinery in the open automated tests
serb
parents: 47216
diff changeset
   223
        System.out.println( "The test failed: " + whyFailed );
9cf279436b9d 8205153: Delete "standard instructions" machinery in the open automated tests
serb
parents: 47216
diff changeset
   224
        System.out.println( "The test is over, hit  Ctl-C to stop Java VM" );
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
        //check if this called from main thread
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
        if ( mainThread == Thread.currentThread() )
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
            {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
                //If main thread, fail now 'cause not sleeping
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
                throw new RuntimeException( whyFailed );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
        theTestPassed = false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
        testGeneratedInterrupt = true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
        failureMessage = whyFailed;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
        mainThread.interrupt();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
    }//fail()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
}// class OpensWithNoGrab
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
//This exception is used to exit from any level of call nesting
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
// when it's determined that the test has passed, and immediately
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
// end the test.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   242
class TestPassedException extends RuntimeException
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   244
}