test/jdk/java/awt/event/KeyEvent/KeyTyped/CtrlASCII.java
author serb
Wed, 27 Feb 2019 18:46:55 -0800
changeset 54231 e4813eded7cb
parent 50834 9cf279436b9d
permissions -rw-r--r--
8213110: Remove the use of applets in automatic tests Reviewed-by: prr
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
50834
9cf279436b9d 8205153: Delete "standard instructions" machinery in the open automated tests
serb
parents: 47216
diff changeset
     2
 * Copyright (c) 2007, 2018, Oracle and/or its affiliates. All rights reserved.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     4
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
90ce3da70b43 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
90ce3da70b43 Initial load
duke
parents:
diff changeset
     7
 * published by the Free Software Foundation.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
90ce3da70b43 Initial load
duke
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
90ce3da70b43 Initial load
duke
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    13
 * accompanied this code).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    14
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
90ce3da70b43 Initial load
duke
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    18
 *
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    21
 * questions.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    22
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    23
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
/*
54231
e4813eded7cb 8213110: Remove the use of applets in automatic tests
serb
parents: 50834
diff changeset
    25
  @test
e4813eded7cb 8213110: Remove the use of applets in automatic tests
serb
parents: 50834
diff changeset
    26
  @key headful
e4813eded7cb 8213110: Remove the use of applets in automatic tests
serb
parents: 50834
diff changeset
    27
  @bug  6497426
e4813eded7cb 8213110: Remove the use of applets in automatic tests
serb
parents: 50834
diff changeset
    28
  @summary ests that pressing of Ctrl+ascii mostly fires KEY_TYPED with a Unicode control symbols
e4813eded7cb 8213110: Remove the use of applets in automatic tests
serb
parents: 50834
diff changeset
    29
  @run main CtrlASCII
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
import java.awt.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
import java.awt.event.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
import java.util.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
//
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
// In this test, a key listener for KEY_TYPED checks if a character typed has
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
// a correspondent keycode in an initially filled hashtable.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
// If it does not, test fails. If character was produced by
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
// pressing a wrong key still listed in the hashtable, test cannot detect it.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
// Under MS Windows, unlike X Window, some Ctrl+Ascii keystrokes don't
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
// produce a unicode character, so there will be no KEY_TYPED and no problem.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
// Test doesn't try to verify Ctrl+deadkey behavior.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
//
54231
e4813eded7cb 8213110: Remove the use of applets in automatic tests
serb
parents: 50834
diff changeset
    45
public class CtrlASCII extends Frame implements KeyListener
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
    // Declare things used in the test, like buttons and labels here
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
    static Hashtable<Character, Integer> keycharHash = new Hashtable<Character, Integer>();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
    static boolean testFailed = false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
    //Frame frame;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
    TextField tf;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
    Robot robot;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
    static void fillHash( boolean isMSWindows ) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
        keycharHash.put(    (char)0x20         , KeyEvent.VK_SPACE        );                      /*32,x20*/ /*' ' */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
        keycharHash.put(    (char)0x21         , KeyEvent.VK_EXCLAMATION_MARK        );           /*33,x21*/ /*'!' fr*/
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
        keycharHash.put(    (char)0x22         , KeyEvent.VK_QUOTEDBL        );                   /*34,x22*/ /*'"' fr*/
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
        keycharHash.put(    (char)0x23         , KeyEvent.VK_NUMBER_SIGN        );                /*35,x23*/ /*'#' de*/
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
        keycharHash.put(    (char)0x24         , KeyEvent.VK_DOLLAR        );                      /*36,x24*/ /*'$', de_CH*/
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
        //keycharHash.put('%',                                  (char)0x25        );                                  /*37,x25*/ /*no VK, cannot test*/
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
        keycharHash.put(    (char)0x26    , KeyEvent.VK_AMPERSAND        );                  /*38,x26*/ /*'&', fr*/
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
        keycharHash.put(    (char)0x27    , KeyEvent.VK_QUOTE        );                      /*39,x27*/ /*''', fr*/
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
        keycharHash.put(    (char)0x28    , KeyEvent.VK_LEFT_PARENTHESIS        );           /*40,x28*/ /*'(', fr*/
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
        keycharHash.put(    (char)0x29    , KeyEvent.VK_RIGHT_PARENTHESIS        );           /*41,x29*/ /*')', fr*/
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
        keycharHash.put(    (char)0x2a    , KeyEvent.VK_ASTERISK        );                    /*42,x2a*/ /*'*', fr*/
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
        keycharHash.put(    (char)0x2b    , KeyEvent.VK_PLUS        );                        /*43,x2b*/ /*'+', de*/
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
        keycharHash.put(    (char)0x2c    , KeyEvent.VK_COMMA        );                       /*44,x2c*/  /*','*/
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
        keycharHash.put(    (char)0x2d    , KeyEvent.VK_MINUS        );                       /*45,x2d*/ /*'-'*/
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
        keycharHash.put(    (char)0x2e    , KeyEvent.VK_PERIOD        );                      /*46,x2e*/ /*'.'*/
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
        keycharHash.put(    (char)0x2f    , KeyEvent.VK_SLASH        );                       /*47,x2f*/ /*'/'*/
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
        keycharHash.put(    (char)0x30    , KeyEvent.VK_0        );                           /*48,x30*/
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
        keycharHash.put(    (char)0x31    , KeyEvent.VK_1        );                           /*49,x31*/
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
        keycharHash.put(    (char)0x32    , KeyEvent.VK_2        );                           /*50,x32*/
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
        keycharHash.put(    (char)0x33    , KeyEvent.VK_3        );                           /*51,x33*/
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
        keycharHash.put(    (char)0x34    , KeyEvent.VK_4        );                           /*52,x34*/
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
        keycharHash.put(    (char)0x35    , KeyEvent.VK_5        );                           /*53,x35*/
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
        keycharHash.put(    (char)0x36    , KeyEvent.VK_6        );                           /*54,x36*/
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
        keycharHash.put(    (char)0x37    , KeyEvent.VK_7        );                           /*55,x37*/
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
        keycharHash.put(    (char)0x38    , KeyEvent.VK_8        );                           /*56,x38*/
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
        keycharHash.put(    (char)0x39    , KeyEvent.VK_9        );                           /*57,x39*/
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
        keycharHash.put(    (char)0x3a    , KeyEvent.VK_COLON        );                       /*58,x3a*/ /*':', fr*/
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
        keycharHash.put(    (char)0x3b    , KeyEvent.VK_SEMICOLON        );                   /*59,x3b*/ /*';'*/
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
        keycharHash.put(    (char)0x3c    , KeyEvent.VK_LESS        );                        /*60,x3c*/ /*'<' us 102*/
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
        keycharHash.put(    (char)0x3d    , KeyEvent.VK_EQUALS        );                      /*61,x3d*/
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
        keycharHash.put(    (char)0x3e    , KeyEvent.VK_GREATER        );                     /*62,x3e*/ /*'>' ?????? where???*/
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
            // Javadoc says: "there is no keycode for the question mark because
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
            // there is no keyboard for which it appears on the primary layer."
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
            // Well, it's Lithuanian standard.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
        //keycharHash.put('?',                                 (char)0x3f        );                                   /*63,x3f*/ /*no VK, cannot test*/
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
        keycharHash.put(    (char)0x40   , KeyEvent.VK_AT        );                          /*64,x40*/ /*'@' ?????? where???*/
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
        keycharHash.put(    (char)0x1    , KeyEvent.VK_A        );                             /*65,x41*/
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
        keycharHash.put(    (char)0x2    , KeyEvent.VK_B        );                            /*66,x42*/
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
        keycharHash.put(    (char)0x3    , KeyEvent.VK_C        );                            /*67,x43*/
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
        keycharHash.put(    (char)0x4    , KeyEvent.VK_D        );                            /*68,x44*/
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
        keycharHash.put(    (char)0x5    , KeyEvent.VK_E        );                            /*69,x45*/
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
        keycharHash.put(    (char)0x6    , KeyEvent.VK_F        );                            /*70,x46*/
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
        keycharHash.put(    (char)0x7    , KeyEvent.VK_G        );                            /*71,x47*/
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
        keycharHash.put(    (char)0x8    , KeyEvent.VK_H        );                            /*72,x48*/
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
        keycharHash.put(    (char)0x9    , KeyEvent.VK_I        );                            /*73,x49*/
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
        keycharHash.put(    (char)0xa    , KeyEvent.VK_J        );                            /*74,x4a*/
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
        keycharHash.put(    (char)0xb    , KeyEvent.VK_K        );                            /*75,x4b*/
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
        keycharHash.put(    (char)0xc    , KeyEvent.VK_L        );                            /*76,x4c*/
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
        keycharHash.put(    (char)0xd    , KeyEvent.VK_M        );                            /*77,x4d*/
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
        keycharHash.put(    (char)0xe    , KeyEvent.VK_N        );                            /*78,x4e*/
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
        keycharHash.put(    (char)0xf    , KeyEvent.VK_O        );                            /*79,x4f*/
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
        keycharHash.put(    (char)0x10   , KeyEvent.VK_P        );                           /*80,x50*/
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
        keycharHash.put(    (char)0x11   , KeyEvent.VK_Q        );                           /*81,x51*/
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
        keycharHash.put(    (char)0x12   , KeyEvent.VK_R        );                           /*82,x52*/
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
        keycharHash.put(    (char)0x13   , KeyEvent.VK_S        );                           /*83,x53*/
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
        keycharHash.put(    (char)0x14   , KeyEvent.VK_T        );                           /*84,x54*/
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
        keycharHash.put(    (char)0x15   , KeyEvent.VK_U        );                           /*85,x55*/
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
        keycharHash.put(    (char)0x16   , KeyEvent.VK_V        );                           /*86,x56*/
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
        keycharHash.put(    (char)0x17   , KeyEvent.VK_W        );                           /*87,x57*/
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
        keycharHash.put(    (char)0x18   , KeyEvent.VK_X        );                           /*88,x58*/
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
        keycharHash.put(    (char)0x19   , KeyEvent.VK_Y        );                           /*89,x59*/
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
        keycharHash.put(    (char)0x1a   , KeyEvent.VK_Z        );                           /*90,x5a*/
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
        keycharHash.put(    (char)0x1b   , KeyEvent.VK_OPEN_BRACKET        );             /*91,x5b*/ /*'['*/
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
        keycharHash.put(    (char)0x1c   , KeyEvent.VK_BACK_SLASH        );               /*92,x5c*/ /*'\'*/
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
        keycharHash.put(    (char)0x1d   , KeyEvent.VK_CLOSE_BRACKET        );            /*93,x5d*/ /*']'*/
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
        keycharHash.put(    (char)0x5e   , KeyEvent.VK_CIRCUMFLEX        );               /*94,x5e*/  /*'^' ?? nodead fr, de??*/
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
        keycharHash.put(    (char)0x1f   , KeyEvent.VK_UNDERSCORE        );               /*95,x5f*/  /*'_' fr*/
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
        keycharHash.put(    (char)0x60   , KeyEvent.VK_BACK_QUOTE        );               /*96,x60*/
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
        /********* Same as uppercase*/
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
        //keycharHash.put(  (char)0x1         , KeyEvent.VK_a        );/*97,x61*/
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
        //keycharHash.put(  (char)0x2         , KeyEvent.VK_b        );/*98,x62*/
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
        //keycharHash.put(  (char)0x3         , KeyEvent.VK_c        );/*99,x63*/
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
        //keycharHash.put(  (char)0x4         , KeyEvent.VK_d        );/*100,x64*/
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
        //keycharHash.put(  (char)0x5         , KeyEvent.VK_e        );/*101,x65*/
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
        //keycharHash.put(  (char)0x6         , KeyEvent.VK_f        );/*102,x66*/
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
        //keycharHash.put(  (char)0x7         , KeyEvent.VK_g        );/*103,x67*/
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
        //keycharHash.put(  (char)0x8         , KeyEvent.VK_h        );/*104,x68*/
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
        //keycharHash.put(  (char)0x9         , KeyEvent.VK_i        );/*105,x69*/
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
        //keycharHash.put(  (char)0xa         , KeyEvent.VK_j        );/*106,x6a*/
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
        //keycharHash.put(  (char)0xb         , KeyEvent.VK_k        );/*107,x6b*/
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
        //keycharHash.put(  (char)0xc         , KeyEvent.VK_l        );/*108,x6c*/
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
        //keycharHash.put(  (char)0xd         , KeyEvent.VK_m        );/*109,x6d*/
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
        //keycharHash.put(  (char)0xe         , KeyEvent.VK_n        );/*110,x6e*/
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
        //keycharHash.put(  (char)0xf         , KeyEvent.VK_o        );/*111,x6f*/
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
        //keycharHash.put(  (char)0x10        , KeyEvent.VK_p        );/*112,x70*/
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
        //keycharHash.put(  (char)0x11        , KeyEvent.VK_q        );/*113,x71*/
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
        //keycharHash.put(  (char)0x12        , KeyEvent.VK_r        );/*114,x72*/
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
        //keycharHash.put(  (char)0x13        , KeyEvent.VK_s        );/*115,x73*/
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
        //keycharHash.put(  (char)0x14        , KeyEvent.VK_t        );/*116,x74*/
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
        //keycharHash.put(  (char)0x15        , KeyEvent.VK_u        );/*117,x75*/
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
        //keycharHash.put(  (char)0x16        , KeyEvent.VK_v        );/*118,x76*/
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
        //keycharHash.put(  (char)0x17        , KeyEvent.VK_w        );/*119,x77*/
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
        //keycharHash.put(  (char)0x18        , KeyEvent.VK_x        );/*120,x78*/
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
        //keycharHash.put(  (char)0x19        , KeyEvent.VK_y        );/*121,x79*/
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
        //keycharHash.put(  (char)0x1a        , KeyEvent.VK_z        );/*122,x7a*/
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
        keycharHash.put(    (char)0x7b      , KeyEvent.VK_BRACELEFT        );             /*123,x7b*/ /*'{' la (Latin American)*/
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
        //keycharHash.put(  (char)0x1c        , KeyEvent.VK_|        );                   /*124,x7c*/ /* no VK, cannot test*/
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
        keycharHash.put(    (char)0x7d      , KeyEvent.VK_BRACERIGHT        );            /*125,x7d*/ /*'}' la */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
        //keycharHash.put(  (char)0x1e        , KeyEvent.VK_~        );                   /*126,x7e*/ /* no VK, cannot test*/
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
    public static void main(String[] args) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
        CtrlASCII test = new CtrlASCII();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
        test.init();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
        test.start();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
    public void init()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
        fillHash( false );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
        this.setLayout (new BorderLayout ());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
    }//End  init()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
    public void start ()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
        setSize(400,300);
