8328631: Convert java/awt/InputMethods/InputMethodsTest/InputMethodsTest.java applet test to manual

Reviewed-by: prr
This commit is contained in:
Alexander Zvegintsev 2024-03-21 13:19:22 +00:00
parent 700d2b91de
commit 43080173e8
2 changed files with 52 additions and 85 deletions

View File

@ -1,40 +0,0 @@
<!--
Copyright (c) 2013, 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.
-->
<html>
<head>
<title> InputMethodsTest </title>
</head>
<body>
<applet code="InputMethodsTest.class" width=350 height=200></applet>
This test is for Linux only. For other platforms please simply push "Pass".
Test run requires some Japanese input method to be installed.
To test JDK-7146572 fix please perform the following steps:
1. Switch on input method and type Japanese in the above text fields.
2. Push "Disable Input Methods" button.
3. Try to type Japanese again. If it can be done then the test is failed; otherwise passed.
</body>
</html>

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2013, 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
@ -21,68 +21,75 @@
* questions.
*/
import java.awt.TextArea;
import java.awt.TextField;
import javax.swing.Box;
import javax.swing.JButton;
import javax.swing.JComponent;
/*
@test
@bug 7146572 8024122
@summary Check if 'enableInputMethods' works properly for TextArea and TextField on Linux platform
@author a.stepanov
@run applet/manual=yesno InputMethodsTest.html
* @test
* @bug 7146572 8024122
* @summary Check if 'enableInputMethods' works properly for TextArea and TextField on Linux platform
* @requires (os.family == "linux")
* @library /java/awt/regtesthelpers
* @build PassFailJFrame
* @run main/manual InputMethodsTest
*/
public class InputMethodsTest {
import java.applet.Applet;
import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
private static final String INSTRUCTIONS = """
Test run requires some Japanese input method to be installed.
To test the JDK-7146572 fix, please follow these steps:
1. Enable the input method.
2. Type Japanese in the text area and the text field to the right.
2. Press the "Disable Input Methods" button.
3. Try typing Japanese again.
4. If input methods are not disabled, then press fail;
otherwise, press pass.
""";
public class InputMethodsTest extends Applet {
static boolean inputMethodsEnabled = true;
TextArea txtArea = null;
TextField txtField = null;
JButton btnIM = null;
boolean inputMethodsEnabled = true;
public void init() {
this.setLayout(new BorderLayout());
public static void main(String[] args) throws Exception {
PassFailJFrame
.builder()
.title("InputMethodsTest Instructions")
.instructions(INSTRUCTIONS)
.splitUIRight(InputMethodsTest::createPanel)
.testTimeOut(10)
.rows(10)
.columns(40)
.build()
.awaitAndCheck();
}
public void start() {
public static JComponent createPanel() {
Box verticalBox = Box.createVerticalBox();
setSize(350, 200);
TextArea textArea = new TextArea();
verticalBox.add(textArea);
JPanel panel = new JPanel();
panel.setLayout(new GridLayout(2, 1));
TextField textField = new TextField();
verticalBox.add(textField);
txtArea = new TextArea();
panel.add(txtArea);
JButton btnIM = new JButton();
setBtnText(btnIM);
txtField = new TextField();
panel.add(txtField);
add(panel, BorderLayout.CENTER);
btnIM = new JButton();
setBtnText();
btnIM.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
inputMethodsEnabled = !inputMethodsEnabled;
setBtnText();
txtArea.enableInputMethods(inputMethodsEnabled);
txtField.enableInputMethods(inputMethodsEnabled);
}
btnIM.addActionListener(e -> {
inputMethodsEnabled = !inputMethodsEnabled;
setBtnText(btnIM);
textArea.enableInputMethods(inputMethodsEnabled);
textField.enableInputMethods(inputMethodsEnabled);
});
add(btnIM, BorderLayout.SOUTH);
validate();
setVisible(true);
verticalBox.add(btnIM);
return verticalBox;
}
private void setBtnText() {
private static void setBtnText(JButton btnIM) {
String s = inputMethodsEnabled ? "Disable" : "Enable";
btnIM.setText(s + " Input Methods");
}