jdk/test/java/awt/MouseAdapter/MouseAdapterUnitTest/MouseAdapterUnitTest.java
author iignatyev
Sun, 03 Aug 2014 12:04:17 +0400
changeset 25924 4c3dd8541530
parent 5506 202f599c92aa
child 40128 e635645d2a8a
permissions -rw-r--r--
8051896: jtreg tests don't use $TESTJAVAOPTS Reviewed-by: kvn, ctornqvi
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     2
 * Copyright (c) 2006, 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
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
  @bug 4453162
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
  @summary MouseAdapter should implement MouseMotionListener and MouseWheelListener
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
  @author andrei.dmitriev: area=
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
  @library ../../regtesthelpers
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
  @build Util
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
  @run main MouseAdapterUnitTest
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
*/
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
import java.awt.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
import java.awt.event.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
import test.java.awt.regtesthelpers.Util;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
public class MouseAdapterUnitTest
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
    static Point pt;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
    static Frame frame = new Frame("Test Frame");
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
    static Button b = new Button("Test Button");
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
    static Robot robot;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
    static boolean clicked = false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
    static boolean pressed = false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
    static boolean released = false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
    static boolean entered = false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
    static boolean exited = false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
    static boolean rotated = false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
    static boolean dragged = false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
    static boolean moved = false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
    private static void init()
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
        String[] instructions =
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
        {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
            "This is an AUTOMATIC test, simply wait until it is done.",
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
            "The result (passed or failed) will be shown in the",
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
            "message window below."
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
        };
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
        Sysout.createDialog( );
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
        Sysout.printInstructions( instructions );
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
        MouseAdapter ma = new MouseAdapter(){
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
                public void mouseClicked(MouseEvent e) {clicked = true;}
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
                public void mousePressed(MouseEvent e) { pressed = true;}
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
                public void mouseReleased(MouseEvent e) {released = true;}
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
                public void mouseEntered(MouseEvent e) { entered = true;}
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
                public void mouseExited(MouseEvent e) {exited  = true;}
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
                public void mouseWheelMoved(MouseWheelEvent e){rotated = true;}
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
                public void mouseDragged(MouseEvent e){dragged = true;}
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
                public void mouseMoved(MouseEvent e){moved = true;}
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
            };
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
        b.addMouseListener(ma);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
        b.addMouseWheelListener(ma);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
        b.addMouseMotionListener(ma);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
        frame.add(b);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
        frame.pack();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
        frame.setVisible(true);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
        try{
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
            robot = new Robot();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
            robot.setAutoWaitForIdle(true);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
            robot.setAutoDelay(50);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
            Util.waitForIdle(robot);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
            pt = b.getLocationOnScreen();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
            testPressMouseButton(InputEvent.BUTTON1_MASK);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
            testDragMouseButton(InputEvent.BUTTON1_MASK);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
            testMoveMouseButton();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
            testCrossingMouseButton();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
            testWheelMouseButton();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
        } catch (Throwable e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
            throw new RuntimeException("Test failed. Exception thrown: "+e);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
        MouseAdapterUnitTest.pass();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
    }//End  init()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
    public static void testPressMouseButton(int button){
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
        robot.mouseMove(pt.x + b.getWidth()/2, pt.y + b.getHeight()/2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
        robot.delay(100);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
        robot.mousePress(button);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
        robot.mouseRelease(button);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
        robot.delay(300);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
        if ( !pressed || !released || !clicked ){
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
            dumpListenerState();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
            fail("press, release or click hasn't come");
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
    public static void testWheelMouseButton(){
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
        robot.mouseMove(pt.x + b.getWidth()/2, pt.y + b.getHeight()/2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
        robot.mouseWheel(10);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
        if ( !rotated){
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
            dumpListenerState();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
            fail("Wheel event hasn't come");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
    public static void testDragMouseButton(int button) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
        robot.mouseMove(pt.x + b.getWidth()/2, pt.y + b.getHeight()/2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
        robot.mousePress(button);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
        moveMouse(pt.x + b.getWidth()/2, pt.y +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
                  b.getHeight()/2,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
                  pt.x + b.getWidth()/2,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
                  pt.y + 2 * b.getHeight());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
        robot.mouseRelease(button);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
        if ( !dragged){
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
            dumpListenerState();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
            fail("dragged hasn't come");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
    public static void testMoveMouseButton() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
        moveMouse(pt.x + b.getWidth()/2, pt.y +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
                  b.getHeight()/2,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
                  pt.x + b.getWidth()/2,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
                  pt.y + 2 * b.getHeight());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
        if ( !moved){
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
            dumpListenerState();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
            fail("dragged hasn't come");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
    public static void moveMouse(int x0, int y0, int x1, int y1){
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
        int curX = x0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
        int curY = y0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
        int dx = x0 < x1 ? 1 : -1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
        int dy = y0 < y1 ? 1 : -1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
        while (curX != x1){
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
            curX += dx;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
            robot.mouseMove(curX, curY);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
        while (curY != y1 ){
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
            curY += dy;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
            robot.mouseMove(curX, curY);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
    public static void testCrossingMouseButton() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
        //exit
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
        moveMouse(pt.x + b.getWidth()/2,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
                  pt.y + b.getHeight()/2,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
                  pt.x + b.getWidth()/2,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
                  pt.y + 2 * b.getHeight());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
        //enter
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
        moveMouse(pt.x + b.getWidth()/2,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
                  pt.y + 2 * b.getHeight()/2,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
                  pt.x + b.getWidth()/2,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
                  pt.y + b.getHeight());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
        if ( !entered || !exited){
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
            dumpListenerState();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
            fail("enter or exit hasn't come");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
    public static void dumpListenerState(){
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
        System.out.println("pressed = "+pressed);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
        System.out.println("released = "+released);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
        System.out.println("clicked = "+clicked);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
        System.out.println("entered = "+exited);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
        System.out.println("rotated = "+rotated);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
        System.out.println("dragged = "+dragged);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
        System.out.println("moved = "+moved);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
    /*****************************************************
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
     * Standard Test Machinery Section
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
     * DO NOT modify anything in this section -- it's a
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
     * standard chunk of code which has all of the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
     * synchronisation necessary for the test harness.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
     * By keeping it the same in all tests, it is easier
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
     * to read and understand someone else's test, as
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
     * well as insuring that all tests behave correctly
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
     * with the test harness.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
     * There is a section following this for test-
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
     * classes
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
     ******************************************************/
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
    private static boolean theTestPassed = false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
    private static boolean testGeneratedInterrupt = false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
    private static String failureMessage = "";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
    private static Thread mainThread = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
    private static int sleepTime = 300000;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
    // Not sure about what happens if multiple of this test are
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
    //  instantiated in the same VM.  Being static (and using
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
    //  static vars), it aint gonna work.  Not worrying about
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
    //  it for now.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
    public static void main( String args[] ) throws InterruptedException
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
        mainThread = Thread.currentThread();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
        try
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
        {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
            init();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
        catch( TestPassedException e )
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
        {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   242
            //The test passed, so just return from main and harness will
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
            // interepret this return as a pass
90ce3da70b43 Initial load
duke
parents:
diff changeset
   244
            return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   246
        //At this point, neither test pass nor test fail has been
90ce3da70b43 Initial load
duke
parents:
diff changeset
   247
        // called -- either would have thrown an exception and ended the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   248
        // test, so we know we have multiple threads.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   249
90ce3da70b43 Initial load
duke
parents:
diff changeset
   250
        //Test involves other threads, so sleep and wait for them to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   251
        // called pass() or fail()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   252
        try
90ce3da70b43 Initial load
duke
parents:
diff changeset
   253
        {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   254
            Thread.sleep( sleepTime );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   255
            //Timed out, so fail the test
90ce3da70b43 Initial load
duke
parents:
diff changeset
   256
            throw new RuntimeException( "Timed out after " + sleepTime/1000 + " seconds" );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   257
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   258
        catch (InterruptedException e)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   259
        {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   260
            //The test harness may have interrupted the test.  If so, rethrow the exception
90ce3da70b43 Initial load
duke
parents:
diff changeset
   261
            // so that the harness gets it and deals with it.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   262
            if( ! testGeneratedInterrupt ) throw e;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   263
90ce3da70b43 Initial load
duke
parents:
diff changeset
   264
            //reset flag in case hit this code more than once for some reason (just safety)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   265
            testGeneratedInterrupt = false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   266
90ce3da70b43 Initial load
duke
parents:
diff changeset
   267
            if ( theTestPassed == false )
90ce3da70b43 Initial load
duke
parents:
diff changeset
   268
            {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   269
                throw new RuntimeException( failureMessage );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   270
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   271
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   272
90ce3da70b43 Initial load
duke
parents:
diff changeset
   273
    }//main
90ce3da70b43 Initial load
duke
parents:
diff changeset
   274
90ce3da70b43 Initial load
duke
parents:
diff changeset
   275
    public static synchronized void setTimeoutTo( int seconds )
90ce3da70b43 Initial load
duke
parents:
diff changeset
   276
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   277
        sleepTime = seconds * 1000;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   278
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   279
90ce3da70b43 Initial load
duke
parents:
diff changeset
   280
    public static synchronized void pass()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   281
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   282
        Sysout.println( "The test passed." );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   283
        Sysout.println( "The test is over, hit  Ctl-C to stop Java VM" );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   284
        //first check if this is executing in main thread
90ce3da70b43 Initial load
duke
parents:
diff changeset
   285
        if ( mainThread == Thread.currentThread() )
90ce3da70b43 Initial load
duke
parents:
diff changeset
   286
        {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   287
            //Still in the main thread, so set the flag just for kicks,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   288
            // and throw a test passed exception which will be caught
90ce3da70b43 Initial load
duke
parents:
diff changeset
   289
            // and end the test.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   290
            theTestPassed = true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   291
            throw new TestPassedException();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   292
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   293
        theTestPassed = true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   294
        testGeneratedInterrupt = true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   295
        mainThread.interrupt();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   296
    }//pass()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   297
90ce3da70b43 Initial load
duke
parents:
diff changeset
   298
    public static synchronized void fail()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   299
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   300
        //test writer didn't specify why test failed, so give generic
90ce3da70b43 Initial load
duke
parents:
diff changeset
   301
        fail( "it just plain failed! :-)" );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   302
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   303
90ce3da70b43 Initial load
duke
parents:
diff changeset
   304
    public static synchronized void fail( String whyFailed )
90ce3da70b43 Initial load
duke
parents:
diff changeset
   305
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   306
        Sysout.println( "The test failed: " + whyFailed );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   307
        Sysout.println( "The test is over, hit  Ctl-C to stop Java VM" );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   308
        //check if this called from main thread
90ce3da70b43 Initial load
duke
parents:
diff changeset
   309
        if ( mainThread == Thread.currentThread() )
90ce3da70b43 Initial load
duke
parents:
diff changeset
   310
        {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   311
            //If main thread, fail now 'cause not sleeping
90ce3da70b43 Initial load
duke
parents:
diff changeset
   312
            throw new RuntimeException( whyFailed );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   313
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   314
        theTestPassed = false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   315
        testGeneratedInterrupt = true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   316
        failureMessage = whyFailed;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   317
        mainThread.interrupt();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   318
    }//fail()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   319
90ce3da70b43 Initial load
duke
parents:
diff changeset
   320
}// class MouseAdapterUnitTest
90ce3da70b43 Initial load
duke
parents:
diff changeset
   321
90ce3da70b43 Initial load
duke
parents:
diff changeset
   322
//This exception is used to exit from any level of call nesting
90ce3da70b43 Initial load
duke
parents:
diff changeset
   323
// when it's determined that the test has passed, and immediately
90ce3da70b43 Initial load
duke
parents:
diff changeset
   324
// end the test.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   325
class TestPassedException extends RuntimeException
90ce3da70b43 Initial load
duke
parents:
diff changeset
   326
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   327
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   328
90ce3da70b43 Initial load
duke
parents:
diff changeset
   329
//*********** End Standard Test Machinery Section **********
90ce3da70b43 Initial load
duke
parents:
diff changeset
   330
90ce3da70b43 Initial load
duke
parents:
diff changeset
   331
90ce3da70b43 Initial load
duke
parents:
diff changeset
   332
//************ Begin classes defined for the test ****************
90ce3da70b43 Initial load
duke
parents:
diff changeset
   333
90ce3da70b43 Initial load
duke
parents:
diff changeset
   334
// if want to make listeners, here is the recommended place for them, then instantiate
90ce3da70b43 Initial load
duke
parents:
diff changeset
   335
//  them in init()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   336
90ce3da70b43 Initial load
duke
parents:
diff changeset
   337
/* Example of a class which may be written as part of a test
90ce3da70b43 Initial load
duke
parents:
diff changeset
   338
class NewClass implements anInterface
90ce3da70b43 Initial load
duke
parents:
diff changeset
   339
 {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   340
   static int newVar = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   341
90ce3da70b43 Initial load
duke
parents:
diff changeset
   342
   public void eventDispatched(AWTEvent e)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   343
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   344
      //Counting events to see if we get enough
90ce3da70b43 Initial load
duke
parents:
diff changeset
   345
      eventCount++;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   346
90ce3da70b43 Initial load
duke
parents:
diff changeset
   347
      if( eventCount == 20 )
90ce3da70b43 Initial load
duke
parents:
diff changeset
   348
       {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   349
         //got enough events, so pass
90ce3da70b43 Initial load
duke
parents:
diff changeset
   350
90ce3da70b43 Initial load
duke
parents:
diff changeset
   351
         MouseAdapterUnitTest.pass();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   352
       }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   353
      else if( tries == 20 )
90ce3da70b43 Initial load
duke
parents:
diff changeset
   354
       {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   355
         //tried too many times without getting enough events so fail
90ce3da70b43 Initial load
duke
parents:
diff changeset
   356
90ce3da70b43 Initial load
duke
parents:
diff changeset
   357
         MouseAdapterUnitTest.fail();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   358
       }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   359
90ce3da70b43 Initial load
duke
parents:
diff changeset
   360
    }// eventDispatched()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   361
90ce3da70b43 Initial load
duke
parents:
diff changeset
   362
 }// NewClass class
90ce3da70b43 Initial load
duke
parents:
diff changeset
   363
90ce3da70b43 Initial load
duke
parents:
diff changeset
   364
*/
90ce3da70b43 Initial load
duke
parents:
diff changeset
   365
90ce3da70b43 Initial load
duke
parents:
diff changeset
   366
90ce3da70b43 Initial load
duke
parents:
diff changeset
   367
//************** End classes defined for the test *******************
90ce3da70b43 Initial load
duke
parents:
diff changeset
   368
90ce3da70b43 Initial load
duke
parents:
diff changeset
   369
90ce3da70b43 Initial load
duke
parents:
diff changeset
   370
90ce3da70b43 Initial load
duke
parents:
diff changeset
   371
90ce3da70b43 Initial load
duke
parents:
diff changeset
   372
/****************************************************
90ce3da70b43 Initial load
duke
parents:
diff changeset
   373
 Standard Test Machinery
90ce3da70b43 Initial load
duke
parents:
diff changeset
   374
 DO NOT modify anything below -- it's a standard
90ce3da70b43 Initial load
duke
parents:
diff changeset
   375
  chunk of code whose purpose is to make user
90ce3da70b43 Initial load
duke
parents:
diff changeset
   376
  interaction uniform, and thereby make it simpler
90ce3da70b43 Initial load
duke
parents:
diff changeset
   377
  to read and understand someone else's test.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   378
 ****************************************************/
90ce3da70b43 Initial load
duke
parents:
diff changeset
   379
90ce3da70b43 Initial load
duke
parents:
diff changeset
   380
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   381
 This is part of the standard test machinery.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   382
 It creates a dialog (with the instructions), and is the interface
90ce3da70b43 Initial load
duke
parents:
diff changeset
   383
  for sending text messages to the user.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   384
 To print the instructions, send an array of strings to Sysout.createDialog
90ce3da70b43 Initial load
duke
parents:
diff changeset
   385
  WithInstructions method.  Put one line of instructions per array entry.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   386
 To display a message for the tester to see, simply call Sysout.println
90ce3da70b43 Initial load
duke
parents:
diff changeset
   387
  with the string to be displayed.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   388
 This mimics System.out.println but works within the test harness as well
90ce3da70b43 Initial load
duke
parents:
diff changeset
   389
  as standalone.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   390
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   391
90ce3da70b43 Initial load
duke
parents:
diff changeset
   392
class Sysout
90ce3da70b43 Initial load
duke
parents:
diff changeset
   393
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   394
    private static TestDialog dialog;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   395
90ce3da70b43 Initial load
duke
parents:
diff changeset
   396
    public static void createDialogWithInstructions( String[] instructions )
90ce3da70b43 Initial load
duke
parents:
diff changeset
   397
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   398
        dialog = new TestDialog( new Frame(), "Instructions" );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   399
        dialog.printInstructions( instructions );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   400
        dialog.setVisible(true);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   401
        println( "Any messages for the tester will display here." );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   402
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   403
90ce3da70b43 Initial load
duke
parents:
diff changeset
   404
    public static void createDialog( )
90ce3da70b43 Initial load
duke
parents:
diff changeset
   405
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   406
        dialog = new TestDialog( new Frame(), "Instructions" );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   407
        String[] defInstr = { "Instructions will appear here. ", "" } ;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   408
        dialog.printInstructions( defInstr );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   409
        dialog.setVisible(true);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   410
        println( "Any messages for the tester will display here." );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   411
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   412
90ce3da70b43 Initial load
duke
parents:
diff changeset
   413
90ce3da70b43 Initial load
duke
parents:
diff changeset
   414
    public static void printInstructions( String[] instructions )
90ce3da70b43 Initial load
duke
parents:
diff changeset
   415
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   416
        dialog.printInstructions( instructions );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   417
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   418
90ce3da70b43 Initial load
duke
parents:
diff changeset
   419
90ce3da70b43 Initial load
duke
parents:
diff changeset
   420
    public static void println( String messageIn )
90ce3da70b43 Initial load
duke
parents:
diff changeset
   421
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   422
        dialog.displayMessage( messageIn );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   423
        System.out.println(messageIn);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   424
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   425
90ce3da70b43 Initial load
duke
parents:
diff changeset
   426
}// Sysout  class
90ce3da70b43 Initial load
duke
parents:
diff changeset
   427
90ce3da70b43 Initial load
duke
parents:
diff changeset
   428
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   429
  This is part of the standard test machinery.  It provides a place for the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   430
   test instructions to be displayed, and a place for interactive messages
90ce3da70b43 Initial load
duke
parents:
diff changeset
   431
   to the user to be displayed.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   432
  To have the test instructions displayed, see Sysout.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   433
  To have a message to the user be displayed, see Sysout.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   434
  Do not call anything in this dialog directly.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   435
  */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   436
class TestDialog extends Dialog
90ce3da70b43 Initial load
duke
parents:
diff changeset
   437
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   438
90ce3da70b43 Initial load
duke
parents:
diff changeset
   439
    TextArea instructionsText;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   440
    TextArea messageText;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   441
    int maxStringLength = 80;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   442
90ce3da70b43 Initial load
duke
parents:
diff changeset
   443
    //DO NOT call this directly, go through Sysout
90ce3da70b43 Initial load
duke
parents:
diff changeset
   444
    public TestDialog( Frame frame, String name )
90ce3da70b43 Initial load
duke
parents:
diff changeset
   445
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   446
        super( frame, name );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   447
        int scrollBoth = TextArea.SCROLLBARS_BOTH;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   448
        instructionsText = new TextArea( "", 15, maxStringLength, scrollBoth );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   449
        add( "North", instructionsText );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   450
90ce3da70b43 Initial load
duke
parents:
diff changeset
   451
        messageText = new TextArea( "", 5, maxStringLength, scrollBoth );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   452
        add("Center", messageText);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   453
90ce3da70b43 Initial load
duke
parents:
diff changeset
   454
        pack();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   455
90ce3da70b43 Initial load
duke
parents:
diff changeset
   456
        setVisible(true);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   457
    }// TestDialog()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   458
90ce3da70b43 Initial load
duke
parents:
diff changeset
   459
    //DO NOT call this directly, go through Sysout
90ce3da70b43 Initial load
duke
parents:
diff changeset
   460
    public void printInstructions( String[] instructions )
90ce3da70b43 Initial load
duke
parents:
diff changeset
   461
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   462
        //Clear out any current instructions
90ce3da70b43 Initial load
duke
parents:
diff changeset
   463
        instructionsText.setText( "" );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   464
90ce3da70b43 Initial load
duke
parents:
diff changeset
   465
        //Go down array of instruction strings
90ce3da70b43 Initial load
duke
parents:
diff changeset
   466
90ce3da70b43 Initial load
duke
parents:
diff changeset
   467
        String printStr, remainingStr;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   468
        for( int i=0; i < instructions.length; i++ )
90ce3da70b43 Initial load
duke
parents:
diff changeset
   469
        {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   470
            //chop up each into pieces maxSringLength long
90ce3da70b43 Initial load
duke
parents:
diff changeset
   471
            remainingStr = instructions[ i ];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   472
            while( remainingStr.length() > 0 )
90ce3da70b43 Initial load
duke
parents:
diff changeset
   473
            {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   474
                //if longer than max then chop off first max chars to print
90ce3da70b43 Initial load
duke
parents:
diff changeset
   475
                if( remainingStr.length() >= maxStringLength )
90ce3da70b43 Initial load
duke
parents:
diff changeset
   476
                {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   477
                    //Try to chop on a word boundary
90ce3da70b43 Initial load
duke
parents:
diff changeset
   478
                    int posOfSpace = remainingStr.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   479
                        lastIndexOf( ' ', maxStringLength - 1 );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   480
90ce3da70b43 Initial load
duke
parents:
diff changeset
   481
                    if( posOfSpace <= 0 ) posOfSpace = maxStringLength - 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   482
90ce3da70b43 Initial load
duke
parents:
diff changeset
   483
                    printStr = remainingStr.substring( 0, posOfSpace + 1 );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   484
                    remainingStr = remainingStr.substring( posOfSpace + 1 );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   485
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   486
                //else just print
90ce3da70b43 Initial load
duke
parents:
diff changeset
   487
                else
90ce3da70b43 Initial load
duke
parents:
diff changeset
   488
                {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   489
                    printStr = remainingStr;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   490
                    remainingStr = "";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   491
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   492
90ce3da70b43 Initial load
duke
parents:
diff changeset
   493
                instructionsText.append( printStr + "\n" );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   494
90ce3da70b43 Initial load
duke
parents:
diff changeset
   495
            }// while
90ce3da70b43 Initial load
duke
parents:
diff changeset
   496
90ce3da70b43 Initial load
duke
parents:
diff changeset
   497
        }// for
90ce3da70b43 Initial load
duke
parents:
diff changeset
   498
90ce3da70b43 Initial load
duke
parents:
diff changeset
   499
    }//printInstructions()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   500
90ce3da70b43 Initial load
duke
parents:
diff changeset
   501
    //DO NOT call this directly, go through Sysout
90ce3da70b43 Initial load
duke
parents:
diff changeset
   502
    public void displayMessage( String messageIn )
90ce3da70b43 Initial load
duke
parents:
diff changeset
   503
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   504
        messageText.append( messageIn + "\n" );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   505
        System.out.println(messageIn);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   506
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   507
90ce3da70b43 Initial load
duke
parents:
diff changeset
   508
}// TestDialog  class