54231
e4813eded7cb 8213110: Remove the use of applets in automatic tests
serb
parents: 50834
diff changeset
   175
        setLocationRelativeTo(null);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
        setVisible(true);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
        String original = "0123456789";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
        tf = new TextField(original, 20);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
        this.add(tf);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
        tf.addKeyListener(this);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
        validate();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
            robot = new Robot();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
            robot.setAutoWaitForIdle(true);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
            robot.setAutoDelay(100);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
            robot.waitForIdle();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
            // wait for focus, etc.  (Hack.)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
            robot.delay(2000);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
            this.requestFocus();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
            tf.requestFocusInWindow();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
            Point pt = getLocationOnScreen();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
            robot.mouseMove( pt.x+100, pt.y+100 );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
            robot.delay(2000);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
            robot.mousePress( InputEvent.BUTTON1_MASK );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
            robot.mouseRelease( InputEvent.BUTTON1_MASK );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
            Enumeration<Integer> enuElem = keycharHash.elements();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
            int kc;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
            while( enuElem.hasMoreElements()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
                kc = enuElem.nextElement();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
                punchCtrlKey( robot, kc );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
            robot.delay(500);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
        } catch (Exception e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
            throw new RuntimeException("The test was not completed.\n\n" + e);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
        if( testFailed ) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
            throw new RuntimeException("The test failed.\n\n");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
        }
