jdk/test/java/awt/print/PrinterJob/ScaledText/ScaledText.java
author psadhukhan
Fri, 17 Jun 2016 16:52:38 +0530
changeset 39520 df99c6e834bc
parent 24143 064337def883
permissions -rw-r--r--
6966350: Empty pages when printing on Lexmark E352dn PS3 with "1200 IQ" setting Reviewed-by: prr, jdv
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
24143
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
     1
/*
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
     2
 * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved.
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
     4
 *
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
     7
 * published by the Free Software Foundation.
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
     8
 *
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
    13
 * accompanied this code).
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
    14
 *
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
    18
 *
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
    21
 * questions.
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
    22
 */
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
    23
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
    24
/*
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
    25
  @test
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
    26
  @bug 4291373
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
    27
  @summary  Printing of scaled text is wrong / disappearing
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
    28
  @author prr: area=PrinterJob
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
    29
  @run main/manual ScaledText
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
    30
*/
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
    31
import java.awt.*;
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
    32
import java.awt.event.*;
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
    33
import java.awt.print.*;
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
    34
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
    35
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
    36
public class ScaledText implements Printable {
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
    37
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
    38
   private Image opaqueimg,transimg;
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
    39
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
    40
   private static void init() {
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
    41
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
    42
        //*** Create instructions for the user here ***
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
    43
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
    44
        String[] instructions = {
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
    45
         "On-screen inspection is not possible for this printing-specific",
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
    46
         "test therefore its only output is two printed pages.",
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
    47
         "To be able to run this test it is required to have a default",
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
    48
         "printer configured in your user environment.",
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
    49
         "",
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
    50
         "Visual inspection of the printed pages is needed. A passing",
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
    51
         "test will print a page on which 6 lines of text will be",
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
    52
         "printed, all of the same size. The test fails only if the sizes",
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
    53
         "are different, or not all of the sizes labelled 1.0, 2.0, 4.0",
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
    54
         "8.0, 16.0, 32.0 appear."
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
    55
       };
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
    56
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
    57
      Sysout.createDialog( );
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
    58
      Sysout.printInstructions( instructions );
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
    59
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
    60
        PrinterJob pjob = PrinterJob.getPrinterJob();
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
    61
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
    62
        Book book = new Book();
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
    63
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
    64
        PageFormat portrait = pjob.defaultPage();
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
    65
        book.append(new ScaledText(),portrait);
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
    66
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
    67
        pjob.setPageable(book);
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
    68
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
    69
        if (pjob.printDialog()) {
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
    70
            try {
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
    71
                pjob.print();
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
    72
            } catch (PrinterException e) {
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
    73
                System.err.println(e);
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
    74
                e.printStackTrace();
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
    75
            }
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
    76
        }
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
    77
        System.out.println("Done Printing");
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
    78
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
    79
    }//End  init()
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
    80
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
    81
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
    82
  public ScaledText() {
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
    83
  }
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
    84
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
    85
  public int print(Graphics g, PageFormat pgFmt, int pgIndex) {
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
    86
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
    87
       Graphics2D g2D = (Graphics2D) g;
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
    88
       g2D.translate(pgFmt.getImageableX(), pgFmt.getImageableY());
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
    89
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
    90
       g2D.setColor(Color.black);
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
    91
       Font font = new Font("serif", Font.PLAIN, 1);
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
    92
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
    93
       float scale;
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
    94
       float x;
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
    95
       float y;
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
    96
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
    97
       scale = 1.0f;
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
    98
       x     = 3.0f;
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
    99
       y     = 3.0f;
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
   100
       printScale(g2D, font, scale, x, y);
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
   101
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
   102
       scale = 2.0f;
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
   103
       x     = 3.0f;
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
   104
       y     = 3.5f;
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
   105
       printScale(g2D, font, scale, x, y);
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
   106
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
   107
       scale = 4.0f;
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
   108
       x     = 3.0f;
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
   109
       y     = 4.0f;
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
   110
       printScale(g2D, font, scale, x, y);
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
   111
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
   112
       scale = 8.0f;
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
   113
       x     = 3.0f;
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
   114
       y     = 4.5f;
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
   115
       printScale(g2D, font, scale, x, y);
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
   116
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
   117
       scale = 16.0f;
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
   118
       x     = 3.0f;
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
   119
       y     = 5.0f;
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
   120
       printScale(g2D, font, scale, x, y);
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
   121
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
   122
       scale = 32.0f;
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
   123
       x     = 3.0f;
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
   124
       y     = 5.5f;
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
   125
       printScale(g2D, font, scale, x, y);
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
   126
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
   127
       return Printable.PAGE_EXISTS;
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
   128
  }
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
   129
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
   130
  /**
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
   131
   * The graphics is scaled and the font and the positions
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
   132
   * are reduced in respect to the scaling, so that all
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
   133
   * printing should be the same.
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
   134
   *
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
   135
   * @param g2D     graphics2D to paint on
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
   136
   * @param font    font to paint
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
   137
   * @param scale   scale for the painting
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
   138
   * @param x       x position
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
   139
   * @param y       y position
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
   140
   */
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
   141
  private void printScale(Graphics2D g2D, Font font,
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
   142
                           float scale, float x, float y) {
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
   143
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
   144
    int RES = 72;
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
   145
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
   146
    g2D.scale(scale, scale);
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
   147
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
   148
    g2D.setFont   (font.deriveFont(10.0f / scale));
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
   149
    g2D.drawString("This text is scaled by a factor of " + scale,
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
   150
                   x * RES / scale, y * RES / scale);
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
   151
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
   152
    g2D.scale(1/scale, 1/scale);
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
   153
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
   154
}
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
   155
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
   156
   /*****************************************************
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
   157
     Standard Test Machinery Section
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
   158
      DO NOT modify anything in this section -- it's a
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
   159
      standard chunk of code which has all of the
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
   160
      synchronisation necessary for the test harness.
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
   161
      By keeping it the same in all tests, it is easier
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
   162
      to read and understand someone else's test, as
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
   163
      well as insuring that all tests behave correctly
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
   164
      with the test harness.
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
   165
     There is a section following this for test-defined
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
   166
      classes
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
   167
   ******************************************************/
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
   168
   private static boolean theTestPassed = false;
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
   169
   private static boolean testGeneratedInterrupt = false;
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
   170
   private static String failureMessage = "";
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
   171
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
   172
   private static Thread mainThread = null;
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
   173
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
   174
   private static int sleepTime = 300000;
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
   175
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
   176
   public static void main( String args[] ) throws InterruptedException
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
   177
    {
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
   178
      mainThread = Thread.currentThread();
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
   179
      try
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
   180
       {
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
   181
         init();
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
   182
       }
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
   183
      catch( TestPassedException e )
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
   184
       {
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
   185
         //The test passed, so just return from main and harness will
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
   186
         // interepret this return as a pass
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
   187
         return;
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
   188
       }
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
   189
      //At this point, neither test passed nor test failed has been
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
   190
      // called -- either would have thrown an exception and ended the
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
   191
      // test, so we know we have multiple threads.
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
   192
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
   193
      //Test involves other threads, so sleep and wait for them to
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
   194
      // called pass() or fail()
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
   195
      try
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
   196
       {
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
   197
         Thread.sleep( sleepTime );
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
   198
         //Timed out, so fail the test
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
   199
         throw new RuntimeException( "Timed out after " + sleepTime/1000 + " seconds" );
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
   200
       }
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
   201
      catch (InterruptedException e)
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
   202
       {
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
   203
         if( ! testGeneratedInterrupt ) throw e;
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
   204
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
   205
         //reset flag in case hit this code more than once for some reason (just safety)
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
   206
         testGeneratedInterrupt = false;
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
   207
         if ( theTestPassed == false )
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
   208
          {
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
   209
            throw new RuntimeException( failureMessage );
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
   210
          }
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
   211
       }
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
   212
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
   213
    }//main
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
   214
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
   215
   public static synchronized void setTimeoutTo( int seconds )
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
   216
    {
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
   217
      sleepTime = seconds * 1000;
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
   218
    }
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
   219
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
   220
   public static synchronized void pass()
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
   221
    {
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
   222
      Sysout.println( "The test passed." );
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
   223
      Sysout.println( "The test is over, hit  Ctl-C to stop Java VM" );
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
   224
      //first check if this is executing in main thread
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
   225
      if ( mainThread == Thread.currentThread() )
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
   226
       {
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
   227
         //Still in the main thread, so set the flag just for kicks,
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
   228
         // and throw a test passed exception which will be caught
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
   229
         // and end the test.
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
   230
         theTestPassed = true;
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
   231
         throw new TestPassedException();
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
   232
       }
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
   233
      //pass was called from a different thread, so set the flag and interrupt
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
   234
      // the main thead.
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
   235
      theTestPassed = true;
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
   236
      testGeneratedInterrupt = true;
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
   237
      mainThread.interrupt();
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
   238
    }//pass()
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
   239
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
   240
   public static synchronized void fail()
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
   241
    {
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
   242
      //test writer didn't specify why test failed, s     fail( "it just plain failed! :-)" );
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
   243
    }
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
   244
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
   245
   public static synchronized void fail( String whyFailed )
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
   246
    {
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
   247
      Sysout.println( "The test failed: " + whyFailed );
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
   248
      Sysout.println( "The test is over, hit  Ctl-C to stop Java VM" );
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
   249
      //check if this called from main thread
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
   250
      if ( mainThread == Thread.currentThread() )
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
   251
       {
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
   252
         //If main thread, fail now 'cause not sleeping
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
   253
         throw new RuntimeException( whyFailed );
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
   254
       }
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
   255
      theTestPassed = false;
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
   256
      testGeneratedInterrupt = true;
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
   257
      failureMessage = whyFailed;
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
   258
      mainThread.interrupt();
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
   259
    }//fail()
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
   260
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
   261
}// class ScaledText
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
   262
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
   263
