test/jdk/java/awt/event/HierarchyEvent/AncestorResized/AncestorResized.java
author serb
Sun, 24 Jun 2018 16:35:21 -0700
changeset 50834 9cf279436b9d
parent 47216 71c04702a3d5
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) 2007, 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: 5506
diff changeset
    26
  @key headful
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
  @bug 6533330
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
  @summary ANCESTOR_RESIZED is not sent while resizing a frame. Regression caused by 6500477.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
  @author anthony.petrov: area=awt.toplevel
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
  @library ../../../regtesthelpers
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
  @build Util
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
  @run main AncestorResized
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
*/
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
 * AncestorResized.java
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
 * summary:  After fixing the 6500477, the ANCESTOR_RESIZED event stoped
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
 *           firing while resizing a frame. This was a regression.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
 *           The test checks whether the event starts dispatching as it
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
 *           was before fixing the 6500477.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
import java.awt.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
import java.awt.event.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
import test.java.awt.regtesthelpers.Util;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
public class AncestorResized
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
    public static volatile int ancestorResizedCounter = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
    static class HierarchyBoundsListenerImpl implements HierarchyBoundsListener {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
        public void ancestorMoved(HierarchyEvent ce) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
            // ANCESTOR_MOVED seems to work OK.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
        public void ancestorResized(HierarchyEvent ce) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
            ancestorResizedCounter++;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
    private static void init()
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
        Frame frame;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
        Panel panel;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
        Button button;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
        Label label;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
        Component[] components;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
        frame = new Frame("Test Frame");
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
        frame.setLayout(new FlowLayout());
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
        panel = new Panel();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
        button = new Button("Button");
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
        label = new Label("Label");
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
        components = new Component[] {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
            panel, button, label
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
        };
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
        frame.setSize(300, 300);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
        frame.setVisible(true);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
        Robot robot = Util.createRobot();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
        robot.setAutoDelay(20);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
        // To ensure the window is shown and packed
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
        Util.waitForIdle(robot);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
        Insets insets = frame.getInsets();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
        if (insets.right == 0 || insets.bottom == 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
            // Because we want to catch the "size-grip" of the frame.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
            System.out.println("The test environment must have non-zero right & bottom insets! The current insets are: " + insets);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
            pass();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
            return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
        // Let's move the mouse pointer to the bottom-right coner of the frame (the "size-grip")
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
        Rectangle bounds = frame.getBounds();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
        robot.mouseMove(bounds.x + bounds.width - 1, bounds.y + bounds.height - 1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
        // From now on the ANCESTOR_RESIZED events get counted.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
        HierarchyBoundsListener listener = new HierarchyBoundsListenerImpl();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
        for (int i = 0; i < components.length; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
            components[i].addHierarchyBoundsListener(listener);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
            frame.add(components[i]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
        // ... and start resizing
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
        robot.mousePress( InputEvent.BUTTON1_MASK );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
        robot.mouseMove(bounds.x + bounds.width + 20, bounds.y + bounds.height + 15);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
        Util.waitForIdle(robot);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
        if (ancestorResizedCounter == 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
            robot.mouseRelease( InputEvent.BUTTON1_MASK );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
            AncestorResized.fail("No ANCESTOR_RESIZED events received.");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
            return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
        robot.mouseRelease( InputEvent.BUTTON1_MASK );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
        AncestorResized.pass();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
    }//End  init()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
    /*****************************************************
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
     * Standard Test Machinery Section
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
     * DO NOT modify anything in this section -- it's a
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
     * standard chunk of code which has all of the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
     * synchronisation necessary for the test harness.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
     * By keeping it the same in all tests, it is easier
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
     * to read and understand someone else's test, as
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
     * well as insuring that all tests behave correctly
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
     * with the test harness.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
     * There is a section following this for test-
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
     * classes
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
     ******************************************************/
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
    private static boolean theTestPassed = false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
    private static boolean testGeneratedInterrupt = false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
    private static String failureMessage = "";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
    private static Thread mainThread = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
    private static int sleepTime = 300000;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
    // Not sure about what happens if multiple of this test are
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
    //  instantiated in the same VM.  Being static (and using
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
    //  static vars), it aint gonna work.  Not worrying about
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
    //  it for now.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
    public static void main( String args[] ) throws InterruptedException
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
        mainThread = Thread.currentThread();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
        try
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
        {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
            init();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
        catch( TestPassedException e )
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
        {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
            //The test passed, so just return from main and harness will
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
            // interepret this return as a pass
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
            return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
        //At this point, neither test pass nor test fail has been
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
        // called -- either would have thrown an exception and ended the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
        // test, so we know we have multiple threads.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
        //Test involves other threads, so sleep and wait for them to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
        // called pass() or fail()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
        try
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
        {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
            Thread.sleep( sleepTime );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
            //Timed out, so fail the test
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
            throw new RuntimeException( "Timed out after " + sleepTime/1000 + " seconds" );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
        catch (InterruptedException e)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
        {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
            //The test harness may have interrupted the test.  If so, rethrow the exception
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
            // so that the harness gets it and deals with it.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
            if( ! testGeneratedInterrupt ) throw e;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
            //reset flag in case hit this code more than once for some reason (just safety)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
            testGeneratedInterrupt = false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
            if ( theTestPassed == false )
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
            {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
                throw new RuntimeException( failureMessage );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
    }//main
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
    public static synchronized void setTimeoutTo( int seconds )
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
        sleepTime = seconds * 1000;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
    public static synchronized void pass()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
    {
50834
9cf279436b9d 8205153: Delete "standard instructions" machinery in the open automated tests
serb
parents: 47216
diff changeset
   203
        System.out.println( "The test passed." );
9cf279436b9d 8205153: Delete "standard instructions" machinery in the open automated tests
serb
parents: 47216
diff changeset
   204
        System.out.println( "The test is over, hit  Ctl-C to stop Java VM" );
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
        //first check if this is executing in main thread
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
        if ( mainThread == Thread.currentThread() )
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
        {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
            //Still in the main thread, so set the flag just for kicks,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
            // and throw a test passed exception which will be caught
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
            // and end the test.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
            theTestPassed = true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
            throw new TestPassedException();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
        theTestPassed = true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
        testGeneratedInterrupt = true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
        mainThread.interrupt();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
    }//pass()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
    public static synchronized void fail()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
        //test writer didn't specify why test failed, so give generic
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
        fail( "it just plain failed! :-)" );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
    public static synchronized void fail( String whyFailed )
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
    {
50834
9cf279436b9d 8205153: Delete "standard instructions" machinery in the open automated tests
serb
parents: 47216
diff changeset
   227
        System.out.println( "The test failed: " + whyFailed );
9cf279436b9d 8205153: Delete "standard instructions" machinery in the open automated tests
serb
parents: 47216
diff changeset
   228
        System.out.println( "The test is over, hit  Ctl-C to stop Java VM" );
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
        //check if this called from main thread
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
        if ( mainThread == Thread.currentThread() )
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
        {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
            //If main thread, fail now 'cause not sleeping
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
            throw new RuntimeException( whyFailed );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
        theTestPassed = false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
        testGeneratedInterrupt = true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
        failureMessage = whyFailed;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
        mainThread.interrupt();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
    }//fail()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
}// class AncestorResized
90ce3da70b43 Initial load
duke
parents:
diff changeset
   242
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
//This exception is used to exit from any level of call nesting
90ce3da70b43 Initial load
duke
parents:
diff changeset
   244
// when it's determined that the test has passed, and immediately
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
// end the test.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   246
class TestPassedException extends RuntimeException
90ce3da70b43 Initial load
duke
parents:
diff changeset
   247
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   248
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   249
90ce3da70b43 Initial load
duke
parents:
diff changeset
   250
//*********** End Standard Test Machinery Section **********
90ce3da70b43 Initial load
duke
parents:
diff changeset
   251
90ce3da70b43 Initial load
duke
parents:
diff changeset
   252
90ce3da70b43 Initial load
duke
parents:
diff changeset
   253
//************ Begin classes defined for the test ****************
90ce3da70b43 Initial load
duke
parents:
diff changeset
   254
90ce3da70b43 Initial load
duke
parents:
diff changeset
   255
// if want to make listeners, here is the recommended place for them, then instantiate
90ce3da70b43 Initial load
duke
parents:
diff changeset
   256
//  them in init()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   257
90ce3da70b43 Initial load
duke
parents:
diff changeset
   258
/* Example of a class which may be written as part of a test
90ce3da70b43 Initial load
duke
parents:
diff changeset
   259
class NewClass implements anInterface
90ce3da70b43 Initial load
duke
parents:
diff changeset
   260
 {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   261
   static int newVar = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   262
90ce3da70b43 Initial load
duke
parents:
diff changeset
   263
   public void eventDispatched(AWTEvent e)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   264
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   265
      //Counting events to see if we get enough
90ce3da70b43 Initial load
duke
parents:
diff changeset
   266
      eventCount++;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   267
90ce3da70b43 Initial load
duke
parents:
diff changeset
   268
      if( eventCount == 20 )
90ce3da70b43 Initial load
duke
parents:
diff changeset
   269
       {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   270
         //got enough events, so pass
90ce3da70b43 Initial load
duke
parents:
diff changeset
   271
90ce3da70b43 Initial load
duke
parents:
diff changeset
   272
         AncestorResized.pass();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   273
       }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   274
      else if( tries == 20 )
90ce3da70b43 Initial load
duke
parents:
diff changeset
   275
       {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   276
         //tried too many times without getting enough events so fail
90ce3da70b43 Initial load
duke
parents:
diff changeset
   277
90ce3da70b43 Initial load
duke
parents:
diff changeset
   278
         AncestorResized.fail();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   279
       }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   280
90ce3da70b43 Initial load
duke
parents:
diff changeset
   281
    }// eventDispatched()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   282
90ce3da70b43 Initial load
duke
parents:
diff changeset
   283
 }// NewClass class
90ce3da70b43 Initial load
duke
parents:
diff changeset
   284
90ce3da70b43 Initial load
duke
parents:
diff changeset
   285
*/
90ce3da70b43 Initial load
duke
parents:
diff changeset
   286
90ce3da70b43 Initial load
duke
parents:
diff changeset
   287
90ce3da70b43 Initial load
duke
parents:
diff changeset
   288
//************** End classes defined for the test *******************