50834
9cf279436b9d 8205153: Delete "standard instructions" machinery in the open automated tests
serb
parents: 47216
diff changeset
   215
        System.out.println("Success\n");
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
    }// start()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
    public void punchCtrlKey( Robot ro, int keyCode ) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
        ro.keyPress(KeyEvent.VK_CONTROL);
32128
8506d9dade57 6544871: java/awt/event/KeyEvent/KeyTyped/CtrlASCII.html fails from jdk b09 on windows
yan
parents: 5506
diff changeset
   220
        try {
8506d9dade57 6544871: java/awt/event/KeyEvent/KeyTyped/CtrlASCII.html fails from jdk b09 on windows
yan
parents: 5506
diff changeset
   221
            ro.keyPress(keyCode);
8506d9dade57 6544871: java/awt/event/KeyEvent/KeyTyped/CtrlASCII.html fails from jdk b09 on windows
yan
parents: 5506
diff changeset
   222
            ro.keyRelease(keyCode);
8506d9dade57 6544871: java/awt/event/KeyEvent/KeyTyped/CtrlASCII.html fails from jdk b09 on windows
yan
parents: 5506
diff changeset
   223
        }catch(IllegalArgumentException iae) {
8506d9dade57 6544871: java/awt/event/KeyEvent/KeyTyped/CtrlASCII.html fails from jdk b09 on windows
yan
parents: 5506
diff changeset
   224
            System.err.println("skip probably invalid keyCode "+keyCode);
8506d9dade57 6544871: java/awt/event/KeyEvent/KeyTyped/CtrlASCII.html fails from jdk b09 on windows
yan
parents: 5506
diff changeset
   225
        }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
        ro.keyRelease(KeyEvent.VK_CONTROL);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
        ro.delay(200);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
    public void keyPressed(KeyEvent evt)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
        //printKey(evt);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
    public void keyTyped(KeyEvent evt)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
        printKey(evt);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
        char keych = evt.getKeyChar();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
        if( !keycharHash.containsKey( keych ) ) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
            System.out.println("Unexpected keychar: "+keych);