//This exception is used to exit from any level of call nesting
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
   264
// when it's determined that the test has passed, and immediately
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
   265
// end the test.
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
   266
class TestPassedException extends RuntimeException
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
   267
 {
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
   268
 }
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
   269
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
   270
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
   271
//************** End classes defined for the test *******************
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
   272
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
   273
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
   274
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
   275
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
   276
/****************************************************
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
   277
 Standard Test Machinery
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
   278
 DO NOT modify anything below -- it's a standard
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
   279
  chunk of code whose purpose is to make user
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
   280
  interaction uniform, and thereby make it simpler
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
   281
  to read and understand someone else's test.
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
   282
 ****************************************************/
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
   283
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
   284
/**
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
   285
 This is part of the standard test machinery.
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
   286
 It creates a dialog (with the instructions), and is the interface
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
   287
  for sending text messages to the user.
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
   288
 To print the instructions, send an array of strings to Sysout.createDialog
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
   289
  WithInstructions method.  Put one line of instructions per array entry.
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
   290
 To display a message for the tester to see, simply call Sysout.println
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
   291
  with the string to be displayed.
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
   292
 This mimics System.out.println but works within the test harness as well
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
   293
  as standalone.
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
   294
 */
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
   295
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
   296
class Sysout
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
   297
 {
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
   298
   private static TestDialog dialog;
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
   299
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
   300
   public static void createDialogWithInstructions( String[] instructions )
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
   301
    {
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
   302
      dialog = new TestDialog( new Frame(), "Instructions" );
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
   303
      dialog.printInstructions( instructions );
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
   304
      dialog.show();
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
   305
      println( "Any messages for the tester will display here." );
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
   306
    }
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
   307
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
   308
   public static void createDialog( )
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
   309
    {
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
   310
      dialog = new TestDialog( new Frame(), "Instructions" );
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
   311
      String[] defInstr = { "Instructions will appear here. ", "" } ;
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
   312
      dialog.printInstructions( defInstr );
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
   313
      dialog.show();
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
   314
      println( "Any messages for the tester will display here." );
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
   315
    }
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
   316
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
   317
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
   318
   public static void printInstructions( String[] instructions )
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
   319
    {
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
   320
      dialog.printInstructions( instructions );
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
   321
    }
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
   322
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
   323
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
   324
   public static void println( String messageIn )
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
   325
    {
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
   326
      dialog.displayMessage( messageIn );
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
   327
    }
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
   328
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
   329
 }// Sysout  class
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
   330
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
   331
