diff --git a/test/jdk/java/awt/im/4490692/bug4490692.html b/test/jdk/java/awt/im/4490692/bug4490692.html deleted file mode 100644 index f75d9a8740e..00000000000 --- a/test/jdk/java/awt/im/4490692/bug4490692.html +++ /dev/null @@ -1,61 +0,0 @@ - - - - - - Test for KEY_PRESS event for accented characters - - - -

Test for KEY_PRESS event for accented characters: Bug id 4490692

- -This test is for unix platforms only. Press OK if you are not -testing on those platforms. - -Before the test, you need to modify the keyboard mapping for X by issueing -the following command: - -xmodmap -e 'keycode 60 = aacute' (this is for Solaris Sparc keyboard) -xmodmap -e 'keycode 23 = aacute' (this is for Linux PC keyboard) - -This command lets you type 'a with acute' character when you press 'Tab' keytop. Please -do not fail to restore the original key mapping by doing the following after the test - -xmodmap -e 'keycode 60 = Tab' (this is for Solaris Sparc keyboard) -xmodmap -e 'keycode 23 = Tab' (this is for Linux PC keyboard) - -Confirm the following two behaviors: - - "KEYPRESS received for aacute" is displayed when you press 'Tab' keytop. - On Solaris Sparc keyboard, The key sequence ("Compose", "a", "'") generates a-acute character in en_US locale - - - - diff --git a/test/jdk/java/awt/im/4490692/bug4490692.java b/test/jdk/java/awt/im/4490692/bug4490692.java deleted file mode 100644 index 7875b745e60..00000000000 --- a/test/jdk/java/awt/im/4490692/bug4490692.java +++ /dev/null @@ -1,70 +0,0 @@ -/* - * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -/** - * - * @bug 4490692 - * @author Naoto Sato - */ - -import java.awt.*; -import java.awt.event.*; -import javax.swing.*; - -public class bug4490692 extends javax.swing.JApplet { - public void init() { - new TestFrame(); - } -} - -class TestFrame extends JFrame implements KeyListener { - JTextField text; - JLabel label; - - TestFrame () { - text = new JTextField(); - text.addKeyListener(this); - label = new JLabel(" "); - Container c = getContentPane(); - BorderLayout borderLayout1 = new BorderLayout(); - c.setLayout(borderLayout1); - c.add(text, BorderLayout.CENTER); - c.add(label, BorderLayout.SOUTH); - setSize(300, 200); - setVisible(true); - } - - public void keyPressed(KeyEvent e) { - if (e.getKeyChar() == 0x00e1) { - label.setText("KEYPRESS received for aacute"); - } else { - label.setText(" "); - } - } - - public void keyTyped(KeyEvent e) { - } - - public void keyReleased(KeyEvent e) { - } -} diff --git a/test/jdk/java/awt/im/bug4490692.java b/test/jdk/java/awt/im/bug4490692.java new file mode 100644 index 00000000000..8b095ae3745 --- /dev/null +++ b/test/jdk/java/awt/im/bug4490692.java @@ -0,0 +1,107 @@ +/* + * Copyright (c) 2007, 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.awt.event.KeyAdapter; +import java.awt.event.KeyEvent; +import javax.swing.JComponent; +import javax.swing.JLabel; +import javax.swing.JPanel; +import javax.swing.JTextField; + +/* + * @test + * @bug 4490692 + * @summary [Linux] Test for KEY_PRESS event for accented characters. + * @requires (os.family == "linux") + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual bug4490692 + */ + +public class bug4490692 { + private static final String INSTRUCTIONS = """ + This test is for unix platforms only. + Before the test, you need to modify the keyboard mapping for + Tab by issuing the following command: + + xmodmap -e 'keycode 23 = aacute' (this is for Linux) + xmodmap -e 'keycode 60 = aacute' (this is for Solaris Sparc) + + This command lets you type 'a with acute (à)' character when you press + 'Tab' key in the JTextField provided below the logging area. + After the test, please DO NOT fail to restore the original + key mapping by doing the following. + + xmodmap -e 'keycode 23 = Tab' (this is for Linux) + xmodmap -e 'keycode 60 = Tab' (this is for Solaris Sparc) + + CASE 1: This is a manual check and for SOLARIS SPARC keyboard + only. Check whether the key sequence ("Compose", "a", " ' ") + generates a-acute character in en_US locale. + + CASE 2: This step is automated and applicable for both + keyboards - LINUX & SOLARIS SPARC. + When Tab key is pressed it should generate a-acute (à) + character, this test automatically passes if the correct character + is generated on keypress else fails. + """; + + public static void main(String[] args) throws Exception { + PassFailJFrame.builder() + .title("Test Instructions") + .instructions(INSTRUCTIONS) + .rows((int) INSTRUCTIONS.lines().count() + 2) + .columns(45) + .testTimeOut(10) + .splitUIBottom(bug4490692::createUI) + .logArea(8) + .build() + .awaitAndCheck(); + } + + private static JComponent createUI() { + JPanel panel = new JPanel(); + JTextField textField = new JTextField("", 20); + panel.add(new JLabel("Text field:")); + + textField.addKeyListener(new KeyAdapter() { + @Override + public void keyPressed(KeyEvent e) { + PassFailJFrame.log(e.paramString()); + if (e.getKeyCode() == 23 || e.getKeyCode() == 60 + || e.paramString().contains("rawCode=23") + || e.paramString().contains("rawCode=60")) { + if (e.getKeyChar() == 0x00e1) { + PassFailJFrame.forcePass(); + } else { + PassFailJFrame.forceFail("Tab keypress DID NOT" + + " produce the expected accented character - aacute"); + } + } + } + }); + + panel.add(textField); + return panel; + } +}