50834
9cf279436b9d 8205153: Delete "standard instructions" machinery in the open automated tests
serb
parents: 47216
diff changeset
   240
            System.out.println("Unexpected keychar: "+keych);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
            testFailed = true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   242
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   244
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
    public void keyReleased(KeyEvent evt)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   246
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   247
        //printKey(evt);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   248
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   249
90ce3da70b43 Initial load
duke
parents:
diff changeset
   250
    protected void printKey(KeyEvent evt)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   251
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   252
        switch(evt.getID())
90ce3da70b43 Initial load
duke
parents:
diff changeset
   253
        {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   254
          case KeyEvent.KEY_TYPED:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   255
          case KeyEvent.KEY_PRESSED:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   256
          case KeyEvent.KEY_RELEASED:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   257
            break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   258
          default:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   259
            System.out.println("Other Event ");
50834
9cf279436b9d 8205153: Delete "standard instructions" machinery in the open automated tests
serb
parents: 47216
diff changeset
   260
            System.out.println("Other Event ");
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   261
            return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   262
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   263
        System.out.print(" 0x"+ Integer.toHexString(evt.getKeyChar()));
50834
9cf279436b9d 8205153: Delete "standard instructions" machinery in the open automated tests
serb
parents: 47216
diff changeset
   264
        System.out.println    (" 0x"+ Integer.toHexString(evt.getKeyChar()));
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   265
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   266
90ce3da70b43 Initial load
duke
parents:
diff changeset
   267
}// class CtrlASCII