/**
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
   332
  This is part of the standard test machinery.  It provides a place for the
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
   333
   test instructions to be displayed, and a place for interactive messages
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
   334
   to the user to be displayed.
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
   335
  To have the test instructions displayed, see Sysout.
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
   336
  To have a message to the user be displayed, see Sysout.
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
   337
  Do not call anything in this dialog directly.
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
   338
  */
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
   339
class TestDialog extends Dialog implements ActionListener {
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
   340
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
   341
   TextArea instructionsText;
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
   342
   TextArea messageText;
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
   343
   int maxStringLength = 80;
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
   344
   Panel  buttonP = new Panel();
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
   345
   Button passB = new Button( "pass" );
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
   346
   Button failB = new Button( "fail" );
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
   347
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
   348
   //DO NOT call this directly, go through Sysout
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
   349
   public TestDialog( Frame frame, String name )
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
   350
    {
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
   351
      super( frame, name );
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
   352
      int scrollBoth = TextArea.SCROLLBARS_BOTH;
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
   353
      instructionsText = new TextArea( "", 15, maxStringLength, scrollBoth );
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
   354
      add( "North", instructionsText );
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
   355
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
   356
      messageText = new TextArea( "", 5, maxStringLength, scrollBoth );
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
   357
      add("Center", messageText);
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
   358
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
   359
      passB = new Button( "pass" );
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
   360
      passB.setActionCommand( "pass" );
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
   361
      passB.addActionListener( this );
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
   362
      buttonP.add( "East", passB );
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
   363
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
   364
      failB = new Button( "fail" );
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
   365
      failB.setActionCommand( "fail" );
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
   366
      failB.addActionListener( this );
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
   367
      buttonP.add( "West", failB );
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
   368
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
   369
      add( "South", buttonP );
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
   370
      pack();
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
   371
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
   372
      show();
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
   373
    }// TestDialog()
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
   374
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
   375
   //DO NOT call this directly, go through Sysout
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
   376
   public void printInstructions( String[] instructions )
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
   377
    {
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
   378
      //Clear out any current instructions
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
   379
      instructionsText.setText( "" );
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
   380
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
   381
      //Go down array of instruction strings
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
   382
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
   383
      String printStr, remainingStr;
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
   384
      for( int i=0; i < instructions.length; i++ )
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
   385
       {
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
   386
         //chop up each into pieces maxSringLength long
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
   387
         remainingStr = instructions[ i ];
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
   388
         while( remainingStr.length() > 0 )
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
   389
          {
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
   390
            //if longer than max then chop off first max chars to print
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
   391
            if( remainingStr.length() >= maxStringLength )
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
   392
             {
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
   393
               //Try to chop on a word boundary
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
   394
               int posOfSpace = remainingStr.
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
   395
                  lastIndexOf( ' ', maxStringLength - 1 );
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
   396
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
   397
               if( posOfSpace <= 0 ) posOfSpace = maxStringLength - 1;
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
   398
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
   399
               printStr = remainingStr.substring( 0, posOfSpace + 1 );
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
   400
               remainingStr = remainingStr.substring( posOfSpace + 1 );
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
   401
             }
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
   402
            //else just print
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
   403
            else
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
   404
             {
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
   405
               printStr = remainingStr;
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
   406
               remainingStr = "";
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
   407
             }
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
   408
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
   409
            instructionsText.append( printStr + "\n" );
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
   410
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
   411
          }// while
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
   412
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
   413
       }// for
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
   414
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
   415
    }//printInstructions()
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
   416
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
   417
   //DO NOT call this directly, go through Sysout
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
   418
   public void displayMessage( String messageIn )
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
   419
    {
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
   420
      messageText.append( messageIn + "\n" );
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
   421
    }
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
   422
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
   423
   //catch presses of the passed and failed buttons.
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
   424
   //simply call the standard pass() or fail() static methods of
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
   425
   //ScaledText
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
   426
   public void actionPerformed( ActionEvent e )
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
   427
    {
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
   428
      if( e.getActionCommand() == "pass" )
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
   429
       {
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
   430
         ScaledText.pass();
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
   431
       }
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
   432
      else
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
   433
       {
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
   434
         ScaledText.fail();
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
   435
       }
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
   436
    }
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
   437
064337def883 8038723: Openup some PrinterJob tests
prr
parents:
diff changeset
   438
 }// TestDialog  class